Пример #1
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;
 }