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

71 lines
2.4 KiB
PHP

<?php
// error_reporting(E_ERROR | E_PARSE);
include('includes/config/config.php');
include('includes/functions.php');
include_once("log_entry.php");
$patient = $_POST['p_id'];
$box_number = $_POST['box_number'];
$ambulance_number = $_POST['ambulance_number'];
$ohc_loc = $_POST['ohc_loc'];
$data = array();
$first_aid_id = getTableFieldValue('ohc_type', 'ohc_type_id', 'upper(ohc_code)', '"FABDISH"');
$amb_id = getTableFieldValue('ohc_type', 'ohc_type_id', 'upper(ohc_code)', '"OHCAMB"');
$patient_ohc_id = getTableFieldValue('ohc_type', 'ohc_type_id', 'upper(ohc_code)', '"EMP"');
$param = '';
if (!empty($_POST['box_number'])) {
$param = "si.amb_no_box_code='" . $_POST['box_number'] . "' and si.ohc_location_id='$first_aid_id' and ";
}
if (!empty($_POST['ambulance_number'])) {
$param = "si.amb_no_box_code='" . $_POST['ambulance_number'] . "' and si.ohc_location_id='$amb_id' and ";
}
if (!empty($_POST['p_id'])) {
$param = "si.amb_no_box_code='" . $patient . "' and si.ohc_location_id='$patient_ohc_id' and";
}
$sql_stock_item = "SELECT distinct(i.item_id),trim(concat(ifnull(i.item_code,''),' ',i.item_name)) item_name
FROM tbl_items i
JOIN stock_issue_items s ON i.item_id=s.item_id
JOIN stock_issue si ON si.stock_issue_id=s.stock_issue_id
WHERE $param i.status='1' and i.is_group_item!='P' order by item_name;";
error_log("get item::" . $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);
$data[] = $row_stock_item;
}
} else {
$data['status'] = 200;
$data['message'] = "Data not found!";
}
if (!empty($_POST['p_id'])) {
$sql_opd = "SELECT distinct(i.item_id),trim(concat(ifnull(i.item_code,''),' ',i.item_name)) item_name
FROM treatment t left join tbl_items i on t.item_id=i.item_id
WHERE t.appointment_id in (select appointment_id from employee_appointment where emp_id='" . $_POST['p_id'] . "' and ohc_type_id='" . $_SESSION['current_ohcttype'] . "' )";
error_log("get item::" . $sql_opd);
if (!$result_opd = @mysqli_query($conn, $sql_opd)) {
die(mysqli_error($conn));
}
if (@mysqli_num_rows($result_opd) > 0) {
while ($row_opd = @mysqli_fetch_assoc($result_opd)) {
array_push($data, $row_opd);
}
}
}
error_log(print_r($data, true));
echo json_encode($data);