ohctech_p8/pohc_report_excel.php
2024-10-16 19:18:52 +05:30

119 lines
4.2 KiB
PHP

<?php
include('includes/config/config.php');
include('includes/functions.php');
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=pohc_report_excel.xls");
header("Pragma: no-cache");
header("Expires: 0");
error_reporting(E_ERROR | E_PARSE);
// Get form data
$start_date = date('d-m-Y', strtotime($_POST['startDate2']));
$end_date = date('d-m-Y', strtotime($_POST['endDate2']));
$exam_type = $_POST['exam_type'];
$bu_id = $_POST['bu_id'];
error_log($start_date);
error_log($end_date);
error_log('exam_type' . $exam_type);
error_log('bu_id' . $bu_id);
?>
<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: 18px"><strong>Health Index Record of
<?php if ($bu_id == 'all') { ?>All <?php } else {
echo getTableFieldValue('bussiness_unit', 'bu_name', 'bu_id', $bu_id);
} ?> Division</strong></td>
</tr>
<tr>
<td align="center" style="font-size: 13px;padding-top: 10px;"><strong>(For
<?= getTableFieldValue('checkup_type', 'checkup_type_name', 'checkup_type_id', $exam_type) ?>)</strong>
</td>
</tr>
<tr>
<td align="right" style="font-size: 15px"><button align="center" id="printPageButton" class="btn btn-success" onClick="window.print();">Print</button></td>
</tr>
</table>
<table border="1" width="100%" cellspacing="0">
<tr bgcolor="#eeeeee">
<td width="3%">Sr.</td>
<td align="left" width="15%">Ticket No</td>
<td align="left" width="8%">Check Up Date</td>
<td align="left" width="15%">Patient Name</td>
<td align="left" width="5%">Emp Code</td>
<td align="left" width="10%">DOB</td>
<td align="left" width="10%">Designation</td>
<td align="left" width="10%">Plant</td>
<td valign="top" align="left" width="8%">Health Index</td>
</tr>
<?php
if ($bu_id == "all") {
$sql = "SELECT cf.*, p.* FROM checkup_form cf LEFT JOIN patient_master p ON cf.emp_id = p.id WHERE cf.checkup_type_id = '" . $exam_type . "' AND DATE(cf.checkup_date) BETWEEN STR_TO_DATE('" . $start_date . "', '%d-%m-%Y') AND STR_TO_DATE('" . $end_date . "', '%d-%m-%Y') ORDER BY cf.checkup_date ASC";
} else {
$sql = "SELECT cf.*, p.* FROM checkup_form cf LEFT JOIN patient_master p ON cf.emp_id = p.id WHERE p.bu_id='" . $bu_id . "' AND cf.checkup_type_id = '" . $exam_type . "' AND DATE(cf.checkup_date) BETWEEN STR_TO_DATE('" . $start_date . "', '%d-%m-%Y') AND STR_TO_DATE('" . $end_date . "', '%d-%m-%Y') ORDER BY cf.checkup_date ASC";
}
error_log("Query: " . $sql);
$result = mysqli_query($conn, $sql);
$count = 1;
while ($row1 = mysqli_fetch_assoc($result)) {
// Extracting row data into variables
extract($row1);
// Calculating age
$age = ageCalculator($row1['dob']);
?>
<tr>
<td><?php echo $count ?></td>
<td><?php echo $row1['ticket_no'] ?></td>
<td><?php echo date('d-m-Y', strtotime($row1['checkup_date'])) ?></td>
<td><?php echo $row1['patient_name'] ?></td>
<td><?php echo $row1['emp_code'] ?></td>
<td><?php echo date('d-m-Y', strtotime($row1['dob'])) ?></td>
<td><?php echo getTableFieldValue('designation', 'designation_name', 'designation_id', $row1['designation_id']) ?></td>
<td><?php echo getTableFieldValue('plant_master', 'plant_name', 'plant_id', $row1['plant_id']) ?></td>
<td><?php echo $row1['health_index'] ?></td>
</tr>
<?php
$count++;
}
?>
</table>
</body>