///<summary>If already clocked in, this does nothing. Returns false if not able to clock in due to security, or true if successful.</summary> private static bool ClockIn(PhoneTile tile) { long employeeNum = Security.CurUser.EmployeeNum; //tile.PhoneCur.EmployeeNum; if (employeeNum == 0) //Can happen if logged in as 'admin' user (employeeNum==0). Otherwise should not happen, means the employee trying to clock doesn't exist in the employee table. { MsgBox.Show(langThis, "Inavlid OD User: "******"Working"; Employees.Update(EmpCur); return(true); }
private void MapAreaRoomControl_MouseUp(object sender,MouseEventArgs e) { if(!_allowClickOptions || _phoneCur==null) { return;//disable click options in setup window. } if(e==null || e.Button!=MouseButtons.Right) { if(e.Button==MouseButtons.Left && !IsFlashing && Status!="OnWay") { if(_rectName.Contains(e.Location)) { PhoneUI.EmployeeSettings(_phoneCur); return; } if(_rectPhone.Contains(e.Location) && _phoneCur.PatNum!=0) { OnGoToChanged(); } } return; } bool allowStatusEdit=ClockEvents.IsClockedIn(EmployeeNum); if(EmployeeNum==Security.CurUser.EmployeeNum) {//can always edit yourself allowStatusEdit=true; } if(Status==Phones.ConvertClockStatusToString(ClockStatusEnum.NeedsHelp)) { //Always allow any employee to change any other employee from NeedsAssistance to Available allowStatusEdit=true; } string statusOnBehalfOf=EmployeeName; bool allowSetSelfAvailable=false; if(!ClockEvents.IsClockedIn(EmployeeNum) //No one is clocked in at this extension. && !ClockEvents.IsClockedIn(Security.CurUser.EmployeeNum)) //This user is not clocked in either. { //Vacant extension and this user is not clocked in so allow this user to clock in at this extension. statusOnBehalfOf=Security.CurUser.UserName; allowSetSelfAvailable=true; } AddToolstripGroup("menuItemStatusOnBehalf","Status for: "+statusOnBehalfOf); AddToolstripGroup("menuItemRingGroupOnBehalf","Queues for ext: "+Extension.ToString()); AddToolstripGroup("menuItemClockOnBehalf","Clock event for: "+EmployeeName); AddToolstripGroup("menuItemCustomer","Customer: "+_phoneCur.CustomerNumber); AddToolstripGroup("menuItemEmployee","Employee: "+EmployeeName); SetToolstripItemText("menuItemAvailable",allowStatusEdit || allowSetSelfAvailable); SetToolstripItemText("menuItemTraining",allowStatusEdit); SetToolstripItemText("menuItemTeamAssist",allowStatusEdit); SetToolstripItemText("menuItemNeedsHelp",allowStatusEdit); SetToolstripItemText("menuItemWrapUp",allowStatusEdit); SetToolstripItemText("menuItemOfflineAssist",allowStatusEdit); SetToolstripItemText("menuItemUnavailable",allowStatusEdit); SetToolstripItemText("menuItemTCResponder",allowStatusEdit); SetToolstripItemText("menuItemBackup",allowStatusEdit); SetToolstripItemText("menuItemLunch",allowStatusEdit); SetToolstripItemText("menuItemHome",allowStatusEdit); SetToolstripItemText("menuItemBreak",allowStatusEdit); menuItemGoTo.Enabled=true; if(_phoneCur.PatNum==0) {//disable go to if not a current patient menuItemGoTo.Enabled=false; } Point p=new Point(Location.X+e.Location.X,Location.Y+e.Location.Y); menuStatus.Show(Cursor.Position); }
private void FormVoiceMails_FormClosing(object sender, FormClosingEventArgs e) { //Change the ClockStatus to Available if the logged on user is clocked in and the same user as the extension. if (FormOpenDental.PhoneTile.PhoneCur != null && ClockEvents.IsClockedIn(Security.CurUser.EmployeeNum) && Security.CurUser.EmployeeNum == FormOpenDental.PhoneTile.PhoneCur.EmployeeNum) { FormOpenDental.S_SetPhoneStatusAvailable(); } }
private void labelStatusAndNote_MouseUp(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) { return; } if (_phoneCur == null) { return; } //Jason - Allowed to be 0 here. The Security.UserCur.EmpNum will be used when they go to clock in and that is where the 0 check needs to be. //if(phoneCur.EmployeeNum==0) { // return; //} OnSelectedTileChanged(); bool allowStatusEdit = ClockEvents.IsClockedIn(PhoneCur.EmployeeNum); if (PhoneCur.EmployeeNum == Security.CurUser.EmployeeNum) //Always allow status edit for yourself { allowStatusEdit = true; } if (PhoneCur.ClockStatus == ClockStatusEnum.NeedsHelp) //Always allow any employee to change any other employee from NeedsAssistance to Available { allowStatusEdit = true; } string statusOnBehalfOf = PhoneCur.EmployeeName; bool allowSetSelfAvailable = false; if (!ClockEvents.IsClockedIn(PhoneCur.EmployeeNum) && //No one is clocked in at this extension. !ClockEvents.IsClockedIn(Security.CurUser.EmployeeNum)) //This user is not clocked in either. { //Vacant extension and this user is not clocked in so allow this user to clock in at this extension. statusOnBehalfOf = Security.CurUser.UserName; allowSetSelfAvailable = true; } AddToolstripGroup("menuItemStatusOnBehalf", "Status for: " + statusOnBehalfOf); AddToolstripGroup("menuItemRingGroupOnBehalf", "Queues for ext: " + PhoneCur.Extension.ToString()); AddToolstripGroup("menuItemClockOnBehalf", "Clock event for: " + PhoneCur.EmployeeName); SetToolstripItemText("menuItemAvailable", allowStatusEdit || allowSetSelfAvailable); SetToolstripItemText("menuItemTraining", allowStatusEdit); SetToolstripItemText("menuItemTeamAssist", allowStatusEdit); SetToolstripItemText("menuItemNeedsHelp", allowStatusEdit); SetToolstripItemText("menuItemWrapUp", allowStatusEdit); SetToolstripItemText("menuItemOfflineAssist", allowStatusEdit); SetToolstripItemText("menuItemUnavailable", allowStatusEdit); SetToolstripItemText("menuItemTCResponder", allowStatusEdit); SetToolstripItemText("menuItemBackup", allowStatusEdit); SetToolstripItemText("menuItemLunch", allowStatusEdit); SetToolstripItemText("menuItemHome", allowStatusEdit); SetToolstripItemText("menuItemBreak", allowStatusEdit); MenuStatus.Show(labelStatusAndNote, e.Location); }
public static void Available(Phone phone) { long employeeNum = Security.CurUser.EmployeeNum; if (Security.CurUser.EmployeeNum != phone.EmployeeNum) //We are on someone else's tile. So Let's do some checks before we assume we can take over this extension. { if (phone.ClockStatus == ClockStatusEnum.NeedsHelp) { //Allow the specific state where we are changing their status back from NeedsHelp to Available. //This does not require any security permissions as any tech in can perform this action on behalf of any other tech. Phones.SetPhoneStatus(ClockStatusEnum.Available, phone.Extension, phone.EmployeeNum); //green return; } //We are on a tile that is not our own //If another employee is occupying this extension then assume we are trying to change that employee's status back to available. if (ClockEvents.IsClockedIn(phone.EmployeeNum)) //This tile is taken by an employee who is clocked in. //Transition the employee back to available. { ChangeTileStatus(phone, ClockStatusEnum.Available); PhoneAsterisks.SetToDefaultQueue(phone.EmployeeNum); return; } if (phone.ClockStatus != ClockStatusEnum.None && phone.ClockStatus != ClockStatusEnum.Home) { //Another person is still actively using this extension. MsgBox.Show(langThis, "Cannot take over this extension as it is currently occuppied by someone who is likely on Break or Lunch."); return; } //If another employee is NOT occupying this extension then assume we are trying clock in at this extension. if (ClockEvents.IsClockedIn(employeeNum)) //We are already clocked in at a different extension. { MsgBox.Show(langThis, "You are already clocked in at a different extension. You must clock out of the current extension you are logged into before moving to another extension."); return; } //We got this far so fall through and allow user to clock in. } //We go here so all of our checks passed and we may login at this extension if (!ClockIn()) //Clock in on behalf of yourself { return; } //Update the Phone tables accordingly. PhoneEmpDefaults.SetAvailable(phone.Extension, employeeNum); PhoneAsterisks.SetToDefaultQueue(phone.EmployeeNum); Phones.SetPhoneStatus(ClockStatusEnum.Available, phone.Extension, employeeNum); //green }
public static void BuildMenuStatus(ContextMenuStrip menuStatus, Phone phoneCur) { //Jason - Allowed to be 0 here. The Security.UserCur.EmpNum will be used when they go to clock in and that is where the 0 check needs to be. //if(phoneCur.EmployeeNum==0) { // return; //} bool allowStatusEdit = ClockEvents.IsClockedIn(phoneCur.EmployeeNum); if (phoneCur.EmployeeNum == Security.CurUser.EmployeeNum) //Always allow status edit for yourself { allowStatusEdit = true; } if (phoneCur.ClockStatus == ClockStatusEnum.NeedsHelp) //Always allow any employee to change any other employee from NeedsAssistance to Available { allowStatusEdit = true; } string statusOnBehalfOf = phoneCur.EmployeeName; bool allowSetSelfAvailable = false; if (!ClockEvents.IsClockedIn(phoneCur.EmployeeNum) && //No one is clocked in at this extension. !ClockEvents.IsClockedIn(Security.CurUser.EmployeeNum)) //This user is not clocked in either. { //Vacant extension and this user is not clocked in so allow this user to clock in at this extension. statusOnBehalfOf = Security.CurUser.UserName; allowSetSelfAvailable = true; } AddToolstripGroup(menuStatus, "menuItemStatusOnBehalf", "Status for: " + statusOnBehalfOf); AddToolstripGroup(menuStatus, "menuItemRingGroupOnBehalf", "Queues for ext: " + phoneCur.Extension.ToString()); AddToolstripGroup(menuStatus, "menuItemClockOnBehalf", "Clock event for: " + phoneCur.EmployeeName); SetToolstripItemText(menuStatus, "menuItemAvailable", allowStatusEdit || allowSetSelfAvailable); SetToolstripItemText(menuStatus, "menuItemTraining", allowStatusEdit); SetToolstripItemText(menuStatus, "menuItemTeamAssist", allowStatusEdit); SetToolstripItemText(menuStatus, "menuItemNeedsHelp", allowStatusEdit); SetToolstripItemText(menuStatus, "menuItemWrapUp", allowStatusEdit); SetToolstripItemText(menuStatus, "menuItemOfflineAssist", allowStatusEdit); SetToolstripItemText(menuStatus, "menuItemUnavailable", allowStatusEdit); SetToolstripItemText(menuStatus, "menuItemTCResponder", allowStatusEdit); SetToolstripItemText(menuStatus, "menuItemBackup", allowStatusEdit); SetToolstripItemText(menuStatus, "menuItemLunch", allowStatusEdit); SetToolstripItemText(menuStatus, "menuItemHome", allowStatusEdit); SetToolstripItemText(menuStatus, "menuItemBreak", allowStatusEdit); }
///<summary>Verify... ///1) Security.CurUser is clocked in. ///2) Target status change employee is clocked in. ///3) Secruity.CurUser has TimecardsEditAll permission.</summary> private static bool ChangeTileStatus(Phone phoneCur, ClockStatusEnum newClockStatus) { if (!ClockEvents.IsClockedIn(Security.CurUser.EmployeeNum)) //Employee performing the action must be clocked in. { MsgBox.Show(langThis, "You must clock in before completing this action."); return(false); } if (!ClockEvents.IsClockedIn(phoneCur.EmployeeNum)) //Employee having action performed must be clocked in. { MessageBox.Show(Lan.g(langThis, "Target employee must be clocked in before setting this status:") + " " + phoneCur.EmployeeName); return(false); } if (!CheckUserCanChangeStatus(phoneCur)) { return(false); } PhoneEmpDefaults.SetAvailable(phoneCur.Extension, phoneCur.EmployeeNum); Phones.SetPhoneStatus(newClockStatus, phoneCur.Extension); return(true); }
///<summary>If already clocked in, this does nothing. Returns false if not able to clock in due to security, or true if successful.</summary> private bool ClockIn() { long employeeNum = PhoneList[rowI].EmployeeNum; if (employeeNum == 0) { MsgBox.Show(this, "No employee at that extension."); return(false); } if (ClockEvents.IsClockedIn(employeeNum)) { return(true); } if (PrefC.GetBool(PrefName.TimecardSecurityEnabled)) { if (Security.CurUser.EmployeeNum != employeeNum) { if (!Security.IsAuthorized(Permissions.TimecardsEditAll)) { MsgBox.Show(this, "Not authorized."); return(false); } } } try{ ClockEvents.ClockIn(employeeNum); } catch (Exception ex) { if (ex.Message.Contains("Already clocked in")) { return(true); } return(false); } Employee EmpCur = Employees.GetEmp(employeeNum); EmpCur.ClockStatus = Lan.g(this, "Working");; Employees.Update(EmpCur); return(true); }
public static void Unavailable(Phone phone) { if (!ClockEvents.IsClockedIn(Security.CurUser.EmployeeNum)) //Employee performing the action must be clocked in. { MsgBox.Show("PhoneUI", "You must clock in before completing this action."); return; } if (!ClockEvents.IsClockedIn(phone.EmployeeNum)) //Employee having action performed must be clocked in. { MessageBox.Show(Lan.g("PhoneUI", "Target employee must be clocked in before setting this status:") + " " + phone.EmployeeName); return; } if (!CheckUserCanChangeStatus(phone)) { return; } int extension = phone.Extension; long employeeNum = phone.EmployeeNum; PhoneEmpDefault ped = PhoneEmpDefaults.GetByExtAndEmp(extension, employeeNum); if (ped == null) { MessageBox.Show("PhoneEmpDefault (employee setting row) not found for Extension " + extension.ToString() + " and EmployeeNum " + employeeNum.ToString()); return; } FormPhoneEmpDefaultEdit formPED = new FormPhoneEmpDefaultEdit(); formPED.PedCur = ped; formPED.PedCur.StatusOverride = PhoneEmpStatusOverride.Unavailable; if (formPED.ShowDialog() == DialogResult.OK && formPED.PedCur.StatusOverride == PhoneEmpStatusOverride.Unavailable) { //This phone status update can get skipped from within the editor if the employee is not clocked in. //This would be the case when you are setting an employee other than yourself to Unavailable. //So we will set it here. This keeps the phone table and phone panel in sync. Phones.SetPhoneStatus(ClockStatusEnum.Unavailable, formPED.PedCur.PhoneExt, formPED.PedCur.EmployeeNum); PhoneAsterisks.SetQueueForExtension(phone.Extension, AsteriskQueues.None); } }
///<summary>If already clocked in, this does nothing. Returns false if not able to clock in due to security, or true if successful.</summary> private bool ClockIn() { long employeeNum = PhoneList[rowI].EmployeeNum; if (employeeNum == 0) { MsgBox.Show(this, "No employee at that extension."); return(false); } if (ClockEvents.IsClockedIn(employeeNum)) { return(true); } if (PrefC.GetBool(PrefName.TimecardSecurityEnabled)) { if (Security.CurUser.EmployeeNum != employeeNum) { if (!Security.IsAuthorized(Permissions.TimecardsEditAll)) { MsgBox.Show(this, "Not authorized."); return(false); } } } try{ ClockEvents.ClockIn(employeeNum); } catch { //This should never happen. Fail silently. return(true); } Employee EmpCur = Employees.GetEmp(employeeNum); EmpCur.ClockStatus = Lan.g(this, "Working");; Employees.Update(EmpCur); return(true); }
///<summary>If already clocked in, this does nothing. Returns false if not able to clock in due to security, or true if successful.</summary> private static bool ClockIn(PhoneTile tile) { long employeeNum = tile.PhoneCur.EmployeeNum; if (employeeNum == 0) { MsgBox.Show(langThis, "No employee at that extension."); return(false); } if (ClockEvents.IsClockedIn(employeeNum)) { return(true); } if (Security.CurUser.EmployeeNum != employeeNum) { if (!Security.IsAuthorized(Permissions.TimecardsEditAll, true)) { if (!CheckSelectedUserPassword(employeeNum)) { return(false); } } } try { ClockEvents.ClockIn(employeeNum); } catch { //This should never happen. Fail silently. return(true); } Employee EmpCur = Employees.GetEmp(employeeNum); EmpCur.ClockStatus = "Working"; Employees.Update(EmpCur); return(true); }
private void butOK_Click(object sender, System.EventArgs e) { //Using a switch statement in case we want special functionality for the other statuses later on. switch ((PhoneEmpStatusOverride)listStatusOverride.SelectedIndex) { case PhoneEmpStatusOverride.None: if (_pedOld.StatusOverride == PhoneEmpStatusOverride.Unavailable) { MsgBox.Show(this, "Change your status from unavailable by using the small phone panel."); return; } break; case PhoneEmpStatusOverride.OfflineAssist: if (_pedOld.StatusOverride == PhoneEmpStatusOverride.Unavailable) { MsgBox.Show(this, "Change your status from unavailable by using the small phone panel."); return; } break; } if (IsNew) { if (textEmployeeNum.Text == "") { MsgBox.Show(this, "Unique EmployeeNum is required."); return; } if (textEmpName.Text == "") { MsgBox.Show(this, "Employee name is required."); return; } PedCur.EmployeeNum = PIn.Long(textEmployeeNum.Text); } //Get the current database state of the phone emp default (before we change it) PhoneEmpDefault pedFromDatabase = PhoneEmpDefaults.GetOne(PedCur.EmployeeNum); if (pedFromDatabase == null) { pedFromDatabase = new PhoneEmpDefault(); } else if (pedFromDatabase != null && IsNew) { MessageBox.Show("Employee Num already in use.\r\nEdit their current phone settings entry instead of creating a duplicate."); return; } int newExtension = PIn.Int(textPhoneExt.Text); bool extensionChange = pedFromDatabase.PhoneExt != newExtension; if (extensionChange) //Only check when extension has changed and clocked in. //We need to prevent changes to phoneempdefault table which involve employees who are currently logged in. //Failing to do so would cause subtle race conditions between the phone table and phoneempdefault. //Net result would be the phone panel looking wrong. { if (ClockEvents.IsClockedIn(PedCur.EmployeeNum)) //Prevent any change if employee being edited is currently clocked in. { MsgBox.Show(this, "You must first clock out before making changes"); return; } //Find out if the target extension is already being occuppied by a different employee. Phone phoneOccuppied = Phones.GetPhoneForExtensionDB(PIn.Int(textPhoneExt.Text)); if (phoneOccuppied != null) { if (ClockEvents.IsClockedIn(phoneOccuppied.EmployeeNum)) //Prevent change if employee's new extension is occupied by a different employee who is currently clocked in. { MessageBox.Show(Lan.g(this, "This extension cannot be inherited because it is currently occuppied by an employee who is currently logged in.\r\n\r\nExisting employee: ") + phoneOccuppied.EmployeeName); return; } if (phoneOccuppied.EmployeeNum != PedCur.EmployeeNum) { //We are setting to a new employee so let's clean up the old employee. //This will prevent duplicates in the phone table and subsequently prevent duplicates in the phone panel. Phones.UpdatePhoneToEmpty(phoneOccuppied.EmployeeNum, -1); PhoneEmpDefault pedOccuppied = PhoneEmpDefaults.GetOne(phoneOccuppied.EmployeeNum); if (pedOccuppied != null) //prevent duplicate in phoneempdefault { pedOccuppied.PhoneExt = 0; PhoneEmpDefaults.Update(pedOccuppied); } } } //Get the employee that is normally assigned to this extension (assigned ext set in the employee table). long permanentLinkageEmployeeNum = Employees.GetEmpNumAtExtension(pedFromDatabase.PhoneExt); if (permanentLinkageEmployeeNum >= 1) //Extension is nomrally assigned to an employee. { if (PedCur.EmployeeNum != permanentLinkageEmployeeNum) //This is not the normally linked employee so let's revert back to the proper employee. { PhoneEmpDefault pedRevertTo = PhoneEmpDefaults.GetOne(permanentLinkageEmployeeNum); //Make sure the employee we are about to revert is not logged in at yet a different workstation. This would be rare but it's worth checking. if (pedRevertTo != null && !ClockEvents.IsClockedIn(pedRevertTo.EmployeeNum)) { //Revert to the permanent extension for this PhoneEmpDefault. pedRevertTo.PhoneExt = pedFromDatabase.PhoneExt; PhoneEmpDefaults.Update(pedRevertTo); //Update phone table to match this change. Phones.SetPhoneStatus(ClockStatusEnum.Home, pedRevertTo.PhoneExt, pedRevertTo.EmployeeNum); } } } } //Ordering of these updates is IMPORTANT!!! //Phone Emp Default must be updated first PedCur.EmpName = textEmpName.Text; PedCur.IsGraphed = checkIsGraphed.Checked; PedCur.HasColor = checkHasColor.Checked; PedCur.RingGroups = (AsteriskQueues)listRingGroup.SelectedIndex; PedCur.PhoneExt = PIn.Int(textPhoneExt.Text); PedCur.StatusOverride = (PhoneEmpStatusOverride)listStatusOverride.SelectedIndex; PedCur.Notes = textNotes.Text; if (comboSite.SelectedIndex > -1) { PedCur.SiteNum = ((ODBoxItem <Site>)comboSite.SelectedItem).Tag.SiteNum; } PedCur.IsPrivateScreen = true; //we no longer capture screen shots. PedCur.IsTriageOperator = checkIsTriageOperator.Checked; if (IsNew) { PhoneEmpDefaults.Insert(PedCur); //insert a new Phone record to keep the 2 tables in sync an entry for the new extension in the phone table doesn't already exist. if (PedCur.PhoneExt != 0 && Phones.GetPhoneForExtensionDB(PedCur.PhoneExt) == null) { Phone phoneNew = new Phone(); phoneNew.EmployeeName = PedCur.EmpName; phoneNew.EmployeeNum = PedCur.EmployeeNum; phoneNew.Extension = PedCur.PhoneExt; phoneNew.ClockStatus = ClockStatusEnum.Home; Phones.Insert(phoneNew); } } else { PhoneEmpDefaults.Update(PedCur); } //It is now safe to update Phone table as it will draw from the newly updated Phone Emp Default row if ((PhoneEmpStatusOverride)listStatusOverride.SelectedIndex == PhoneEmpStatusOverride.Unavailable && ClockEvents.IsClockedIn(PedCur.EmployeeNum)) { //We set ourselves unavailable from this window because we require an explanation. //This is the only status that will synch with the phone table, all others should be handled by the small phone panel. Phones.SetPhoneStatus(ClockStatusEnum.Unavailable, PedCur.PhoneExt, PedCur.EmployeeNum); } if (extensionChange) { //Phone extension has changed so update the phone table as well. //We have already guaranteed that this employee is Clocked Out (above) so set to home and update phone table. Phones.SetPhoneStatus(ClockStatusEnum.Home, PedCur.PhoneExt, PedCur.EmployeeNum); } //The user just flagged themselves as a triage operator //OR //This user used to be a triage operator and they no longer want to be one which will need their ring group set back to their default. if ((!_pedOld.IsTriageOperator && checkIsTriageOperator.Checked) || (_pedOld.IsTriageOperator && !checkIsTriageOperator.Checked)) { //Set the queue for this phone emp default to whatever the current ClockStatus is for the phone row associated to this PED. PhoneAsterisks.SetQueueForClockStatus(PedCur); } DialogResult = DialogResult.OK; }