Пример #1
0
 /**
  * @param array  $criteria
  * @param string $settingName
  * @return string
  */
 protected static function getLocation(array $criteria, $settingName = '')
 {
     $location = isset($criteria['Location']['location']['value']) ? $criteria['Location']['location']['value'] : '';
     $locationInfo['zipCode'] = isset($criteria['Location_ZipCode']['geo']['location']) ? $criteria['Location_ZipCode']['geo']['location'] : '';
     if (isset($criteria['Location_City']['like'])) {
         $locationInfo['city'] = $criteria['Location_City']['like'];
     } else {
         if (isset($criteria['Location_City']['multi_like_and'][0])) {
             $locationInfo['city'] = $criteria['Location_City']['multi_like_and'][0];
         }
     }
     if (isset($criteria['Location_State']['multi_like'])) {
         foreach ($criteria['Location_State']['multi_like'] as $stateSID) {
             if (!empty($stateSID)) {
                 $stateInfo = SJB_StatesManager::getStateInfoBySID($stateSID);
                 $locationInfo['state'] = !empty($stateInfo['state_code']) ? $stateInfo['state_code'] : '';
             }
         }
     }
     $result = '';
     if (!empty($location)) {
         $result = $location;
     }
     foreach ($locationInfo as $value) {
         if (!empty($value) && $value != $location) {
             if (!empty($result)) {
                 $result .= ",{$value}";
             } else {
                 $result = $value;
             }
         }
     }
     if (!empty($settingName) && empty($result)) {
         $result = SJB_Settings::getSettingByName($settingName);
     }
     if (!empty($result)) {
         $result = trim($result);
         $result = urlencode($result);
     }
     return empty($result) ? '' : $result;
 }
Пример #2
0
 private static function changeLocationProperties(&$exportProperties, &$exportData)
 {
     $locationFieldsInfo = SJB_UserProfileFieldManager::getFieldsInfoByType('location');
     foreach ($locationFieldsInfo as $fieldInfo) {
         if (isset($exportProperties[$fieldInfo['id']])) {
             unset($exportProperties[$fieldInfo['id']]);
             $exportLocationProperties[$fieldInfo['id'] . '.Country'] = $fieldInfo['id'] . '.Country';
             $exportLocationProperties[$fieldInfo['id'] . '.State'] = $fieldInfo['id'] . '.State';
             $exportLocationProperties[$fieldInfo['id'] . '.City'] = $fieldInfo['id'] . '.City';
             $exportLocationProperties[$fieldInfo['id'] . '.ZipCode'] = $fieldInfo['id'] . '.ZipCode';
             $exportLocationProperties[$fieldInfo['id'] . '.Address'] = $fieldInfo['id'] . '.Address';
             ksort($exportLocationProperties);
             $exportProperties = array_merge($exportProperties, $exportLocationProperties);
             foreach ($exportData as $userSID => $property) {
                 if (isset($property[$fieldInfo['id']]) && is_array($property[$fieldInfo['id']])) {
                     $propertyLocation = array();
                     foreach ($property[$fieldInfo['id']] as $locationField => $fieldValue) {
                         if ($locationField == 'Country' && !empty($locationField)) {
                             $countryInfo = SJB_CountriesManager::getCountryInfoBySID($fieldValue);
                             $fieldValue = !empty($countryInfo['country_name']) ? $countryInfo['country_name'] : '';
                         } elseif ($locationField == 'State') {
                             $stateInfo = SJB_StatesManager::getStateInfoBySID($fieldValue);
                             $fieldValue = !empty($stateInfo['state_name']) ? $stateInfo['state_name'] : '';
                         }
                         $propertyLocation[$fieldInfo['id'] . '.' . $locationField] = $fieldValue;
                     }
                     unset($property[$fieldInfo['id']]);
                     ksort($propertyLocation);
                     $exportData[$userSID] = array_merge($property, $propertyLocation);
                 }
             }
         }
     }
 }
