GIF89a;
Server IP : 172.26.0.195 / Your IP : 3.145.57.5 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/../jobs/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * Description of Session * * @author Softpro India Pvt. Ltd */ class Sessions extends CI_Controller { //put your code here public function __construct() { parent::__construct(); $this->load->model("admin/SessionManagement"); } public function index() { if ($this->sessionvalidator->validateSession()) { $viewData['allSessions'] = $this->SessionManagement->getSessions()->result(); $this->load->view('admin/sessions', $viewData); } else { redirect("admin"); } } public function createSession() { if ($this->sessionvalidator->validateSession()) { $this->load->view("admin/createSession"); } else { redirect("admin"); } } public function saveSession() { if ($this->sessionvalidator->validateSession()) { $this->form_validation->set_rules("sessionName", "session name", "required", array("required" => "Enter Session Name.")); $this->form_validation->set_rules("sessionDesc", "session description", "required", array("required" => "Enter Session Description.")); $sessionName = addslashes(trim($this->input->post("sessionName"))); $sessionDescription = addslashes(trim($this->input->post("sessionDesc"))); $currentSession = ($this->input->post("isCurrentSession") !== null) ? "C" : "O"; if ($this->form_validation->run() == false) { $this->createSession(); } else { if (sizeof($this->SessionManagement->getSession($sessionName)->result()) > 0) { $this->session->set_flashdata("errorMessage", "Session Already With This Name."); $this->createSession(); } else { $sessionData = array( 'session_name' => $sessionName, 'session_desc' => $this->input->post("sessionDesc"), 'session_added_on' => date("Y-m-d H:i:s"), 'session_updated_on' => date("Y-m-d H:i:s"), 'session_status' => $currentSession ); if ($this->SessionManagement->saveSession($sessionData) > 0) { $this->session->set_flashdata("successMessage", "Session Saved Successfully."); $this->index(); } else { $this->session->set_flashdata("errorMessage", "Failed To Save Session."); $this->createSession(); } } } } else { redirect("admin"); } } public function editSession($session_id) { if ($this->sessionvalidator->validateSession()) { $viewData["session"] = $this->SessionManagement->getSessionByID($session_id)->result()[0]; $this->load->view("admin/editSession", $viewData); } else { redirect("admin"); } } public function updateSession() { if ($this->sessionvalidator->validateSession()) { $this->form_validation->set_rules("sessionName", "session name", "required", array("required" => "Enter Session Name.")); $this->form_validation->set_rules("sessionDesc", "session description", "required", array("required" => "Enter Session Description.")); $sessionName = addslashes(trim($this->input->post("sessionName"))); $sessionDescription = $this->input->post("sessionDesc"); $session_id = $this->input->post("session_id"); $currentSession = ($this->input->post("isCurrentSession") !== null) ? "C" : "O"; if ($this->form_validation->run() == false) { $this->createSession(); } else { if (sizeof($this->SessionManagement->getSession($sessionName, $session_id)->result()) > 0) { $this->session->set_flashdata("errorMessage", "Session Already With This Name."); $this->createSession(); } else { $sessionData = array( 'session_name' => $sessionName, 'session_desc' => $this->input->post("sessionDesc"), 'session_updated_on' => date("Y-m-d H:i:s"), 'session_status' => $currentSession ); if ($this->SessionManagement->updateSession($sessionData, $session_id) > 0) { $this->session->set_flashdata("successMessage", "Session Updated Successfully."); $this->index(); } else { $this->session->set_flashdata("errorMessage", "Failed To Update Session."); $this->createSession(); } } } } else { redirect("admin"); } } public function toggleSessionStatus($session_id, $toUpdateStatus) { if ($this->sessionvalidator->validateSession()) { $sessionUpdateData = array( 'session_id' => $session_id, 'session_updated_on' => date("Y-m-d H:i:s"), 'session_active_status' => $toUpdateStatus ); if ($this->SessionManagement->updateSession($sessionUpdateData)) { $this->session->set_flashdata('successMessage', 'Sessions Status Updated Successfully.'); redirect("admin/Sessions"); } else { $this->session->set_flashdata('errorMessage', 'Failed To Update Session Status.'); redirect("admin/Sessions"); } } else { redirect("admin"); } } public function markAsCurrentSession($session_id) { if ($this->sessionvalidator->validateSession()) { $allSessionUpdateData = array( 'session_status' => "O" ); $thisSessionUpdateData = array( 'session_id' => $session_id, 'session_updated_on' => date("Y-m-d H:i:s"), 'session_status' => "C" ); $this->db->trans_start(); if ($this->SessionManagement->updateSession($allSessionUpdateData, true)) { if ($this->SessionManagement->updateSession($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->validateSession()) { $sessionUpdateData = array( 'session_id' => $session_id, 'session_updated_on' => date("Y-m-d H:i:s"), 'session_delete_status' => 'T' ); if ($this->SessionManagement->updateSession($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->validateSession()) { $sessionUpdateData = array( 'session_id' => $session_id, 'session_updated_on' => date("Y-m-d H:i:s"), 'session_delete_status' => 'F' ); if ($this->SessionManagement->updateSession($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"); } } }