File: /home/cafsindia/ntc_cafsinfotech_in_bk/application/controllers/Trip_current_location.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Trip_current_location extends Action_controller{
public function __construct(){
parent::__construct('trip_current_location');
$this->collect_base_info();
}
// LOAD PAGE QUICK LINK,FILTERS AND TABLE HEADERS
public function index(){
$this->load->view("$this->control_name/manage",$data);
}
//LOAD TABEL WITH FILTERS
public function check_log_details(){
$start_date = str_replace("/","-",$this->input->post('start_date'));
$end_date = str_replace("/","-",$this->input->post('end_date'));
$from_date = date('Y-m-d',strtotime($start_date));
$to_date = date('Y-m-d',strtotime($end_date));
$this->db->from(' cw_trip_map');
$this->db->join('cw_ntc_load','cw_ntc_load.prime_ntc_load_id = cw_trip_map.prime_trip_map_id','left');
$this->db->join('cw_vehicle_trip_info','cw_vehicle_trip_info.prime_vehicle_info_id = cw_trip_map.prime_trip_map_id','left');
$this->db->join(' cw_vehicle_master','cw_vehicle_master.prime_vehicle_master_id = cw_trip_map.prime_trip_map_id','left');
$this->db->join('cw_order_receiving','cw_order_receiving.order_receiving_id = cw_trip_map.prime_trip_map_id','left');
$this->db->join('cw_load_customer_type','cw_load_customer_type.prime_load_customer_type_id = cw_trip_map.prime_trip_map_id','left');
$this->db->join('cw_product_dispatch','cw_product_dispatch.product_dispatch_id = cw_trip_map.prime_trip_map_id','left');
$get_data_rslt = $this->db->get()->result();
$trip_info = array(1=>"Schedule",2=>"Confirm",3=>"Onprogress",4=>"Cancelled",5=>"Completed",6=>"Incompleted");
$tr_line = "";
foreach ($get_data_rslt as $key => $value) {
$trip_sts = "-";
if($trip_info[(int)$value->trip_status]){
$trip_sts = $trip_info[(int)$value->trip_status];
}
$tr_line .="<tr>
<td>".$position_date = $value->position_date."</td>
<td>".$reg_no = $value->reg_no."</td>
<td>".$vehicle_no = $value->vehicle_no."</td>
<td>".$driver_name = $value->driver_name."</td>
<td>".$trip_status = $trip_sts."</td>
<td>".$customer_type = $value->load_customer_type."</td>
<td>".$location = $value->location."</td>
</tr>";
}
if($get_data_rslt){
$table_content = "<div style='margin:20px;'>
<table class='table table-striped table-bordered' id='trip_report'>
<thead>
<tr>
<td>DATE AND TIME</td>
<td>VEHICLE REG</td>
<td>FLEET NO</td>
<td>DRIVER</td>
<td>TRIP STATUS</td>
<td>CUSTOMER</td>
<td>CURRENT LOCATION</td>
</tr>
</thead>
<tbody>
$tr_line
</tbody>
</table>
</div>";
echo json_encode(array('success'=>true,'table_content'=>$table_content));
}else{
echo json_encode(array('success'=>false,'message'=>'NO DATA AVAILABLE','table_content'=>$table_content));
}
}
}
?>