ok

Mini Shell

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

<?php
//ini_set('memory_limit', '-1');
include("../inc/config.php");

    $from = $_POST['fromm'];
    $to = $_POST['too'];
    $status = $_POST['statuss'];
    $role = $_POST['role'];
    $client_id = $_POST['role_id'];
try{
    ob_start();
 if($role=="Admin") 
    {
        if($status=='all' && $client_id=='all')
        {
           $condition='';  
        } 
        elseif($status!='all' && $client_id=='all')
        {
           $condition='WHERE pickup_entry.status="'.$status.'"';
        }
        elseif($status=='all' && $client_id!='all')
        {
           $condition='WHERE pickup_entry.client_id='.$client_id;
        }
        else
        {
            $condition='WHERE pickup_entry.status="'.$status.'" AND pickup_entry.client_id='.$client_id;
        }
        
        $statement = $pdo->prepare("SELECT pickup_entry.*,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 $condition order by pickup_entry.id ASC");   
     
      $msg="SELECT pickup_entry.*,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 $condition order by pickup_entry.id ASC";     
    }
    else
    {
        
        if($status=='all')
        {
         $statement = $pdo->prepare("SELECT pickup_entry.*,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.client_id=$client_id order by pickup_entry.id ASC");   
        $msg="SELECT pickup_entry.*,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.client_id=$client_id order by pickup_entry.id ASC";
            
        }
        else{
        
          $statement = $pdo->prepare("SELECT pickup_entry.*,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.status='$status' AND pickup_entry.client_id=$client_id order by pickup_entry.id ASC");   
        $msg="SELECT pickup_entry.*,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.status='$status' AND pickup_entry.client_id=$client_id order by pickup_entry.id ASC";
            
        }
        
        
    }	
    
    
      	$statement->execute();
        $result = $statement->fetchAll(PDO::FETCH_ASSOC);	

	$now = gmdate("YmdHis");
		header('Content-Type: text/csv; charset=utf-8');  
		header('Content-Disposition: attachment; filename=Pickup_list_'.$now.'.csv');  
		$output = fopen("php://output", "w");  
		   fputcsv($output, array('SL', 'AWB Number', 'Ref Number','Destination', 'Company Name', 'Customer Name', 'Address', 'Pincode', 'Mobile', 'Actual Weight', 'Charged Weight', 'No.Of Pics', 'Status', 'Delivery Date'));  
        $i=1;
		foreach ($result as $row) {
		    $date=date_create($row['created_at']);
			 $day=date_format($date,'d-m-Y');
			   $created=date_create($row['created_at']);
                     $da=date_format($created,'Y-m-d');
                     
                       if($from!='' && $to!=''){
                     if ($from <= $da && $to >= $da)
                    {
                    
		   fputcsv($output, array($i,$row['ref_no'],$row['cust_code'],$row['destination'],$row['client_name'],$row['cust_name'],$row['address'],$row['pincode'],$row['phone'],$row['a_weight'],$row['c_weight'],$row['pics'],$row['status'],$day));
		   $i++;
                    }
                       }
                       else
                       {
        	fputcsv($output, array($i,$row['ref_no'],$row['cust_code'],$row['client_name'],$row['cust_name'],$row['address'],$row['pincode'],$row['phone'],$row['a_weight'],$row['c_weight'],$row['pics'],$row['status'],$day));
        		    $i++;
                       }
		} 
		fclose($output);
		
ob_end_clean();}catch(excption $e){
    echo $e;
    ob_end_clean();
}
?>

Zerion Mini Shell 1.0