csrtechnew.ohctech.in/first_aid_box_report.php
2025-04-14 13:28:09 +05:30

129 lines
3.5 KiB
PHP

<?php
include('includes/functions.php');
include('pdf_header_reverse.php');
//include('pop_up_top.php');
?>
<?php
$month = $_POST['first_month'];
$month_name = date("F", mktime(0, 0, 0, $month, 10));
$y = $_POST['first_year'];
$d = cal_days_in_month(CAL_GREGORIAN, $month, $y);
$box_no = $_POST['box_no'];
?>
<link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" />
<body>
<?php $sql_comp = "select * from company_profile where company_id=5";
$result_comp = mysqli_query($conn, $sql_comp);
$row_comp = mysqli_fetch_array($result_comp); ?>
<center>
<?php
include("pdf_ohc_header.php");
?>
<p style="font-size: medium; text-align: center;">RECORD OF FIRST AID BOX REFILLING</p>
<br>
</center>
<table width="100%" >
<tr>
<br>
<td><strong>DEPARTMENT:<?=getFieldFromTable('box_name','first_aid_box','box_id',$box_no)?></strong></td>
</tr>
<tr>
<td><strong>FIRST AID BOX NUMBER: <?=getFieldFromTable('box_code','first_aid_box','box_id',$box_no)?></strong></td>
</tr>
</table>
<br>
<table border="1" cellspacing="0" width="100%">
<tr>
<th>Date</th>
<th>Refilled by</th>
<th>Item Name</th>
<th>Issued Quantity</th>
</tr>
<?php
function getIssueQty($item_id,$issue_date){
$sql_qty = "select b.issue_qty from stock_issue a left join stock_issue_items b on a.stock_issue_id = b.stock_issue_id where b.item_id=$item_id and a.issue_date = '$issue_date' and a.ohc_location_id=(select ohc_type_id from ohc_type where ohc_category = 'FAB')";
error_log("QUANTITY:".$sql_qty);
$result_qty = mysqli_query($GLOBALS['conn'], $sql_qty);
$row_qty = mysqli_fetch_array($result_qty);
return $row_qty['issue_qty'];
}
$sql = "SELECT ohc_type_id from ohc_type where ohc_category = 'FAB'";
$result = mysqli_query($conn, $sql);
$ohcid = mysqli_fetch_assoc($result);
$ohcidd = $ohcid['ohc_type_id'];
$sql_med = "select distinct(c.item_name), a.filled_by ,b.item_id,a.issue_date from stock_issue a left join stock_issue_items b on a.stock_issue_id = b.stock_issue_id left join tbl_items c on b.item_id = c.item_id where a.ohc_location_id='$ohcidd' and c.item_name != '' and year(a.issue_date)='$y' and month(a.issue_date)='$month' and a.amb_no_box_code = '$box_no'";
error_log("STOCK QUERY:".$sql_med);
$result_med = mysqli_query($conn, $sql_med);
$num_med = mysqli_num_rows($result_med);
while($row_med = mysqli_fetch_array($result_med)){
?>
<tr>
<td><?=date_format(date_create($row_med['issue_date']),"d-M-Y ")?></td>
<?php //$sql_items = "select distinct(c.item_name),b.item_id,b.issue_date from stock_issue a left join stock_issue_items b on a.stock_issue_id = b.stock_issue_id left join tbl_items c on b.item_id = c.item_id where a.ohc_location_id= (select ohc_type_id from ohc_type where ohc_category = 'FAB') and c.item_name != '' and year(a.issue_date)='$y' and month(a.issue_date)='$month' and a.amb_no_box_code = '$box_no'";
// error_log("ITEM QUERY:".$sql_items);
// $result_items = mysqli_query($conn, $sql_items);
// $row_item = mysqli_fetch_array($result_items);
// $num_items = mysqli_num_rows($result_items);
// for($i=0;$i<$num_items;$i++){?>
<td>
<?php
$name = $row_med['filled_by'];
echo getFieldFromTable('patient_name','patient_master','id',$name);
?>
</td>
<td><?=$row_med['item_name']?></td>
<td><?=getIssueQty($row_med['item_id'],$row_med['issue_date'])?></td>
<?php //}?>
</tr>
<?php }?>
</tr>
</table>
<br><br>
<footer style="text-align: right;">
<p>Signature of Factory Medical Officer</p>
</footer>
</body>
<?php
include('pdf_footer.php');
?>