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/taxicamera/old/applicationold/controllers/admin/Report.php
<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Report extends MY_Controller
{
    public function __construct()
    {
        parent::__construct();
        //$this->redirect_guest();
        $this->admin = $this->session->userdata('admin');
        $this->load->model('admin/mreport');


        if ($this->session->userdata('admin') != 1) {
            redirect('admin');
        }
    }


    // Default load function for header and footer inculded
    private function _load_view($data)
    {
        $this->load->view('admin/layouts/index', $data);
    }


    /*
	author: Arindam Biswas
	purpose: Levy Report
	date: 11-10-2019
	*/
    public function levy()
    {
        $result = array();
        $result['content'] = 'admin/report/levy/list';
        $result['company_list'] = $this->mcommon->getDetails('master_company',array('company_status'=>1));
        $result['driver_list'] = $this->mreport->get_driver_list();
        
        
        $result['settled_levy_list'] = $this->get_levy_report('', '', '', '',1);
        $result['unsettled_levy_list'] = $this->get_levy_report('', '', '', '',0);
        //pr($result['unsettled_levy_list']);
        $this->_load_view($result);
    }

    public function levy_report_search(){

        $start_date=$this->input->post('start_date');
        $levy_settled_flag=$this->input->post('levy_settled_flag');
        $end_date=$this->input->post('end_date');
        $driver_id=$this->input->post('driver_id');
        $company_id=$this->input->post('company_id');

        //echo $levy_settled_flag;die;
        $levy_list = $this->get_levy_report($start_date, $end_date, $driver_id, $company_id,$levy_settled_flag);
        $return_data=array('status'=>true,'levy_list'=>$levy_list);
        echo json_encode($return_data);
        
    }

    public function get_driver_against_company(){

        $company_id=$this->input->post('company_id');
        if(empty($company_id)){
            $driver_list = $this->mreport->get_driver_list();
        }
        else{

            $driver_list = $this->mreport->get_driver_against_company($company_id);
        }
    
        $return_data=array('status'=>true,'driver_list'=>$driver_list);
        echo json_encode($return_data);
    
    }

    public function get_levy_report($start_date = null, $end_date = null, $driver_id = null, $company_id = null,$levy_settled_flag=null){
        
        if (!empty($start_date)  && !empty($end_date)) {
            $start_date = date('Y-m-d', strtotime(str_replace('/', '-', $start_date)));
            $end_date = date('Y-m-d', strtotime(str_replace('/', '-', $end_date)));
        }

        return $this->mreport->get_levy_report($start_date, $end_date, $driver_id, $company_id,$levy_settled_flag);
    }

    public function settle_checked_levy(){

        $checked_unsettle_string=$this->input->post('checked_unsettle_string');
        $checked_unsettle_array=array();
        if(!empty($checked_unsettle_string)){

            $checked_unsettle_array=explode(',',$checked_unsettle_string);
        }
        $update_data=array('levy_settled_flag'=>1);
        foreach($checked_unsettle_array as $payin_id){
            $condition=array('payin_id'=>$payin_id);
            $updated_payin_id=$this->mcommon->update('payin',$condition,$update_data);
        }
       

        if($updated_payin_id){
            $return_data=array('status'=>true,'msg'=>'Levy Settled Successfully');

        }
        else{
            $return_data=array('status'=>false,'msg'=>'Oops!Something went wrong');

        }
        echo json_encode($return_data);

    }

    /*
	author: Arindam Biswas
	purpose: Meter Reading Report
	date: 15-10-2019
	*/
    public function meter_reading()
    {
        $result = array();
        $result['content'] = 'admin/report/meter_reading/list';
        $result['car_list'] = $this->mcommon->getDetails('master_car',array('status'=>1));
        $result['meter_reading_list'] = $this->get_meter_reading_report();
        $this->_load_view($result);
    }

    public function meter_reading_report_search(){

        $start_date=$this->input->post('start_date');
        $end_date=$this->input->post('end_date');
        $car_id=$this->input->post('car_id');
       

        //echo $levy_settled_flag;die;
        $meter_reading_list = $this->get_meter_reading_report($start_date, $end_date, $car_id);
        $return_data=array('status'=>true,'meter_reading_list'=>$meter_reading_list);
        echo json_encode($return_data);
        
    }

    

    private function get_meter_reading_report($start_date = null, $end_date = null, $car_id = null){
        
        if (!empty($start_date)  && !empty($end_date)) {
            $start_date = date('Y-m-d', strtotime(str_replace('/', '-', $start_date)));
            $end_date = date('Y-m-d', strtotime(str_replace('/', '-', $end_date)));
        }

        return $this->mreport->get_meter_reading_report($start_date, $end_date, $car_id);
    }


    /*
	author: Arindam Biswas
	purpose: Income Report
	date: 16-10-2019
	*/
    public function income_report()
    {
        $result = array();
        $result['content'] = 'admin/report/income_report/list';
        $result['car_list'] = $this->mcommon->getDetails('master_car',array('status'=>1));
        $result['company_list'] = $this->mcommon->getDetails('master_company',array('company_status'=>1));
        $this->_load_view($result);
    }


    public function get_income_report(){
        $start_date=$this->input->post('start_date');
        $end_date=$this->input->post('end_date');
        $car_id=$this->input->post('car_id');
        $company_id=$this->input->post('company_id');
        
        if (!empty($start_date)  && !empty($end_date)) {
            $start_date = date('Y-m-d', strtotime(str_replace('/', '-', $start_date)));
            $end_date = date('Y-m-d', strtotime(str_replace('/', '-', $end_date)));
        }

        $income_list= $this->mreport->get_income_report($start_date, $end_date, $car_id,$company_id);
        //pr($income_list);
        $return_data=array('status'=>true,'income_list'=>$income_list);
        echo json_encode($return_data);
    }


     public function get_car_against_company(){

        $company_id=$this->input->post('company_id');
        if(empty($company_id)){
            $car_list = $this->mcommon->getDetails('master_car',array('status'=>1));
        }
        else{

            $car_list = $this->mreport->get_car_against_company($company_id);
        }
    
        $return_data=array('status'=>true,'car_list'=>$car_list);
        echo json_encode($return_data);
    
    }

    /*
	author: Arindam Biswas
	purpose: Driver Income Report
	date: 17-10-2019
	*/
    public function driver_income_report()
    {
        $result = array();
        $result['content'] = 'admin/report/driver_income_report/list';
        $result['driver_list'] = $this->mreport->get_driver_list();
        $this->_load_view($result);
    }


    public function get_driver_income_report(){
        $start_date=$this->input->post('start_date');
        $end_date=$this->input->post('end_date');
        $driver_id=$this->input->post('driver_id');
        
        
        if (!empty($start_date)  && !empty($end_date)) {
            $start_date = date('Y-m-d', strtotime(str_replace('/', '-', $start_date)));
            $end_date = date('Y-m-d', strtotime(str_replace('/', '-', $end_date)));
        }

        $income_list= $this->mreport->get_driver_income_report($start_date, $end_date, $driver_id);
        $return_data=array('status'=>true,'income_list'=>$income_list);
        echo json_encode($return_data);
    }

    public function service_notification()
    {
        $result = array();
        $result['content'] = 'admin/report/service_notification/list';
        $this->_load_view($result);
    }

    public function get_service_notification_report(){

        $service_notification_list= $this->mreport->get_service_notification_report();
        $return_data=array('status'=>true,'service_notification_list'=>$service_notification_list);
        echo json_encode($return_data);
    }

    public function settlement_due()
    {
        $result = array();
        $result['content'] = 'admin/report/settlement_due/list';
        $this->_load_view($result);
    }
    
    public function get_settlement_due_report(){

        $settlement_due_list= $this->mreport->get_settlement_due_report();
        $return_data=array('status'=>true,'settlement_due_list'=>$settlement_due_list);
        echo json_encode($return_data);
    }

    public function download_pdf($levy_settled_flag,$driver_id,$start_date=null,$end_date=null){
        
        //echo $levy_settled_flag.'<br>'.$driver_id.'<br>'.$start_date.'<br>'.$end_date; die;
        $levy_data = $this->mreport->get_levy_report_details($start_date, $end_date, $driver_id, $company_id=NULL,$levy_settled_flag); 
        $data['logo']  			= './public/images/logo_pdf.png';
        $data['levy_data']	= $levy_data;
        $data['sro_status']=($levy_settled_flag==0)?'<span style="color: white;padding: 8px;background-color: #f44336;">SRO PENDING</span>':'<span style="color: white;padding: 8px;background-color: #4CAF50;">SRO PAID</span>';
		$html					= $this->load->view('admin/report/levy/levy_report_pdf', $data, true);
        //echo $html;die;
        $dompdf = new Dompdf\Dompdf();
		$dompdf->set_option("isPhpEnabled", true);
		$dompdf->loadHtml($html);
		$dompdf->setPaper('A3', 'portrait');
		$dompdf->render();
        $filename='levy_report_'.time();
		$dompdf->stream($filename);
    }
    
    public function service_booked($service_notification_id){

        $result = array();
        $result = $this->mcommon->update('service_notification',array('service_notification_id'=>$service_notification_id),
        array('service_status'=>1,'updated_ts'=>date('Y-m-d H:i:s')));
		if($result)
		{
			$this->session->set_flashdata('success_msg','Service booked successfully...');
			redirect('admin/report/service_notification');
		}else{
            $this->session->set_flashdata('error_msg','Oops!Something went wrong...');
            redirect('admin/report/service_notification');
		}

    }

    public function service_pending($service_notification_id){

        $result = array();
        $result = $this->mcommon->update('service_notification',array('service_notification_id'=>$service_notification_id),
        array('service_status'=>0,'updated_ts'=>date('Y-m-d H:i:s')));
		if($result)
		{
			$this->session->set_flashdata('success_msg','Service status changed successfully...');
			redirect('admin/report/service_notification');
		}else{
            $this->session->set_flashdata('error_msg','Oops!Something went wrong...');
            redirect('admin/report/service_notification');
		}

    }

    

    public function download_pdf_metered_fare($start_date = null, $end_date = null, $car_id = null){
        
        //echo $levy_settled_flag.'<br>'.$driver_id.'<br>'.$start_date.'<br>'.$end_date; die;
        $data['start_date']='';
        $data['end_date']='';
        if (!empty($start_date)  && !empty($end_date)) {
            $data['start_date']=date('d/m/Y', strtotime($start_date));
            $data['end_date']=date('d/m/Y', strtotime($end_date));
            // $start_date = date('Y-m-d', strtotime(str_replace('/', '-', $start_date)));
            // $end_date = date('Y-m-d', strtotime(str_replace('/', '-', $end_date)));
        }

        $meter_reading_data= $this->mreport->get_meter_reading_report($start_date, $end_date, $car_id);
        
        $data['logo']  			= './public/images/logo_pdf.png';
		$data['meter_reading_data']	= $meter_reading_data;
		$html					= $this->load->view('admin/report/meter_reading/meter_reading_report_pdf', $data, true);
		$dompdf = new Dompdf\Dompdf();
		$dompdf->set_option("isPhpEnabled", true);
		$dompdf->loadHtml($html);
		$dompdf->setPaper('A2', 'portrait');
		$dompdf->render();
        $filename='meter_reading_report_'.time();
		$dompdf->stream($filename);
    }

    public function download_pdf_income_report($start_date = null, $end_date = null, $car_id = null,$company_id =null){
        
        //echo $levy_settled_flag.'<br>'.$driver_id.'<br>'.$start_date.'<br>'.$end_date; die;
        $data['start_date']='';
        $data['end_date']='';
        if (!empty($start_date)  && !empty($end_date)) {
            $data['start_date']=date('d/m/Y', strtotime($start_date));
            $data['end_date']=date('d/m/Y', strtotime($end_date));
            // $start_date = date('Y-m-d', strtotime(str_replace('/', '-', $start_date)));
            // $end_date = date('Y-m-d', strtotime(str_replace('/', '-', $end_date)));
        }

        $income_list= $this->mreport->get_income_report($start_date, $end_date, $car_id,$company_id);

        $data['logo']  			= './public/images/logo_pdf.png';
		$data['income_list']	= $income_list;
		$html					= $this->load->view('admin/report/income_report/income_report_pdf', $data, true);
		$dompdf = new Dompdf\Dompdf();
		$dompdf->set_option("isPhpEnabled", true);
		$dompdf->loadHtml($html);
		$dompdf->setPaper('A2', 'portrait');
		$dompdf->render();
        $filename='income_report_'.time();
		$dompdf->stream($filename);
    }

    public function download_pdf_driver_income_report(){
        
        $start_date = $_GET['start_date'];
        $end_date = $_GET['end_date']; 
        $driver_id = $_GET['driver_id']; 
        
        // echo $driver_id;die;
        
        $data['start_date']='';
        $data['end_date']='';
        if (!empty($start_date)  && !empty($end_date)) {
            $data['start_date']=date('d/m/Y', strtotime($start_date));
            $data['end_date']=date('d/m/Y', strtotime($end_date));
            // $start_date = date('Y-m-d', strtotime(str_replace('/', '-', $start_date)));
            // $end_date = date('Y-m-d', strtotime(str_replace('/', '-', $end_date)));
        }
        //echo $driver_id;die;
        $income_list= $this->mreport->get_driver_income_report($start_date, $end_date, $driver_id);

        $data['logo']  			= './public/images/logo_pdf.png';
        $data['income_list']	= $income_list;
        //echo '<pre>';print_r($data);die;
		$html					= $this->load->view('admin/report/driver_income_report/driver_income_report_pdf', $data, true);
		$dompdf = new Dompdf\Dompdf();
		$dompdf->set_option("isPhpEnabled", true);
		$dompdf->loadHtml($html);
		$dompdf->setPaper('A2', 'portrait');
		$dompdf->render();
        $filename='driver_income_report_'.time();
		$dompdf->stream($filename);
    }


    public function customer_statement()
    {
        $result = array();
        $result['customer_list']=$this->mcommon->getDetails('master_customer',array('customer_status'=>1));
        $result['content'] = 'admin/report/customer_statement/list';
        $this->_load_view($result);
    }
    
    public function get_customer_statement_report(){

        $start_date=$this->input->post('start_date');
        $end_date=$this->input->post('end_date');
        $customer_id=$this->input->post('customer_id');
        
        
        if (!empty($start_date)  && !empty($end_date)) {
            $start_date = date('Y-m-d', strtotime(str_replace('/', '-', $start_date)));
            $end_date = date('Y-m-d', strtotime(str_replace('/', '-', $end_date)));
        }

        $customer_statement_list= $this->mreport->get_customer_statement_report($start_date,$end_date,$customer_id);
        $return_data=array('status'=>true,'customer_statement_list'=>$customer_statement_list);
        echo json_encode($return_data);
    }
    
    public function download_pdf_customer_statement_report(){
        
        $start_date = $_GET['start_date'];
        $end_date = $_GET['end_date']; 
        $customer_id = $_GET['customer_id']; 
        
        // echo $driver_id;die;
        
        $data['start_date']='';
        $data['end_date']='';
        if (!empty($start_date)  && !empty($end_date)) {
            $data['start_date']=date('d/m/Y', strtotime($start_date));
            $data['end_date']=date('d/m/Y', strtotime($end_date));
        }
        //echo $driver_id;die;
        $income_list= $this->mreport->get_customer_statement_report($start_date, $end_date, $customer_id);

        $data['logo']  			= './public/images/logo_pdf.png';
        $data['income_list']	= $income_list;
        //echo '<pre>';print_r($data);die;
		$html					= $this->load->view('admin/report/customer_statement/customer_statement_pdf', $data, true);
		$dompdf = new Dompdf\Dompdf();
		$dompdf->set_option("isPhpEnabled", true);
		$dompdf->loadHtml($html);
		$dompdf->setPaper('A2', 'portrait');
		$dompdf->render();
        $filename='customer_statement_report'.time();
		$dompdf->stream($filename);
    }
    public function bank_transfer(){
        $this->_load_bank_transfer_report_list();  
              
    } 
    public function  _load_bank_transfer_report_list(){
        $data['content']            = 'admin/report/bank_transfer/bank_transfer_report_list';
        $this->load->view('admin/layouts/index', $data);
    } 
    public function BankPaymentReportGenerate() {
        $data                       = array();
        $responce_arr               = array();
        if($this->input->post("from_date") && $this->input->post("to_date")){
            $from_date                  = date('Y-m-d',strtotime(str_replace('/','-',$this->input->post("from_date"))));
            $to_date                    = date('Y-m-d',strtotime(str_replace('/','-',$this->input->post("to_date")))); 
            
            $cond                       = "DS.bank_transfer_amt != '0.00' and DS.created_on between '".$from_date."' and '".$to_date."'";
        }
        else{
            $cond                       = array('DS.bank_transfer_amt !='=>'0.00');
        }
        $joindata   = array('select'        =>"DS.*,master_user.dc_no,CONCAT(user_profile.first_name,' ',ifnull(user_profile.middle_name,''),' ',user_profile.last_name) AS FULLNAME,user_profile.bank_name,user_profile.bsb,user_profile.account_no,payin.bank_payment_flag",
                            'first_table'   =>'driver_settlement DS',
                            'second_table'  =>'master_user',
                            'dependency1'   =>'DS.driver_id = master_user.user_id',
                            'join_type1'    =>'inner',                  
                        /********************************/ 
                            'third_table'   =>'user_profile',
                            'dependency2'   =>'user_profile.user_id = master_user.user_id',
                            'join_type2'    =>'inner',
                        /*********************************/   
                            'forth_table'   =>'payin',
                            'dependency3'   =>'payin.payin_id = DS.payin_id',
                            'join_type3'    =>'inner'
                        );

        
        $bnk_trnf_report_data       = $this->mcommon->joinQuery($joindata,$cond,'result','DS.dr_settlement_id','DESC');
        //pr($bnk_trnf_report_data);
        if(!empty($bnk_trnf_report_data)){            
            
            $data['bnk_trnf_report_data']     = $bnk_trnf_report_data;
        }
        else{
            $data['bnk_trnf_report_data']     = '';
        }
        $responce_arr['html'] = $this->load->view('admin/report/bank_transfer/ajax_bank_transfer_report_list',$data,true);
        echo json_encode($responce_arr);exit;
    }
    public function BankPaymentStatusChange(){
        $payinId        = $this->input->post('payin_id');
        $condition      = array('payin_id' => $payinId);
        $update_data    = array('bank_payment_flag' =>'1',
                                'updated_by'        => $this->session->userdata('user_data')
                        );
        $update_respn   = $this->mcommon->update('payin',$condition,$update_data);
        if($update_respn){
            echo "1";exit;
        }
        else{
            echo "0";exit;
        }
    }
   
}