ok

Mini Shell

Direktori : /home2/selectio/www/lilyexpresslive/software/admin/excel/
Upload File :
Current File : /home2/selectio/www/lilyexpresslive/software/admin/excel/overall-report-copy.php

<?php
ini_set('memory_limit', '-1');
include("../inc/config.php");
include("../db.php");
$status='';$client_id='';
    $from = $_POST['from'];
    $to = $_POST['to'];
    
if(isset($_POST['set_status'])){
     $status = $_POST['set_status'];
}    
   
    $client_id = $_POST['client_id'];
    $report_name="Overall-Report";
    $client_type="";
    
    
$client_idss="0";
if(isset($client_id) && is_array($client_id)){
foreach($client_id as $ids){
    $client_idss.=",";
    $client_idss.=$ids;
}
}
$client_id=$client_idss;

if($client_id=='0'){
    $client_id="all";
}

$status_idss="";
if(isset($status) && is_array($status)){
foreach($status as $ids){
    if($status_idss!=""){
        $status_idss.=",";
    }
    
    $status_idss.="'".$ids."'";
}
}
$status=$status_idss;

if($status==''){
    $status="all";
}    
    

    
    $where="";
    if($status!="all"){
        $where.=" and pickup_entry.status in (".$status.")";
    }
    if(isset($_POST['entry_type']) && $_POST['entry_type']!=""){
           $where.=" and pickup_entry.entry_type=".$_POST['entry_type'];
        }
    if($client_id!="all"){
        $where.="and pickup_entry.client_id in (".$client_id.")";
        $report_name="";
        $statements = "SELECT role,full_name FROM `tbl_user` WHERE id in (".$client_id.")";
        $client_result=mysqli_query($conn,$statements);
        foreach ($client_result as $row) {
            $report_name.=$row['full_name']."-";
            $client_type=$row['role'];
        }
        
        
    }
    if($from!='' && $to!=''){
       $where.=' and pickup_entry.created_at BETWEEN "'.$from.'" and "'.$to.'"'; 
    }
    
    
        $statement = "SELECT pickup_entry.*,(select created_at from tbl_tracking where pickup_entry_id=pickup_entry.id order BY t_id DESC LIMIT 1) as current_status_date,(SELECT COUNT(id) from tbl_pod WHERE awb_id=pickup_entry.id) as pod_status,tbl_user.full_name as client_name,pickup_entry.created_at as added,tbl_customer.cust_code as cust_code,
    	       material_desc.full_desc as content,tbl_customer.cust_name as cust_name FROM pickup_entry INNER JOIN tbl_user INNER JOIN tbl_customer INNER JOIN material_desc 
    	       on pickup_entry.client_id=tbl_user.id AND pickup_entry.content_desc=material_desc.id AND pickup_entry.customer_id=tbl_customer.cust_id 
    	       where pickup_entry.id!=0 $where order by pickup_entry.id DESC";
        
            	
	                 	$result=mysqli_query($conn,$statement);
	                 
            /*	
            	$statement->execute();
            	$result = $statement->fetchAll(PDO::FETCH_ASSOC);*/	
            	
        header('Content-Type: text/csv; charset=utf-8');  
		header('Content-Disposition: attachment; filename='.$report_name.'-'.date("Y-m-d").'.csv');  
		$output = fopen("php://output", "w");  
		
		
		if($client_type!="Cargo"){
    		//fputcsv($output, array('SL', 'AWB Number', 'Ref Number', 'status', 'Company Name', 'Address', 'Pincode', 'Mobile', 'Actual Weight', 'Charged Weight', 'No.Of Pics', 'Date Added', 'Customer Name'));  
            fputcsv($output, array('SL', 'AWB Number', 'Ref Number', 'Packing List No','Destination', 'Sender Name', 'Customer Name', 'Address', 'Pincode', 'Mobile', 'Actual Weight', 'Charged Weight', 'No.Of Pics', 'Status', 'Status Updated Date','Booking Date','POD Status'));   
            $i=1;
    		foreach ($result as $row) {
    		    $date=date_create($row['created_at']);
    			 $day=date_format($date,'d-m-Y');
    			 
    			 $current_status_date=date_create($row['current_status_date']);
    			 $current_status_date=date_format($current_status_date,'d-m-Y');
    			 
    			 
    			 $time= date('h:i:s A', strtotime($row['updated_at']));
    			 
    if($row['pod_status']>0){
        $pod_status="POD Updated";
    }else{
        $pod_status="POD Not Updated";
    }
                              fputcsv($output, array($i,$row['ref_no'],$row['cust_code'],$row['picklist_no'],$row['destination'],$row['client_name'],$row['cust_name'],$row['address'],$row['pincode'],str_replace("$","",$row["phone"]),$row['a_weight'],$row['c_weight'],$row['pics'],$row['status'],$current_status_date,$day,$pod_status));
            			//fputcsv($output, array($i,$row['ref_no'],$row['cust_code'],$row['status'],$row['client_name'],$row['address'],$row['pincode'],$row['phone'],$row['a_weight'],$row['c_weight'],$row['pics'],$day,$row['cust_name']));
            		    $i++;
    		} 
		}else{
		    fputcsv($output, array('SL', 'AWB Number', 'Ref Number', 'Booked Date','Destination', 'Sender Name', 'Customer Name', 'Address', 'Pincode', 'Mobile','Length','Width','Height','No of Box', 'Actual Weight', 'Charged Weight', 'Total Actual Weight', 'Total Charged Weight', 'Total No.Of Pics','Invoice Number','E-way Bill No','Content', 'Status', 'Status Updated Date','POD Status'));   
            $i=1;
    		foreach ($result as $row) {
    		    $date=date_create($row['created_at']);
    			 $day=date_format($date,'d-m-Y');
    			 
    			 $current_status_date=date_create($row['current_status_date']);
    			 $current_status_date=date_format($current_status_date,'d-m-Y');
    			 
    			 if($row['pod_status']>0){
        $pod_status="POD Updated";
    }else{
        $pod_status="POD Not Updated";
    }
    			 
    			 $fn=0;
    			 if($row['length1']!="" && $row['length1']!=0 && $row['width1']!="" && $row['width1']!=0 && $row['height1']!="" && $row['height1']!=0 && $row['nob1']!="" && $row['nob1']!=0){
    			     $char_wt=$row['length1']*$row['width1']*$row['height1']*$row['nob1'];
            if($char_wt!=0 && $char_wt!=0.00){
                $char_wt=$char_wt/4500;$char_wt=number_format((float)$char_wt, 2, '.', '');
            }
    			     fputcsv($output, array($i,$row['ref_no'],$row['cust_code'],$day,$row['destination'],$row['client_name'],$row['cust_name'],$row['address'],$row['pincode'],str_replace("$","",$row["phone"]),$row['length1'],$row['width1'],$row['height1'],$row['nob1'],$row['act_wt1'],$char_wt,$row['a_weight'],$row['c_weight'],$row['pics'],$row['invoice_no'],$row['e_way_bill_no'],$row['content'],$row['status'],$current_status_date,$pod_status));
    			 $fn=1;
    				 }
    			 if($row['length2']!="" && $row['length2']!=0 && $row['width2']!="" && $row['width2']!=0 && $row['height2']!="" && $row['height2']!=0 && $row['nob2']!="" && $row['nob2']!=0){
    			     
    			      $char_wt=$row['length2']*$row['width2']*$row['height2']*$row['nob2'];
            if($char_wt!=0 && $char_wt!=0.00){
                $char_wt=$char_wt/4500;$char_wt=number_format((float)$char_wt, 2, '.', '');
            }
            fputcsv($output, array('','','','','','','','','','',$row['length2'],$row['width2'],$row['height2'],$row['nob2'],$row['act_wt2'],$char_wt,'','','','',''));
    			 $fn=1;}
    			 if($row['length3']!="" && $row['length3']!=0 && $row['width3']!="" && $row['width3']!=0 && $row['height3']!="" && $row['height3']!=0 && $row['nob3']!="" && $row['nob3']!=0){
    			     $char_wt=$row['length3']*$row['width3']*$row['height3']*$row['nob3'];
            if($char_wt!=0 && $char_wt!=0.00){
                $char_wt=$char_wt/4500;$char_wt=number_format((float)$char_wt, 2, '.', '');
            }
    			     fputcsv($output, array('','','','','','','','','','',$row['length3'],$row['width3'],$row['height3'],$row['nob3'],$row['act_wt3'],$char_wt,'','','','',''));
    			 $fn=1;}
    			 if($row['length4']!="" && $row['length4']!=0 && $row['width4']!="" && $row['width4']!=0 && $row['height4']!="" && $row['height4']!=0 && $row['nob4']!="" && $row['nob4']!=0){
    			      $char_wt=$row['length4']*$row['width4']*$row['height4']*$row['nob4'];
            if($char_wt!=0 && $char_wt!=0.00){
                $char_wt=$char_wt/4500;$char_wt=number_format((float)$char_wt, 2, '.', '');
            }
    			     fputcsv($output, array('','','','','','','','','','',$row['length4'],$row['width4'],$row['height4'],$row['nob4'],$row['act_wt4'],$char_wt,'','','','',''));
    			 $fn=1;}
    			 if($row['length5']!="" && $row['length5']!=0 && $row['width5']!="" && $row['width5']!=0 && $row['height5']!="" && $row['height5']!=0 && $row['nob5']!="" && $row['nob5']!=0){
    			      $char_wt=$row['length5']*$row['width5']*$row['height5']*$row['nob5'];
            if($char_wt!=0 && $char_wt!=0.00){
                $char_wt=$char_wt/4500;$char_wt=number_format((float)$char_wt, 2, '.', '');
            }
    			     fputcsv($output, array('','','','','','','','','','',$row['length5'],$row['width5'],$row['height5'],$row['nob5'],$row['act_wt5'],$char_wt,'','','','',''));
    			 $fn=1;}
    			 if($fn==0){
    			     fputcsv($output, array($i,$row['ref_no'],$row['cust_code'],$day,$row['destination'],$row['client_name'],$row['cust_name'],$row['address'],$row['pincode'],str_replace("$","",$row["phone"]),'','','','','','',$row['a_weight'],$row['c_weight'],$row['pics'],$row['invoice_no'],$row['e_way_bill_no'],$row['content'],$row['status'],$current_status_date,$pod_status));
    			 }
    
                        
            			
            		    $i++;
    		} 
		}
		
		
		fclose($output);




?>

Zerion Mini Shell 1.0