Пример #3
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action', 'list');
     $countrySID = SJB_Request::getVar('country_sid', false);
     $errors = array();
     $template = 'states.tpl';
     $countries = SJB_CountriesManager::getAllCountries();
     $paginator = new SJB_StatesPagination();
     switch ($action) {
         case 'move_state':
         case 'save_order':
             $template = 'move_state.tpl';
             $itemSIDs = SJB_Request::getVar('item_order', array());
             try {
                 SJB_StatesManager::saveItemsOrder($paginator->currentPage, $paginator->itemsPerPage, $itemSIDs);
                 $tp->assign('action', $action);
             } catch (Exception $e) {
                 $errors['SAVING_ORDER'] = $e->getMessage();
             }
             $states = SJB_StatesManager::getAllStates($countrySID);
             $tp->assign('states', $states);
             break;
         case 'activate':
             $statesSIDs = array_keys(SJB_Request::getVar('states', array()));
             foreach ($statesSIDs as $stateSID) {
                 SJB_StatesManager::activateStateBySID($stateSID);
             }
             $action = 'list';
             break;
         case 'deactivate':
             $statesSIDs = array_keys(SJB_Request::getVar('states', array()));
             foreach ($statesSIDs as $stateSID) {
                 SJB_StatesManager::deactivateStateBySID($stateSID);
             }
             $action = 'list';
             break;
         case 'delete':
             $statesSIDs = array_keys(SJB_Request::getVar('states', array()));
             foreach ($statesSIDs as $stateSID) {
                 SJB_StatesManager::deleteStateBySID($stateSID);
             }
             $action = 'list';
             break;
         case 'add_state':
             $template = 'add_state.tpl';
             $formSubmitted = SJB_Request::getVar('action_add', false);
             $state = new SJB_State($_REQUEST);
             $addStateForm = new SJB_Form($state);
             $addStateForm->registerTags($tp);
             $addValidParam = array('field' => 'country_sid', 'value' => $countrySID);
             if ($formSubmitted && $addStateForm->isDataValid($errors, $addValidParam)) {
                 $state->addProperty(array('id' => 'country_sid', 'type' => 'list', 'value' => $countrySID, 'is_required' => true, 'is_system' => true));
                 SJB_StatesManager::saveState($state);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/states/?country_sid=" . $countrySID);
             } else {
                 $formFields = $addStateForm->getFormFieldsInfo();
                 $tp->assign('form_fields', $formFields);
             }
             break;
         case 'edit_state':
             $template = 'edit_state.tpl';
             $stateSID = SJB_Request::getVar('state_id', false);
             $formSubmitted = SJB_Request::getVar('action_add', false);
             $stateInfo = SJB_StatesManager::getStateInfoBySID($stateSID);
             if ($stateInfo) {
                 $stateInfo = array_merge($stateInfo, $_REQUEST);
                 $state = new SJB_State($stateInfo);
                 $addStateForm = new SJB_Form($state);
                 $addStateForm->registerTags($tp);
                 $state->setSID($stateSID);
                 $addValidParam = array('field' => 'country_sid', 'value' => $stateInfo['country_sid']);
                 if ($formSubmitted && $addStateForm->isDataValid($errors, $addValidParam)) {
                     SJB_StatesManager::saveState($state);
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/states/?country_sid=" . $stateInfo['country_sid']);
                 } else {
                     $formFields = $addStateForm->getFormFieldsInfo();
                     $tp->assign('form_fields', $formFields);
                     $tp->assign('state_id', $stateSID);
                 }
             } else {
                 $tp->assign('action', 'edit');
                 $errors['WRONG_STATE_ID_SPECIFIED'] = 'WRONG_STATE_ID_SPECIFIED';
                 $template = 'state_errors.tpl';
             }
             break;
         case 'import_states':
             $template = 'import_states.tpl';
             $fileInfo = isset($_FILES['import_file']) ? $_FILES['import_file'] : null;
             $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
             if ($fileInfo['error']) {
                 $errors[] = SJB_UploadFileManager::getErrorId($fileInfo['error']);
             } elseif ($fileInfo) {
                 $fileFormats = array('csv', 'xls', 'xlsx');
                 $pathInfo = pathinfo($fileInfo['name']);
                 $fileExtension = isset($pathInfo['extension']) ? strtolower($pathInfo['extension']) : '';
                 if (!in_array(strtolower($fileExtension), $fileFormats)) {
                     $errors[] = 'Please choose Excel or csv file';
                 } else {
                     $importFile = new SJB_ImportFileXLS($fileInfo);
                     $importFile->parse();
                     $importedData = $importFile->getData();
                     $state = new SJB_State();
                     $count = 0;
                     foreach ($importedData as $key => $importedColumn) {
                         if ($key == 1) {
                             $data = array_merge(array(array('state_code', 'state_name')), array($importedColumn));
                             $importedProcessor = new SJB_ImportedStateProcessor($data, $state);
                         }
                         if (!$importedColumn) {
                             continue;
                         }
                         $stateInfo = $importedProcessor->getData($importedColumn);
                         if (!empty($stateInfo['state_code']) && !empty($stateInfo['state_name'])) {
                             $state = new SJB_State($stateInfo);
                             $state->addProperty(array('id' => 'country_sid', 'type' => 'list', 'value' => $countrySID, 'is_required' => true, 'is_system' => true));
                             $state->setPropertyValue('active', 1);
                             $stateSID = SJB_StatesManager::getStateSIDByStateCode($stateInfo['state_code'], $countrySID);
                             if ($stateSID) {
                                 $state->setSID($stateSID);
                             } else {
                                 $count++;
                             }
                             SJB_StatesManager::saveState($state);
                         }
                     }
                     $tp->assign('imported_states_count', $count);
                     $template = 'import_states_result.tpl';
                 }
             }
             break;
     }
     if ($action == 'list') {
         $countryCode = SJB_Settings::getSettingByName('default_country_code');
         if (!$countrySID) {
             $countrySID = SJB_CountriesManager::getCountrySIDByCountryCode($countryCode);
         }
         if (!$countrySID) {
             $allCountries = SJB_CountriesManager::getAllCountries();
             foreach ($allCountries as $country) {
                 $countrySID = $country['sid'];
                 break;
             }
         }
         $countryInfo = SJB_CountriesManager::getCountryInfoBySID($countrySID);
         if ($countryInfo && $countryInfo['country_code'] != $countryCode) {
             SJB_Settings::updateSetting('default_country_code', $countryInfo['country_code']);
         }
         $states = SJB_StatesManager::getAllStates($countrySID, ($paginator->currentPage - 1) * $paginator->itemsPerPage, $paginator->itemsPerPage);
         $paginator->setItemsCount(SJB_StatesManager::countStates($countrySID));
         $tp->assign('states', $states);
         $tp->assign('paginationInfo', $paginator->getPaginationInfo());
     }
     $tp->assign("countries", $countries);
     $tp->assign("country_sid", $countrySID);
     $tp->assign("errors", $errors);
     $tp->display($template);
 }
