MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/allyindian_com/sbltt/application/controllers/Op_trip_report.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Secure_Controller.php");
class Op_trip_report  extends Secure_Controller
{
 
	public function __construct(){
		parent::__construct('op_trip_report');
		$this->load->model('Op_trip_report_model');
	}
	public function index(){
		if(!$this->Appconfig->isAppvalid()){
			redirect('config');
		}
		$data['table_headers']=$this->xss_clean(get_trip_wise_headers());
		$this->load->view('op_trip_report/manage',$data);
	}
	public function search(){
		$search=$this->input->get('search');
		$limit=$this->input->get('limit');
		$offset=$this->input->get('offset');
		$sort=$this->input->get('sort');
		$order=$this->input->get('order');
		
		$filters = array('start_date' => $this->input->get('start_date'),'end_date' => $this->input->get('end_date'));
		$trip_wise=$this->Op_trip_report_model->search($search,$filters,$limit,$offset,$sort,$order);
		$TotalRows=$this->Op_trip_report_model->get_found_rows($search,$filters);
		$DataRows=array();

		foreach ($trip_wise->result() as $person){	
			$DataRows[]=get_trip_wise_datarows($person,$this);
		}
		$DataRows=$this->xss_clean($DataRows);
		echo json_encode(array('total'=>$TotalRows,'rows'=>$DataRows));
	}
		/*public function columnLetter($c){
			
			$c = intval($c);
			if ($c < = 0) return '';

			$abc = '';
					 
			while($c != 0){
			   $p = ($c - 1) % 26;
			   $c = intval(($c - $p) / 26);
			   $abc = chr(65 + $p) . $abc;
			}
			
			return $abc;
				
		}*/

