212 lines
6.6 KiB
PHP
212 lines
6.6 KiB
PHP
<?php
|
|
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=first_aid_box_report_excel.xls");
|
|
header("Pragma: no-cache");
|
|
header("Expires: 0");
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
?>
|
|
<?php
|
|
include('functions.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_locs = $_POST['box_locs'];
|
|
$box_locs=explode(",", $box_locs);
|
|
|
|
error_log('$box_loc='.print_r($box_locs,true));
|
|
|
|
?>
|
|
<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>
|
|
|
|
|
|
<!-- xxxxxxxxxxx -->
|
|
<?php
|
|
function cost_latest($item_id)
|
|
{
|
|
|
|
|
|
|
|
$sql_procurement = "select * from item_rate where item_id = '$item_id' ";
|
|
|
|
|
|
// error_log("exp_cost:".$item_id . $sql_procurement);
|
|
|
|
$result_procurement = mysqli_query($GLOBALS['conn'],$sql_procurement);
|
|
|
|
$procurement_qty_total = 0;
|
|
|
|
while ($row_procurement = mysqli_fetch_assoc($result_procurement)) {
|
|
|
|
$procurement_qty_total += ($row_procurement['item_rate']/$row_procurement['unit']);
|
|
}
|
|
|
|
return $procurement_qty_total;
|
|
|
|
|
|
}
|
|
|
|
|
|
function getIssueQty($item_id,$issue_date){
|
|
|
|
$ohc_code="'FAB".getTableFieldValue("ohc_type","ohc_code","ohc_type_id",$_SESSION["current_ohcttype"])."'";
|
|
|
|
|
|
$ohcidd =getTableFieldValue("ohc_type","ohc_type_id","ohc_code",$ohc_code);
|
|
|
|
|
|
$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='$ohcidd'";
|
|
|
|
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'];
|
|
}
|
|
for($i=0;$i<count($box_locs);$i++){
|
|
$box_loc=strtoupper($box_locs[$i]);
|
|
|
|
$ohc_code="'FAB".getTableFieldValue("ohc_type","ohc_code","ohc_type_id",$_SESSION["current_ohcttype"])."'";
|
|
|
|
|
|
$ohcidd =getTableFieldValue("ohc_type","ohc_type_id","ohc_code",$ohc_code);
|
|
|
|
if($box_loc=='ALL'){
|
|
$box_sql="select DISTINCT(amb_no_box_code) as box_no from stock_issue where year(issue_date)='$y' and month(issue_date)='$month' and ohc_location_id='$ohcidd'";
|
|
}
|
|
else{
|
|
$box_sql="select DISTINCT(amb_no_box_code) as box_no from stock_issue where year(issue_date)='$y' and month(issue_date)='$month' and ohc_location_id='$ohcidd' and amb_no_box_code in (select box_id from first_aid_box where box_loc='$box_loc' ) ";
|
|
}
|
|
|
|
error_log('xxx'.$box_sql);
|
|
$result_box = mysqli_query($conn, $box_sql);
|
|
$box_no='(';
|
|
|
|
while($row_box = mysqli_fetch_array($result_box)){
|
|
|
|
$box_no.=$row_box['box_no'].',';
|
|
|
|
}
|
|
$box_no.='0)';
|
|
|
|
error_log('num_row'.$box_no);
|
|
|
|
|
|
?>
|
|
<table width="100%" style="margin-top: 10px;margin-bottom: 5px;">
|
|
|
|
<tr>
|
|
<td><strong>LOCATION/DIVISION:
|
|
<?=$box_loc?></strong></td>
|
|
</tr>
|
|
</table>
|
|
|
|
<table border="1" cellspacing="0" width="100%">
|
|
|
|
<tr>
|
|
<th width='20%'>Department</th>
|
|
<th width='10%'>First Aid Box N.</th>
|
|
<th width='15%'>First Aider</th>
|
|
<th width='15%'>Date</th>
|
|
<th width='15%'>Refilled by</th>
|
|
<th width='20%'>Item Name</th>
|
|
<th width='10%'>Issued Quantity</th>
|
|
<th width='10%'>Item Amount</th>
|
|
</tr>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
$sql_med = "select distinct(c.item_name),a.amb_no_box_code,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 in $box_no";
|
|
|
|
error_log("STOCK QUERY:".$sql_med);
|
|
|
|
$result_med = mysqli_query($conn, $sql_med);
|
|
|
|
$num_med = mysqli_num_rows($result_med);
|
|
$amt=0;
|
|
while($row_med = mysqli_fetch_array($result_med)){
|
|
|
|
?>
|
|
<tr>
|
|
<td><?=getFieldFromTable('box_name','first_aid_box','box_id',$row_med['amb_no_box_code'])?></td>
|
|
<td width='10%'><?=getFieldFromTable('box_code','first_aid_box','box_id',$row_med['amb_no_box_code'])?></td>
|
|
<td width='10%'>
|
|
<?=getCommaSeperatedValuesForInClause("select patient_name from patient_master","id",getFieldFromTable('first_aider','first_aid_box','box_id',$row_med['amb_no_box_code']))?>
|
|
</td>
|
|
<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>
|
|
|
|
<td><?php
|
|
$amt+=number_format((float)(getIssueQty($row_med['item_id'],$row_med['issue_date'])*cost_latest($row_med['item_id'])), 2, '.', '');
|
|
echo number_format((float)(getIssueQty($row_med['item_id'],$row_med['issue_date'])*cost_latest($row_med['item_id'])), 2, '.', '');?>
|
|
</td>
|
|
|
|
<?php //}?>
|
|
</tr>
|
|
|
|
<!-- xxxxxxxxxxx -->
|
|
|
|
|
|
|
|
|
|
|
|
<?php }?>
|
|
<tr>
|
|
<td colspan="6" align='right'><b>Total Amount</b></td>
|
|
<td><b><?=number_format((float)$amt, 2, '.', '')?></td>
|
|
</tr>
|
|
</table>
|
|
<?php }?>
|
|
|
|
<br><br>
|
|
<footer style="text-align: right;">
|
|
<p>Signature of Factory Medical Officer</p>
|
|
</footer>
|
|
</body>
|