public function updateWorkShift() { $obj = $this->getObjTime(); $workShift = $obj[0]; $assignedEmployees = $obj[1]; $id = $workShift->getWorkshiftId(); if (!$this->_isWorkshiftNameAvailable($workShift)) { try { $workShift->save(); $workShift->removeAssignedEmployees(); $workShift->assignEmployees($assignedEmployees); /* Updating pending leaves accordingly: Begins */ $empList = $workShift->getAssignedEmployees(); if (!empty($empList)) { foreach ($empList as $emp) { $empIdList[] = $emp[Workshift::DB_FIELD_EMP_NUMBER]; } $duration = $workShift->getHoursPerDay(); $leaveObj = new Leave(); if (!$leaveObj->adjustLeaveToWorkshift($duration, $empIdList)) { throw new Exception('Updating pending leaves failed for new workshift value'); } } /* Updating pending leaves accordingly: Ends */ } catch (WorkshiftException $exception) { $this->redirect('UPDATE_FAILURE', '?timecode=Time&action=View_Edit_Work_Shift&id=' . $id); } $this->redirect('UPDATE_SUCCESS', '?timecode=Time&action=View_Edit_Work_Shift&id=' . $id); } else { $this->redirect('Duplicate_Name_FAILURE', '?timecode=Time&action=View_Edit_Work_Shift&id=' . $id); } }