	public function excel($start_date,$end_date){
		$this->load->library('excel');
		$obj = new Excel();
		//$c=1;
		// Add new sheet
		 $objWorkSheet = $obj->createSheet(0); //Setting index when creating
		 $obj->setActiveSheetIndex(0); //First sheet open in excel sheet
		 
		//Write cells head column name
		 $objWorkSheet->setCellValue('A1', 'Si.No')
		 ->setCellValue('B1', 'Tour No')
		 ->setCellValue('C1', 'Customer Name')
		 ->setCellValue('D1', 'Billing Name')
		 ->setCellValue('E1', 'Customer Mobile')
		 ->setCellValue('F1', 'Trip Type')
		 ->setCellValue('G1', 'Origin')
		 ->setCellValue('H1', 'Destination')
		 ->setCellValue('I1', 'Avg KM')
		 ->setCellValue('J1', 'From Date')	
		 ->setCellValue('K1', 'To Date')	
		 ->setCellValue('L1', 'Trip Days')
		 ->setCellValue('M1', 'Vehicle Type')
		 ->setCellValue('N1', 'Bus Count')
		 ->setCellValue('O1', 'Customer Type')
		 ->setCellValue('P1', 'Vehicle No')
		 ->setCellValue('Q1', 'Driver Name')
		 ->setCellValue('R1', 'Secondary Driver Name')
		 ->setCellValue('S1', 'Route Info')
		 ->setCellValue('T1', 'Travels Name')
		 ->setCellValue('U1', 'Hire Amount')
		 ->setCellValue('V1', 'Start KM')
		 ->setCellValue('W1', 'End KM')
		 ->setCellValue('X1', 'Total KM')
		 ->setCellValue('Y1', 'Extra KM')
		 ->setCellValue('Z1', 'Per KM')
		 ->setCellValue('AA1', 'Extra Amount')
		 ->setCellValue('AB1', 'Diesel Amount')
		 ->setCellValue('AC1', 'Suspense Amount')
		 //->setCellValue('Z1', 'Ref By')
		 ->setCellValue('AD1', 'Status');
		 //->setCellValue('AE1', '');
		 //->setCellValue('AB1', 'Status');
		 
		 
		 // set database value
		
		$data = $this->Op_trip_report_model->excel_operation_trip_report($start_date,$end_date);
		//print_r($data); die;
		$i=2;
		$k=1;
		//$c= 1;
		foreach ($data as $key => $value) {
			$serial               = $k;
			$from_date            = date('d-m-Y', strtotime($value['from_date']));
			$to_date              = date('d-m-Y', strtotime($value['to_date']));
			$name                 = $value['customer_name'];
			$mob                  = $value['phone_number'];
			$origin               = $value['frm_city_name'];
			$destination          = $value['to_city_name'];
			$trip_days            = $value['trip_days'];
			$bus_count            = $value['bus_count'];
			$tour_no              = $value['tour_no'];
			$report_address       = $value['report_address'];
			$billing_name         = $value['billing_name'];
			$avg_km               = $value['avg_km'];
			$trip_type_name       = $value['trip_type_name'];
			$veh_type             = $value['veh_type'];
			$type                 = $value['booking_type_name'];
			$trip_details         = $value['trip_details'];
			$operation_type       = $value['operation_type'];
			$booking_amount       = $value['booking_amount'];
			$advance_amount       = $value['advance_amount'];
			$balance_amount       = $value['balance_amount'];
			$discount_amount      = $value['discount_amount'];
			$payment_type         = $value['payment_type'];
			$op_suspence_amt      = $value['op_suspence_amt'];
			$hire_charges         = $value['hire_charges'];
			$op_driver_name       = $value['op_driver_name'];
			$vehicle_no           = $value['vehicle_no'];
			$operation_sts        = $value['operation_sts'];
			$first_name           = $value['first_name'];
			$tp_info              = $value['tp_info'];
			$op_extra_km          = $value['op_extra_km'];
			$op_extra_amt         = $value['op_extra_amt'];
			$diesel_amt           = $value['diesel_amt'];
			$second_driver_name   = $value['second_driver_name'];
			$trip_start_km        = $value['trip_start_km'];
			$trip_end_km          = $value['trip_end_km'];
			$op_extra_pre_km      = $value['op_extra_pre_km'];
			$cust_rout_info       = $value['cust_rout_info'];
			$owned_by             = $value['vendor_name'];
			
			$total_km = $trip_end_km - $trip_start_km;
			
			if($operation_sts === "1"){
				$operation_sts = "Follow Up";
			}else
			if($operation_sts === "2"){
				$operation_sts = "Confirm";
			}else
			if($operation_sts === "3"){
				$operation_sts = "Cancelled";
			}else
			if($operation_sts === "4"){
				$operation_sts = "Completed";
			}else
			if($operation_sts === "5"){
				$operation_sts = "On progress";
			}
			if($operation_type === "1"){
				$operation_type = "Vehicle with Driver";
			}else
			if($operation_type === "2"){
				$operation_type = "Driver Only";
			}
			$objWorkSheet->setCellValue('A'.$i, $serial)
				->setCellValue('B'.$i, $tour_no)
				->setCellValue('C'.$i, $name)
				->setCellValue('D'.$i, $billing_name)
				->setCellValue('E'.$i, $mob)
				->setCellValue('F'.$i, $trip_type_name)
				->setCellValue('G'.$i, $origin)
				->setCellValue('H'.$i, $destination)
				->setCellValue('I'.$i, $avg_km)
				->setCellValue('J'.$i, $from_date)
				->setCellValue('K'.$i, $to_date)
				->setCellValue('L'.$i, $trip_days)
				->setCellValue('M'.$i, $veh_type)
				->setCellValue('N'.$i, $bus_count)
				->setCellValue('O'.$i, $type)
				->setCellValue('P'.$i, $vehicle_no)
				->setCellValue('Q'.$i, $op_driver_name)
				->setCellValue('R'.$i, $second_driver_name)
				->setCellValue('S'.$i, $cust_rout_info)
				->setCellValue('T'.$i, $owned_by)
				->setCellValue('U'.$i, $hire_charges)
				->setCellValue('V'.$i, $trip_start_km)
				->setCellValue('W'.$i, $trip_end_km)
				->setCellValue('X'.$i, $total_km)
				->setCellValue('Y'.$i, $op_extra_km)
				->setCellValue('Z'.$i, $op_extra_pre_km)
				->setCellValue('AA'.$i, $op_extra_amt)
				->setCellValue('AB'.$i, $diesel_amt)
				->setCellValue('AC'.$i, $op_suspence_amt)
				//->setCellValue('Z'.$i, $first_name)
				->setCellValue('AD'.$i, $operation_sts);
				//->setCellValue('AD'.$i, );
		$k++;
		$i++;
		
		}
		// Rename worksheet name
		 $objWorkSheet->setTitle("Detailed");
		 $filename="Operation Tripwise Report_".date('d-m-Y').".xls"; //save our workbook as this file name
		 header('Content-Type: application/vnd.ms-excel'); //mime type
		 header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell browser what's the file name
		 header('Cache-Control: max-age=0'); //no cache
		 
		//save it to Excel5 format (excel 2003 .XLS file), change this to 'Excel2007' (and adjust the filename extension, also the header mime type)
		 //if you want to save it as .XLSX Excel 2007 format
		 $objWriter = PHPExcel_IOFactory::createWriter($obj, 'Excel5');
		 //force user to download the Excel file without writing it to server's HD
		 $objWriter->save('php://output');
	}
	
	
}
?>