ok
Direktori : /home2/selectio/www/lilyexpresslive/software/admin/data-tables/ |
Current File : /home2/selectio/www/lilyexpresslive/software/admin/data-tables/delivery-data-table.php |
<?php include("../inc/config.php"); include("../db.php"); $client_id=array(); // $status=array(); $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']; } ini_set('memory_limit', '1024M'); $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 =>'awb_no', 3 =>'content', 4 =>'client_name', 5 =>'address', 6 =>'phone', 7 =>'status', 8 =>'payment_mode', 9 =>'cust_name' ); /*Fetch All Data Start*/ $condition='where 1=1 and pickup_entry.status!="Delivered" '; 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(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' "; } 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 $condition 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 $condition 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 $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.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']."%' )"; } $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"]; $day=date_create($row['created_at']);$created=date_format($day,'d-m-Y'); $nestedData[] =$created; $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']=="pending"){ $btn="<p class='btn btn-primary btn-xs'> Booked</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> "; } elseif($row['status']=="Delivery"){ $btn="<p class='btn btn-primary btn-xs' style='background-color: #25f10c;'> Delivery</p> "; } elseif($row['status']=="Delivered"){ $btn="<p class='btn btn-primary btn-xs' style='background-color: #25f10c;'> Delivered</p> "; } elseif($row['status']=="Return To Origin"){ $btn="<p class='btn btn-warning btn-xs' style='background-color: #25f10c;'> Return To Origin</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"]; $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 ?>