JezK
Edit File: total_stock_ajax.php
<?php include_once("adminObj.php"); include('checkSession.php'); $data =array(); $limit = ""; $tableColumns = array('uos.quotation_id::TEXT','uos.warehouse_id::TEXT','umw.warehouse_name','uos.created_date::TEXT','uos.qty::TEXT','uos.available_quantity::TEXT','uos.itemcode::TEXT'); if (isset($_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) { $limit = "OFFSET ".$customerObj->db->escape($_GET['iDisplayStart'] )." LIMIT ". $customerObj->db->escape($_GET['iDisplayLength'] ); } $order="order by uos.created_date desc"; $whereCondition = ""; if(isset($_SESSION['customer_user_id']) && $_SESSION['customer_user_id'] != ""){ $whereCondition = "where uos.user_id=".$_SESSION['customer_user_id']." and available_quantity !=".'0'; } 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 .= ') '; } $sql="select umw.warehouse_name, uos.randval,uos.quotation_id,uos.created_date,uos.warehouse_id,uos.itemcode,uos.available_quantity,uos.qty from uflexit_onhand_stock as uos join uflexit_master_warehouse as umw on umw.warehouse_id=uos.warehouse_id $whereCondition $order $limit "; // echo $sql; // exit; $rows = $customerObj->db->get_results($sql); $sql2="select umw.warehouse_name, uos.randval,uos.quotation_id,uos.created_date,uos.warehouse_id,uos.itemcode,uos.available_quantity,uos.qty from uflexit_onhand_stock as uos join uflexit_master_warehouse as umw on umw.warehouse_id=uos.warehouse_id $whereCondition"; $rows2 = $customerObj->db->get_results($sql2); $totalRecord =$rows ? count($rows):0; $totalRecords =$rows2 ? count($rows2):0; // $totalRecords = count($rows); if($totalRecord>0) { $j=1; foreach($rows as $fetch) { $fetch['action']='<small class="d-inline-flex tableData smallFont"> <a href="received_transaction_view.php?rnd='.$fetch['randval'].'&ino='.$fetch['itemcode'].'" class="pl-md-2" title="view details"><img src="./images/view.png"></a> </small>'; $date=date_create($fetch['created_date']); $fetch['created_date']=date_format($date,"d-m-Y"); $data[]=$fetch; } } $data = ["sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $totalRecord, "iTotalDisplayRecords" => $totalRecords, "aaData" => $data ]; echo json_encode($data); exit; ?>