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/Tour_fb_report.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require_once("Secure_Controller.php");

class Tour_fb_report extends Secure_Controller
{
	public function __construct()
	{
		parent::__construct('tour_fb_report');
		$this->load->model('Tour_fb_model');
	}

	public function index()
	{

		if(!$this->Appconfig->isAppvalid()){
			redirect('config');
		}
		 $data['table_headers'] = $this->xss_clean(get_Tour_fb_report_table_headers());

		$this->load->view('tour_fb_report/manage', $data);
	}

	/*
	Returns Supplier table data rows. This will be called with AJAX.
	*/
	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'));
       $all_leads = $this->Tour_fb_model->search($search, $filters, $limit, $offset, $sort, $order);
        $total_rows = $this->Tour_fb_model->get_found_rows($search, $filters);
        $data_rows = array();
        foreach($all_leads->result() as $leads){
            $data_rows[] = get_Tour_fb_report_data_row($leads, $this);
        }
        echo json_encode(array('total' => $total_rows, 'rows' => $data_rows));
	}	
// Tour Trip Report
	public function excel($start_date,$end_date){
		$this->load->library('excel');
		$obj = new Excel();
		
		// 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', 'Customer Mobile')
		 ->setCellValue('E1', 'Trip Type')
		 ->setCellValue('F1', 'Origin')
		 ->setCellValue('G1', 'Destination')
		 ->setCellValue('H1', 'Avg KM')
		 ->setCellValue('I1', 'From Date')
		 ->setCellValue('J1', 'To Date')	
		 ->setCellValue('K1', 'Trip Days')	
		 ->setCellValue('L1', 'Vehicle Type')
		 ->setCellValue('M1', 'Bus Count')
		 ->setCellValue('N1', 'Vehicle No')
		 ->setCellValue('O1', 'Customer Type')
		 ->setCellValue('P1', 'Driver Name')
		 ->setCellValue('Q1', 'Vehicle Quality')
		 ->setCellValue('R1', 'Media Quality')
		 ->setCellValue('S1', 'Seat Quality')
		 ->setCellValue('T1', 'Driver Skill')
		 ->setCellValue('U1', 'Driver Behaviour')
		 ->setCellValue('V1', 'Sightseeing')
		 ->setCellValue('W1', 'Ops Type')
		 ->setCellValue('X1', 'Tp info')
		 ->setCellValue('Y1', 'Status');
		 //->setCellValue('Z1', 'Driver Suspense')
		 //->setCellValue('1', 'Ref By')
		 //->setCellValue('AA1', 'Status');
		 
		 
		 // set database value
		
		$data = $this->Tour_fb_model->excel_tour_fb_report($start_date,$end_date);
		//print_r($data); die;
		$i=2;
		$k=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_type     = $value['operation_type'];
			$operation_sts      = $value['operation_sts'];
			$first_name         = $value['first_name'];
			$tp_info            = $value['tp_info'];
			$vch_quality        = $value['vch_quality'];
			$vch_media          = $value['vch_media'];
			$vch_seat           = $value['vch_seat'];
			$driving_skill      = $value['driving_skill'];
			$driver_behaviour   = $value['driver_behaviour'];
			$sightseeing        = $value['sightseeing'];
			
			if($operation_sts === "4"){
				$operation_sts = "Completed";
			}
			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, $mob)
				->setCellValue('E'.$i, $trip_type_name)
				->setCellValue('F'.$i, $origin)
				->setCellValue('G'.$i, $destination)
				->setCellValue('H'.$i, $avg_km)
				->setCellValue('I'.$i, $from_date)
				->setCellValue('J'.$i, $to_date)
				->setCellValue('K'.$i, $trip_days)
				->setCellValue('L'.$i, $veh_type)
				->setCellValue('M'.$i, $bus_count)
				->setCellValue('N'.$i, $vehicle_no)
				->setCellValue('O'.$i, $type)
				->setCellValue('P'.$i, $op_driver_name)
				->setCellValue('Q'.$i, $vch_quality)
				->setCellValue('R'.$i, $vch_media)
				->setCellValue('S'.$i, $vch_seat)
				->setCellValue('T'.$i, $driving_skill)
				->setCellValue('U'.$i, $driver_behaviour)
				->setCellValue('V'.$i, $sightseeing)
				->setCellValue('W'.$i, $operation_type)
				->setCellValue('X'.$i, $tp_info)
				->setCellValue('Y'.$i, $operation_sts);
				//->setCellValue('Y'.$i, $op_suspence_amt)
				//->setCellValue('Z'.$i, $first_name)
				//->setCellValue('AA'.$i, $sightseeing);
		$k++;
		$i++;
		
		}
		// Rename worksheet name
		 $objWorkSheet->setTitle("Detailed");
		 $filename="Tour Feedback 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');
	}

}
?>