Пример #4
0
 public static function getListingsFromBeyond($params)
 {
     $listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($params->listing_type_sid);
     if ($listingTypeID == 'Job' && $GLOBALS['uri'] == '/search-results-jobs/' || $GLOBALS['uri'] == '/ajax/') {
         $limit = SJB_Settings::getSettingByName('countBeyondListings');
         $start = $limit * ($params->listing_search_structure['current_page'] - 1) + 1;
         if ($limit) {
             // SET PARAMS FOR REQUEST
             $criteria = $params->criteria_saver->criteria;
             $categoryCriteria = isset($criteria['JobCategory']['multi_like']) ? $criteria['JobCategory']['multi_like'] : '';
             $category = SJB_Settings::getSettingByName('BeyondIndustryList');
             if (!empty($categoryCriteria)) {
                 $categoryFromCriteria = self::getCategory($categoryCriteria);
                 if ($category) {
                     $category = explode('|', $category);
                     $category = array_unique(array_merge($category, $categoryFromCriteria));
                 } else {
                     $category = $categoryFromCriteria;
                 }
                 $category = implode('|', $category);
             }
             $keywords = SJB_Settings::getSettingByName('BeyondKeywords');
             foreach ($criteria as $field) {
                 if (is_array($field)) {
                     foreach ($field as $fieldType => $values) {
                         if ($fieldType === 'multi_like_and') {
                             foreach ($values as $val) {
                                 if ($keywords != '') {
                                     $keywords .= ' AND ';
                                 }
                                 $keywords .= $val;
                             }
                         }
                         if ($fieldType === 'location') {
                             if (isset($values['value']) && !empty($values['value'])) {
                                 if ($keywords != '') {
                                     $keywords .= ' AND ';
                                 }
                                 $keywords .= $values['value'];
                             }
                         }
                         if ($fieldType === 'like') {
                             if ($keywords != '') {
                                 $keywords .= ' AND ';
                             }
                             $keywords .= $values;
                         }
                     }
                 }
             }
             if (isset($criteria['keywords']) && !empty($criteria['keywords'])) {
                 foreach ($criteria['keywords'] as $key => $item) {
                     if (in_array($key, array('exact_phrase', 'any_words', 'all_words', 'like'))) {
                         if (!empty($keywords)) {
                             $keywords .= ' OR ';
                         }
                         $keywords .= $item;
                     }
                 }
             }
             if (substr($keywords, -4) == ' OR ') {
                 $keywords = substr($keywords, 0, strlen($keywords) - 4);
             }
             $keywords = trim($keywords);
             $keywords = urlencode($keywords);
             $keywords = !empty($keywords) ? "({$keywords})" : '';
             $city = '';
             if (!empty($criteria['Location_City']['like'])) {
                 $city = urlencode($criteria['Location_City']['like']);
             } else {
                 if (!empty($criteria['Location_City']['multi_like_and'][0])) {
                     $city = urlencode($criteria['Location_City']['multi_like_and'][0]);
                 } else {
                     if (!empty($criteria['Location']['location']['value'])) {
                         $city = urlencode($criteria['Location']['location']['value']);
                     }
                 }
             }
             $state = SJB_Settings::getSettingByName('BeyondState');
             if (isset($criteria['Location_State']['multi_like'])) {
                 foreach ($criteria['Location_State']['multi_like'] as $stateSID) {
                     if (!empty($stateSID)) {
                         $stateInfo = SJB_StatesManager::getStateInfoBySID($stateSID);
                         $state = !empty($stateInfo['state_code']) ? $stateInfo['state_code'] : '';
                     }
                 }
             }
             $countryCriteria = isset($criteria['Location_Country']['multi_like'][0]) ? $criteria['Location_Country']['multi_like'][0] : SJB_Settings::getSettingByName('BeyondCountry');
             $country = SJB_Settings::getSettingByName('BeyondCountry');
             if ($countryCriteria && is_numeric($countryCriteria)) {
                 $countryInfo = SJB_CountriesManager::getCountryInfoBySID($countryCriteria);
                 $country = !empty($countryInfo['country_code']) ? $countryInfo['country_code'] : '';
             }
             $employmentTypeCriteria = isset($criteria['EmploymentType']['multi_like']) ? $criteria['EmploymentType']['multi_like'] : '';
             $employmentType = SJB_Settings::getSettingByName('BeyonEmploymentType');
             if ($employmentTypeCriteria) {
                 $employmentType = self::getEmploymentType($employmentTypeCriteria);
             }
             $zipCode = SJB_Settings::getSettingByName('BeyondZipcode');
             if (isset($criteria['Location_ZipCode']['geo']['location']) && !empty($criteria['Location_ZipCode']['geo']['location'])) {
                 $zipCode = $criteria['Location_ZipCode']['geo']['location'];
             }
             $educationLevel = SJB_Settings::getSettingByName('BeyonEducationLevel');
             $experienceLevel = SJB_Settings::getSettingByName('BeyonExperienceLevel');
             $affID = SJB_Settings::getSettingByName('BeyondAffiliateID');
             $isIPhone = false;
             if (class_exists('MobilePlugin')) {
                 $isIPhone = MobilePlugin::isPhone();
             }
             if (str_replace('www.', '', $_SERVER['HTTP_HOST']) === SJB_Settings::getValue('mobile_url') || SJB_Settings::getValue('detect_iphone') && $isIPhone) {
                 $mobileAffID = SJB_Settings::getSettingByName('MobileBeyondAffiliateID');
                 $affID = $mobileAffID ? $mobileAffID : $affID;
             }
             $url = "http://www.beyond.com/common/services/job/search/default.asp?aff={$affID}&kw={$keywords}&kt=3&il={$category}&ct={$country}&st={$state}&zc={$zipCode}&el={$educationLevel}&et={$employmentType}&ex={$experienceLevel}&nw=e&pn={$start}&mx={$limit}&fwhere={$city}";
             $ch = curl_init();
             // set URL and other appropriate options
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             // grab URL and pass it to the browser
             $xml = curl_exec($ch);
             // close cURL resource, and free up system resources
             curl_close($ch);
             $beyondListings = array();
             if ($xml !== false) {
                 $doc = new DOMDocument();
                 $doc->loadXML($xml, LIBXML_NOERROR | LIBXML_NOWARNING);
                 $results = $doc->getElementsByTagName('Item');
                 if ($results instanceof DOMNodeList) {
                     // if we need just total results number
                     foreach ($results as $node) {
                         $resultXML = simplexml_import_dom($node);
                         $jobKey = (string) $resultXML->SourceInformationID;
                         $location = explode(',', (string) $resultXML->Location);
                         $state = '';
                         $stateCode = '';
                         $country = '';
                         $city = !empty($location[0]) ? $location[0] : '';
                         if (isset($location[1])) {
                             $location = explode(' ', trim($location[1]));
                             if (!empty($location[0])) {
                                 $stateCode = trim($location[0]);
                                 $state = self::getState($stateCode);
                             }
                             if (!empty($location[1])) {
                                 $country = self::getCountry(trim($location[1]));
                             }
                         }
                         $beyondListings[$jobKey] = array('Title' => (string) $resultXML->Title, 'CompanyName' => (string) $resultXML->CompanyName, 'JobDescription' => (string) $resultXML->ShortDescription, 'JobCategory' => (string) $resultXML->CareerFocus, 'State' => $state, 'Country' => $country, 'City' => $city, 'Location' => array('Country' => $country, 'State' => $state, 'State_Code' => $stateCode, 'City' => $city), 'url' => SJB_System::getSystemSettings('SITE_URL') . '/partnersite/?url=' . base64_encode((string) $resultXML->ApplyURL), 'jobkey' => $jobKey, 'activation_date' => (string) $resultXML->Modified, 'api' => 'beyond', 'code' => '<span id=beyond_at><a href="http://www.beyond.com/">jobs</a> by <a href="http://www.beyond.com/" title="Job Search"><img src="' . SJB_System::getSystemSettings('SITE_URL') . '/system/plugins/beyond_integration_plugin/logo.png" style="border: 0; vertical-align: middle;" alt="Beyond job search"></a></span>');
                     }
                 } else {
                     SJB_Logger::error('CANT GET BEYOND XML RESULTS');
                 }
             } else {
                 SJB_Logger::error('NOT VALID RESPONSE FROM BEYOND');
             }
             self::$beyondListings = $beyondListings;
         }
     }
     return $params;
 }
