public function address()
 {
     $address = "";
     if (isset($this->address) && !empty($this->address)) {
         $address .= $this->address . ":";
     }
     if (isset($this->address2) && !empty($this->address2)) {
         $address .= $this->address2 . ":";
     }
     if (isset($this->city) && !empty($this->city)) {
         $city = City::find_by_code($this->country, $this->state_province, $this->county, $this->city);
         $address .= $city->name . ":";
     }
     //county
     if (isset($this->county) && !empty($this->county)) {
         $county = County::find_by_code($this->country, $this->state_province, $this->county);
         $address .= $county->name . ":";
     }
     //states
     if (isset($this->state_province) && !empty($this->state_province)) {
         $state_province = StateProvince::find_by_code($this->country, $this->state_province);
         $address .= $state_province->name . ":";
     }
     //post code
     if (isset($this->post_code) && !empty($this->post_code)) {
         $address .= $this->post_code . ":";
     }
     //country
     if (isset($this->country) && !empty($this->country)) {
         $country = Country::find_by_code($this->country);
         $address .= $country->name . ":";
     } else {
         return "";
     }
     return $address;
 }
<?php

$req = return_url();
$var_name = $req[1];
$jobs = new Job();
$job = $jobs->find_by_var_name($var_name);
$smarty->assign('job', $job);
$job_id = (int) $job->id;
if ($job && !empty($job)) {
    $smarty->assign('job_title', safe_output(strip_html($job->job_title)));
    $smarty->assign('job_description', subtrack_string(strip_html($job->job_description), 500));
    $smarty->assign('created_at', safe_output(strftime(DATE_FORMAT, strtotime($job->created_at))));
    $city = City::find_by_code($job->country, $job->state_province, $job->county, $job->city);
    $city_name = empty($city) ? $job->city : $city->name;
    $smarty->assign('location', $city_name);
}
if (isset($_POST['bt_send'])) {
    $error = array();
    /** SNED to email address and check for vaildation on entered emails */
    $_SESSION['share']['send_to'] = $send_to = safe_output($_POST['txt_send_to1']);
    if ($send_to == "") {
        $error[] = format_lang('errormsg', 38);
    }
    if ($send_to != "") {
        $send = split(",", $send_to);
        for ($i = 0; $i < sizeof($send); $i++) {
            $ch = check_email($send[$i]);
            if ($ch == "") {
                $error[] = format_lang('error', 'incorrect_format_email') . " - " . $send[$i];
            }
        }
$country_var_name = $country_arry->var_name;
$country_name = $country_arry->name;
$smarty->assign('country', $country_name);
//states
$state = StateProvince::find_by_code($cv_details->country, $cv_details->state_province);
$state_name = empty($state) ? $cv_details->state_province : $state->name;
$state_var_name = $state ? $state->var_name : $cv_details->state_province;
$smarty->assign('state', $state_name);
$smarty->assign('state_url', $country_var_name . "/" . $state_var_name . "/");
//county
$county = County::find_by_code($cv_details->country, $cv_details->state_province, $cv_details->county);
$county_name = empty($county) ? $cv_details->county : $county->name;
$county_var_name = $county ? $county->var_name : $cv_details->county;
$smarty->assign('county', $county_name);
$smarty->assign('county_url', $country_var_name . "/" . $state_var_name . "/" . $county_var_name . "/");
$city = City::find_by_code($cv_details->country, $cv_details->state_province, $cv_details->county, $cv_details->city);
$city_name = empty($city) ? $cv_details->city : $city->name;
$city_var_name = empty($city) ? $cv_details->city : $city->var_name;
$smarty->assign('city', $city_name);
$smarty->assign('city_url', $country_var_name . "/" . $state_var_name . "/" . $county_var_name . "/" . $city_var_name . "/");
//end of location
$authorised_to_work = format_lang('select', 'authorised_to_work');
$aya = !empty($cv_details->are_you_auth) ? $authorised_to_work[$cv_details->are_you_auth] : format_lang('none');
$smarty->assign('aya', $aya);
$wtr = !empty($cv_details->willing_to_relocate) ? $get_NoYes[$cv_details->willing_to_relocate] : format_lang('none');
$smarty->assign('wtr', $wtr);
$wtt = $cv_details->willing_to_travel;
$smarty->assign('wtt', $wtt);
$notes = $cv_details->additional_notes ? $cv_details->additional_notes : format_lang('none');
$smarty->assign('notes', $notes);
$html_title = SITE_NAME . " - " . format_lang("page_title", 'ReviewCV');
 public static function recommendedJob($user_id = 0, $cvjob_title = null, $cvjob_title2 = null, $cvjob_city = null, $cvjob_county = null, $cvjob_state = null, $cvjob_country = null)
 {
     global $database, $db;
     $select = " SELECT job_title, city, county, state_province, country, fk_employer_id,var_name, created_at ";
     $select .= ", match( job.job_title, job.job_description ) against ('" . $cvjob_title . "' '+" . $cvjob_title2 . "' IN BOOLEAN MODE) as relevance ";
     $from = " FROM " . self::$table_name . " AS job ";
     $where = " WHERE job.id NOT IN ( SELECT job_h.fk_job_id from " . TBL_HISTORY . " as job_h WHERE job_h.fk_employee_id={$user_id}) ";
     $where .= " AND job.is_active='Y' AND job.job_status='approved' AND job.id > 0 ";
     //$where .= " AND var_name <> '".$old."' ";
     $where .= " AND match( job.job_title, job.job_description ) against ('" . $cvjob_title . "' '+" . $cvjob_title2 . "' IN BOOLEAN MODE)";
     $where .= " AND  DATE_ADD( job.created_at, INTERVAL " . JOBLASTFOR . " DAY ) > NOW() ";
     //$where .= " AND city='{$cvjob_city}' ";
     $where .= " AND county='{$cvjob_county}' ";
     $where .= " AND state_province='{$cvjob_state}'";
     $where .= " AND country='{$cvjob_country}'";
     $order = " ORDER BY relevance, created_at DESC ";
     $limit = " LIMIT 10 ";
     //SELECT job.job_title, job.city, job.county, job.state_province, job.country
     //FROM jobberland_job AS job
     //WHERE job.id NOT IN (SELECT job_h.fk_job_id from jobberland_job_history as job_h WHERE fk_employer_id = 1)
     $sql = $select . $from . $where . $order . $limit;
     //echo $sql;
     $result = $database->query($sql);
     $num_rows = $database->num_rows($result);
     if ($num_rows > 0) {
         $i = 1;
         $temp = array();
         while ($row = $database->fetch_object($result)) {
             $temp[$i]['job_title'] = $row->job_title;
             $temp[$i]['var_name'] = $row->var_name;
             $temp[$i]['created_at'] = strftime(DATE_FORMAT, strtotime($row->created_at));
             //country
             $country_arry = Country::find_by_code($row->country);
             $country_name = $country_arry->name;
             //states
             $state = StateProvince::find_by_code($row->country, $row->state_province);
             $state_name = empty($state) ? $row->state_province : $state->name;
             //county
             $county = County::find_by_code($row->country, $row->state_province, $row->county);
             $county_name = empty($county) ? $row->county : $county->name;
             //city
             $city = City::find_by_code($row->country, $row->state_province, $row->county, $row->city);
             $city_name = empty($city) ? $row->city : $city->name;
             $temp[$i]['location'] = $city_name . ", " . $county_name . ", " . $state_name . ", " . $country_name;
             $employer = Employer::find_by_id($row->fk_employer_id);
             $company_name = $employer->company_name;
             $temp[$i]['company_name'] = $company_name;
             //$temp[$i]['job_title'] = $row->job_title;
             //$temp[$i]['job_title'] = $row->job_title;
             $i++;
         }
         return $temp;
     }
     return false;
 }
    $i = 1;
    $job_suggestions = Job::apply_suggestion($jobs->job_title, $var_name);
    foreach ($job_suggestions as $job_suggestion) {
        $employer = Employer::find_by_id($job_suggestion->fk_employer_id);
        //locations
        //country
        $country_arry = Country::find_by_code($job_suggestion->country);
        $country_name = $country_arry->name;
        //states
        $state = StateProvince::find_by_code($job_suggestion->country, $job_suggestion->state_province);
        $state_name = empty($state) ? $job_suggestion->state_province : $state->name;
        //county
        $county = County::find_by_code($job_suggestion->country, $job_suggestion->state_province, $job_suggestion->county);
        $county_name = empty($county) ? $job_suggestion->county : $county->name;
        //city
        $city = City::find_by_code($job_suggestion->country, $job_suggestion->state_province, $job_suggestion->county, $job_suggestion->city);
        $city_name = empty($city) ? $job_suggestion->city : $city->name;
        //end
        $job_s[$i]['id'] = $job_suggestion->id;
        $job_s[$i]['var_name'] = $job_suggestion->var_name;
        $job_s[$i]['job_title'] = $job_suggestion->job_title;
        $job_s[$i]['company_name'] = $employer->company_name;
        $job_s[$i]['created_at'] = strftime(DATE_FORMAT, strtotime($job_suggestion->created_at));
        $job_s[$i]['location'] = $city_name . ", " . $county_name . ", " . $state_name . ", " . $country_name;
        $i++;
    }
    $smarty->assign('job_suggestion', $job_s);
}
$smarty->assign('lang', $lang);
$smarty->assign('message', $message);
$smarty->assign('rendered_page', $smarty->fetch('apply_suggestion.tpl'));
         $state_name = $state_code ? $state_code->name : $job_state->country;
         $activeLink[$i]['name'] = $state_name;
         $activeLink[$i]['var_name'] = $state_var_name;
         $activeLink[$i]['url'] = "";
         $i++;
     }
     $smarty->assign('activeLink', $activeLink);
 }
 ///jobs
 $job_by_locations = Job::list_job_by_location($country_code);
 if ($job_by_locations2) {
     $location = array();
     $i = 1;
     foreach ($job_by_locations as $job_by_location) {
         //city
         $city_code = City::find_by_code($country_a, null, null, $job_by_location->city);
         $city_var_name = $city_code ? $city_code->var_name : $job_by_location->city;
         //states
         $state_code = $job_by_location->state_province;
         $state_ = StateProvince::find_by_code($country_a, $state_code);
         $state_var_name = $state_ ? $state_->var_name : $job_by_location->state_province;
         //county
         $county_code = $job_by_location->county;
         $county_ = County::find_by_code($country_a, $state_code, $county_code);
         $county_var_name = $county_ ? $county_->var_name : $job_by_location->county;
         if ($city_code) {
             /**check length of text */
             $location_name = strlen($city_code->name) > 60 ? substr($city_code->name, 0, 30) . " ... " : $city_code->name;
         } else {
             /**check length of text */
             $location_name = strlen($city_var_name) > 60 ? substr($city_var_name, 0, 30) . " ... " : $city_var_name;