HEX
Server: Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/5.6.40
System: Linux ip-172-31-40-18 4.14.146-93.123.amzn1.x86_64 #1 SMP Tue Sep 24 00:45:23 UTC 2019 x86_64
User: apache (48)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /var/www/html/pmw24/pmw_live_testing/app/application/controllers/admin/Servicehistory_01_02_19.php
<?php 
defined('BASEPATH') OR exit('No direct script access allowed');

class Servicehistory extends MY_Controller {
	public function __construct() {
		parent::__construct();
		$this->redirect_guest();
		$this->admin=$this->session->userdata('admin');		
		$this->load->model('admin/mservicehistory');
		$this->load->dbutil();
	    $this->load->helper('file');
	    $this->load->helper('download');
	}
	
	public function index() {	
		$this->_load_list_view();		
	}
	
	private function _load_list_view() {
		$condition = array();
		$data['cars'] = $this->mservicehistory->getRows('car',$condition);		
		$data['content'] = 'admin/servicehistory/list';
		$this->load->view('admin/layouts/index', $data);
	}
	
	public function all_content_list(){
		$start_date = $_POST['start_date'];
		$end_date = $_POST['end_date'];	
		$car_id = $_POST['car_id'];
		$list = $this->mservicehistory->get_datatables($start_date,$end_date,$car_id);
		
        $data = array();
        $no = $_POST['start'];
		$i=1;
        foreach ($list as $person) {
            $no++;
            $row = array();						
			$row[] =$no;
			$row[] = $person->car_no;
			$row[] = $person->service_date;	
			$row[] = '<a class="cstm_view" id="view" style="padding-left:5px" href="javascript:void(0)" title="'.$person->job_id.'" car_id="'.$person->car_id.'"><i class="glyphicon glyphicon-eye-open"></i></a>';
            $data[] = $row;
			$i++;
        }
        $output = array(
                        "draw" => $_POST['draw'],
                        "recordsTotal" => $this->mservicehistory->count_all($start_date,$end_date,$car_id),
                        "recordsFiltered" => $this->mservicehistory->count_filtered($start_date,$end_date,$car_id),
                        "data" => $data,
                );
        echo json_encode($output);
	}
	public function all_content_list_csv(){

		$start_date = $_POST['start_date'];
		$end_date = $_POST['end_date'];	
		$car_id = $_POST['car_id'];
	
        $filename= 'service_history_report'.time().'.csv';
       /* $this->db->select('*');
        $query = $this->db->get('car');*/

        $this->db->select('car.car_no,job_service_date.service_date');
        $this->db->from('job_service_date');	
		$this->db->join('car', 'car.car_id = job_service_date.car_id', 'left');				
		$this->db->where("job_service_date.service_date>=",$start_date);
		$this->db->where("job_service_date.service_date<=",$end_date);	
		$this->db->where("job_service_date.car_id",$car_id);
        $query = $this->db->get();

      // echo $query = $this->db->last_query(); die;

        @query_to_csv($query,TRUE,$filename);
        echo $filename;

	}
	
	public function all_details(){
		$job_id = $this->input->post('job_id');		
		$car_id = $this->input->post('car_id');	
		$services = $this->mservicehistory->get_details($job_id);	
		foreach($services as $key=>$service)
		{
			//$condition = array("service_id"=>$service['service_id']);			
			//$task = $this->mservicehistory->getRows('task',$condition);
			$task=$this->mservicehistory->selected_task_list_for_particular_service($job_id,$service['service_id']);
			$services[$key]['task'] = $task;
		}
		$result['services'] = $services;
		$car_condition = array("car_id"=>$car_id);
		$car = $this->mservicehistory->getRow('car',$car_condition);
		$result['job_details']=$this->mservicehistory->get_job_details($job_id);	
		$result['job_image_details']=$this->mservicehistory->getRows('job_images',array('job_id'=>$job_id));
		$result['car'] = $car;
		echo json_encode($result);
	}
}