ESH/less_qty_medi_pre_excel.php

189 lines
5.0 KiB
PHP
Raw Permalink Normal View History

2024-10-23 18:28:06 +05:30
<?php //include('pdf_header_reverse.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=less_qty_medicine_prescribe_report.xls");
header("Pragma: no-cache");
header("Expires: 0");
?>
<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>
<?php include('excel_ohc_header.php'); ?>
<table width="100%">
<tr>
<td align="center" style="font-size: 15px"><strong>Less Qty Prescribe Medicine Report</strong></td>
</tr>
<tr>
<td align="left" style="font-size: 12px"><strong>For :<?php echo date('d-m-Y', strtotime($_POST['startDate_l_qty'])) . " To " . date('d-m-Y', strtotime($_POST['endDate_l_qty'])) ?></strong></td>
</tr>
</table>
<table border="1" width="100%" cellspacing="0">
<strong>
<tr bgcolor="#eeeeee">
<th><strong>Sr</th>
<th><strong>Emp Code</th>
<th><strong>Patient Name</th>
<th><strong>Designation</th>
<th><strong>Division</th>
<th><strong>Department</th>
<th><strong>Section</th>
<th><strong>Items Name</th>
<th><strong>Frequency</th>
<th><strong>Duration / Days</th>
<th><strong>Daily Dose Qty</th>
<th><strong>Prescribe Qty </th>
<th><strong>Issued Qty</th>
<th><strong>Less Qty</th>
<th><strong>Batch</th>
</tr>
<?php
$start = date('Y-m-d', strtotime($_POST['startDate_l_qty']));
$end = date('Y-m-d', strtotime($_POST['endDate_l_qty']));
$query = "SELECT t.* , a.appointment_date , a.appointment_id,a.emp_id FROM treatment t INNER JOIN employee_appointment a ON t.appointment_id = a.appointment_id WHERE t.issued_qty < (t.for_days * t.item_qty) AND a.appointment_date between '$start' AND '$end'";
error_log("###########QQQQQQQQ" . $query);
$result = mysqli_query($conn, $query);
$total = mysqli_num_rows($result);
if ($total != 0) { ?>
<?
while ($row = mysqli_fetch_assoc($result)) {
$item_from_id = getTableFieldValue("tbl_items", "item_form_id", "item_id", $row['item_id']);
$is_qty_fixed = getTableFieldValue("medicine_form", "is_qty_fixed", "form_id", $item_from_id);
if($is_qty_fixed != 'YES'){
}else{
continue;
}
?>
<tr>
<td align="left"><?= ++$count ?></td>
<?php $emp_id = getTableFieldValue("employee_appointment", "emp_id", "appointment_id", $row['appointment_id']);
$emp_code = getTableFieldValue("patient_master", "emp_code", "id", $emp_id);
?>
<td align="left"><?= $emp_code ?></td>
<?php
$patient_name = getTableFieldValue("patient_master", "patient_name", "id", $emp_id);
?>
<td align="left"><?= $patient_name ?></td>
<td align="left"><?php
$designation_id = getTableFieldValue("patient_master", "designation_id", "id", $emp_id);
echo getTableFieldValue('designation', 'designation_name', $designation_id, 'designation_id',); ?></td>
<td><?php
$bu_id = getTableFieldValue("patient_master", "bu_id", "id", $emp_id);
echo getTableFieldValue('bussiness_unit', 'bu_name', $bu_id, 'bu_id');
?></td>
<td><?php
$dept_id = getTableFieldValue("patient_master", "dept_id", "id", $emp_id);
echo getTableFieldValue('department', 'dept_name', $dept_id, 'dept_id');
?></td>
<td><?php
$section_id = getTableFieldValue("patient_master", "section_id", "id", $emp_id);
echo getTableFieldValue('section', 'section_name', $section_id, 'section_id') ?>
</td>
<?php $item_name = getTableFieldValue("tbl_items", "item_name", "item_id", $row['item_id']) ?>
<td align="left"><?= $item_name ?></td>
<?php $frequency_name = getTableFieldValue("medicine_frequency", "frequency_description", "frequency_id", $row['frequency_id']) ?>
<td align="left"><?= $frequency_name ?></td>
<td align="left"><?php echo $row['for_days'] ?></td>
<td align="left"><?php echo $row['item_qty'] ?></td>
<td align="left"><?php echo $prescribe_qty = $row['item_qty'] * $row['for_days'] ?></td>
<td align="left"><?php echo $row['issued_qty'] ?></td>
<td align="left"><?php echo $prescribe_qty - $row['issued_qty'] ?></td>
<td align="left"><?php echo $row['item_batch_no'] ?></td>
</tr>
<?php }
}
?>
</table>
</body>