This function always returns FALSE
:
function rank($applicant_id_number = 0) {
$this->load->model('advert_model');
$application = $this->advert_model->get_applications();
// $user = $this->flexi_auth->get_user_by_identity_row_array();
$rank = 0;
$sql1 = "SELECT * FROM applicant_details";
$results = $this->db->query($sql1)->result();
$sql3 = "SELECT * FROM job_advert";
$job_advert = $this->db->query($sql3)->result();
foreach ($results as $key => $applicant) {
$applicant_age = $applicant->age;
$applicant_id_number = $applicant->id_number;
$applicant_job_experience = $applicant->job_experience;
$applicant_industry_type = $applicant->industry_type;
$applicant_qualification_type = $applicant->qualification_type;
$applicant_city = $applicant->city;
$applicant_relocate = $applicant->relocate;
$applicant_first_name = $applicant->firstname;
$applicant_phone = $applicant->upro_phone;
$applicant_min_salary = $applicant->minimum_salary;
$applicant_prefered_salary = $applicant->preferred_salary;
$applicant_licence = $applicant->license;
$applicant_employment_equity = $applicant->employment_equity;
$applicant_email = $applicant->uacc_email;
$applicant_gender = $applicant->gender;
$applicants = array();
$sql = "SELECT DISTINCT account.uacc_group_fk, demo.id_number
FROM user_accounts AS account
INNER JOIN demo_user_profiles AS demo ON account.uacc_id = demo.upro_uacc_fk
WHERE demo.id_number = {$applicant_id_number}";
$user_group = $this->db->query($sql)->result();
foreach ($user_group as $group) {
$admin = $group->uacc_group_fk;
// print_r($admin);
foreach ($job_advert as $key => $advert) {
$advert_id = $advert->advert_id;
$job_title = $advert->job_title;
$salary_offered = $advert->salary_offered;
$is_negotiable = $advert->negotiable;
$company_location = $advert->company_location;
$Job_experience = $advert->required_experience;
$age = $advert->age_group;
$male = $advert->male;
$female = $advert->female;
$job_industry = $advert->industry_type;
$employment_equity = $advert->employment_equity;
$qualification_type = $advert->qualification_type;
$qualification_name = $advert->qualification_name;
$drivers_licence = $advert->drivers_licence;
$status = $advert->status;
//check age group
if ($age = "b") {
$agegroup = "18-23";
} else if ($age = "c") {
$agegroup = "24-30";
} else if ($age = "d") {
$agegroup = "31-40";
} else if ($age = "e") {
$agegroup = "40-1000";
}
$agegroups = explode("-", $agegroup);
// Rank age group
if ($age === "any" || $applicant_age >= $agegroups[0] || $applicant_age <= $agegroups[1]) {
$applicants[$applicant_id_number] = $rank;
} else {
$applicants[$applicant_id_number] = $rank + 5;
}
// Rank industry type && job_experience
if ($applicant_industry_type == $job_industry || $applicant_industry_type != NULL) {
$applicants[$applicant_id_number]+=0;
if ($applicant_job_experience >= $Job_experience || $applicant_job_experience != NULL) {
$applicants[$applicant_id_number]+=0;
} else {
$applicants[$applicant_id_number]+=30;
}
} else {
$applicants[$applicant_id_number]+=30;
}
// rank salary
$p_salary = explode("-", $applicant_prefered_salary);
$m_salary = explode("-", $applicant_min_salary);
if ($p_salary[0] >= $salary_offered && $p_salary[1] <= $salary_offered || $m_salary[0] >= $salary_offered && $m_salary[1] <= $salary_offered || $is_negotiable) {
$applicants[$applicant_id_number] +=0;
} else {
$applicants[$applicant_id_number] = $rank + 20;
}
//rank qualification Type
if ($applicant_qualification_type == $qualification_type || $qualification_type != NULL || $applicant_qualification_type != NULL) {
$applicants[$applicant_id_number]+=0;
} else {
$applicants[$applicant_id_number]+=30;
}
//rank by gender
if ($applicant_gender < 5000) {
$gender = "female";
} else {
$gender = "male";
}
if ($male == 1 && $gender = "male") {
$applicants[$applicant_id_number]+=0;
} else if ($female == 1 && $gender = "female") {
$applicants[$applicant_id_number]+=0;
} else if ($male == 0 && $female == 0) {
$applicants[$applicant_id_number]+=0;
} else {
$applicants[$applicant_id_number]+=35;
}
//check if user group this is not to rank admin users
if ($admin == 1) {
$applicants[$applicant_id_number]+=0;
} else {
$applicants[$applicant_id_number]+=90;
}
//rank employment_equity
if ($applicant_employment_equity == $employment_equity || $employment_equity == "any") {
$applicants[$applicant_id_number]+=0;
} else {
$applicants[$applicant_id_number]+=25;
}
//rank drivers licence
if ($applicant_licence == $drivers_licence || $applicant_licence != NULL && $drivers_licence != NULL || $applicant_licence == NULL && $drivers_licence == NULL) {
$applicants[$applicant_id_number]+=0;
if ($applicant_licence != NULL && $drivers_licence = NULL) {
$applicants[$applicant_id_number]+=0;
}
} else {
$applicants[$applicant_id_number]+=5;
}
if ($applicant_industry_type == $job_industry) {
$applicants[$applicant_id_number]+=0;
} else {
$applicants[$applicant_id_number]+=30;
}
asort($applicants);
$counter = 1;
$id_number = array();
$advert_identity = array();
$id_number['id_number'] = $applicant_id_number;
$advert_identity['advert_id'] = $advert_id;
if ($applicants[$applicant_id_number] < 35) {
$this->called = TRUE;
$this->set_rank_results($applicant_id_number, $advert_id, $applicants[$applicant_id_number], $this->applied);
$sql = "DELETE FROM rank_results
WHERE job_id in (SELECT advert_id FROM job_advert WHERE status =0)";
$this->db->query($sql);
return TRUE;
} else {
return FALSE;
}
}
}
}
}
Why wont it return TRUE
? and how can I make it return TRUE
if a applicants rank is less than 35?