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

63 lines
2.7 KiB
PHP

<?php
include('includes/config/config.php');
include('includes/functions.php');
include('log_entry.php');
$itemId = $_REQUEST['item_id'];
$query = "select a.min_indent_level,a.max_indent_level, a.item_id,a.unit_id,a.item_name,a.reorder_store_level,a.min_store_level,a.indent_percent_reorderlevel,sum(i.stock_qty) as item_stock_qty
from tbl_items a left join item_stock i on a.item_id = i.item_id where a.item_id='" . $itemId . "' ";
error_log($query);
if (!$result = @mysqli_query($conn, $query)) {
die(mysqli_error($conn));
}
$data = array();
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$row['item_qty'] = $row['item_stock_qty'];
if ($row['item_qty'] == '' || $row['item_qty'] == null) {
$row['item_qty'] = 0;
}
$row['item_desc'] = getItemWithFormName($row['item_id']);
$row['reorder_store_level'] = $row['reorder_store_level'];
$row['min_indent'] = $row['min_indent_level'];
$row['max_indent'] = $row['max_indent_level'];
$row['required'] = (($row['indent_percent_reorderlevel'] * $row['reorder_store_level']) / 100) + $row['reorder_store_level'] - $row['item_stock_qty'];
// $row['item_rate'] = getTableFieldValue('item_rate', 'item_rate', "item_id", $row['item_id']);
// $row['item_unit'] = getTableFieldValue('item_rate', 'unit', "item_id", $row['item_id']);
$row['unit_name'] = getTableFieldValue('unit_master', 'unit_name', 'unit_id', $row['unit_id']);
if ($row['item_unit'] == '' || $row['item_unit'] == null) {
$row['item_perUnit_rate'] = 0;
} else {
$row['item_perUnit_rate'] = round(($row['item_rate'] / $row['item_unit']), 2);
}
if ($row['min_indent'] == '' || $row['min_indent'] == null) {
$row['min_indent'] = 0;
}
if ($row['max_indent'] == '' || $row['max_indent'] == null) {
$row['max_indent'] = 500;
}
$last_proc = getTableFieldValue('last_proc_qty_view', 'total_qty', 'item_id', $row['item_id'], 'ohc_type_id', $_SESSION['current_ohcttype']);
$row['item_last_proc'] = $last_proc == '' || $last_proc == null ? 0 : $last_proc;
$last_used = getTableFieldValue('last_month_used_qty_view', 'final_qty', 'item_id', $row['item_id'], 'ohc_type_id', $_SESSION['current_ohcttype']);
$row['item_last_used'] = $last_used == '' ? 0 : $last_used;
if ($row['required'] < 0) {
$row['required'] = 0;
}
$data = $row;
}
} else {
$data['status'] = 200;
$data['message'] = "Data not found!";
$data['sql'] = $query;
}
error_log("final data " . print_r($data, true));
echo json_encode($data);