ok

Mini Shell

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

<?php
include("../inc/config.php");
include("../db.php");
$clientType=$_REQUEST['client_type'];
$clientId=$_REQUEST['client_id'];
$from=$_REQUEST['from'];
$to=$_REQUEST['to'];
ini_set('memory_limit', '1024M');
/*$clientType="Admin";
$clientId=28;*/
     
     
$requestData= $_REQUEST;


/*Fetch Database column Details*/
        $columns = array( 
            0 =>'id', 
            1 =>'ref_no', 
            2 =>'awb_no',
            3 =>'content',
            4 =>'client_name',
            5 =>'address',
            6 =>'phone',
            7 =>'status',
            8 =>'payment_mode',
            9 =>'cust_name'
        );
        
/*Fetch All Data Start*/        
        if($clientType=="Admin")
    	 { 
    		$statement = $pdo->prepare("SELECT pickup_entry.*,tbl_user.full_name as client_name,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 and (pickup_entry.status='picked' or pickup_entry.status='manifest' or pickup_entry.status='In Transit' or pickup_entry.status='Received at destination' or pickup_entry.status='Out for delivery' or pickup_entry.status='Undelivery')  order by pickup_entry.id DESC");
    	   // $sql_query = "SELECT pickup_entry.*,tbl_user.full_name as client_name,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 and (pickup_entry.status='picked' or pickup_entry.status='manifest' or pickup_entry.status='In Transit' or pickup_entry.status='Received at destination' or pickup_entry.status='Out for delivery' or pickup_entry.status='Undelivery')  order by pickup_entry.id DESC";
    	     
    	 }
    	 else
    	 {
    	     $statement = $pdo->prepare("SELECT pickup_entry.*,tbl_user.full_name as client_name,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 and (pickup_entry.status='picked' or pickup_entry.status='manifest' or pickup_entry.status='In Transit' or pickup_entry.status='Received at destination' or pickup_entry.status='Out for delivery' or pickup_entry.status='Undelivery') and pickup_entry.client_id=$clientId  order by pickup_entry.id DESC");
    	   // $sql_query="SELECT pickup_entry.*,tbl_user.full_name as client_name,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 and (pickup_entry.status='picked' or pickup_entry.status='manifest' or pickup_entry.status='In Transit' or pickup_entry.status='Received at destination' or pickup_entry.status='Out for delivery' or pickup_entry.status='Undelivery') and pickup_entry.client_id=$clientId  order by pickup_entry.id DESC";
    	     
    	 }
    	 
    	 //$result=mysqli_query($conn,$statement);
    	// $totalData=mysqli_num_rows($result);
		$statement->execute();
		//$query = $statement->fetchAll(PDO::FETCH_ASSOC);
		$totalData = $statement->rowCount();
        $totalFiltered = $totalData;
/*Fetch All Data End*/       
        
/*Fetch Filter Data Start*/    
         $sql="SELECT pickup_entry.*,tbl_user.full_name as client_name,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 and (pickup_entry.status='picked' or pickup_entry.status='manifest' or pickup_entry.status='In Transit' or pickup_entry.status='Received at destination' or pickup_entry.status='Out for delivery' or pickup_entry.status='Undelivery') ";
         if($clientType!="Admin"){ 
    	    $sql.=" AND pickup_entry.client_id=$clientId";
    	 }
        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.created_at LIKE '%".$requestData['search']['value']."%' ";
        	$sql.=" OR pickup_entry.awb_no LIKE '%".$requestData['search']['value']."%' ";
        	$sql.=" OR pickup_entry.phone LIKE '%".$requestData['search']['value']."%' )";
        	
        	}
        	//$sql1.="order by pickup_entry.id LIMIT 25000"; 
        //	 $sql.=" AND pickup_entry.client_id=$clientId";
        	 
         if(!empty($from)&&!empty($to)){ $sql.=" where DATE(pickup_entry.created_at) >= '".$from."' and DATE(pickup_entry.created_at) <= '".$to."'"; }
       
       $statement = $pdo->prepare($sql);
        $statement->execute();
		$query = $statement->fetchAll(PDO::FETCH_ASSOC);
        $totalFiltered = $statement->rowCount();
        
/*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);

$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['id']."'/>";
	$nestedData[] = $row["ref_no"];
	$nestedData[] = $row["awb_no"];
	$nestedData[] = $row["content"];
	$nestedData[] = $row["client_name"];
	$nestedData[] = $row["address"];
	$nestedData[] = $row["phone"];
	if($row['status']=="manifest"){ $btn="<p class='btn btn-success btn-xs'> Manifest</p>";} 
    elseif($row['status']=="picked"){ $btn="<p class='btn btn-primary btn-xs'> Picked</p> "; }
    elseif($row['status']=="In Transit"){ $btn="<p class='btn btn-primary btn-xs' style='background-color: #59e005;'> In Transit</p>"; }
    elseif($row['status']=="Received at destination"){ $btn="<p class='btn btn-primary btn-xs' style='background-color: #e42cd6;'> Received at Destination</p> "; }
    elseif($row['status']=="Out for delivery"){ $btn="<p class='btn btn-primary btn-xs' style='background-color: #2913dc;'> Out for Delivery</p> "; }
    elseif($row['status']=="Undelivery"){ $btn="<p class='btn btn-primary btn-xs' style='background-color: #25f10c;'> Undelivery</p> "; }
    else{ $btn="<p class='btn btn-primary btn-xs' style='background-color: #59e005;'>-----</p> "; }
	$nestedData[] = $btn;
	$nestedData[] = $row["payment_mode"];
	$nestedData[] = $row["cust_name"];
	$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

?>

Zerion Mini Shell 1.0