include('includes/config/config.php');
include('includes/functions.php');
header("Content-type:application/octet-stream");
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=daily_log_report_excel.xls");
header("Pragma: no-cache");
header("Expires: 0");
error_reporting(E_ERROR | E_PARSE);
?>
Daily Medicine Log Report |
For Date: echo date("d-M-Y", strtotime($from_date)); ?> |
|
Sr |
Items |
Total Consumed |
//echo $to_date;
// $emp_id=$_POST['empName'];
error_reporting(E_ERROR | E_PARSE);
$count = 0;
//echo $emp_id;
$data = "";
$ZeroAllowed = "N";
error_log("key val before" . $ZeroAllowed);
$ZeroAllowedKey = getConfigKey("ZERO_QUANTITY_ALLOWED");
error_log("key val " . $ZeroAllowedKey);
if ($ZeroAllowedKey == "TRUE") {
$ZeroAllowed = "Y";
}
error_log("key val after " . $ZeroAllowed);
function consume_details($item_id, $from_date, $ohc)
{
$issued_qty_total = 0;
$sql_direct_issue_query = "SELECT ifnull(sum(dd.issue_qty), 0) as direct_issue_total FROM direct_medicine_issue_log_details dd LEFT JOIN direct_medicine_issue_log dm ON dd.issue_log_id = dm.issue_log_id WHERE item_id='$item_id' and date_format(date(dm.date_of_issue),'%d-%m-%Y')='$from_date' and ohc_location_id = '" . $ohc . "'";
error_log("sql_direct_issue_query: " . $sql_direct_issue_query);
$result_sql_direct_issue_query = mysqli_query($GLOBALS['conn'], $sql_direct_issue_query);
$row_result_sql_direct_issue_query = mysqli_fetch_array($result_sql_direct_issue_query);
$issued_qty_total += $row_result_sql_direct_issue_query['direct_issue_total'];
error_log("issued_qty_total:::" . $issued_qty_total);
$sql_opd_consumables = "SELECT ifnull(sum(c.issued_qty), 0) as consumable_issue FROM opd_consumables c LEFT JOIN employee_appointment e ON c.consume_id = e.appointment_id where medicine = '$item_id' and date_format(date(e.appointment_date),'%d-%m-%Y') = '$from_date' and ohc_type_id = '" . $ohc . "' ";
error_log("sql_opd_consumables: " . $sql_opd_consumables);
$result_sql_opd_consumables = mysqli_query($GLOBALS['conn'], $sql_opd_consumables);
$row_result_sql_opd_consumables = mysqli_fetch_array($result_sql_opd_consumables);
$issued_qty_total += $row_result_sql_opd_consumables['consumable_issue'];
error_log("issued_qty_total_2:::" . $issued_qty_total);
$sql_detention_intake = "SELECT ifnull(sum(c.issued_qty), 0) as detention_issue FROM detention_intake c LEFT JOIN employee_appointment e ON c.det_id = e.appointment_id where c.medicine = '$item_id' and date_format(date(e.appointment_date),'%d-%m-%Y') = '$from_date' and ohc_type_id = '" . $ohc . "' ";
error_log("sql_detention_intake: " . $sql_detention_intake);
$result_sql_detention_intake = mysqli_query($GLOBALS['conn'], $sql_detention_intake);
$row_result_sql_detention_intake = mysqli_fetch_array($result_sql_detention_intake);
$issued_qty_total += $row_result_sql_detention_intake['detention_issue'];
error_log("issued_qty_total_2:::" . $issued_qty_total);
$sql_consume = "select ifnull(sum(a.issued_qty), 0) as total_issued from treatment a left join employee_appointment b on a.appointment_id = b.appointment_id where item_id = '$item_id' and date_format(date(b.appointment_date),'%d-%m-%Y') = '$from_date' and b.ohc_type_id = '" . $ohc . "' ";
error_log("cccccccons" . $sql_consume);
$result_consume = mysqli_query($GLOBALS['conn'], $sql_consume);
$row_consume = mysqli_fetch_array($result_consume);
$issued_qty_total += $row_consume['total_issued'];
error_log("issued_qty_total_3:::" . $issued_qty_total);
return $issued_qty_total;
}
$query = "select i.item_id, i.item_name from tbl_items i where i.status = '1' and ohc_type_id='" . $ohc . "'";
error_log("query to get data from tbl items " . $query);
$result = mysqli_query($conn, $query);
$total = mysqli_num_rows($result);
if ($total != 0) { ?>
while ($row = mysqli_fetch_assoc($result)) {
$total_consumed = consume_details($row['item_id'], $from_date, $ohc);
if ($total_consumed == '0' && $ZeroAllowed == "N") {
} else {
?>
= ++$count ?> |
= getItemWithFormName($row['item_id']) ?> |
= consume_details($row['item_id'], $from_date, $ohc) ?> |