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

167 lines
5.7 KiB
PHP

<?php
include('includes/config/config.php');
include('includes/functions.php');
$start = $_POST['adii_date1'];
$end = $_POST['adii_date2'];
$location = $_POST['location'];
$supplier_name = isset($_POST['supplier_name']) ? $_POST['supplier_name'] : '';
$amb_no_box_code = '';
if (!empty($_POST['ambulance_number'])) {
$amb_no_box_code = $_POST['ambulance_number'];
$title_name = getTableFieldValue('ambulance_details_new', 'ambulance_number', 'id', $_POST['ambulance_number']);
} elseif (!empty($_POST['supplier_name'])) {
$title_name = getTableFieldValue('supplier_name', 'supplier_name', 'id', $_POST['supplier_name']);
} elseif (!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']);
} elseif (!empty($_POST['patient_id'])) {
$amb_no_box_code = $_POST['patient_id'];
$title_name = getTableFieldValue('patient_master', 'patient_name', 'id', $_POST['patient_id']);
}
$ohc_loc = getTableFieldValue('ohc_type', 'ohc_type_name', 'ohc_type_id', $_POST['location']);
?>
<link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" />
<style>
@page {
margin: 15px;
}
.btn {
background-color: #4CAF50;
border-radius: 5%;
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 style="font-size: 15px;">
<strong style="margin-left: 600px">Add Direct Item Issue Report</strong>
</td>
<br>
</tr>
</table>
<br>
<table width="100%">
<tr>
<td style="font-size: 12px;">
<strong style="margin-left: 600px"><?php echo $ohc_loc . " (" . $title_name . ")" ?></strong>
</td>
<br>
</tr>
</table>
<table width="100%">
<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 border="1" width="100%" cellspacing="0">
<?php
$supplier_filter = $supplier_name ? " AND supplier_name = '$supplier_name'" : "";
$sql_count = "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')
$supplier_filter";
$result_count = mysqli_query($conn, $sql_count);
$row0 = mysqli_fetch_assoc($result_count);
$sql = "SELECT si.filled_by, si.stock_issue_id, si.issue_ref_no, si.issue_date, si.remarks
FROM stock_issue si
WHERE si.ohc_location_id ='$location' AND si.amb_no_box_code ='$amb_no_box_code'
AND si.issue_ohc_type_id='" . $_SESSION['current_ohcttype'] . "'
AND si.issue_date BETWEEN STR_TO_DATE('$start','%d-%m-%Y') AND STR_TO_DATE('$end','%d-%m-%Y')
$supplier_filter";
$result = mysqli_query($conn, $sql);
?>
<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>
<td align="left" width="2%">Requested Items</td>
</tr>
<?php
$count = 1;
while ($row1 = mysqli_fetch_assoc($result)) {
@extract($row1);
$item_desc = "";
$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_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 $issue_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>
<td><?php echo $item_desc; ?></td>
</tr>
<?php
$count++;
}
?>
<tr Height="10px">
<td colspan="8"><b>TOTAL: &nbsp;<?php echo $row0['total'] ?></b></td>
</tr>
</table>
</body>
<script>
$(document).ready(function() {
window.print();
});
</script>