Пример #5
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $appsPerPage = SJB_Request::getVar('appsPerPage', 10);
     $this->currentPage = SJB_Request::getVar('page', 1);
     $currentUser = SJB_UserManager::getCurrentUser();
     $appJobId = SJB_Request::getVar('appJobId', false, null, 'int');
     $score = SJB_Request::getVar('score', false);
     $orderBy = SJB_Request::getVar('orderBy', 'date');
     $order = SJB_Request::getVar('order', 'desc');
     $displayTemplate = "view.tpl";
     $errors = array();
     // не бум пускать незарегенных
     if (SJB_UserManager::isUserLoggedIn() === false) {
         $tp->assign("ERROR", "NOT_LOGIN");
         $tp->display("../miscellaneous/error.tpl");
         return;
     }
     $filename = SJB_Request::getVar('filename', false);
     if ($filename) {
         $appsID = SJB_Request::getVar('appsID', false);
         if ($appsID) {
             $file = SJB_UploadFileManager::openApplicationFile($filename, $appsID);
             if (!$file) {
                 $errors['NO_SUCH_FILE'] = true;
             }
         } else {
             $errors['NO_SUCH_APPS'] = true;
         }
     }
     if (!is_numeric($this->currentPage) || $this->currentPage < 1) {
         $this->currentPage = 1;
     }
     if (!is_numeric($appsPerPage) || $appsPerPage < 1) {
         $appsPerPage = 10;
     }
     if ($order != 'asc' && $order != 'desc') {
         $order = 'desc';
     }
     if (!empty($score) && $score != 'passed' && $score != 'not_passed') {
         $score = false;
     }
     $tp->assign("orderBy", $orderBy);
     $tp->assign("order", $order);
     if (isset($orderBy) && isset($order) && $orderBy != "") {
         switch ($orderBy) {
             case "date":
                 $orderInfo = array('sorting_field' => 'date', 'sorting_order' => $order);
                 break;
             case "title":
                 $orderInfo = array('sorting_field' => 'Title', 'sorting_order' => $order, 'inner_join' => array('table' => 'listings', 'field1' => 'sid', 'field2' => 'listing_id'));
                 break;
             case "applicant":
                 $orderInfo = false;
                 $sortByUsername = true;
                 break;
             case "status":
                 $orderInfo = array('sorting_field' => 'status', 'sorting_order' => $order);
                 break;
             case "score":
                 $orderInfo = array('sorting_field' => 'score', 'sorting_order' => $order);
                 break;
             case "company":
                 $orderInfo = array('sorting_field' => 'CompanyName', 'sorting_order' => $order, 'inner_join' => array('table' => 'listings', 'field1' => 'sid', 'field2' => 'listing_id'), 'inner_join2' => array('table1' => 'users', 'table2' => 'listings', 'field1' => 'sid', 'field2' => 'user_sid'));
                 break;
             default:
                 $orderInfo = array('sorting_field' => 'date', 'sorting_order' => $order);
         }
     }
     if ($currentUser->getUserGroupSID() == 41) {
         // Работадатель
         switch (SJB_Request::getVar('action', '')) {
             case "approve":
                 $applications = SJB_Request::getVar('applications', '');
                 if (!empty($applications)) {
                     if (is_array($applications)) {
                         foreach ($applications as $key => $value) {
                             $this->approveApplication($key);
                         }
                     } else {
                         $this->approveApplication($applications);
                     }
                 }
                 break;
             case "reject":
                 $applications = SJB_Request::getVar('applications', '');
                 if (!empty($applications)) {
                     if (is_array($applications)) {
                         foreach ($applications as $key => $value) {
                             $this->rejectApplication($key);
                         }
                     } else {
                         $this->rejectApplication($applications);
                     }
                 }
                 break;
             case "delete":
                 if (isset($_POST["applications"])) {
                     foreach ($_POST["applications"] as $key => $value) {
                         SJB_Applications::hideEmp($key);
                     }
                 }
                 break;
         }
         $whereSubuser = '';
         if (!empty($subuser)) {
             $whereSubuser = '******' . SJB_DB::quote($subuser);
         }
         $jobs = SJB_DB::query('select `Title` as `title`, `sid` as `id` from `listings` where `user_sid` = ?n' . $whereSubuser, $currentUser->sid);
         $listingTitle = null;
         foreach ($jobs as $job) {
             if ($job['id'] == $appJobId) {
                 $listingTitle = $job['title'];
             }
         }
         $apps = $this->executeApplicationsForEmployer($appsPerPage, $appJobId, $currentUser, $score, $orderInfo, $listingTitle);
         if (empty($apps) && $this->currentPage > 1) {
             $this->currentPage = 1;
             $apps = $this->executeApplicationsForEmployer($appsPerPage, $appJobId, $currentUser, $score, $orderInfo, $listingTitle);
         }
         foreach ($apps as $i => $app) {
             $apps[$i]["job"] = SJB_ListingManager::getListingInfoBySID($apps[$i]["listing_id"]);
             if (!empty($apps[$i]["job"]['screening_questionnaire'])) {
                 $screening_questionnaire = SJB_ScreeningQuestionnaires::getInfoBySID($apps[$i]["job"]['screening_questionnaire']);
                 $passing_score = 0;
                 switch ($screening_questionnaire['passing_score']) {
                     case 'acceptable':
                         $passing_score = 1;
                         break;
                     case 'good':
                         $passing_score = 2;
                         break;
                     case 'very_good':
                         $passing_score = 3;
                         break;
                     case 'excellent':
                         $passing_score = 4;
                         break;
                 }
                 if ($apps[$i]['score'] >= $passing_score) {
                     $apps[$i]['passing_score'] = 'Passed';
                 } else {
                     $apps[$i]['passing_score'] = 'Not passed';
                 }
             }
             if (isset($apps[$i]["resume"]) && !empty($apps[$i]["resume"])) {
                 $apps[$i]["resumeInfo"] = SJB_ListingManager::getListingInfoBySID($apps[$i]["resume"]);
             }
             // если это анонимный соискатель - то возьмем имя из пришедшего поля 'username'
             if ($apps[$i]['jobseeker_id'] == 0) {
                 $apps[$i]["user"]["FirstName"] = $apps[$i]['username'];
             } else {
                 $apps[$i]["user"] = SJB_UserManager::getUserInfoBySID($apps[$i]["jobseeker_id"]);
                 $apps[$i]['user']['stateInfo'] = SJB_StatesManager::getStateInfoBySID($apps[$i]['user']['Location_State']);
                 if (isset($apps[$i]['user']['stateInfo']['state_code'])) {
                     $apps[$i]['user']['Location']['State_Code'] = $apps[$i]['user']['stateInfo']['state_code'];
                 }
             }
         }
         $tp->assign("appsPerPage", $appsPerPage);
         $tp->assign("currentPage", $this->currentPage);
         $tp->assign("pages", $this->pages);
         $tp->assign("totalPages", $this->totalPages);
         $tp->assign("appJobs", $jobs);
         $tp->assign("score", $score);
         $tp->assign("current_filter", $appJobId);
         $tp->assign("listing_title", $listingTitle);
     } else {
         // Соискатель
         if (SJB_Request::getVar('action', '', 'POST') == "delete") {
             foreach (SJB_Request::getVar('applications', array(), 'POST') as $key => $value) {
                 SJB_Applications::hideJS($key);
             }
         }
         $apps = SJB_Applications::getByJobseeker($currentUser->sid, $orderInfo);
         for ($i = 0; $i < count($apps); ++$i) {
             $apps[$i]["job"] = SJB_ListingManager::getListingInfoBySID($apps[$i]["listing_id"]);
             $apps[$i]["company"] = SJB_UserManager::getUserInfoBySID($apps[$i]["job"]["user_sid"]);
         }
         $displayTemplate = "view_seeker.tpl";
     }
     if (isset($sortByUsername)) {
         $sortKeys = array();
         $order = $order == "desc" ? SORT_DESC : SORT_ASC;
         foreach ($apps as $key => $value) {
             if (!isset($apps[$key]["user"]["FirstName"])) {
                 $apps[$key]["user"]["FirstName"] = '';
             }
             if (!isset($apps[$key]["user"]["LastName"])) {
                 $apps[$key]["user"]["LastName"] = '';
             }
             $sortKeys[$key] = $apps[$key]["user"]["FirstName"] . " " . $apps[$key]["user"]["LastName"];
         }
         array_multisort($sortKeys, $order, SORT_REGULAR, $apps);
     }
     if (empty($apps) && empty($errors['NOT_OWNER_OF_APPLICATIONS'])) {
         $errors['APPLICATIONS_NOT_FOUND'] = true;
     }
     $tp->assign("METADATA", SJB_Application::getApplicationMeta());
     $tp->assign("applications", $apps);
     $tp->assign("errors", $errors);
     $tp->display($displayTemplate);
 }