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;
 }
 /**
  * Get Corporate directory employee details as array
  * @param type $includeTerminated
  * @return Array
  */
 public function getCorporateDirectoryEmployeeDetailsAsArray($includeTerminated = false)
 {
     $filters = array();
     if ($includeTerminated) {
         $filters['termination'] = EmployeeSearchForm::WITH_TERMINATED;
     }
     $count = $this->getEmployeeDirectoryService()->getSearchEmployeeCount($filters);
     $parameterHolder = new EmployeeSearchParameterHolder();
     $parameterHolder->setLimit($count);
     $parameterHolder->setFilters($filters);
     $employees = $this->getEmployeeDirectoryService()->searchEmployees($parameterHolder);
     $employeeList = array();
     foreach ($employees as $employee) {
         $employeeDetails = array('emp_number' => $employee->getEmpNumber(), 'employee_id' => $employee->getEmployeeId(), 'emp_firstname' => $employee->getFirstName(), 'emp_lastname' => $employee->getLastName(), 'home_telephone' => $employee->getEmpHmTelephone(), 'work_telephone' => $employee->getEmpWorkTelephone(), 'mobile' => $employee->getEmpMobile(), 'work_email' => $employee->getEmpWorkEmail(), 'other_email' => $employee->getEmpOthEmail(), 'profile_image_url' => url_for('directory/viewDirectoryPhoto?empNumber=' . $employee->getEmpNumber()), 'terminated' => $employee->getTerminationId());
         if ($employee->getLocations()->getFirst() instanceof Location) {
             $employeeDetails['location_id'] = $employee->getLocations()->getFirst()->getId();
         } else {
             $employeeDetails['location_id'] = null;
         }
         if ($employee->getJobTitleCode() instanceof JobTitle) {
             $employeeDetails['job_title_id'] = $employee->getJobTitleCode()->getId();
         } else {
             $employeeDetails['job_title_id'] = null;
         }
         if ($employee->getSubDivision() instanceof Subunit) {
             $employeeDetails['subunit_id'] = $employee->getSubDivision()->getId();
         } else {
             $employeeDetails['subunit_id'] = null;
         }
         $employeeList[] = $employeeDetails;
     }
     return $employeeList;
 }
 private function _getParameterHolder()
 {
     $filters = array('employee_name' => 'Kayla', 'id' => '', 'employee_status' => 0, 'termination' => 1, 'supervisor_name' => '', 'job_title' => 0, 'sub_unit' => 0);
     $parameterHolder = new EmployeeSearchParameterHolder();
     $parameterHolder->setFilters($filters);
     $parameterHolder->setOrderField('empNumber');
     return $parameterHolder;
 }
 private function _getParameterHolder()
 {
     $filters = array('employee_name' => 'Saman', 'id' => '', 'job_title' => 0);
     $parameterHolder = new EmployeeSearchParameterHolder();
     $parameterHolder->setFilters($filters);
     $parameterHolder->setOrderField('empNumber');
     return $parameterHolder;
 }
 protected function getMatchingEmployees($parameters)
 {
     $parameterHolder = new EmployeeSearchParameterHolder();
     $filters = array('location' => $parameters['location'], 'sub_unit' => $parameters['subunit']);
     $parameterHolder->setFilters($filters);
     $parameterHolder->setLimit(NULL);
     $employees = $this->getEmployeeService()->searchEmployees($parameterHolder);
     $names = array();
     foreach ($employees as $employee) {
         $names[] = $employee->getFullName();
     }
     return $names;
 }
 /**
  * Get employees matching the filter parameters.
  * @param type $parameters
  * @return type
  */
 protected function getMatchingEmployees($parameters)
 {
     $parameterHolder = new EmployeeSearchParameterHolder();
     $filters = array('location' => $parameters['location'], 'sub_unit' => $parameters['subunit']);
     $parameterHolder->setFilters($filters);
     $parameterHolder->setLimit(NULL);
     $parameterHolder->setReturnType(EmployeeSearchParameterHolder::RETURN_TYPE_ARRAY);
     $employees = $this->getEmployeeService()->searchEmployees($parameterHolder);
     $ids = array();
     foreach ($employees as $employee) {
         $ids[] = $employee['empNumber'];
     }
     return $ids;
 }
 public function execute($request)
 {
     $request->setParameter('initialActionName', 'viewDirectory');
     $isPaging = $request->getParameter('hdnAction') == 'search' ? 1 : $request->getParameter('pageNo', 1);
     $pageNumber = $isPaging;
     if (!empty($empNumber) && $this->getUser()->hasAttribute('pageNumber')) {
         $pageNumber = $this->getUser()->getAttribute('pageNumber');
     }
     $noOfRecords = sfConfig::get('app_items_per_page');
     $offset = $pageNumber >= 1 ? ($pageNumber - 1) * $noOfRecords : ($request->getParameter('pageNo', 1) - 1) * $noOfRecords;
     // Reset filters if requested to
     if ($request->hasParameter('reset')) {
         $this->setFilters(array());
         $this->setSortParameter(array("field" => NULL, "order" => NULL));
         $this->setPage(1);
     }
     $this->setForm(new EmployeeDirectorySearchForm($this->getFilters()));
     //handles post method
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             if ($this->form->getValue('isSubmitted') == 'yes') {
                 $this->setSortParameter(array("field" => NULL, "order" => NULL));
             }
             $this->setFilters($this->form->getValues());
         } else {
             $this->setFilters(array());
         }
         $this->setPage(1);
     }
     //handles get method
     if ($request->isMethod('get')) {
         $sortParam = array("field" => $request->getParameter('sortField'), "order" => $request->getParameter('sortOrder'));
         $this->setSortParameter($sortParam);
         $this->setPage(1);
     }
     $filters = $this->getFilters();
     if (isset($filters['emp_name']) && $filters['emp_name']['empName'] != __('Type for hints...')) {
         if (strpos($filters['emp_name']['empName'], __('Past Employee')) !== false) {
             $filters['termination'] = EmployeeSearchForm::WITH_TERMINATED;
         }
         $filters['employee_name'] = str_replace(' (' . __('Past Employee') . ')', '', $filters['emp_name']['empName']);
     }
     $this->filterApply = !empty($filters);
     $empList = $this->getEmployeeService()->getEmployeeIdList();
     if (count($empList) > 0) {
         $filters['employee_id_list'] = $empList;
         $count = $this->getDirectoryService()->getSearchEmployeeCount($filters);
         $parameterHolder = new EmployeeSearchParameterHolder();
         $parameterHolder->setOrderField($sortField);
         $parameterHolder->setOrderBy($sortOrder);
         $parameterHolder->setLimit($noOfRecords);
         $parameterHolder->setOffset($offset);
         $parameterHolder->setFilters($filters);
         $this->list = $this->getDirectoryService()->searchEmployees($parameterHolder);
     } else {
         $count = 0;
         $list = array();
     }
     $recordsLimit = sfConfig::get('app_items_per_page');
     //self::$itemsPerPage;//
     $pageNo = $request->getParameter('pageNo', 1);
     /*         * if (self::$pageNumber) {
               $pageNo = self::$pageNumber;
               } else { */
     //$pageNo = 1; //$request->getParameter('pageNo', 1);
     //}
     $numberOfRecords = $count;
     //replace with the count of all the records(self::$listData instanceof Doctrine_Collection) ? self::$listData->count() : count(self::$listData); // TODO: Remove the dependancy of ORM here; Use a Countable interface and a Iterator interface
     if ($recordsLimit < $numberOfRecords) {
         $this->isPaginated = TRUE;
     }
     $pager = new SimplePager($this->className, $recordsLimit);
     $pager->setPage($pageNo);
     $pager->setNumResults($numberOfRecords);
     $pager->init();
     $offset = $pager->getOffset();
     $offset = empty($offset) ? 0 : $offset;
     $this->offset = $offset;
     $this->pager = $pager;
     $this->recordLimit = $recordsLimit;
     //$this->currentSortField = $request->getParameter('sortField', '');
     //$this->currentSortOrder = $request->getParameter('sortOrder', '');
 }
 /**
  * Index action. Displays employee list
  *      `
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     if ($this->getUser()->hasFlash('templateMessage')) {
         list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
     }
     $empNumber = $request->getParameter('empNumber');
     $isPaging = $request->getParameter('hdnAction') == 'search' ? 1 : $request->getParameter('pageNo', 1);
     $pageNumber = $isPaging;
     if (!empty($empNumber) && $this->getUser()->hasAttribute('pageNumber')) {
         $pageNumber = $this->getUser()->getAttribute('pageNumber');
     }
     $noOfRecords = sfConfig::get('app_items_per_page');
     $offset = $pageNumber >= 1 ? ($pageNumber - 1) * $noOfRecords : ($request->getParameter('pageNo', 1) - 1) * $noOfRecords;
     // Reset filters if requested to
     if ($request->hasParameter('reset')) {
         $this->setFilters(array());
         $this->setSortParameter(array("field" => NULL, "order" => NULL));
         $this->setPage(1);
     }
     $this->form = new EmployeeSearchForm($this->getFilters());
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             if ($this->form->getValue('isSubmitted') == 'yes') {
                 $this->setSortParameter(array("field" => NULL, "order" => NULL));
             }
             $this->setFilters($this->form->getValues());
         } else {
             $this->setFilters(array());
         }
         $this->setPage(1);
     }
     if ($request->isMethod('get')) {
         $sortParam = array("field" => $request->getParameter('sortField'), "order" => $request->getParameter('sortOrder'));
         $this->setSortParameter($sortParam);
         $this->setPage(1);
     }
     $sort = $this->getSortParameter();
     $sortField = $sort["field"];
     $sortOrder = $sort["order"];
     $filters = $this->getFilters();
     if (isset($filters['employee_name'])) {
         $filters['employee_name'] = str_replace(' (' . __('Past Employee') . ')', '', $filters['employee_name']['empName']);
     }
     if (isset($filters['supervisor_name'])) {
         $filters['supervisor_name'] = str_replace(' (' . __('Past Employee') . ')', '', $filters['supervisor_name']);
     }
     $this->filterApply = !empty($filters);
     $accessibleEmployees = UserRoleManagerFactory::getUserRoleManager()->getAccessibleEntityIds('Employee');
     if (count($accessibleEmployees) > 0) {
         $filters['employee_id_list'] = $accessibleEmployees;
         $count = $this->getEmployeeService()->getSearchEmployeeCount($filters);
         $parameterHolder = new EmployeeSearchParameterHolder();
         $parameterHolder->setOrderField($sortField);
         $parameterHolder->setOrderBy($sortOrder);
         $parameterHolder->setLimit($noOfRecords);
         $parameterHolder->setOffset($offset);
         $parameterHolder->setFilters($filters);
         $list = $this->getEmployeeService()->searchEmployees($parameterHolder);
     } else {
         $count = 0;
         $list = array();
     }
     $this->setListComponent($list, $count, $noOfRecords, $pageNumber);
     // Show message if list is empty, and we don't already have a message.
     if (empty($this->message) && count($list) == 0) {
         // Check to see if we have any employees in system
         $employeeCount = $this->getEmployeeService()->getEmployeeCount();
         $this->messageType = "warning";
         if (empty($employeeCount)) {
             $this->message = __("No Employees Available");
         } else {
             $this->message = __(TopLevelMessages::NO_RECORDS_FOUND);
         }
     }
 }