MMCT TEAM
Server IP : 192.185.129.71  /  Your IP : 18.118.3.199
Web Server : Apache
System : Linux bh-ht-3.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : svymadmin ( 4072)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home4/svymadmin/public_html/vivekaexcel.edu.in/bkp/school/application/controllers/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home4/svymadmin/public_html/vivekaexcel.edu.in/bkp/school/application/controllers/Transport.php
<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');



class Transport extends CI_Controller
{
	function __construct()
	{
		parent::__construct();
		$this->load->database();
        $this->load->library('session');
        $this->load->model(array('Ajaxdataload_model' => 'ajaxload'));
        $this->load->model('Transport_model');

       /*cache control*/
		$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
		$this->output->set_header('Pragma: no-cache');

    }

    public function index()
    {
        if ($this->session->userdata('transport_login') != 1)
            redirect(site_url('login'), 'refresh');
        if ($this->session->userdata('transport_login') == 1)
            redirect(site_url('transport/dashboard'), 'refresh');
    }

    // LIBRARIAN DASHBOARD
    function dashboard()
    {
        if ($this->session->userdata('transport_login') != 1)
            redirect(base_url(), 'refresh');

        $page_data['page_name']  = 'dashboard';
        $page_data['page_title'] = get_phrase('transport_dashboard');
        $this->load->view('backend/index', $page_data);
    }

  
    // MANAGE OWN PROFILE AND CHANGE PASSWORD
    function manage_profile($param1 = '', $param2 = '', $param3 = '')
    {
        if ($this->session->userdata('transport_login') != 1)
            redirect(site_url('login'), 'refresh');

        if ($param1 == 'update_profile_info') {
            $data['name']  = $this->input->post('name');
            $data['email'] = $this->input->post('email');

            $validation = email_validation_for_edit($data['email'], $this->session->userdata('transport_id'), 'transport');
            if($validation == 1){
                $this->db->where('transport_id', $this->session->userdata('transport_id'));
                $this->db->update('transport', $data);
                $this->session->set_flashdata('flash_message', get_phrase('account_updated'));
            }
            else{
                $this->session->set_flashdata('error_message', get_phrase('this_email_id_is_not_available'));
            }
            redirect(site_url('transport/manage_profile'), 'refresh');
        }

        if ($param1 == 'change_password') {
            $data['password']             = sha1($this->input->post('password'));
            $data['new_password']         = sha1($this->input->post('new_password'));
            $data['confirm_new_password'] = sha1($this->input->post('confirm_new_password'));

            $current_password = $this->db->get_where('transport', array(
                'librarian_id' => $this->session->userdata('transport_id')
            ))->row()->password;
            if ($current_password == $data['password'] && $data['new_password'] == $data['confirm_new_password']) {
                $this->db->where('transport_id', $this->session->userdata('transport_id'));
                $this->db->update('transport', array(
                    'password' => $data['new_password']
                ));
                $this->session->set_flashdata('flash_message', get_phrase('password_updated'));
            } else {
                $this->session->set_flashdata('flash_message', get_phrase('password_mismatch'));
            }
            redirect(site_url('transport/manage_profile'), 'refresh');
        }

        $page_data['page_name']  = 'manage_profile';
        $page_data['page_title'] = get_phrase('manage_profile');
        $page_data['edit_data']  = $this->db->get_where('transport', array(
            'librarian_id' => $this->session->userdata('transport_id')
        ))->result_array();
        $this->load->view('backend/index', $page_data);
    }
    
