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;
 }
 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);
         }
     }
 }