42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
include('log_entry.php');
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
|
|
$salt = $_POST['generics'];
|
|
error_log("salt names " . $salt);
|
|
|
|
$data = [];
|
|
|
|
$ids = getCommaSeperatedValuesForInClause("select salt_id from salt_master", "salt_name", $salt);
|
|
error_log("salt ids " . $ids);
|
|
if ($salt != '') {
|
|
$sql = "select item_id from item_salt where salt_id in ($ids) ";
|
|
error_log("query to get data " . $sql);
|
|
$result = mysqli_query($conn, $sql);
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$sql_qty = "select sum(b.stock_qty) as qty from tbl_items a left join item_stock b on a.item_id = b.item_id where a.item_id = '" . $row['item_id'] . "' and a.is_group_item = 'N' and b.ohc_type_id = '" . $_SESSION['current_ohcttype'] . "' and b.expiry_date >= CURDATE() having qty > 0 limit 1";
|
|
error_log("query to get qty data " . $sql_qty);
|
|
$result_qty = mysqli_query($conn, $sql_qty);
|
|
$row_qty = mysqli_fetch_assoc($result_qty);
|
|
$item_qty = $row_qty['qty'];
|
|
|
|
if ($item_qty > 0) {
|
|
|
|
$item_id = $row['item_id'];
|
|
$item_name = getItemWithFormName($item_id);
|
|
|
|
$item_data = array(
|
|
'item_id' => $item_id,
|
|
'item_name' => $item_name
|
|
);
|
|
|
|
array_push($data, $item_data);
|
|
}
|
|
}
|
|
}
|
|
error_log("final data " . print_r($data, true));
|
|
echo json_encode($data);
|