ok

Mini Shell

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

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

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



$requestData= $_REQUEST;
/*Fetch Database column Details*/
        $columns = array( 
            0 =>'id', 
            1 =>'awb_no', 
            2 =>'ref_no',
            3 =>'cust_code',
            4 =>'client_name',
            5 =>'address',
            6 =>'pincode',
            7 =>'phone',
            8 =>'a_weight',
            9 =>'c_weight',
            10 =>'pics',
            11 =>'created_at',
            12 =>'cust_name',
            13 =>'read_count',
            14 =>'updated_at',
            15 =>'destination'
        );
     
     $condition="where tbl_user.role='Modicare' and pickup_entry.read_status=0 "; 
     
     if(isset($_REQUEST['entry_type']) && $_REQUEST['entry_type']!=""){
           $condition=" and pickup_entry.entry_type=".$_REQUEST['entry_type'];
        }
     
/*Fetch All Data Start*/        
        if($clientType=="Admin")
    	 { 
    	        if($status=='all' && $client_id=='all')
                {
                   $condition.='';  
                } 
                elseif($status!='all' && $client_id=='all')
                {
                   $condition='and pickup_entry.status="'.$status.'"';
                }
                elseif($status=='all' && $client_id!='all')
                {
                   $condition='and pickup_entry.client_id='.$client_id;
                }
                else
                {
                    $condition='and pickup_entry.status="'.$status.'" AND pickup_entry.client_id='.$client_id;
                }
                
                if($from!='' && $to!='')
                {
                    $condition.=" and pickup_entry.created_at BETWEEN '$from' AND '$to' ";
                }
    		$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 ");
    	 }          
    	 else
    	 {
    	     if($from!='' && $to!='')
                {
                    $condition=" and pickup_entry.created_at BETWEEN '$from' AND '$to' ";
                }
                else
                {
                    $condition="";
                }
    	     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 and pickup_entry.client_id=$client_id $condition");   
                }
                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 $condition");   
                }	 
    	 }
		$statement->execute();
		$query = $statement->fetchAll(PDO::FETCH_ASSOC);
		$totalData = $statement->rowCount();
        $totalFiltered = $totalData;
/*Fetch All Data End*/       
        
/*Fetch Filter Data Start*/    
 $condition="where tbl_user.role='Modicare' and pickup_entry.read_status=0 ";
 if(isset($_REQUEST['entry_type']) && $_REQUEST['entry_type']!=""){
           $condition=" and pickup_entry.entry_type=".$_REQUEST['entry_type'];
        }
    	 if($clientType=="Admin")
    	 { 
    	        if($status=='all' && $client_id=='all')
                {
                   $condition.='';  
                } 
                elseif($status!='all' && $client_id=='all')
                {
                   $condition='and pickup_entry.status="'.$status.'"';
                }
                elseif($status=='all' && $client_id!='all')
                {
                   $condition='and pickup_entry.client_id='.$client_id;
                }
                else
                {
                    $condition='and pickup_entry.status="'.$status.'" AND pickup_entry.client_id='.$client_id;
                }
                
                if($from!='' && $to!='')
                {
                    $condition.=" and pickup_entry.created_at BETWEEN '$from' AND '$to' ";
                }
               
    		$sql="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 ";
    	 }
    	 else
    	 {
    	     if($from!='' && $to!='')
                {
                    $condition.=" and pickup_entry.created_at BETWEEN '$from' AND '$to' ";
                }
                else
                {
                    $condition="";
                }
    	     if($status=='all')
                {
                 $sql="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 and pickup_entry.client_id=$client_id and tbl_user.role='Modicare' $condition";   
                }
                else{
                
                  $sql="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 and tbl_user.role='Modicare' and pickup_entry.status='$status' AND pickup_entry.client_id=$client_id $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);
    	     error_log($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']."   ";
 
 //error_log($sql);
//  $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;
//  	if($status=='picked'){ $nestedData[] = "<input type='checkbox' class='checkbox' name='checkboxlist' value='".$row['awb_no']."'/>"; }
//  	elseif($status=='pending'){ $nestedData[] = "<input type='checkbox' class='checkbox' name='checkboxlist' value='".$row['id']."'/>"; } 
	$nestedData[] = "<input type='checkbox' class='checkbox' name='checkboxlist' value='".$row['id']."'/>";
	$nestedData[] = $row["ref_no"];
	$nestedData[] = $row["cust_code"];
	$nestedData[] = $row["client_name"];
	$nestedData[] = $row["address"];
	$nestedData[] = $row["pincode"];
	$nestedData[] = $row["phone"];
	$nestedData[] = "<a href='modicare-pickup-entry-edit.php?id=".$row['id']."' class='btn btn-primary btn-xs'>Edit</a>";
	$nestedData[] = $row["a_weight"];
	$nestedData[] = $row["c_weight"];
	$nestedData[] = $row["pics"];
	$day=date_create($row['created_at']);$created=date_format($day,'d-m-Y');
	$nestedData[] =$created;
	$nestedData[] = $row["cust_name"];
	$nestedData[] = $row["destination"];
	$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