JezK
Edit File: asnList-ajax.php
<?php include_once("adminObj.php"); include('checkSession.php'); // print_r($_SESSION) $data =array(); $limit = ""; $tableColumns = array('asn.warehouse_id::TEXT','asn.request_type','asn.quotation_id::TEXT','asn.price::TEXT'); if (isset($_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) { $limit = "OFFSET ".$customerObj->db->escape($_GET['iDisplayStart'] )." LIMIT ". $customerObj->db->escape($_GET['iDisplayLength'] ); } $order="Order by asn.created_date desc"; $whereCondition = ""; if ( $_GET['sSearch'] != "" ) { $whereCondition = " and ("; for ( $i=0 ; $i<count($tableColumns) ; $i++ ) { $whereCondition .= $tableColumns[$i]." ILIKE '%".$customerObj->db->escape($_GET['sSearch'] )."%' OR "; } $whereCondition = substr_replace( $whereCondition, "", -3 ); $whereCondition .= ') '; } $condition = ""; if(isset($_SESSION['customer_user_id'])) { $condition = "asn.user_id=".$_SESSION['customer_user_id']; } $sql= "select uc.currency,urq.quotation_id,asn.warehouse_id,asn.request_type,asn.quotation_id,asn.price, asn.asn_id from uflexit_asn_request as asn join uflexit_request_quote as urq on urq.quotation_id=asn.quotation_id join uflexit_countries as uc on uc.country_id =urq.currency_type WHERE $condition $whereCondition $order $limit "; $rows = $customerObj->db->get_results($sql); $totalRecord = $rows ? count($rows) : 0; $query="SELECT count(*) from uflexit_asn_request as asn WHERE $condition $whereCondition "; $count_result = $customerObj->db->get_results($query); // $res_rec=$customerObj->db->get_results($count_result); $totalRecords = 0; if($count_result !="" && $count_result[0] !="") { $totalRecords = $count_result[0]['count']; } // print_r($totalRecords);exit; if($totalRecord>0) { foreach($rows as $fetch) { $fetch['action']='<small class="d-inline-flex tableData smallFont"> <a href="viewasn.php?asn_id='.$fetch["asn_id"].'" title="Edit"><img src="./images/view.png" /></a> </small>'; $fetch['price']="<span class='priceValue' title='".$fetch['price']."'>".$fetch['price']."</span>"; $fetch['currency']="<span class='currencyType'>".$fetch['currency']."</span>"; $data[]=$fetch; } } $data = ["sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $totalRecord, "iTotalDisplayRecords" => $totalRecords, "aaData" => $data ]; echo json_encode($data); exit; ?>