ESH/daily_respiratory_report_excel.php
2024-10-23 18:28:06 +05:30

172 lines
7.2 KiB
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=daily_respiratory_report_excel.xls");
header("Pragma: no-cache");
header("Expires: 0");
error_reporting(E_ERROR | E_PARSE);
?>
<?php
$from_date1 = date('Y-m-d', strtotime($_POST['startdate7']));
error_log("from_date1:::" . $from_date1);
$rec_date = date('Y-m-d', strtotime($from_date1 . ' - 1 days'));
error_log("rec_date:::" . $rec_date);
$from_date = date('Y-m-d', strtotime($from_date1));
$ohc = $_SESSION['current_ohcttype'];
?>
<style>
th {
font-size: 10px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font: bold;
}
td {
font-size: 10px;
font-family: 'Calibri, sans-serif;
}
</style>
<body>
<? include('excel_ohc_header.php'); ?>
<table width="100%">
<tr>
<td align="center" style="font-size: 15px"><strong>Daily Respiratory Report</strong></td>
</tr>
<tr>
<td align="left" style="font-size: 12px"><strong>For Date: <? echo date("d-M-Y", strtotime($from_date)); ?></strong></td>
</tr>
</table>
<br>
<table width="100%" border="1" cellspacing="0">
<tr style="background-color:skyblue; height: 50px;">
<th width="1%" align="center">Sr</th>
<th align="center" width="10%">Patients Name</th>
<th align="center" width="5%">Dob</th>
<th align="center" width="5%">Emp Id</th>
<td align="center" width="3%">Employer</td>
<th align="center" width="5%">Designation</th>
<th align="center" width="5%">Division</th>
<th align="center" width="5%">Department</th>
<th align="center" width="5%">Ute</th>
<th align="center" width="5%">Station</th>
<th align="center" width="5%">Contact No</th>
<th align="center" width="5%">Supervisor</th>
<th align="center" width="5%">Symptoms</th>
<th align="center" width="5%">Diagnosis</th>
<th align="center" width="5%">Temp(1st)</th>
<th align="center" width="5%">Temp(2nd)</th>
<th align="center" width="5%">Temp(3rd)</th>
<th align="center" width="5%">Reporting By</th>
<th align="center" width="5%">Advice</th>
<th align="center" width="5%">Reffered By/RTW</th>
<th align="center" width="10%">Remarks</th>
</tr>
<?php
error_reporting(E_ERROR | E_PARSE);
$count = 0;
$sql = "select e.*,p.* from employee_appointment e left join patient_master p on e.emp_id = p.id where date(e.appointment_date) = '" . $from_date1 . "' and e.ailment_systems_new='3' and e.ohc_type_id='" . $ohc . "' ";
error_log("respiratory query " . $sql);
$result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($result)) {
$count++;
$dob = '';
if ($row['dob'] == '' || $row['dob'] == '0000-00-00' || $row['dob'] == null) {
$dob = 'NA';
} else {
$dob = $row['dob'];
}
$division = getFieldFromTable('bu_name', 'bussiness_unit', 'bu_id', $row['bu_id']);
$diagnosis = getCommaSeperatedValuesForInClause("select ailment_name from ailment ", "ailment_id", $row['ailments_new']);
?>
<tr style="height: 50px;">
<td width="1%" align="center"><?= $count ?></td>
<td align="center" width="10%"><?= $row['patient_name'] ?></td>
<td align="center" width="5%"><?= $dob ?></td>
<td align="center" width="5%"><?= $row['emp_code'] ?></td>
<td><?php echo getFieldFromTable('employer_contractor_name', 'employer_contractor', 'id', $row['employer_contractor_id']) ?></td>
<td align="center" width="5%"><?= getFieldFromTable('designation_name', 'designation', 'designation_id', $row['designation_id']) ?></td>
<?php
if ($division == 'Car') {
?>
<td align="center" width="5%" style="background-color:#4CAF50;"><?= $division ?></td>
<?php
} else if ($division == 'Corporate') {
?>
<td align="center" width="5%" style="background-color:slateblue"><?= $division ?></td>
<?php
} else if ($division == 'PWT') {
?>
<td align="center" width="5%" style="background-color:yellow;"><?= $division ?></td>
<?php
} else {
?>
<td align="center" width="5%" style="background-color:aliceblue;"><?= $division ?></td>
<?php
}
?>
<td align="center" width="5%"><?= getFieldFromTable('dept_name', 'department', 'dept_id', $row['dept_id']) ?></td>
<td align="center" width="5%"><?= getFieldFromTable('section_name', 'section', 'section_id', $row['section_id']) ?></td>
<td align="center" width="5%"><?= getFieldFromTable('sub_section_name', 'sub_section', 'sub_section_id', $row['sub_section_id']) ?></td>
<td align="center" width="5%"><?= $row['primary_phone'] ?></td>
<td align="center" width="5%"><?= getFieldFromTable('patient_name', 'patient_master', 'id', $row['emp_mgr_code']) ?></td>
<?php
$complaint_ids = $row['complaints'];
$complaint_ids_array = array();
$complaint_ids_array = explode(",", $complaint_ids);
$complaints = "";
for ($i = 0; $i < count($complaint_ids_array); $i++) {
if ($i == 0) {
if (is_numeric($complaint_ids_array[$i])) {
$complaints = getTableFieldValue('complaints', 'complaint', 'complaint_id', $complaint_ids_array[$i]);
} else {
$complaints = $complaint_ids_array[$i];
}
} else {
if (is_numeric($complaint_ids_array[$i])) {
$complaints = $complaints . "," . getTableFieldValue('complaints', 'complaint', 'complaint_id', $complaint_ids_array[$i]);
} else {
$complaints = $complaints . "," . $complaint_ids_array[$i];
}
}
}
?>
<td align="center" width="5%"><?= $complaints ?></td>
<td align="center" width="5%"><?= $diagnosis ?></td>
<td align="center" width="5%"><?= $row['temperature'] ?></td>
<td align="center" width="5%"></td>
<td align="center" width="5%"></td>
<td align="center" width="5%"></td>
<td align="center" width="5%"></td>
<td align="center" width="5%"></td>
<td align="center" width="10%"></td>
</tr>
<?php
}
?>
</table>
</body>