protected function getMatchingEmployees($parameters)
 {
     $parameterHolder = new EmployeeSearchParameterHolder();
     $filters = array('location' => $parameters['location'], 'sub_unit' => $parameters['subunit']);
     $fromDate = isset($parameters['fd']) ? $parameters['fd'] : null;
     $toDate = isset($parameters['td']) ? $parameters['td'] : null;
     $leaveType = isset($parameters['lt']) ? $parameters['lt'] : null;
     $newValue = isset($parameters['ent']) ? $parameters['ent'] : null;
     $offset = isset($parameters['offset']) ? $parameters['offset'] : 0;
     $pageSize = sfConfig::get('app_items_per_page');
     $parameterHolder->setFilters($filters);
     $parameterHolder->setOffset($offset);
     $parameterHolder->setLimit($pageSize);
     $parameterHolder->setReturnType(EmployeeSearchParameterHolder::RETURN_TYPE_ARRAY);
     $employees = $this->getEmployeeService()->searchEmployees($parameterHolder);
     $names = array();
     foreach ($employees as $employee) {
         $leaveEntitlementSearchParameterHolder = new LeaveEntitlementSearchParameterHolder();
         $leaveEntitlementSearchParameterHolder->setEmpNumber($employee['empNumber']);
         $leaveEntitlementSearchParameterHolder->setFromDate($fromDate);
         $leaveEntitlementSearchParameterHolder->setLeaveTypeId($leaveType);
         $leaveEntitlementSearchParameterHolder->setToDate($toDate);
         $entitlementList = $this->getEntitlementService()->searchLeaveEntitlements($leaveEntitlementSearchParameterHolder);
         $oldValue = 0;
         if (count($entitlementList) > 0) {
             $existingLeaveEntitlement = $entitlementList->getFirst();
             $oldValue = $existingLeaveEntitlement->getNoOfDays();
         }
         $names[] = array($employee['firstName'] . ' ' . $employee['middleName'] . ' ' . $employee['lastName'], $oldValue, $newValue + $oldValue);
     }
     $data = array('offset' => $offset, 'pageSize' => $pageSize, 'data' => $names);
     return $data;
 }
 protected function getEmployeeEntitlement($parameters)
 {
     $leaveEntitlementSearchParameterHolder = new LeaveEntitlementSearchParameterHolder();
     $leaveEntitlementSearchParameterHolder->setEmpNumber($parameters['empId']);
     $leaveEntitlementSearchParameterHolder->setFromDate($parameters['fd']);
     $leaveEntitlementSearchParameterHolder->setLeaveTypeId($parameters['lt']);
     $leaveEntitlementSearchParameterHolder->setToDate($parameters['td']);
     $entitlementList = $this->getEntitlementService()->searchLeaveEntitlements($leaveEntitlementSearchParameterHolder);
     $oldValue = 0;
     $newValue = $parameters['ent'];
     if (count($entitlementList) > 0) {
         $existingLeaveEntitlement = $entitlementList->getFirst();
         $oldValue = $existingLeaveEntitlement->getNoOfDays();
     }
     return array($oldValue, $newValue + $oldValue);
 }
 protected function getEmployeeEntitlement($parameters)
 {
     $localizationService = new LocalizationService();
     $inputDatePattern = sfContext::getInstance()->getUser()->getDateFormat();
     $fromDate = $localizationService->convertPHPFormatDateToISOFormatDate($inputDatePattern, $parameters['fd']);
     $toDate = $localizationService->convertPHPFormatDateToISOFormatDate($inputDatePattern, $parameters['td']);
     $leaveEntitlementSearchParameterHolder = new LeaveEntitlementSearchParameterHolder();
     $leaveEntitlementSearchParameterHolder->setEmpNumber($parameters['empId']);
     $leaveEntitlementSearchParameterHolder->setFromDate($fromDate);
     $leaveEntitlementSearchParameterHolder->setLeaveTypeId($parameters['lt']);
     $leaveEntitlementSearchParameterHolder->setToDate($toDate);
     $entitlementList = $this->getEntitlementService()->searchLeaveEntitlements($leaveEntitlementSearchParameterHolder);
     $oldValue = 0;
     $newValue = $parameters['ent'];
     foreach ($entitlementList as $existingEntitlement) {
         $oldValue += $existingEntitlement->getNoOfDays();
     }
     return array($oldValue, $newValue + $oldValue);
 }
コード例 #4
0
 public function testSearchLeaveEntitlementsByEmpNumber()
 {
     $parameterHolder = new LeaveEntitlementSearchParameterHolder();
     $entitlementList = TestDataService::loadObjectList('LeaveEntitlement', $this->fixture, 'LeaveEntitlement');
     // employee with multiple records
     $parameterHolder->setEmpNumber(1);
     $expected = array($entitlementList[0], $entitlementList[2], $entitlementList[3]);
     $results = $this->dao->searchLeaveEntitlements($parameterHolder);
     $this->_compareEntitlements($expected, $results);
     // employee with one record
     $parameterHolder->setEmpNumber(2);
     $expected = array($entitlementList[1]);
     $results = $this->dao->searchLeaveEntitlements($parameterHolder);
     $this->_compareEntitlements($expected, $results);
     // employee with no records
     $parameterHolder->setEmpNumber(4);
     $results = $this->dao->searchLeaveEntitlements($parameterHolder);
     $this->assertEquals(0, count($results));
     // non existing employee
     $parameterHolder->setEmpNumber(100);
     $results = $this->dao->searchLeaveEntitlements($parameterHolder);
     $this->assertEquals(0, count($results));
 }
コード例 #5
0
 protected function getSearchParameterObject($filters)
 {
     $searchParameters = new LeaveEntitlementSearchParameterHolder();
     $employeeName = $filters['employee'];
     $id = $employeeName['empId'];
     $userRoleManager = $this->getContext()->getUserRoleManager();
     $isAccessible = $userRoleManager->isEntityAccessible('Employee', $id);
     if (!empty($id)) {
         if ($isAccessible || $this->getUser()->getAttribute('auth.empNumber') == $id) {
             $searchParameters->setEmpNumber($id);
         } else {
             $this->getUser()->setFlash('warning', 'Access Denied to Selected Employee');
             $this->redirect('leave/viewLeaveEntitlements');
         }
     }
     $searchParameters->setLeaveTypeId($filters['leave_type']);
     $searchParameters->setFromDate($filters['date']['from']);
     $searchParameters->setToDate($filters['date']['to']);
     return $searchParameters;
 }