276 lines
9.1 KiB
PHP
276 lines
9.1 KiB
PHP
|
|
<?php
|
||
|
|
//include ('pdf_header_reverse.php');
|
||
|
|
include('includes/config/config.php');
|
||
|
|
include('includes/functions.php');
|
||
|
|
|
||
|
|
?>
|
||
|
|
<?php
|
||
|
|
$from_date1 = date('Y-m-d', strtotime($_POST['startDate1']));
|
||
|
|
|
||
|
|
error_log("from_date1:::" . $from_date1);
|
||
|
|
$rec_date = date('Y-m-d', strtotime($from_date1 . ' - 1 days'));
|
||
|
|
|
||
|
|
error_log("rec_date:::" . $rec_date);
|
||
|
|
|
||
|
|
$from_date = date('d-m-Y', strtotime($from_date1));
|
||
|
|
$ohc = $_SESSION['current_ohcttype'];
|
||
|
|
|
||
|
|
?>
|
||
|
|
|
||
|
|
|
||
|
|
<link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" />
|
||
|
|
<style>
|
||
|
|
@page {
|
||
|
|
margin: 15px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.btn {
|
||
|
|
background-color: #4CAF50;
|
||
|
|
border-radius: 5%;
|
||
|
|
/* Green */
|
||
|
|
border: none;
|
||
|
|
color: white;
|
||
|
|
padding: 5px 8px;
|
||
|
|
text-align: center;
|
||
|
|
text-decoration: none;
|
||
|
|
display: inline-block;
|
||
|
|
font-size: 12px;
|
||
|
|
margin: 4px 2px;
|
||
|
|
cursor: pointer;
|
||
|
|
}
|
||
|
|
|
||
|
|
@media print {
|
||
|
|
#printPageButton {
|
||
|
|
display: none;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
</style>
|
||
|
|
|
||
|
|
<body>
|
||
|
|
<?php include('pdf_ohc_header.php'); ?>
|
||
|
|
<table width="100%">
|
||
|
|
<tr>
|
||
|
|
|
||
|
|
<td align="center" style="font-size: 15px"><strong>Daily Medicine Log Report</strong></td>
|
||
|
|
|
||
|
|
</tr>
|
||
|
|
<tr>
|
||
|
|
<td align="left" style="font-size: 12px"><strong>For Date: <?php echo date("d-M-Y", strtotime($from_date)); ?></strong></td>
|
||
|
|
<td align="right" style="font-size: 15px"><button align="center" id="printPageButton" class="btn btn-success" onClick="window.print();">Print</button></td>
|
||
|
|
</tr>
|
||
|
|
</table>
|
||
|
|
<br>
|
||
|
|
|
||
|
|
<table width="100%" border="1" cellspacing="0">
|
||
|
|
<tr>
|
||
|
|
<th width="1%" align="center">Sr</th>
|
||
|
|
<th align="center" width="5%">Items</th>
|
||
|
|
<th align="center" width="2%">Fresh</th>
|
||
|
|
<th align="center" width="2%">Previous</th>
|
||
|
|
|
||
|
|
<th width="2%" align="center">Total</th>
|
||
|
|
<th align="center" width="40%">Consumption Details</th>
|
||
|
|
<th align="center" width="2%">Total Consumed</th>
|
||
|
|
<th align="center" width="2%">Balance</th>
|
||
|
|
|
||
|
|
|
||
|
|
</tr>
|
||
|
|
<?php
|
||
|
|
|
||
|
|
//echo $to_date;
|
||
|
|
|
||
|
|
|
||
|
|
// $emp_id=$_POST['empName'];
|
||
|
|
error_reporting(E_ERROR | E_PARSE);
|
||
|
|
$count = 0;
|
||
|
|
//echo $emp_id;
|
||
|
|
$data = "";
|
||
|
|
$sql = "select cat_id from tbl_categories where cat_code not in ('CNC') order by sequence asc";
|
||
|
|
|
||
|
|
error_log("SSSSSSS$$$$$$$$$" . $sql);
|
||
|
|
|
||
|
|
$result = mysqli_query($GLOBALS['conn'],$sql);
|
||
|
|
|
||
|
|
$med_cat = array();
|
||
|
|
|
||
|
|
function consume_details($item_id, $a, $fromdate, $ohc)
|
||
|
|
{
|
||
|
|
|
||
|
|
$consume_detail = '';
|
||
|
|
$issued_qty_total = 0;
|
||
|
|
|
||
|
|
$sql_diect_issue_query = "SELECT ifnull(dd.issue_qty,0) as direct_issue 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')='$fromdate' and ohc_location_id = '" . $ohc . "'";
|
||
|
|
|
||
|
|
error_log("sql_diect_issue_query: " . $sql_diect_issue_query);
|
||
|
|
|
||
|
|
$result_sql_diect_issue_query = mysqli_query($GLOBALS['conn'],$sql_diect_issue_query);
|
||
|
|
|
||
|
|
while ($row_result_sql_diect_issue_query = mysqli_fetch_array($result_sql_diect_issue_query)) {
|
||
|
|
|
||
|
|
$consume_detail .= 'DIRECT ISSUE ' . ':' . $row_result_sql_diect_issue_query['direct_issue'] . ' : ';
|
||
|
|
$issued_qty_total += $row_result_sql_diect_issue_query['direct_issue'];
|
||
|
|
}
|
||
|
|
|
||
|
|
error_log("issued_qty_total:::" . $issued_qty_total);
|
||
|
|
|
||
|
|
$sql_opd_consumables = "SELECT ifnull(c.issued_qty,0) as consumable_issue,e.ticket_no 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') = '$fromdate' and ohc_type_id = '" . $ohc . "' ";
|
||
|
|
|
||
|
|
error_log("sql_opd_consumables: " . $sql_opd_consumables);
|
||
|
|
|
||
|
|
$result_sql_opd_consumables = mysqli_query($GLOBALS['conn'],$sql_opd_consumables);
|
||
|
|
|
||
|
|
while ($row_result_sql_opd_consumables = mysqli_fetch_array($result_sql_opd_consumables)) {
|
||
|
|
|
||
|
|
$consume_detail .= 'ID-' . $row_result_sql_opd_consumables['ticket_no'] . ':' . $row_result_sql_opd_consumables['consumable_issue'] . ' : ';
|
||
|
|
$issued_qty_total += $row_result_sql_opd_consumables['consumable_issue'];
|
||
|
|
}
|
||
|
|
|
||
|
|
error_log("issued_qty_total_2:::" . $issued_qty_total);
|
||
|
|
|
||
|
|
$sql_detention_intake = "SELECT ifnull(c.issued_qty,0) as detention_issue,e.ticket_no 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') = '$fromdate' and ohc_type_id = '" . $ohc . "' ";
|
||
|
|
|
||
|
|
error_log("sql_detention_intake: " . $sql_detention_intake);
|
||
|
|
|
||
|
|
$result_sql_detention_intake = mysqli_query($GLOBALS['conn'],$sql_detention_intake);
|
||
|
|
|
||
|
|
while ($row_result_sql_detention_intake = mysqli_fetch_array($result_sql_detention_intake)) {
|
||
|
|
|
||
|
|
$consume_detail .= 'ID-' . $row_result_sql_detention_intake['ticket_no'] . ':' . $row_result_sql_detention_intake['detention_issue'] . ' : ';
|
||
|
|
$issued_qty_total += $row_result_sql_detention_intake['detention_issue'];
|
||
|
|
}
|
||
|
|
|
||
|
|
error_log("issued_qty_total_2:::" . $issued_qty_total);
|
||
|
|
|
||
|
|
$sql_consume = "select a.appointment_id, ifnull(a.issued_qty,0) as total_issued,b.ticket_no 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') = '$fromdate' and b.ohc_type_id = '" . $ohc . "' ";
|
||
|
|
|
||
|
|
error_log("cccccccons" . $sql_consume);
|
||
|
|
|
||
|
|
$result_consume = mysqli_query($GLOBALS['conn'],$sql_consume);
|
||
|
|
|
||
|
|
|
||
|
|
while ($row_consume = mysqli_fetch_array($result_consume)) {
|
||
|
|
$consume_detail .= 'ID-' . $row_consume['ticket_no'] . ':' . $row_consume['total_issued'] . ' : ';
|
||
|
|
|
||
|
|
$issued_qty_total += $row_consume['total_issued'];
|
||
|
|
|
||
|
|
error_log("detaiilllllllllll" . $row_consume['total_issued']);
|
||
|
|
}
|
||
|
|
|
||
|
|
error_log("issued_qty_total_3:::" . $issued_qty_total);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
if ($a == 1) {
|
||
|
|
return $consume_detail;
|
||
|
|
} else {
|
||
|
|
return $issued_qty_total;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function prevDispensaryItemBalance($item_id, $rec_date, $ohc)
|
||
|
|
{
|
||
|
|
$sql_prev_balance = "select stock_qty from item_stock_dispensary_daily_balance where item_id = '$item_id' and record_date = '$rec_date' and ohc_location_id = '$ohc'";
|
||
|
|
|
||
|
|
error_log("sql_prev_balance:::" . $sql_prev_balance);
|
||
|
|
|
||
|
|
$result_sql_prev_balance = mysqli_query($GLOBALS['conn'],$sql_prev_balance);
|
||
|
|
$row_prev_balance = mysqli_fetch_array($result_sql_prev_balance);
|
||
|
|
|
||
|
|
if ($row_prev_balance == 0) {
|
||
|
|
return 0;
|
||
|
|
} else {
|
||
|
|
return $row_prev_balance['stock_qty'];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function total_qty($fresh, $prev)
|
||
|
|
{
|
||
|
|
$total = $fresh + $prev;
|
||
|
|
|
||
|
|
return $total;
|
||
|
|
}
|
||
|
|
|
||
|
|
function balance($total_balance, $total_consumed)
|
||
|
|
{
|
||
|
|
$b = $total_balance - $total_consumed;
|
||
|
|
return $b;
|
||
|
|
}
|
||
|
|
|
||
|
|
while ($row_m = mysqli_fetch_array($result)) {
|
||
|
|
|
||
|
|
array_push($med_cat, $row_m['cat_id']);
|
||
|
|
}
|
||
|
|
|
||
|
|
foreach ($med_cat as $i => $value) {
|
||
|
|
|
||
|
|
|
||
|
|
$query = "select i.item_id, i.item_name,rsi1.received_sum from tbl_items i left join (select item_id, sum(received_qty) received_sum from received_issue_items rsi where rsi.ohc_location_id='$ohc' and received_id in (select received_id from received_master where received_date = '$from_date1' ) group by item_id) rsi1 on i.item_id=rsi1.item_id where i.cat='$value' and i.status = '1'";
|
||
|
|
|
||
|
|
error_log("###########QQQQQQQQ" . $query);
|
||
|
|
|
||
|
|
$result = mysqli_query($GLOBALS['conn'],$query);
|
||
|
|
|
||
|
|
$total = mysqli_num_rows($result);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
if ($total != 0) { ?>
|
||
|
|
|
||
|
|
<tr rowspan="2">
|
||
|
|
<th colspan='8'>
|
||
|
|
<center><?= getTableFieldValue("tbl_categories", "cat_name", "cat_id", $value) ?></center>
|
||
|
|
</th>
|
||
|
|
</tr>
|
||
|
|
<tr></tr>
|
||
|
|
|
||
|
|
<?php
|
||
|
|
|
||
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
||
|
|
$count++;
|
||
|
|
?>
|
||
|
|
<tr>
|
||
|
|
<td align="left"><?= $count ?></td>
|
||
|
|
<td align="left"><?= getItemWithFormName($row['item_id']) ?></td>
|
||
|
|
<?php if ($row['received_sum'] == 0 || $row['received_sum'] == '') { ?>
|
||
|
|
<td align="left">0.00</td>
|
||
|
|
<?php } else { ?>
|
||
|
|
<td align="left"><?= $row['received_sum'] ?></td>
|
||
|
|
<?php } ?>
|
||
|
|
|
||
|
|
<td align="left"><?= prevDispensaryItemBalance($row['item_id'], $rec_date, $ohc) ?></td>
|
||
|
|
|
||
|
|
<td align="left"><?= ceil(total_qty($row['received_sum'], prevDispensaryItemBalance($row['item_id'], $rec_date, $ohc))) ?></td>
|
||
|
|
|
||
|
|
<td align="left" width="50%"><?= consume_details($row['item_id'], 1, $from_date, $ohc) ?></td>
|
||
|
|
|
||
|
|
<td align="left"><?= consume_details($row['item_id'], 0, $from_date, $ohc) ?></td>
|
||
|
|
|
||
|
|
<td align="left"><?= ceil(balance(total_qty($row['received_sum'], prevDispensaryItemBalance($row['item_id'], $rec_date, $ohc)), consume_details($row['item_id'], 0, $from_date, $ohc))) ?></td>
|
||
|
|
|
||
|
|
</tr>
|
||
|
|
|
||
|
|
<?php }
|
||
|
|
}
|
||
|
|
} ?>
|
||
|
|
</table>
|
||
|
|
|
||
|
|
<table width="100%" style="height:150px;" border="1" cellspacing="0">
|
||
|
|
<tr>
|
||
|
|
<th style="font-size: 14px; margin-left: 5px;" width="50%" align="left">
|
||
|
|
Verified By:
|
||
|
|
</th>
|
||
|
|
|
||
|
|
<th style="font-size: 14px; margin-left: 5px;" width="50%" align="left">
|
||
|
|
Approved By:
|
||
|
|
</th>
|
||
|
|
</tr>
|
||
|
|
</table>
|
||
|
|
</body>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
$(document).ready(function() {
|
||
|
|
window.print();
|
||
|
|
|
||
|
|
});
|
||
|
|
</script>
|