ok

Mini Shell

Direktori : /home2/selectio/www/lilyexpresslive/software/admin/data-tables/
Upload File :
Current File : /home2/selectio/www/lilyexpresslive/software/admin/data-tables/total-reports-data-table.php

<?php
try{
include("../inc/config.php");

    $from = $_REQUEST['from'];
    $to = $_REQUEST['to'];
    $status = $_REQUEST['status'];
     $awb_type = $_REQUEST['awb_type'];
    $clientType = $_REQUEST['client_type'];
    if(isset($_REQUEST['client_id'])){ $client_id = $_REQUEST['client_id']; }
    if(isset($_REQUEST['courier_id'])){ $courier_id = $_REQUEST['courier_id']; }

ini_set('memory_limit', '-1');
$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";
}




$requestData= $_REQUEST;
/*Fetch Database column Details*/
        $columns = array( 
             0 =>'id', 
            1 =>'ref_no',
            2 =>'cust_code',
            3 =>'client_name',
            4 =>'address',
            5 =>'pincode',
            6 =>'phone',
            7 =>'a_weight',
            8 =>'c_weight',
            9 =>'pics',
            10 =>'added',
            11 =>'cust_name',
            12 =>'destination',
            13 =>'e_way_bill_no',
            14 =>'invoice_no',
            15 =>'invoice_value'
        );
        
        $condition='where 1=1 ';
        
        
         
/*Fetch All Data Start*/        
        if($clientType=="Admin")
    	 { 
    	        /*if($status=='all' && $client_id=='all')
                {
                   $condition='';  
                } */
                if($status!='all')
                {
                   //$condition.=' and pickup_entry.status="'.$status.'"';
                   $condition.=" and pickup_entry.status in (".$status.")";
                }
                if($awb_type!='')
                {
                   //$condition.=' and pickup_entry.status="'.$status.'"';
                   $condition.=" and pickup_entry.is_return_awb=".$awb_type;
                }
                
                
                if($client_id!='all')
                {
                   //$condition.='and pickup_entry.client_id in ("'.$client_id.'")';
                   $condition.=" and pickup_entry.client_id in (".$client_id.")";
                   
                }
                if(isset($_REQUEST['entry_type']) && $_REQUEST['entry_type']!=""){
           $condition.=" and pickup_entry.entry_type=".$_REQUEST['entry_type'];
        }
               
                if($from!='' && $to!='')
                {
                    $condition.=" and pickup_entry.created_at BETWEEN '$from' AND '$to' ";
                }
    		$statement = $pdo->prepare("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,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 ");
    	 
    	 /*$s="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,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 ";
    	 error_log('ddd:'.$s); */
    	     
    	 }          
    	 else
    	 {
    	     $condition=' 1=1 ';
    	     if($status!='all')
                {
                   //$condition.=' and pickup_entry.status="'.$status.'"';
                   $condition.=" and pickup_entry.status in (".$status.")";
                }
                if($awb_type!='')
                {
                   //$condition.=' and pickup_entry.status="'.$status.'"';
                   $condition.=" and pickup_entry.is_return_awb=".$awb_type;
                }
                if($client_id!='all')
                {
                   //$condition.='and pickup_entry.client_id in ("'.$client_id.'")';
                   $condition.="and pickup_entry.client_id in (".$client_id.")";
                }
               if(isset($_REQUEST['entry_type']) && $_REQUEST['entry_type']!=""){
           $condition.=" and pickup_entry.entry_type=".$_REQUEST['entry_type'];
        }
                if($from!='' && $to!='')
                {
                    $condition.=" and pickup_entry.created_at BETWEEN '$from' AND '$to' ";
                }
                
                  $statement = $pdo->prepare("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,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  $condition");   
          /*$s="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,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  $condition";
          error_log('ddd:'.$s);*/      	 
    	 }
		$statement->execute();
		$query = $statement->fetchAll(PDO::FETCH_ASSOC);
		$totalData = $statement->rowCount();
        $totalFiltered = $totalData;
/*Fetch All Data End*/       
        
