ohctech_p8/get_item_batch_nos.php
Dushant Mali 899fb3e65a Upgrade 7 to 8
Upgrade 7 to 8
2024-11-02 18:03:13 +05:30

56 lines
1.7 KiB
PHP

<?php
error_reporting(E_ERROR | E_PARSE);
include ('includes/config/config.php');
$ohc_id = $_SESSION['current_ohcttype'];
$data = array();
$selected_batch = "";
if (!empty($_POST['batch'])) {
$selected_batch = " and item_batch_no!='" . $_POST['batch'] . "'";
$sql_stock_item_selected = "select * from item_stock where item_id='" . $_POST['item_id'] . "' and item_batch_no='" . $_POST['batch'] . "' and ohc_type_id='" . $ohc_id . "' order by expiry_date ";
error_log('treatent_batch ' . $sql_stock_item_selected);
if (!$result_stock_item_selected = @mysqli_query($conn, $sql_stock_item_selected)) {
die(mysqli_error($conn));
}
if (mysqli_num_rows($result_stock_item_selected) > 0) {
while ($row_stock_item_selected = mysqli_fetch_assoc($result_stock_item_selected)) {
//extract($row);
array_push($data, $row_stock_item_selected);
}
}
}
$sql_stock_item = "select * from item_stock where item_id='" . $_POST['item_id'] . "' and item_batch_no!='' and stock_qty>0 and ohc_type_id='" . $ohc_id . "' $selected_batch order by expiry_date ";
error_log('treatent_batch' . $sql_stock_item);
if (!$result_stock_item = @mysqli_query($conn, $sql_stock_item)) {
die(mysqli_error($conn));
}
if (mysqli_num_rows($result_stock_item) > 0) {
while ($row_stock_item = mysqli_fetch_assoc($result_stock_item)) {
//extract($row);
if ($row_stock_item['expiry_date'] != "0000-00-00" && $row_stock_item['expiry_date'] != "" && $row_stock_item['expiry_date'] != null) {
$date = date('Y-m-d', strtotime($row_stock_item['expiry_date']));
$date_today = date("Y-m-d");
if ($date >= $date_today) {
array_push($data, $row_stock_item);
}
} else {
array_push($data, $row_stock_item);
}
}
}
echo json_encode($data);