private function onSearch() { $query_jobTitle = ''; $query_companyName = ''; /* Bail out to prevent an error if the GET string doesn't even contain * a field named 'wildCardString' at all. */ if (!isset($_GET['wildCardString'])) { $this->listByView('No wild card string specified.'); return; } $query = trim($_GET['wildCardString']); /* Set up sorting. */ if ($this->isRequiredIDValid('page', $_GET)) { $currentPage = $_GET['page']; } else { $currentPage = 1; } $searchPager = new SearchPager(CANDIDATES_PER_PAGE, $currentPage, $this->_siteID, $_GET); if ($searchPager->isSortByValid('sortBy', $_GET)) { $sortBy = $_GET['sortBy']; } else { $sortBy = 'title'; } if ($searchPager->isSortDirectionValid('sortDirection', $_GET)) { $sortDirection = $_GET['sortDirection']; } else { $sortDirection = 'ASC'; } $baseURL = CATSUtility::getFilteredGET(array('sortBy', 'sortDirection', 'page'), '&'); $searchPager->setSortByParameters($baseURL, $sortBy, $sortDirection); /* Get our current searching mode. */ $mode = $this->getTrimmedInput('mode', $_GET); /* Execute the search. */ $search = new SearchJobOrders($this->_siteID); switch ($mode) { case 'searchByJobTitle': $query_jobTitle = $query; $rs = $search->byTitle($query, $sortBy, $sortDirection, false); break; case 'searchByCompanyName': $query_companyName = $query; $rs = $search->byCompanyName($query, $sortBy, $sortDirection, false); break; default: $this->listByView('Invalid search mode.'); return; break; } foreach ($rs as $rowIndex => $row) { /* Convert '00-00-00' dates to empty strings. */ $rs[$rowIndex]['startDate'] = DateUtility::fixZeroDate($row['startDate']); if ($row['isHot'] == 1) { $rs[$rowIndex]['linkClass'] = 'jobLinkHot'; } else { $rs[$rowIndex]['linkClass'] = 'jobLinkCold'; } $rs[$rowIndex]['recruiterAbbrName'] = StringUtility::makeInitialName($row['recruiterFirstName'], $row['recruiterLastName'], false, LAST_NAME_MAXLEN); $rs[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName($row['ownerFirstName'], $row['ownerLastName'], false, LAST_NAME_MAXLEN); } /* Save the search. */ $savedSearches = new SavedSearches($this->_siteID); $savedSearches->add(DATA_ITEM_JOBORDER, $query, $_SERVER['REQUEST_URI'], false); $savedSearchRS = $savedSearches->get(DATA_ITEM_JOBORDER); $query = urlencode(htmlspecialchars($query)); $jobOderIDs = implode(',', ResultSetUtility::getColumnValues($rs, 'jobOrderID')); $exportForm = ExportUtility::getForm(DATA_ITEM_JOBORDER, $jobOderIDs, 29, 5); $this->_template->assign('active', $this); $this->_template->assign('subActive', 'Search Job Orders'); $this->_template->assign('pager', $searchPager); $this->_template->assign('exportForm', $exportForm); $this->_template->assign('wildCardString', $query); $this->_template->assign('wildCardString_jobTitle', $query_jobTitle); $this->_template->assign('wildCardString_companyName', $query_companyName); $this->_template->assign('savedSearchRS', $savedSearchRS); $this->_template->assign('rs', $rs); $this->_template->assign('isResultsMode', true); $this->_template->assign('mode', $mode); if (!eval(Hooks::get('JO_ON_SEARCH'))) { return; } $this->_template->display('./modules/joborders/Search.tpl'); }
private function considerForJobSearch($candidateIDArray = array()) { /* Get list of candidates. */ if (isset($_REQUEST['candidateIDArrayStored']) && $this->isRequiredIDValid('candidateIDArrayStored', $_REQUEST, true)) { $candidateIDArray = $_SESSION['CATS']->retrieveData($_REQUEST['candidateIDArrayStored']); } else { if ($this->isRequiredIDValid('candidateID', $_REQUEST)) { $candidateIDArray = array($_REQUEST['candidateID']); } else { if ($candidateIDArray === array()) { $dataGrid = DataGrid::getFromRequest(); $candidateIDArray = $dataGrid->getExportIDs(); } } } if (!is_array($candidateIDArray)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid variable type.'); return; } /* Validate each ID */ foreach ($candidateIDArray as $index => $candidateID) { if (!$this->isRequiredIDValid($index, $candidateIDArray)) { echo '&' . $candidateID . '>'; CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid candidate ID.'); return; } } /* Bail out to prevent an error if the POST string doesn't even contain * a field named 'wildCardString' at all. */ if (!isset($_POST['wildCardString']) && isset($_POST['mode'])) { CommonErrors::fatal(COMMONERROR_WILDCARDSTRING, $this, 'No wild card string specified.'); } $query = $this->getTrimmedInput('wildCardString', $_POST); $mode = $this->getTrimmedInput('mode', $_POST); /* Execute the search. */ $search = new SearchJobOrders($this->_siteID); switch ($mode) { case 'searchByJobTitle': $rs = $search->byTitle($query, 'title', 'ASC', true); $resultsMode = true; break; case 'searchByCompanyName': $rs = $search->byCompanyName($query, 'title', 'ASC', true); $resultsMode = true; break; default: $rs = $search->recentlyModified('DESC', true, 5); $resultsMode = false; break; } $pipelines = new Pipelines($this->_siteID); $pipelinesRS = $pipelines->getCandidatePipeline($candidateIDArray[0]); foreach ($rs as $rowIndex => $row) { if (ResultSetUtility::findRowByColumnValue($pipelinesRS, 'jobOrderID', $row['jobOrderID']) !== false && count($candidateIDArray) == 1) { $rs[$rowIndex]['inPipeline'] = true; } else { $rs[$rowIndex]['inPipeline'] = false; } /* Convert '00-00-00' dates to empty strings. */ $rs[$rowIndex]['startDate'] = DateUtility::fixZeroDate($row['startDate']); if ($row['isHot'] == 1) { $rs[$rowIndex]['linkClass'] = 'jobLinkHot'; } else { $rs[$rowIndex]['linkClass'] = 'jobLinkCold'; } $rs[$rowIndex]['recruiterAbbrName'] = StringUtility::makeInitialName($row['recruiterFirstName'], $row['recruiterLastName'], false, LAST_NAME_MAXLEN); $rs[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName($row['ownerFirstName'], $row['ownerLastName'], false, LAST_NAME_MAXLEN); } if (!eval(Hooks::get('CANDIDATE_ON_CONSIDER_FOR_JOB_SEARCH'))) { return; } $this->_template->assign('rs', $rs); $this->_template->assign('isFinishedMode', false); $this->_template->assign('isResultsMode', $resultsMode); $this->_template->assign('candidateIDArray', $candidateIDArray); $this->_template->assign('candidateIDArrayStored', $_SESSION['CATS']->storeData($candidateIDArray)); $this->_template->display('./modules/candidates/ConsiderSearchModal.tpl'); }