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

require_once("Secure_Controller.php");

class Er_report extends Secure_Controller
{
	public function __construct()
	{
		parent::__construct('er_report');
		$this->load->model('Er_report_model');
	}

	public function index()
	{

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

		$this->load->view('er_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->Er_report_model->search($search, $filters, $limit, $offset, $sort, $order);
        $total_rows = $this->Er_report_model->get_found_rows($search, $filters);
        $data_rows = array();
        foreach($all_leads->result() as $leads){
            $data_rows[] = get_Er_report_data_row($leads, $this);
        }
        echo json_encode(array('total' => $total_rows, 'rows' => $data_rows));
	}	
	public function excel($start_date,$end_date){
		//$filters = array('start_date' => $start_date, 'end_date' => $end_date);
		$this->load->library('excel');
		$obj = new Excel();
		// Add new sheet
		 $objWorkSheet = $obj->createSheet(0); //Setting index when creating
		 
		//Write cells
		 $objWorkSheet->setCellValue('A1', 'S.No')
		 ->setCellValue('B1', 'Name')
		 ->setCellValue('C1', 'Billing Name')
		 ->setCellValue('D1', 'Mobile')
		 ->setCellValue('E1', 'Alter Mobile')
		 ->setCellValue('F1', 'Email')
		 ->setCellValue('G1', 'From Date')
		 ->setCellValue('H1', 'To Date')
		 ->setCellValue('I1', 'Orgin')
		 ->setCellValue('J1', 'Destination')
		 ->setCellValue('K1', 'Route Info')
		 ->setCellValue('L1', 'Trip Days')
		 ->setCellValue('M1', 'Trip Type')
		 ->setCellValue('N1', 'Average Km')
		 ->setCellValue('O1', 'Vehicle Type')
		 ->setCellValue('P1', 'No Of Vehicles')
		 ->setCellValue('Q1', 'Booking Amount')
		 ->setCellValue('R1', 'Customer Type')
		 ->setCellValue('S1', 'Custumer Status')
		 ->setCellValue('T1', 'Referred By')
		 ->setCellValue('U1', 'NCD')
		 ->setCellValue('V1', 'Enquiry Status')
		 ->setCellValue('W1', 'Prospect')
		 ->setCellValue('X1', 'Remarks');

		 // set database value
		$data = $this->Er_report_model->get_excel_data($start_date,$end_date);
		
		$i=2;
		$j=1;
		foreach ($data as $key => $value) {
			$serial    = $j;
			$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'];
			$alt_number      = $value['alt_number'];
			$cust_email      = $value['cust_email'];
			$cust_sts      = $value['cust_sts'];
			$trip_days      = $value['trip_days'];
			$bus_count      = $value['bus_count'];
			$report_address      = $value['report_address'];
			$billing_name      = $value['billing_name'];
			$first_name      = $value['first_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'];
			$enquiry_sts = $value['enquiry_sts'];
			$booking_amount = $value['booking_amount'];
			$frm_city_name = $value['frm_city_name'];
			$to_city_name = $value['to_city_name'];
			$prospect = $value['prospect'];
			$trip_details = $value['trip_details'];
			$remark = $value['remark'];
			$ncd = date('d-m-Y', strtotime($value['ncd']));
			if($enquiry_sts === "1"){
				$enquiry_sts = "Follow Up";
			}else
			if($enquiry_sts === "2"){
				$enquiry_sts = "Confirm";
			}else
			if($enquiry_sts === "3"){
				$enquiry_sts = "Cancelled";
			}
			
			if($prospect === "1"){
				$prospect = "Hot";
			}else
			if($prospect === "2"){
				$prospect = "Warm";
			}
			
		$objWorkSheet->setCellValue('A'.$i, $serial)
		->setCellValue('B'.$i, $name)
		->setCellValue('C'.$i, $billing_name)
		->setCellValue('D'.$i, $mob)
		->setCellValue('E'.$i, $alt_number)
		->setCellValue('F'.$i, $cust_email)
		->setCellValue('G'.$i, $from_date)
		->setCellValue('H'.$i, $to_date)
		->setCellValue('I'.$i, $frm_city_name)
		->setCellValue('J'.$i, $to_city_name)
		->setCellValue('K'.$i, $trip_details)
		->setCellValue('L'.$i, $trip_days)
		->setCellValue('M'.$i, $trip_type_name)
		->setCellValue('N'.$i, $avg_km)
		->setCellValue('O'.$i, $veh_type)
		->setCellValue('P'.$i, $bus_count)
		->setCellValue('Q'.$i, $booking_amount)
		->setCellValue('R'.$i, $type)
		->setCellValue('S'.$i, $cust_sts)
		->setCellValue('T'.$i, $first_name)
		->setCellValue('U'.$i, $ncd)
		->setCellValue('V'.$i, $enquiry_sts)
		->setCellValue('W'.$i, $prospect)
		->setCellValue('X'.$i, $remark);
			$i++;
			$j++;
		}
	
		  // Rename sheet
		 $objWorkSheet->setTitle("Detailed");
		 $obj->setActiveSheetIndex(0);

		 $filename="Enquiry 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');
	}


}
?>