Example #1
0
 /**
  * Retriving candidates based on the search criteria
  * @param CandidateSearchParameters $searchParam
  * @return CandidateSearchParameters
  */
 public function searchCandidates($searchCandidateQuery)
 {
     try {
         $pdo = Doctrine_Manager::connection()->getDbh();
         $res = $pdo->query($searchCandidateQuery);
         $candidateList = $res->fetchAll();
         $candidatesList = array();
         foreach ($candidateList as $candidate) {
             $param = new CandidateSearchParameters();
             $param->setVacancyName($candidate['name']);
             $param->setVacancyStatus($candidate['vacancyStatus']);
             $param->setCandidateId($candidate['id']);
             $param->setVacancyId($candidate['vacancyId']);
             $param->setCandidateName($candidate['first_name'] . " " . $candidate['middle_name'] . " " . $candidate['last_name'] . $this->_getCandidateNameSuffix($candidate['candidateStatus']));
             $employeeName = $candidate['emp_firstname'] . " " . $candidate['emp_middle_name'] . " " . $candidate['emp_lastname'];
             $hmName = !empty($candidate['termination_id']) ? $employeeName . " (" . __("Past Employee") . ")" : $employeeName;
             $param->setHiringManagerName($hmName);
             $param->setDateOfApplication($candidate['date_of_application']);
             $param->setAttachmentId($candidate['attachmentId']);
             $param->setStatusName(ucwords(strtolower($candidate['status'])));
             $referralName = $candidate['ref_firstname'] . " " . $candidate['ref_middle_name'] . " " . $candidate['ref_lastname'];
             $param->setReferralName($referralName);
             $candidatesList[] = $param;
         }
         return $candidatesList;
     } catch (Exception $e) {
         throw new DaoException($e->getMessage());
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     $usrObj = $this->getUser()->getAttribute('user');
     $allowedCandidateList = $usrObj->getAllowedCandidateList();
     $allowedVacancyList = $usrObj->getAllowedVacancyList();
     $allowedCandidateListToDelete = $usrObj->getAllowedCandidateListToDelete();
     $isAdmin = $usrObj->isAdmin();
     if (!($usrObj->isAdmin() || $usrObj->isHiringManager() || $usrObj->isInterviewer())) {
         $this->redirect('pim/viewPersonalDetails');
     }
     $param = array('allowedCandidateList' => $allowedCandidateList, 'allowedVacancyList' => $allowedVacancyList, 'allowedCandidateListToDelete' => $allowedCandidateListToDelete);
     list($this->messageType, $this->message) = $this->getUser()->getFlash('candidateListMessageItems');
     $candidateId = $request->getParameter('candidateId');
     $sortField = $request->getParameter('sortField');
     $sortOrder = $request->getParameter('sortOrder');
     $isPaging = $request->getParameter('pageNo');
     $pageNumber = $isPaging;
     if (!is_null($this->getUser()->getAttribute('pageNumber')) && !($pageNumber >= 1)) {
         $pageNumber = $this->getUser()->getAttribute('pageNumber');
     }
     $this->getUser()->setAttribute('pageNumber', $pageNumber);
     $searchParam = new CandidateSearchParameters();
     $searchParam->setIsAdmin($isAdmin);
     $searchParam->setEmpNumber($request->getParameter('referralId'));
     $searchParam->setReferralName($request->getParameter('referralName'));
     $noOfRecords = $searchParam->getLimit();
     $offset = $pageNumber >= 1 ? ($pageNumber - 1) * $noOfRecords : ($request->getParameter('pageNo', 1) - 1) * $noOfRecords;
     $searchParam->setAdditionalParams($request->getParameter('additionalParams', array()));
     $this->setForm(new viewCandidatesForm(array(), $param, true));
     if (!empty($sortField) && !empty($sortOrder) || $isPaging > 0 || $candidateId > 0) {
         if ($this->getUser()->hasAttribute('searchParameters')) {
             $searchParam = $this->getUser()->getAttribute('searchParameters');
             $this->form->setDefaultDataToWidgets($searchParam);
         }
         $searchParam->setSortField($sortField);
         $searchParam->setSortOrder($sortOrder);
     } else {
         $this->getUser()->setAttribute('searchParameters', $searchParam);
         $offset = 0;
         $pageNumber = 1;
     }
     $searchParam->setAllowedCandidateList($allowedCandidateList);
     $searchParam->setAllowedVacancyList($allowedVacancyList);
     $searchParam->setOffset($offset);
     $candidates = $this->getCandidateService()->searchCandidates($searchParam);
     $this->_setListComponent($usrObj, $candidates, $noOfRecords, $searchParam, $pageNumber);
     $params = array();
     $this->parmetersForListCompoment = $params;
     if (empty($isPaging)) {
         if ($request->isMethod('post')) {
             $pageNumber = 1;
             $searchParam->setOffset(0);
             $this->getUser()->setAttribute('pageNumber', $pageNumber);
             $this->form->bind($request->getParameter($this->form->getName()));
             if ($this->form->isValid()) {
                 $srchParams = $this->form->getSearchParamsBindwithFormData($searchParam);
                 $this->getUser()->setAttribute('searchParameters', $srchParams);
                 $candidates = $this->getCandidateService()->searchCandidates($srchParams);
                 $this->_setListComponent($usrObj, $candidates, $noOfRecords, $searchParam, $pageNumber);
             }
         }
     }
 }
 /**
  *
  * @param CandidateSearchParameters $searchParam
  * @return CandidateSearchParameters
  */
 public function getSearchParamsBindwithFormData(CandidateSearchParameters $searchParam)
 {
     $searchParam->setJobTitleCode($this->getValue('jobTitle'));
     $searchParam->setVacancyId($this->getValue('jobVacancy'));
     $searchParam->setHiringManagerId($this->getValue('hiringManager'));
     $searchParam->setStatus($this->getValue('status'));
     $searchParam->setCandidateId($this->getValue('selectedCandidate'));
     $searchParam->setModeOfApplication($this->getValue('modeOfApplication'));
     $dateApplication = $this->getValue('dateApplication');
     $searchParam->setFromDate($dateApplication['from']);
     $searchParam->setToDate($dateApplication['to']);
     $searchParam->setKeywords($this->getValue('keywords'));
     $searchParam->setCandidateName($this->getValue('candidateName'));
     $searchParam->setEmpNumber($this->getValue('referralId'));
     $searchParam->setReferralName($this->getValue('referralName'));
     return $searchParam;
 }