163 lines
5.6 KiB
PHP
163 lines
5.6 KiB
PHP
<?php
|
|
// include('pdf_header.php');
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
header('Content-Type: application/force-download');
|
|
header('Content-disposition: attachment; filename=Add Direct Item Issue Report.xls');
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
$start = $_POST['adii_date1'];
|
|
$end = $_POST['adii_date2'];
|
|
$amb_no_box_code = '';
|
|
$location = $_POST['location'];
|
|
|
|
if (!empty($_POST['ambulance_number'])) {
|
|
$amb_no_box_code = $_POST['ambulance_number'];
|
|
|
|
$title_name = getTableFieldValue('ambulance_details_new', 'ambulance_number', 'id', $_POST['ambulance_number']);
|
|
}
|
|
if (!empty($_POST['supplier_name'])) {
|
|
$supplier_name = $_POST['supplier_name'];
|
|
|
|
$title_name = getTableFieldValue('supplier_name', 'supplier_name', 'id', $_POST['supplier_name']);
|
|
}
|
|
if (!empty($_POST['box_number'])) {
|
|
$amb_no_box_code = $_POST['box_number'];
|
|
|
|
$title_name = getTableFieldValue('first_aid_box', "CONCAT(box_code,'-',box_name)", 'box_id', $_POST['box_number']);
|
|
}
|
|
|
|
if (!empty($_POST['p_id'])) {
|
|
$amb_no_box_code = $_POST['p_id'];
|
|
|
|
$title_name = getTableFieldValue('patient_master', 'patient_name', 'id', $_POST['p_id']);
|
|
}
|
|
|
|
$ohc_loc = getTableFieldValue('ohc_type', 'ohc_type_name', 'ohc_type_id', $_POST['location']);
|
|
|
|
?>
|
|
<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('excel_ohc_header.php'); ?>
|
|
<table width="100%">
|
|
<tr>
|
|
|
|
<td style="font-size: 15px;"><strong style="margin-left: 400px">Add Direct Item Issue Report</strong></td>
|
|
|
|
</tr>
|
|
<tr>
|
|
<td align="left" style="font-size: 12px"><strong>For Duration: <?php echo $start; ?>-
|
|
<?php echo $end; ?></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%">
|
|
<tr>
|
|
|
|
<td style="font-size: 15px;"><strong style="margin-left: 400px"><?php echo $ohc_loc . " (" . $title_name . ")" ?></strong></td>
|
|
|
|
</tr>
|
|
|
|
|
|
</table>
|
|
<br>
|
|
<table border="1" width="100%" cellspacing="0">
|
|
<?php
|
|
$sqll = "SELECT count(*) as total from stock_issue where ohc_location_id ='$location' and amb_no_box_code ='$amb_no_box_code' and issue_ohc_type_id='" . $_SESSION['current_ohcttype'] . "' and issue_date BETWEEN STR_TO_DATE('" . $start . "','%d-%m-%Y') and STR_TO_DATE('" . $end . "','%d-%m-%Y') ";
|
|
|
|
$result_sqll = mysqli_query($conn, $sqll);
|
|
$num_rows = mysqli_num_rows($result_sqll);
|
|
$row0 = mysqli_fetch_assoc($result_sqll);
|
|
error_log("total:" . $sqll);
|
|
|
|
$sql = "SELECT filled_by ,stock_issue_emp_id, stock_issue_id, issue_ref_no,req_id,issue_date,remarks,ohc_location_id,amb_no_box_code,status from stock_issue where ohc_location_id ='$location' and amb_no_box_code ='$amb_no_box_code' and issue_ohc_type_id='" . $_SESSION['current_ohcttype'] . "' and issue_date BETWEEN STR_TO_DATE('" . $start . "','%d-%m-%Y') and STR_TO_DATE('" . $end . "','%d-%m-%Y') ";
|
|
error_log($sql);
|
|
|
|
$result = mysqli_query($conn, $sql);
|
|
|
|
?>
|
|
|
|
<strong>
|
|
<tr bgcolor="#eeeeee">
|
|
<td align="left" width="2%">Sr.</td>
|
|
<td align="left" width="2%">Issue Ref No</td>
|
|
<td align="left" width="2%">Medicine</td>
|
|
<td align="left" width="2%">Issue Qty</td>
|
|
<td align="left" width="2%">Cost</td>
|
|
<td align="left" width="2%">Issue Date</td>
|
|
<td align="left" width="2%">Issue By</td>
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
$count = 1;
|
|
while ($row1 = mysqli_fetch_assoc($result)) {
|
|
@extract($row1);
|
|
|
|
$item_desc = "";
|
|
$total_qty = 0;
|
|
$total_cost = 0;
|
|
|
|
$sql_issue_items = "SELECT sii.*, ti.item_name, pi.net_value / pi.qty AS per_unit_cost
|
|
FROM stock_issue_items sii
|
|
JOIN tbl_items ti ON sii.item_id = ti.item_id
|
|
JOIN procurement_items pi ON sii.item_id = pi.item_id
|
|
WHERE sii.stock_issue_id='" . $row1['stock_issue_id'] . "'";
|
|
|
|
$results_issue_items = mysqli_query($conn, $sql_issue_items);
|
|
while ($row_issue_items = mysqli_fetch_assoc($results_issue_items)) {
|
|
$issue_qty = $row_issue_items['issue_qty'];
|
|
$per_unit_cost = $row_issue_items['per_unit_cost'];
|
|
$cost = $issue_qty * $per_unit_cost;
|
|
$total_qty += $issue_qty;
|
|
$total_cost += $cost;
|
|
|
|
$item_desc .= '<p>' . $row_issue_items['item_name'] . ' - Qty: ' . $issue_qty . ' - Cost: ' . number_format($cost, 2) . '</p>';
|
|
}
|
|
?>
|
|
|
|
<tr>
|
|
<td><?php echo $count ?></td>
|
|
<td><a target="_blank" href="issue_pdf.php?stock_issue_id=<?php echo $row1['stock_issue_id']; ?>"><?php echo $row1['issue_ref_no']; ?></a></td>
|
|
<td><?php echo $item_desc; ?></td>
|
|
<td><?php echo $total_qty; ?></td>
|
|
<td><?php echo number_format($total_cost, 2); ?></td>
|
|
<td><?php echo date_format(date_create($row1['issue_date']), "d-M-Y "); ?></td>
|
|
<td><?php echo getTableFieldValue('patient_master', 'patient_name', 'id', $row1['filled_by']); ?></td>
|
|
</tr>
|
|
<?php
|
|
$count++;
|
|
}
|
|
?>
|
|
<tr Height="10px">
|
|
<td colspan="5"><b>TOTAL: <?php echo $row0['total'] ?></b></td>
|
|
</tr>
|
|
</table>
|
|
</body>
|