Exemplo n.º 1
0
 /**
  * Modify Overlap leave request
  * @param LeaveRequest $leaveRequest
  * @return boolean
  */
 public function modifyOverlapLeaveRequest(LeaveRequest $leaveRequest, $leaveList, $leavePeriod = null)
 {
     try {
         $nextLeavePeriod = false;
         $nextLeaveRequest = false;
         if ($leavePeriod == null) {
             $leavePeriod = Doctrine::getTable('LeavePeriod')->find($leaveRequest->getLeavePeriodId());
         }
         foreach ($leaveList as $leave) {
             if ($leave->getLeaveDate() > $leavePeriod->getEndDate()) {
                 if (!$nextLeavePeriod instanceof LeavePeriod) {
                     $leavePeriodService = new LeavePeriodService();
                     $leavePeriodService->setLeavePeriodDao(new LeavePeriodDao());
                     $nextLeavePeriod = $leavePeriodService->createNextLeavePeriod($leave->getLeaveDate());
                     $nextLeaveRequest = new LeaveRequest();
                     $idGenService = new IDGeneratorService();
                     $idGenService->setEntity($leaveRequest);
                     $nextLeaveRequest->setLeaveRequestId($idGenService->getNextID());
                     $nextLeaveRequest->setLeaveTypeId($leaveRequest->getLeaveTypeId());
                     $nextLeaveRequest->setDateApplied($leaveRequest->getDateApplied());
                     $nextLeaveRequest->setLeavePeriodId($nextLeavePeriod->getLeavePeriodId());
                     $nextLeaveRequest->setLeaveTypeName($leaveRequest->getLeaveTypeName());
                     $nextLeaveRequest->setEmpNumber($leaveRequest->getEmpNumber());
                     $nextLeaveRequest->setLeaveComments($leaveRequest->getLeaveComments());
                     $nextLeaveRequest->save();
                 }
                 $q = Doctrine_Query::create()->update('Leave l')->set('l.leave_request_id=', $nextLeaveRequest->getLeaveRequestId())->where('l.leave_id = ?', $leave->getLeaveId());
                 $q->execute();
             }
         }
         return true;
     } catch (Exception $e) {
         throw new DaoException($e->getMessage());
     }
 }
Exemplo n.º 2
0
 public function configure()
 {
     $leavePeriodPermissions = $this->getOption('leavePeriodPermissions');
     $leavePeriodService = new LeavePeriodService();
     $month = "-- " . __("Month") . " --";
     $date = "-- " . __("Date") . " --";
     $monthsChoiceList = array($month);
     $monthsChoiceList = array_merge($monthsChoiceList, $leavePeriodService->getListOfMonths());
     $datesChoiceList = array($date);
     $currentLeavePeriod = $leavePeriodService->getCurrentLeavePeriodStartDateAndMonth();
     if ($currentLeavePeriod instanceof LeavePeriodHistory) {
         $datesChoiceList = array_merge($datesChoiceList, $leavePeriodService->getListOfDates($currentLeavePeriod->getLeavePeriodStartMonth()));
     }
     $widgets = array('cmbStartMonth' => new sfWidgetFormSelect(array('choices' => $monthsChoiceList)), 'cmbStartDate' => new sfWidgetFormSelect(array('choices' => $datesChoiceList)));
     $validators = array('cmbStartMonth' => new sfValidatorString(array('required' => false)), 'cmbStartDate' => new sfValidatorString(array('required' => false)));
     if (!$leavePeriodPermissions->canUpdate()) {
         foreach ($widgets as $widgetName => $widget) {
             $widget->setAttribute('disabled', 'disabled');
         }
     }
     $this->setWidgets($widgets);
     $this->setValidators($validators);
     $this->widgetSchema->setNameFormat('leaveperiod[%s]');
     $this->getWidgetSchema()->setLabels($this->getFormLabels());
 }
