35 lines
868 B
PHP
35 lines
868 B
PHP
|
|
<?php
|
|
include('includes/config/config.php');
|
|
|
|
|
|
$sql = "SELECT i.item_name, itm_stk.item_stock_qty, i.min_store_level, i.reorder_store_level
|
|
FROM tbl_items i
|
|
JOIN (SELECT item_id, SUM(stock_qty) AS item_stock_qty FROM item_stock GROUP BY item_id) AS itm_stk
|
|
ON itm_stk.item_id = i.item_id
|
|
WHERE item_stock_qty <= reorder_store_level";
|
|
$result = mysqli_query($conn, $sql);
|
|
$data = array();
|
|
$total_items = 0;
|
|
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
$data[] = array(
|
|
"item_name" => $row['item_name'],
|
|
"item_stock_qty" => $row['item_stock_qty'],
|
|
"min_store_level" => $row['min_store_level'],
|
|
"reorder_store_level" => $row['reorder_store_level']
|
|
);
|
|
|
|
|
|
// $total_items++;
|
|
}
|
|
|
|
|
|
$response = array(
|
|
"data" => $data,
|
|
|
|
);
|
|
|
|
// error_log('medicines');
|
|
echo json_encode($response);
|