    /**********MANAGE VEHICLES / ROUTES********************/
   function transport($param1 = '', $param2 = '', $param3 = '')
    {
        if ($this->session->userdata('transport_login') != 1)
            redirect('login', 'refresh');
        if ($param1 == 'create') {
            $data['route_name']        = $this->input->post('route_name');
            $data['number_of_vehicle'] = $this->input->post('number_of_vehicle');
            if ($this->input->post('description') != null) {
               $data['description']    = $this->input->post('description');
            }
            if ($this->input->post('route_fare') != null) {
               $data['route_fare']     = $this->input->post('route_fare');
            }
            if ($this->input->post('number_check_point') != null) {
               $data['number_check_point']     = $this->input->post('number_check_point');
            }
            $this->db->insert('transport', $data);
            $this->session->set_flashdata('flash_message' , get_phrase('data_added_successfully'));
            redirect(site_url('transport/transport'), 'refresh');
        }
          
        if ($param1 == 'do_update') {
            $data['route_name']        = $this->input->post('route_name');
            $data['number_of_vehicle'] = $this->input->post('number_of_vehicle');
            if ($this->input->post('description') != null) {
               $data['description']    = $this->input->post('description');
            }
            else{
                $data['description'] = null;
            }
            if ($this->input->post('route_fare') != null) {
               $data['route_fare']   = $this->input->post('route_fare');
            }
            else{
                $data['route_fare']  = null;
            }
            if ($this->input->post('number_check_point') != null) {
               $data['number_check_point']   = $this->input->post('number_check_point');
            }
            else{
                $data['number_check_point']  = null;
            }
            $this->db->where('transport_id', $param2);
            $this->db->update('transport', $data);
            $this->session->set_flashdata('flash_message' , get_phrase('data_updated'));
            redirect(site_url('transport/transport'), 'refresh');
        } else if ($param1 == 'edit') {
            $page_data['edit_data'] = $this->db->get_where('transport', array(
                'transport_id' => $param2
            ))->result_array();
        }
        if ($param1 == 'delete') {
            $this->db->where('transport_id', $param2);
            $this->db->delete('transport');

            $this->db->where('transport_id', $param2);
            $this->db->delete('routes_vehicles');

            $this->session->set_flashdata('flash_message' , get_phrase('data_deleted'));
            redirect(site_url('transport/transport'), 'refresh');
        }
        $page_data['transports'] = $this->db->get('transport')->result_array();
        $page_data['page_name']  = 'transport';
        $page_data['page_title'] = get_phrase('manage_transport');
        $this->load->view('backend/index', $page_data);

    }
    //===========================================VEHICLES===================================//
    function vehicles($param1="",$param2=""){
        if ($this->session->userdata('transport_login') != 1)
            redirect('login', 'refresh');
        if($param1 == "vehicle_create") {
            $data['v_no'] = $this->input->post('v_no');
            $data['v_type'] = $this->input->post('v_type');
            if ($this->input->post('v_incharge') != null) {
            $data['v_incharge'] = $this->input->post('v_incharge');
            }
            if ($this->input->post('v_insurance') != null) {
            $data['v_insurance'] = $this->input->post('v_insurance');
            }
            if ($this->input->post('v_servicedue') != null) {
            $data['v_servicedue'] = $this->input->post('v_servicedue');
            }
            if ($this->input->post('phone') != null) {
            $data['phone'] = $this->input->post('phone');
            }
            if($_FILES['v_rc']['tmp_name'] !=NULL){
                $path="uploads/transport";
                $target_file = $path . basename($_FILES["v_rc"]["name"]);  
                $FileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));  
                $file_name=$this->input->post('v_no').".".$FileType; 
                move_uploaded_file($_FILES['v_rc']['tmp_name'], $path."/".$file_name);
                $data["v_rc"] = $file_name;
            }
            $this->db->insert('vehicles', $data);
            $vehicle_id=$this->db->insert_id();
             if($vehicle_id){
             $transport=$this->input->post("transport_id");   
             foreach ($transport as $row){
                $route_vehicle= array('transport_id' => $row,'vehicle_id' =>$vehicle_id );
                $this->db->insert('routes_vehicles', $route_vehicle); 
             }               
            $this->session->set_flashdata('flash_message' , get_phrase('data_added_successfully'));    
            }
            redirect(site_url('transport/transport'), 'refresh');
        }
        if($param1 == "vehicle_edit") {
            $data['v_no'] = $this->input->post('v_no');
            $data['v_type'] = $this->input->post('v_type');
            if ($this->input->post('v_incharge') != null) {
            $data['v_incharge'] = $this->input->post('v_incharge');
            }
            if ($this->input->post('v_insurance') != null) {
            $data['v_insurance'] = $this->input->post('v_insurance');
            }
            if ($this->input->post('v_servicedue') != null) {
            $data['v_servicedue'] = $this->input->post('v_servicedue');
            }
            if ($this->input->post('phone') != null) {
            $data['phone'] = $this->input->post('phone');
            }
            $this->db->where("id",$param2);
            $this->db->update('vehicles', $data);              
            $this->session->set_flashdata('flash_message' , get_phrase('data_updated')); 
        }
        if($param1 =='delete_vehicle') {
           $vehicle=$this->db->get_where("vehicles", array('id' => $param2 ))->result_array();  
           if($vehicle){
             if(file_exists("uploads/transport/".$vehicle[0]['v_rc'])){
                unlink("uploads/transport/".$vehicle[0]['v_rc']); 
             }
            $this->db->where('vehicle_id', $param2);
            $this->db->delete('routes_vehicles');

            $this->db->where('id', $param2);
            $this->db->delete('vehicles');

            $this->session->set_flashdata('flash_message' , get_phrase('data_deleted'));
            redirect(site_url('transport/transport'), 'refresh');
           }       
        }
        $page_data['vehicles'] = $this->db->get('vehicles')->result_array();
        $page_data['page_name']  = 'vehicles';
        $page_data['page_title'] = get_phrase('manage_vehicles');
        $this->load->view('backend/index', $page_data);
    }
    //=====================================ROUTE POINT===========================================//
    function route_point($param1="",$param2="")
    {
        if($this->session->userdata('transport_login') != 1)
            redirect('login', 'refresh');
        if($param1== "add_route_point")
        {
            for($i=0;$i<count($this->input->post('from_point_name'));$i++):
                $data['transport_id']        = $this->input->post("transport_id");
                $data['from_point_name'] = $this->input->post('from_point_name')[$i];
                $data['route_point_fare']        = $this->input->post('route_point_fare')[$i];
                $data['timing'] = $this->input->post('timing')[$i];
                $this->db->insert('route_point', $data);
            endfor;
            $this->db->update("transport",array("route_point"=>"1"),array("transport_id"=>$this->input->post("transport_id")));
            $this->session->set_flashdata('flash_message' , get_phrase('data_added_successfully1'));
            redirect(site_url('transport/route_point'), 'refresh');
        }
        if($param1=="do_update")
        {
            if($this->input->post('from_point_name') != NULL && $this->input->post('route_point_fare') != NULL && $this->input->post('timing') != NULL){
            $data['from_point_name'] = $this->input->post('from_point_name');
            $data['route_point_fare']        = $this->input->post('route_point_fare');
            $data['timing'] = $this->input->post('timing');
            $this->db->update('route_point', $data,array("route_point_id"=>$param2));
            $this->session->set_flashdata('flash_message' , get_phrase('data_added_successfully2'));
            redirect(site_url('transport/route_point'), 'refresh');
            }
        }
        if($param1=="delete")
        {
            $this->db->where('route_point_id', $param2);
            $this->db->delete('route_point');
            $this->session->set_flashdata('flash_message' , get_phrase('data_deleted'));
            redirect(site_url('transport/route_point'), 'refresh');
        }
        $page_data["route_point"]   = $this->db->get_where("route_point")->result_array();
        $page_data['transport']    = $this->db->get('transport')->result_array();
        $page_data['page_name']  = 'route_point';
        $page_data['page_title'] = get_phrase('manage_route_point');
        $this->load->view('backend/index', $page_data);    
    }
    //=====================================ROUTE POINT===========================================//
    function transport_route_student($param1="",$param2="")
    {
        if($this->session->userdata('transport_login') != 1)
            redirect('login', 'refresh');
        if($param1=="add_route_student"){
            $running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description;
            if($this->input->post("user_type")=="student"){
                $student_transport_data = $this->Transport_model->get_where("transport_route_student",array("users_id"=>$this->input->post("student_id"),"year"=>$running_year));
            }else{
                $student_transport_data = $this->Transport_model->get_where("transport_route_student",array("users_id"=>$this->input->post("users_id"),"year"=>$running_year));
            }
            if($student_transport_data == NULL){
            if($this->input->post("user_type")=="student"){
                $data["user_type"]=$this->input->post("user_type");
                $data["users_id"]=$this->input->post("student_id");
                $data["route_id"]=$this->input->post("route_id");
                $data["route_point_id"]=$this->input->post("route_point_id");
                $data["year"] = $running_year;
            }else{
                $data["user_type"]=$this->input->post("user_type");
                $data["users_id"]=$this->input->post("users_id");
                $data["route_id"]=$this->input->post("route_id");
                $data["route_point_id"]=$this->input->post("route_point_id");
                $data["year"] = $running_year;
            }
            $this->Transport_model->insert("transport_route_student",$data);
            $this->session->set_flashdata('flash_message',get_phrase('data_added'));
            }else{
                $this->session->set_flashdata('error_message',get_phrase('data_already_add_to_other_bus'));
            }
            redirect(site_url('transport/transport_route_student'),'refresh');
        }
        if($param1=="delete")
        {
            $this->db->where('transport_route_student_id', $param2);
            $this->db->delete('transport_route_student');
            $this->session->set_flashdata('flash_message' , get_phrase('data_deleted'));
            redirect(site_url('transport/transport_route_student'), 'refresh');
        }
        //$page_data['transport_route_student'] = $this->db->get("transport_route_student")->result_array();
        $page_data['page_name']  = 'transport_route_student';
        $page_data['page_title'] = get_phrase('manage_transport_route_student');
        $this->load->view('backend/index', $page_data);    
    }
    
    //=====================================ROUTE POINT===========================================//
    function transport_route_fee($param1="",$param2="")
    {
        if($this->session->userdata('transport_login') != 1)
            redirect('login', 'refresh');
            
        if($param1 == "add_route_fee")
        {
            $data["route_id"] = $this->input->post('route_id');
            $data["route_point_id"] = $this->input->post('route_point_id');
            $data["user_type"] = $this->input->post('user_type');
            $data["users_id"] = $this->input->post('users_id');
            $data["paid_amount"] = $this->input->post('paid_amount');
            $data["paid_date"] = date("Y-m-d");
            $this->Transport_model->insert("transport_route_fee",$data);
            $this->session->set_flashdata('flash_message',get_phrase("data_add_successfully"));
            redirect(site_url('transport/transport_route_fee'),'refresh');
        }
        if($param1 == "do_update")
        {
            $data["paid_amount"] = $this->input->post('paid_amount');
            $data["paid_date"] = date("Y-m-d");
            $this->Transport_model->update("transport_route_fee",$data,array("transport_route_fee_id"=>$param2));
            $this->session->set_flashdata('flash_message',get_phrase("data_add_successfully"));
            redirect(site_url('transport/transport_route_fee'),'refresh');
        }
        if($param1=="delete")
        {
            $this->db->where('transport_route_fee_id', $param2);
            $this->db->delete('transport_route_fee');
            $this->session->set_flashdata('flash_message' , get_phrase('data_deleted'));
            redirect(site_url('transport/transport_route_fee'), 'refresh');
        }
        $page_data['transport_route_fee'] = $this->db->get("transport_route_fee")->result_array();
        $page_data['transport_route_student']  = $this->db->get("transport_route_student")->result_array();
        $page_data['page_name'] = 'transport_route_fee';
        $page_data['page_title'] = get_phrase('manage_transport_route_fee');
        $this->load->view('backend/index', $page_data);    
    }
    
    //=====================================transport_route_route_print===========================================//
    function transport_fee_report_print($param1="",$param2="")
    {
        if($this->session->userdata('transport_login') != 1)
            redirect('login', 'refresh');
            
        $page_data['page_name'] = 'transport_fee_report_print';
        $page_data['page_title'] = get_phrase('manage_transport_fee_report_print');
        $this->load->view('backend/index', $page_data);  
    }
    //=====================================AJAX CALL====================================//
    function get_transport_details($route_point_id)
    {
        $transport_students = $this->db->get_where('student' , array('transport_id' => $route_point_id))->result_array();
        $count = 1;
                foreach($transport_students as $row):
        echo    "<tr>
                    <td>$count</td>
                    <td>$row[name]</td>
                    <td>$row[email]</td>
                    <td>$row[phone]</td>
                </tr>";
                $count++;
                endforeach;
    }
    function get_other_lib_user($type){
        $data=$this->Transport_model->get($type);
        echo  "<option value=''>select user</option>";
        foreach($data as $row){
            $temp=$type.'_id';
         echo  "<option value='".$row[$temp]."'>".$row['name']."</option>";
        }
    }
    function get_lib_section($class_id){
        $sections =$this->Transport_model->get_where('section' , array('class_id' => $class_id)); 
        echo  "<option value=''><?php echo get_phrase('select_class_first') ?></option>";
        foreach($sections as $row){
         echo  "<option value='".$row['section_id']."'>".$row['name']."</option>";
        }
    }
    function get_lib_student($class_id,$section_id){
        $students = $this->Transport_model->get_where('enroll' , array( 'class_id' => $class_id ,'section_id' => $section_id, 'year' => $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description ));
        foreach ($students as $row) {
            $student = $this->Transport_model->get_where('student' , array('student_id' => $row['student_id']));
            foreach ($student as $row1) {
            echo '<option value="' . $row1['student_id'] . '">' .$row1['name'].'['. $row1['student_code'] . '] </option>';
            }
        }
    }
    
    function get_route_point($route_id)
    {
        $route_point = $this->Transport_model->get_where('route_point',array("route_id"=>$route_id));
        foreach($route_point as $row):
            echo '<option value="'.$row['route_point_id'].'">'.$row['from_point_name'].' [Rs '. $row['route_fare'] . ']</option>';
        endforeach;    
    }
    
    function get_transport_student($route_id,$route_point_id,$user_type){
        $running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description;
        $transport_route = $this->db->get_where("transport_route_student",array("route_id"=>$route_id,"route_point_id"=>$route_point_id,"user_type"=>$user_type,"year"=>$running_year))->result_array();
        foreach($transport_route as $row):
            $student = $this->Transport_model->get_where($row['user_type'] , array($row['user_type'].'_id' => $row['users_id']));
            foreach ($student as $row1) {
            echo '<option value="'.$row1['student_id'].'">'.$row1['name'].'['. $row1['student_code'] . '] </option>';
            }
        endforeach;
        
    }
}

MMCT - 2023