/*Fetch Filter Data Start*/    
    	 
    	 if($clientType=="Admin")
    	 { 
    	     $condition='where 1=1 ';
    	      
    	        if($status!='all')
                {
                   //$condition.=' and pickup_entry.status="'.$status.'"';
                   $condition.=" and pickup_entry.status in (".$status.")";
                }
                if($client_id!='all')
                {
                   //$condition.='and pickup_entry.client_id in ("'.$client_id.'")';
                   $condition.="and pickup_entry.client_id in (".$client_id.")";
                }
               if($awb_type!='')
                {
                   //$condition.=' and pickup_entry.status="'.$status.'"';
                   $condition.=" and pickup_entry.is_return_awb=".$awb_type;
                }
                if($from!='' && $to!='')
                {
                    $condition.=" and pickup_entry.created_at BETWEEN '$from' AND '$to' ";
                }
                if(isset($_REQUEST['entry_type']) && $_REQUEST['entry_type']!=""){
           $condition.=" and pickup_entry.entry_type=".$_REQUEST['entry_type'];
        }
               
    		$sql="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 $condition ";
    	 }
    	 else
    	 {
    	    $condition=' 1=1 ';
    	    
    	        if($status!='all')
                {
                   //$condition.=' and pickup_entry.status="'.$status.'"';
                   $condition.=" and pickup_entry.status in (".$status.")";
                }
                if($awb_type!='')
                {
                   //$condition.=' and pickup_entry.status="'.$status.'"';
                   $condition.=" and pickup_entry.is_return_awb=".$awb_type;
                }
                if($client_id!='all')
                {
                   //$condition.='and pickup_entry.client_id in ("'.$client_id.'")';
                   $condition.="and pickup_entry.client_id in (".$client_id.")";
                }
               
                if($from!='' && $to!='')
                {
                    $condition.=" and pickup_entry.created_at BETWEEN '$from' AND '$to' ";
                }
                 if(isset($_REQUEST['entry_type']) && $_REQUEST['entry_type']!=""){
           $condition.=" and pickup_entry.entry_type=".$_REQUEST['entry_type'];
        }
                
                  $sql="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 $condition";   
             	 
    	 }
         if( !empty($requestData['search']['value']) ) 
        {   
        	$sql.=" AND ( pickup_entry.ref_no LIKE '%".$requestData['search']['value']."%' ";    
        	$sql.=" OR tbl_customer.cust_code LIKE '%".$requestData['search']['value']."%' ";    
        	$sql.=" OR pickup_entry.pincode LIKE '%".$requestData['search']['value']."%' ";
        	$sql.=" OR tbl_user.full_name LIKE '%".$requestData['search']['value']."%' ";
        	$sql.=" OR pickup_entry.destination LIKE '%".$requestData['search']['value']."%' ";
        	$sql.=" OR tbl_customer.cust_name LIKE '%".$requestData['search']['value']."%' ";
        	$sql.=" OR pickup_entry.phone LIKE '%".$requestData['search']['value']."%' )";
        }
        
        if($clientType=="Admin"){ 
    		$statement = $pdo->prepare($sql);
    	 }
    	 else{
    	     $statement = $pdo->prepare($sql);
    	 }
        $statement->execute();
		$query = $statement->fetchAll(PDO::FETCH_ASSOC);
        $totalFiltered = $statement->rowCount();
        
   //     error_log('Report Sql Files:  '.$sql);
        
/*Fetch Filter Data End*/       
        


 $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]."   ".$requestData['order'][0]['dir']."  LIMIT ".$requestData['start']." ,".$requestData['length']."   ";
//  $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc  */	
$statement = $pdo->prepare($sql);
        $statement->execute();
		$query = $statement->fetchAll(PDO::FETCH_ASSOC);
//error_log('Overlall Report Result:'.$sql);
$data = array();
$i=$requestData['start']+1;
foreach( $query as $row ) {  // preparing an array
                        $nestedData=array(); 
                     	$nestedData[] = $i;
                     	/*$nestedData[] = "<input type='checkbox' class='checkbox' name='checkboxlist' value='".$row['ref_no']."'/>";*/
                    	$nestedData[] = $row["ref_no"];
                    	$nestedData[] = $row["cust_code"];
                    	$nestedData[] = $row["picklist_no"];
                    	$nestedData[] = strtoupper($row["status"]);
                    	$day=date_create($row['current_status_date']);$created=date_format($day,'d-m-Y');
                    	$nestedData[] =$created;
                    	$nestedData[] = $row["client_name"];
                    	$nestedData[] = $row["address"];
                    	$nestedData[] = $row["pincode"];
                    	$nestedData[] = str_replace("$","",$row["phone"]);
                    	$nestedData[] = $row["a_weight"];
                    	$nestedData[] = $row["c_weight"];
                    	$nestedData[] = $row["pics"];
                    	$day=date_create($row['added']);$created=date_format($day,'d-m-Y');
                    	$nestedData[] =$created;
                    	$nestedData[] = $row["cust_name"];
                    	$nestedData[] = $row["destination"];
                    	$nestedData[] = $row["e_way_bill_no"];
                    	$nestedData[] = $row["invoice_no"];
                    	$nestedData[] = $row["invoice_value"];
                    	
                    	if($row['pod_status']>0){
        $pod_status="POD Updated";
    }else{
        $pod_status="POD Not Updated";
    }
   // error_log('Overlall Report Result:'.$i);
                    	$nestedData[] = $pod_status;
                    	$data[] = $nestedData;
                    	$i++;
                    }



$json_data = array(
			"draw"            => intval( $requestData['draw'] ),   // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. 
			"recordsTotal"    => intval( $totalData ),  // total number of records
			"recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData
			"data"            => $data   // total data array
			);

echo json_encode($json_data);  // send data as json format
}catch(Exception $e){
     error_log('Exception Report Result:'.$e);
}
?>

Zerion Mini Shell 1.0