/** * Retrieve employment status list. * @return array() $choice */ private function _getChoiceData() { $choice = array(); $choice['0'] = __('All'); $companyStructureService = new CompanyStructureService(); $treeObject = $companyStructureService->getSubunitTreeObject(); $tree = $treeObject->fetchTree(); foreach ($tree as $node) { if ($node->getId() != 1) { $value = $this->getSubUnitsChain($node); $choice[$value] = str_repeat(' ', $node['level'] - 1) . $node['name']; } } // asort($choice); return $choice; }
/** * Retrieve employment status list. * @return array() $choice */ private function _getChoiceData() { $choice = array(); $choice['0'] = __('All'); $companyStructureService = new CompanyStructureService(); $treeObject = $companyStructureService->getSubunitTreeObject(); $tree = $treeObject->fetchTree(); foreach ($tree as $node) { if ($node->getId() != 1) { $value = $node->getId(); $children = $node->getNode()->getChildren(); if ($children !== false) { foreach ($children as $childNode) { $value = $value . "," . $childNode->getId(); } } $choice[$value] = str_repeat(' ', $node['level'] - 1) . $node['name']; } } // asort($choice); return $choice; }
/** * Handles showing review search form and * listing searched reviews. */ public function executeViewReview(sfWebRequest $request) { $performanceReviewService = $this->getPerformanceReviewService(); /* Job title list */ $this->jobList = $this->getJobTitleService()->getJobTitleList("", "", false); /* Employee list */ if ($this->loggedAdmin) { $employeeService = new EmployeeService(); $this->empJson = $employeeService->getEmployeeListAsJson(); } elseif ($this->loggedReviewer) { $this->empJson = $performanceReviewService->getRevieweeListAsJson($this->loggedEmpId, true); } /* Showing Performance Review Search form * ====================================== */ $this->form = new ViewReviewForm(array(), array('empJson' => $this->empJson), true); /* Subdivision list */ $compStructure = new CompanyStructureService(); $treeObject = $compStructure->getSubunitTreeObject(); $this->tree = $treeObject->fetchTree(); /* Checking whether a newly invoked search form */ $newSearch = false; if ($request->getParameter('mode') == 'new') { $newSearch = true; } /* Preserving search clues */ $hdnEmpId = $request->getParameter("hdnEmpId"); if (isset($hdnEmpId) && !$newSearch) { // If the user has performed a new search $this->clues = $this->getReviewSearchClues($request); } else { if ($this->getUser()->hasAttribute('prSearchClues') && !$newSearch) { $this->clues = $this->getUser()->getAttribute('prSearchClues'); } if ($this->getUser()->hasFlash('prClues') && !$newSearch) { $this->clues = $this->getUser()->getFlash('prClues'); } } /* Processing reviews * ================== */ if ($request->isMethod('post')) { $page = 1; $this->clues['pageNo'] = 1; } elseif ($request->getParameter('page')) { $page = $request->getParameter('page'); $this->clues['pageNo'] = $page; } elseif ($this->clues['pageNo']) { $page = $this->clues['pageNo']; } /* Preserving search clues */ if (!isset($this->clues)) { $this->clues = $this->getReviewSearchClues($request); } $this->getUser()->setAttribute('prSearchClues', $this->clues); /* Checking whether wrong seacrch criteria */ if (!$this->_isCorrectEmployee($this->clues['empId'], $this->clues['empName']) || !$this->_isCorrectEmployee($this->clues['reviewerId'], $this->clues['reviewerName'])) { $this->templateMessage = array('WARNING', __(TopLevelMessages::NO_RECORDS_FOUND)); return; } /* Setting logged in user type */ if (!$this->loggedAdmin && $this->loggedReviewer) { $this->clues['loggedReviewerId'] = $this->loggedEmpId; } elseif (!$this->loggedAdmin && !$this->loggedReviewer) { $this->clues['loggedEmpId'] = $this->loggedEmpId; } /* Pagination */ if (!isset($page)) { $page = 1; } $this->pager = new SimplePager('PerformanceReview', sfConfig::get('app_items_per_page')); $this->pager->setPage($page); $this->pager->setNumResults($performanceReviewService->countReviews($this->clues)); $this->pager->init(); /* Fetching reviews */ $offset = $this->pager->getOffset(); $offset = empty($offset) ? 0 : $offset; $limit = $this->pager->getMaxPerPage(); $this->reviews = $performanceReviewService->searchPerformanceReview($this->clues, $offset, $limit); /* Setting template message */ if ($this->getUser()->hasFlash('templateMessage')) { $this->templateMessage = $this->getUser()->getFlash('templateMessage'); } elseif (count($this->reviews) == 0) { $this->templateMessage = array('WARNING', __(TopLevelMessages::NO_RECORDS_FOUND)); } }