Exemplo n.º 3
0
 protected function setUp()
 {
     TestDataService::truncateSpecificTables(array('Employee', 'Leave', 'LeaveRequest', 'LeaveType', 'EmployeeLeaveEntitlement', 'LeavePeriod'));
     // Save leave type
     $leaveTypeData = sfYaml::load(sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/leaveType.yml');
     $leaveTypeDao = new LeaveTypeDao();
     $leaveType = new LeaveType();
     $leaveType->setLeaveTypeName($leaveTypeData['leaveType']['LT_001']['name']);
     //                $leaveType->setLeaveRules($leaveTypeData['leaveType']['LT_001']['rule']);
     $leaveTypeDao->saveLeaveType($leaveType);
     $this->leaveType = $leaveType;
     $this->leaveTypeId = $leaveType->getLeaveTypeId();
     // Save leave Period
     $leavePeriodData = sfYaml::load(sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/leavePeriod.yml');
     $leavePeriodService = new LeavePeriodService();
     $leavePeriodService->setLeavePeriodDao(new LeavePeriodDao());
     $leavePeriod = new LeavePeriod();
     $leavePeriod->setStartDate($leavePeriodData['leavePeriod']['1']['startDate']);
     $leavePeriod->setEndDate($leavePeriodData['leavePeriod']['1']['endDate']);
     $leavePeriodService->saveLeavePeriod($leavePeriod);
     $this->leavePeriod = $leavePeriod;
     $this->leavePeriodId = $leavePeriod->getLeavePeriodId();
     // Save Employee
     $employeeservice = new EmployeeService();
     $this->employee = new Employee();
     $employeeservice->saveEmployee($this->employee);
     $this->empNumber = $this->employee->getEmpNumber();
     // save leave quota
     $this->leaveEntitlement = sfYaml::load(sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/leaveEntitlement.yml');
     $this->leaveEntitlementDao = new LeaveEntitlementDao();
 }
Exemplo n.º 4
0
 public function getLeavePeriodService()
 {
     if (is_null($this->leavePeriodService)) {
         $leavePeriodService = new LeavePeriodService();
         $leavePeriodService->setLeavePeriodDao(new LeavePeriodDao());
         $this->leavePeriodService = $leavePeriodService;
     }
     return $this->leavePeriodService;
 }
 private function isLeavePeriodDefined()
 {
     $leavePeriodService = new LeavePeriodService();
     $leavePeriodService->setLeavePeriodDao(new LeavePeriodDao());
     $leavePeriod = $leavePeriodService->getLeavePeriod(strtotime(date("Y-m-d")));
     $flag = 0;
     if ($leavePeriod instanceof LeavePeriod) {
         $flag = 1;
     }
     $_SESSION['leavePeriodDefined'] = $flag;
 }
Exemplo n.º 6
0
 public function configure()
 {
     $leavePeriodService = new LeavePeriodService();
     $month = "-- " . __("Month") . " --";
     $date = "-- " . __("Date") . " --";
     $monthsChoiceList = array($month);
     $monthsChoiceList = array_merge($monthsChoiceList, $leavePeriodService->getListOfMonths());
     $datesChoiceList = array($date);
     $currentLeavePeriod = $leavePeriodService->getCurrentLeavePeriod();
     if (!is_null($currentLeavePeriod)) {
         $datesChoiceList = array_merge($datesChoiceList, $leavePeriodService->getListOfDates($currentLeavePeriod->getStartMonthValue()));
     }
     $this->setWidgets(array('cmbStartMonth' => new sfWidgetFormSelect(array('choices' => $monthsChoiceList), array('class' => 'formSelect')), 'cmbStartDate' => new sfWidgetFormSelect(array('choices' => $datesChoiceList), array('class' => 'formSelect', 'style' => 'width: auto')), 'cmbStartMonthForNonLeapYears' => new sfWidgetFormSelect(array('choices' => $monthsChoiceList, 'default' => 2), array('class' => 'formSelect')), 'cmbStartDateForNonLeapYears' => new sfWidgetFormSelect(array('choices' => array()), array('class' => 'formSelect', 'style' => 'width: auto'))));
     $this->setValidators(array('cmbStartMonth' => new sfValidatorString(array('required' => false)), 'cmbStartDate' => new sfValidatorString(array('required' => false)), 'cmbStartMonthForNonLeapYears' => new sfValidatorString(array('required' => false)), 'cmbStartDateForNonLeapYears' => new sfValidatorString(array('required' => false))));
     $this->widgetSchema->setNameFormat('leaveperiod[%s]');
 }
Exemplo n.º 7
0
 public function configure()
 {
     $leavePeriodService = new LeavePeriodService();
     $month = "-- " . __("Month") . " --";
     $date = "-- " . __("Date") . " --";
     $monthsChoiceList = array($month);
     $monthsChoiceList = array_merge($monthsChoiceList, $leavePeriodService->getListOfMonths());
     $datesChoiceList = array($date);
     $currentLeavePeriod = $leavePeriodService->getCurrentLeavePeriodStartDateAndMonth();
     if ($currentLeavePeriod instanceof LeavePeriodHistory) {
         $datesChoiceList = array_merge($datesChoiceList, $leavePeriodService->getListOfDates($currentLeavePeriod->getLeavePeriodStartMonth()));
     }
     $this->setWidgets(array('cmbStartMonth' => new sfWidgetFormSelect(array('choices' => $monthsChoiceList)), 'cmbStartDate' => new sfWidgetFormSelect(array('choices' => $datesChoiceList))));
     $this->setValidators(array('cmbStartMonth' => new sfValidatorString(array('required' => false)), 'cmbStartDate' => new sfValidatorString(array('required' => false))));
     $this->widgetSchema->setNameFormat('leaveperiod[%s]');
     $this->getWidgetSchema()->setLabels($this->getFormLabels());
 }
 /**
  *
  * @return array
  */
 protected function getFormLabels()
 {
     $requiredMarker = ' <em>*</em>';
     $labels = array('employee' => __('Employee') . $requiredMarker, 'leave_type' => __('Leave Type') . $requiredMarker);
     if (LeavePeriodService::getLeavePeriodStatus() == LeavePeriodService::LEAVE_PERIOD_STATUS_FORCED) {
         $labels['date'] = __('Leave Period') . $requiredMarker;
     } else {
         $labels['date'] = __('Earned Between') . $requiredMarker;
     }
     $labels['entitlement'] = __('Entitlement') . $requiredMarker;
     return $labels;
 }
 public function getLeaveBalance($empNumber, $leaveTypeId, $asAtDate = NULL, $date = NULL)
 {
     if (empty($asAtDate)) {
         $asAtDate = date('Y-m-d', time());
     }
     // If end date is not defined, and leave period is forced, use end date of current leave period
     // as the end date for leave balance calculation
     if (empty($date)) {
         $leavePeriodStatus = LeavePeriodService::getLeavePeriodStatus();
         if ($leavePeriodStatus == LeavePeriodService::LEAVE_PERIOD_STATUS_FORCED) {
             $leavePeriod = $this->getLeaveEntitlementStrategy()->getLeavePeriod($asAtDate, $empNumber, $leaveTypeId);
             if (is_array($leavePeriod) && isset($leavePeriod[1])) {
                 $date = $leavePeriod[1];
             }
         }
     }
     return $this->getLeaveEntitlementDao()->getLeaveBalance($empNumber, $leaveTypeId, $asAtDate, $date);
 }
 /**
  * Get Leave Period List
  * @return string
  */
 public function getLeavePeriodList()
 {
     $choices = array();
     $leavePeriodService = new LeavePeriodService();
     $leavePeriodList = $leavePeriodService->getGeneratedLeavePeriodList();
     foreach ($leavePeriodList as $leavePeriod) {
         $choices[set_datepicker_date_format($leavePeriod[0]) . '$$' . set_datepicker_date_format($leavePeriod[1])] = set_datepicker_date_format($leavePeriod[0]) . ' - ' . set_datepicker_date_format($leavePeriod[1]);
     }
     return $choices;
 }
Exemplo n.º 11
0
 /**
  *
  * @return array
  */
 protected function getFormLabels()
 {
     $labels = array('employee' => __('Employee'), 'leave_type' => __('Leave Type'));
     if (LeavePeriodService::getLeavePeriodStatus() == LeavePeriodService::LEAVE_PERIOD_STATUS_FORCED) {
         $labels['date'] = __('Leave Period');
     } else {
         $labels['date'] = __('Earned Between');
     }
     return $labels;
 }
Exemplo n.º 12
0
 public function bulkAssignLeaveEntitlements($employeeNumbers, LeaveEntitlement $leaveEntitlement)
 {
     $conn = Doctrine_Manager::connection();
     $conn->beginTransaction();
     $pdo = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh();
     try {
         $allEntitlements = array();
         $updateEmpList = array();
         $updateEntitlementIdList = array();
         $savedCount = 0;
         $leaveTypeId = $leaveEntitlement->getLeaveTypeId();
         $fromDate = $leaveEntitlement->getFromDate();
         $toDate = $leaveEntitlement->getToDate();
         $leaveEntitlementSearchParameterHolder = new LeaveEntitlementSearchParameterHolder();
         $leaveEntitlementSearchParameterHolder->setFromDate($fromDate);
         $leaveEntitlementSearchParameterHolder->setLeaveTypeId($leaveTypeId);
         $leaveEntitlementSearchParameterHolder->setToDate($toDate);
         $leaveEntitlementSearchParameterHolder->setEmpIdList($employeeNumbers);
         $leaveEntitlementSearchParameterHolder->setHydrationMode(Doctrine::HYDRATE_ARRAY);
         $entitlementList = $this->searchLeaveEntitlements($leaveEntitlementSearchParameterHolder);
         if (count($entitlementList) > 0) {
             foreach ($entitlementList as $updateEntitlement) {
                 $empNumber = $updateEntitlement['emp_number'];
                 if (!isset($allEntitlements[$empNumber])) {
                     $entitlement = new LeaveEntitlement();
                     $noOfDays = $leaveEntitlement->getNoOfDays();
                     $entitlement->setEmpNumber($empNumber);
                     $entitlement->setLeaveTypeId($leaveTypeId);
                     $entitlement->setCreditedDate($leaveEntitlement->getCreditedDate());
                     $entitlement->setCreatedById($leaveEntitlement->getCreatedById());
                     $entitlement->setCreatedByName($leaveEntitlement->getCreatedByName());
                     $entitlement->setEntitlementType($leaveEntitlement->getEntitlementType());
                     $entitlement->setDeleted(0);
                     $entitlement->setNoOfDays($leaveEntitlement->getNoOfDays());
                     $entitlement->setFromDate($fromDate);
                     $entitlement->setToDate($toDate);
                     $entitlement->setId($updateEntitlement['id']);
                     $allEntitlements[$empNumber] = $entitlement;
                     $updateEmpList[] = $updateEntitlement['emp_number'];
                     $updateEntitlementIdList[] = $updateEntitlement['id'];
                     $savedCount++;
                 }
             }
             $updateQuery = sprintf(" UPDATE ohrm_leave_entitlement SET no_of_days=no_of_days+ %d WHERE id IN (%s)", $leaveEntitlement->getNoOfDays(), implode(',', $updateEntitlementIdList));
             $updateStmt = $pdo->prepare($updateQuery);
             $updateStmt->execute();
         }
         $newEmployeeList = array_diff($employeeNumbers, $updateEmpList);
         if (count($newEmployeeList) > 0) {
             $query = " INSERT INTO ohrm_leave_entitlement(`emp_number`,`leave_type_id`,`from_date`,`to_date`,`no_of_days`,`entitlement_type`) VALUES " . "(?, ?, ?, ?, ?, ?)";
             $stmt = $pdo->prepare($query);
             foreach ($newEmployeeList as $empNumber) {
                 if (!isset($allEntitlements[$empNumber])) {
                     $entitlement = new LeaveEntitlement();
                     $noOfDays = $leaveEntitlement->getNoOfDays();
                     $entitlement->setEmpNumber($empNumber);
                     $entitlement->setLeaveTypeId($leaveEntitlement->getLeaveTypeId());
                     $entitlement->setCreditedDate($leaveEntitlement->getCreditedDate());
                     $entitlement->setCreatedById($leaveEntitlement->getCreatedById());
                     $entitlement->setCreatedByName($leaveEntitlement->getCreatedByName());
                     $entitlement->setEntitlementType($leaveEntitlement->getEntitlementType());
                     $entitlement->setDeleted(0);
                     $entitlement->setNoOfDays($noOfDays);
                     $entitlement->setFromDate($fromDate);
                     $entitlement->setToDate($toDate);
                     $params = array($empNumber, $leaveEntitlement->getLeaveTypeId(), $fromDate, $toDate, $noOfDays, LeaveEntitlement::ENTITLEMENT_TYPE_ADD);
                     $stmt->execute($params);
                     $entitlement->setId($pdo->lastInsertId());
                     $allEntitlements[$empNumber] = $entitlement;
                     $savedCount++;
                 }
             }
         }
         // If leave period is forced, we can bulk assign at once, because from and to date of
         // all leave entitlements will be the same
         $leavePeriodStatus = LeavePeriodService::getLeavePeriodStatus();
         if ($leavePeriodStatus == LeavePeriodService::LEAVE_PERIOD_STATUS_FORCED) {
             $this->bulkLinkLeaveToUnusedLeaveEntitlements($allEntitlements, $leaveTypeId, $fromDate, $toDate);
         } else {
             foreach ($allEntitlements as $leaveEntitlement) {
                 $this->linkLeaveToUnusedLeaveEntitlement($leaveEntitlement);
             }
         }
         $conn->commit();
         return $savedCount;
     } catch (Exception $e) {
         $conn->rollback();
         throw new DaoException($e->getMessage(), 0, $e);
     }
 }
 protected function getLeaveEntitlement($values)
 {
     if (isset($values['filters']['bulk_assign'])) {
         $leaveEntitlement = new LeaveEntitlement();
         $leaveEntitlement->setNoOfDays($values['entitlement']);
     } else {
         if (isset($values['id'])) {
             $id = $values['id'];
             $leaveEntitlement = $this->getLeaveEntitlementService()->getLeaveEntitlement($id);
             $leaveEntitlement->setNoOfDays($values['entitlement']);
         } else {
             if (LeavePeriodService::getLeavePeriodStatus() == LeavePeriodService::LEAVE_PERIOD_STATUS_FORCED) {
                 $empNumber = $values['employee']['empId'];
                 $fromDate = $values['date']['from'];
                 $toDate = $values['date']['to'];
                 $leaveTypeId = $values['leave_type'];
                 $entitlementList = $this->getLeaveEntitlementService()->getMatchingEntitlements($empNumber, $leaveTypeId, $fromDate, $toDate);
                 if (count($entitlementList) > 0) {
                     $leaveEntitlement = $entitlementList->getFirst();
                     $newValue = $leaveEntitlement->getNoOfDays() + $values['entitlement'];
                     $leaveEntitlement->setNoOfDays($newValue);
                 } else {
                     $leaveEntitlement = new LeaveEntitlement();
                     $leaveEntitlement->setNoOfDays($values['entitlement']);
                 }
             } else {
                 $leaveEntitlement = new LeaveEntitlement();
                 $leaveEntitlement->setNoOfDays($values['entitlement']);
             }
         }
     }
     if (isset($values['employee']['empId'])) {
         $leaveEntitlement->setEmpNumber($values['employee']['empId']);
     }
     if (isset($values['leave_type'])) {
         $leaveEntitlement->setLeaveTypeId($values['leave_type']);
     }
     $user = $this->getUser();
     $userId = $user->getAttribute('auth.userId');
     $createdBy = $this->getUser()->getAttribute('auth.firstName');
     $leaveEntitlement->setCreditedDate(date('Y-m-d'));
     $leaveEntitlement->setCreatedById($userId);
     $leaveEntitlement->setCreatedByName($createdBy);
     $leaveEntitlement->setEntitlementType(LeaveEntitlement::ENTITLEMENT_TYPE_ADD);
     $leaveEntitlement->setDeleted(0);
     $leaveEntitlement->setNoOfDays(round($leaveEntitlement->getNoOfDays(), 2));
     $leaveEntitlement->setFromDate($values['date']['from']);
     $leaveEntitlement->setToDate($values['date']['to']);
     return $leaveEntitlement;
 }
Exemplo n.º 14
0
 /**
  * check overlap leave request
  * @return unknown_type
  */
 public function isOverlapLeaveRequest()
 {
     $posts = $this->getValues();
     $leavePeriodService = new LeavePeriodService();
     $leavePeriodService->setLeavePeriodDao(new LeavePeriodDao());
     $leavePeriod = $leavePeriodService->getLeavePeriod(strtotime($posts['txtFromDate']));
     if ($leavePeriod != null) {
         if ($posts['txtToDate'] > $leavePeriod->getEndDate()) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 15
0
 public function fetchRawLeaveSummaryRecords($clues, $offset, $limit)
 {
     $includeTerminated = false;
     if ($clues['cmbWithTerminated'] != 0) {
         $includeTerminated = true;
     }
     $recordsResult = $this->getLeaveSummaryDao()->fetchRawLeaveSummaryRecords($clues, $offset, $limit, $includeTerminated);
     $recordsCount = $this->fetchRawLeaveSummaryRecordsCount($clues, $includeTerminated);
     $leaveEntitlementService = new LeaveEntitlementService();
     $leaveEntitlementService->setLeaveEntitlementDao(new LeaveEntitlementDao());
     $leavePeriodService = new LeavePeriodService();
     $leavePeriodService->setLeavePeriodDao(new LeavePeriodDao());
     $summaryListArray = array();
     if ($recordsCount > 0) {
         $i = 0;
         while ($row = $recordsResult->fetch()) {
             $employeeName = $row['empFirstName'] . ' ' . $row['empLastName'];
             $employeeId = $row['empNumber'];
             $employeeStatus = $row['empStatus'];
             $leaveType = $row['leaveTypeName'];
             $leaveTypeId = $row['leaveTypeId'];
             $leavePeriodId = $clues['cmbLeavePeriod'] ? $clues['cmbLeavePeriod'] : $leavePeriodService->getCurrentLeavePeriod();
             $leaveEntitlementObj = $leaveEntitlementService->readEmployeeLeaveEntitlement($employeeId, $leaveTypeId, $leavePeriodId);
             if ($leaveEntitlementObj instanceof EmployeeLeaveEntitlement) {
                 $leaveEntitled = $leaveEntitlementObj->getNoOfDaysAllotted();
                 $leaveBroughtForward = $leaveEntitlementObj->getLeaveBroughtForward();
                 $leaveCarryForward = $leaveEntitlementObj->getLeaveCarriedForward();
             } else {
                 $leaveEntitled = '0.00';
                 $leaveBroughtForward = '0.00';
                 $leaveCarryForward = '0.00';
             }
             $leaveRequestService = new LeaveRequestService();
             $leaveRequestService->setLeaveRequestDao(new LeaveRequestDao());
             $leaveTaken = $leaveRequestService->getTakenLeaveSum($employeeId, $leaveTypeId, $leavePeriodId);
             $leaveTaken = empty($leaveTaken) ? '0.00' : $leaveTaken;
             //$leaveScheduled = $this->_getLeaveScheduled($employeeId, $leaveTypeId, $leavePeriodId);
             $leaveScheduled = $leaveRequestService->getScheduledLeavesSum($employeeId, $leaveTypeId, $leavePeriodId);
             $leaveScheduled = empty($leaveScheduled) ? '0.00' : $leaveScheduled;
             $leaveRemaining = $leaveEntitled + $leaveBroughtForward - ($leaveTaken + $leaveScheduled + $leaveCarryForward);
             $leaveRemaining = number_format($leaveRemaining, 2);
             $rowDisplayFlag = false;
             $deletedFlag = false;
             //show active leave types
             if ($row['availableFlag'] == 1) {
                 $rowDisplayFlag = true;
             }
             //show inactive leave types if any leaveEntitled, leaveTaken, leaveScheduled of them above 0
             if ($row['availableFlag'] != 1 && ($leaveEntitled > 0 || $leaveTaken > 0 || $leaveScheduled > 0)) {
                 $rowDisplayFlag = true;
                 $deletedFlag = true;
             }
             if ($rowDisplayFlag) {
                 $summaryListRow = array();
                 $employeeLeaveEntitlementObject = new EmployeeLeaveEntitlement();
                 // If readonly value is 1, force read only
                 if (isset($row['readonly']) && $row['readonly'] == 1) {
                     $employeeLeaveEntitlementObject->setForceReadOnly(true);
                 }
                 $employeeLeaveEntitlementObject->setEmployeeId($employeeId);
                 $employeeLeaveEntitlementObject->setEmployeeStatus($employeeStatus);
                 $employeeLeaveEntitlementObject->setLeaveTypeId($leaveTypeId);
                 $employeeLeaveEntitlementObject->setNoOfDaysAllotted($leaveEntitled);
                 $employeeLeaveEntitlementObject->setLeaveBroughtForward($leaveBroughtForward);
                 $employeeLeaveEntitlementObject->setLeaveCarriedForward($leaveCarryForward);
                 $employeeLeaveEntitlementObject->setLeavePeriodId($leavePeriodId);
                 $summaryListArray[] = $employeeLeaveEntitlementObject;
                 $i++;
             }
         }
     }
     return $summaryListArray;
 }
 public function testGetGeneratedLeavePeriodListCase2()
 {
     $leavePeriodHistory = new LeavePeriodHistory();
     $leavePeriodHistory->setLeavePeriodStartMonth(2);
     $leavePeriodHistory->setLeavePeriodStartDay(1);
     $leavePeriodHistory->setCreatedAt('2010-01-01');
     $this->leavePeriodService->saveLeavePeriodHistory($leavePeriodHistory);
     $leavePeriodHistory = new LeavePeriodHistory();
     $leavePeriodHistory->setLeavePeriodStartMonth(1);
     $leavePeriodHistory->setLeavePeriodStartDay(1);
     $leavePeriodHistory->setCreatedAt('2010-01-02');
     $this->leavePeriodService->saveLeavePeriodHistory($leavePeriodHistory);
     $leavePeriodHistory = new LeavePeriodHistory();
     $leavePeriodHistory->setLeavePeriodStartMonth(1);
     $leavePeriodHistory->setLeavePeriodStartDay(2);
     $leavePeriodHistory->setCreatedAt('2010-01-02');
     $this->leavePeriodService->saveLeavePeriodHistory($leavePeriodHistory);
     // work around for cached generated leave period list
     $newLeavePeriodService = new LeavePeriodService();
     $newLeavePeriodService->setLeaveEntitlementService($this->leavePeriodService->getLeaveEntitlementService());
     $result = $newLeavePeriodService->getGeneratedLeavePeriodList(null, true);
     $expected = array(array('2009-02-01', '2011-01-01'), array('2011-01-02', '2012-01-01'), array('2012-01-02', '2013-01-01'), array('2013-01-02', '2014-01-01'));
     // extend range till next year end:
     $now = new DateTime();
     $nextYear = $now->format('Y') + 1;
     $this->assertTrue($nextYear > 2012, 'System clock set to past!. Test should be run with system date 2012 or later.');
     if ($nextYear > 2013) {
         for ($year = 2014; $year <= $nextYear; $year++) {
             $expected[] = array($year . '-01-02', $year + 1 . '-01-01');
         }
     }
     $this->assertEquals($expected, $result);
 }
Exemplo n.º 17
0
 public static function getLeavePeriodStatus($forceReload = false)
 {
     if ($forceReload || is_null(self::$leavePeriodStatus)) {
         self::$leavePeriodStatus = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_LEAVE_PERIOD_STATUS);
     }
     return self::$leavePeriodStatus;
 }