0 and item_stock_id not in (select item_stock_id from cleanup_item_stock) and DATE(expiry_date)<= (CURDATE() + INTERVAL $expiryAlertAdvance DAY ) $searchSql "; error_log("COUNTING QUERY::" .$sql); // echo $sql; $result = mysqli_query($conn,$sql ); // echo $result; $row = mysqli_fetch_array ( $result ); $total = $row [0]; if (! isSet ( $rp )) { $rp = 10; } // Setup paging SQL // $rp=1; $pageStart = ($page - 1) * $rp; $limitSql = "limit $pageStart, $rp"; // Return JSON data $data = array (); $data ['page'] = $page; $data ['total'] = $total; $data ['rows'] = array (); $count = 1; $sql_pending_expiry = "select * from item_stock where ohc_type_id='".$_SESSION['current_ohcttype']."' and stock_qty>0 and item_stock_id not in (select item_stock_id from cleanup_item_stock) and DATE(expiry_date)<= (CURDATE() + INTERVAL $expiryAlertAdvance DAY )"; error_log("PENDING EXPIRY QUERY::" .$sql_pending_expiry); $sql_export = $sql_pending_expiry; $sql_pending_expiry.=" $searchSql $sortSql $limitSql "; $sql_export.=" $searchSql $sortSql "; $results_pending_expiry = mysqli_query($conn,$sql_pending_expiry ); $view_link = ""; $edit_link = ""; $delete_link = ""; $links = ""; /* * if($access_level=='R' ||$access_level=='W' || $access_level=='E' ) * { * //echo "shubham"; * $view_link=""; * } * * if($access_level=='W' || $access_level=='E' ) * { * $edit_link=""; * } * if($access_level=='E' ) * { * $delete_link=""; * } */ while ( $row_pending_expiry = mysqli_fetch_assoc ( $results_pending_expiry ) ) { $id = $row_pending_expiry ['item_stock_id']; $item_id = $row_pending_expiry ['item_id']; $item_desc = getItemWithFormName( $row_pending_expiry ['item_id'] ); $item_qty = $row_pending_expiry ['stock_qty']; $item_batch = $row_pending_expiry ['item_batch_no']; $procurement_qty_query = "select sum(qty) from procurement_items where item_id=" . $item_id . " and batch='" . $item_batch . "' and ohc_type_id='".$_SESSION['current_ohcttype']."' "; error_log("CONSUMPTION QUERY::" .$procurement_qty_query); $results_qty_query = mysqli_query($conn,$procurement_qty_query ); $row_procurement_qty = mysqli_fetch_row ( $results_qty_query ); $procurement_qty = $row_procurement_qty [0]; $item_expiry_date = date_format ( date_create ( $row_pending_expiry ['expiry_date'] ), "M-Y " ); if ($access_level == 'W' || $access_level == 'E') { $edit_link = ""; } $space = "   "; $links = $space . $edit_link; $data ['rows'] [] = array ( 'id' => $row1 ['id'], 'cell' => array ( $count ++, $item_desc, $procurement_qty, $procurement_qty - $item_qty, $item_qty, $item_batch, $item_expiry_date, $links ) ); } $data['rows'][] = array( 'id' => $row['filterkey'], 'cell' => array('', "", "", '', '','', '', '', '', '', '', '', '','', '', '','', '', '','') ); echo json_encode ( $data ); ?>