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;
 }
 $smarty->assign('jobtype', $type2);
 $smarty->assign('var_name', $jobs->var_name);
 $smarty->assign('job_ref', $jobs->job_ref);
 $smarty->assign('job_title', $jobs->job_title);
 $smarty->assign('job_description', $jobs->job_description);
 $smarty->assign('job_postion', $jobs->job_postion);
 //locations
 //country
 $country_arry = Country::find_by_code($jobs->country);
 //$country_a($country_arry) ? $country_arry->code : $country_a;
 $country_var_name = $country_arry->var_name;
 $country_name = $country_arry->name;
 $smarty->assign('country', $country_name);
 $smarty->assign('country_url', $country_var_name);
 //states
 $state = StateProvince::find_by_code($jobs->country, $jobs->state_province);
 $state_name = empty($state) ? $jobs->state_province : $state->name;
 $state_var_name = $state ? $state->var_name : $jobs->state_province;
 $smarty->assign('state', $state_name);
 $smarty->assign('state_url', $country_var_name . "/" . $state_var_name . "/");
 //county
 $county = County::find_by_code($jobs->country, $jobs->state_province, $jobs->county);
 $county_name = empty($county) ? $jobs->county : $county->name;
 $county_var_name = $county ? $county->var_name : $jobs->county;
 $smarty->assign('county', $county_name);
 $smarty->assign('county_url', $country_var_name . "/" . $state_var_name . "/" . $county_var_name . "/");
 $city = City::find_by_code($jobs->country, $jobs->state_province, $jobs->county, $jobs->city);
 $city_name = empty($city) ? $jobs->city : $city->name;
 $city_var_name = empty($city) ? $jobs->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 . "/");
$ljs = $job_status ? $job_status->status_name : format_lang('none');
$smarty->assign('ljs', $ljs);
//job type
$job_t = empty($cv_details->look_job_type) ? 0 : $cv_details->look_job_type;
$job_type_arr = JobType::find_by_id($job_t);
//print_r( $job_type_arr);
$job_types = $job_type_arr ? $job_type_arr->type_name : format_lang('none');
$smarty->assign('job_type', $job_types);
//where do you wont to work
//country
$country_arry = Country::find_by_code($cv_details->country);
$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 . "/");
 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;
 }
$smarty->assign('apply_for', $jobs->job_title . " " . strtolower(format_lang('at')) . " " . $employer->company_name . " " . strtolower(format_lang('in')) . " " . $city_name . ", " . $country_name);
unset($employer, $city, $country_arry);
//Congratulations! You've applied for:
//IT Manager at IT Lab in London EC1A 9PT
if ($jobs) {
    $job_s = array();
    $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++;
         $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;
         }
         $total_jobs = Job::get_total_job_by_location($country_a, null, null, $job_by_location->city);
         $location[$i]['total'] = $total_jobs;
         $location[$i]['name'] = $location_name;