50 lines
2.1 KiB
PHP
50 lines
2.1 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('log_entry.php');
|
|
include('includes/functions.php');
|
|
$indent_id = $_REQUEST['indent_id'];
|
|
$data = array();
|
|
$count = 0;
|
|
$rate = array();
|
|
$query = "select e.form_name,d.unit_name,c.remarks,c.status as ind_status, c.indent_ref_no,c.indent_date,b.indent_id,b.indent_qty,a.max_indent_level,a.min_indent_level,a.item_id,a.unit_id,a.item_name,a.reorder_store_level,a.min_store_level,a.indent_percent_reorderlevel,ifnull(sum(i.stock_qty),0) as item_stock_qty
|
|
from tbl_items a left join indent_items b on a.item_id = b.item_id left join item_stock i on a.item_id = i.item_id
|
|
left join indent_master c on c.indent_id = b.indent_id left join unit_master d on d.unit_id = a.unit_id left join medicine_form e on e.form_id=a.item_form_id where b.indent_id = '" . $indent_id . "' group by a.item_id ";
|
|
error_log("select " . $query);
|
|
if (!$result = @mysqli_query($conn, $query)) {
|
|
die(mysqli_error($conn));
|
|
}
|
|
|
|
while ($row = @mysqli_fetch_assoc($result)) {
|
|
$item_rate = getTableFieldValue('item_rate', 'item_rate', "item_id", $row['item_id']);
|
|
|
|
$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;
|
|
|
|
$item_unit = getTableFieldValue('item_rate', 'unit', "item_id", $row['item_id']);
|
|
$date = date_create($row['indent_date']);
|
|
$indent_date = date_format($date, 'd/m/Y');
|
|
error_log('datexsx' . $indent_date);
|
|
if ($item_unit == '' || $item_unit == null) {
|
|
$item_perUnit_rate = 0;
|
|
} else {
|
|
$item_perUnit_rate = round(($item_rate / $item_unit), 2);
|
|
}
|
|
|
|
|
|
$count++;
|
|
array_push($rate, $item_perUnit_rate);
|
|
$row['indent_date'] = $indent_date;
|
|
|
|
|
|
$data[] = $row;
|
|
}
|
|
$data['count'] = $count;
|
|
$data['perunitRate'] = $rate;
|
|
|
|
error_log(" data from edit button click " . print_r($data, true));
|
|
echo json_encode($data);
|