ESH/diagnosis_opd_report_pdf.php

205 lines
8.3 KiB
PHP
Raw Normal View History

2024-10-23 18:28:06 +05:30
<?php
include('includes/config/config.php');
include('includes/functions.php');
$from_date = date('Y-m-d', strtotime($_POST['DiagDateFrom']));
$to_date = date('Y-m-d', strtotime($_POST['DiagDateTo']));
error_log("from data " . $from_date . " to date " . $to_date);
$ohc_id = $_SESSION['current_ohcttype'];
$ailment_id = $_REQUEST['ailment_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>
<body>
<?php include('pdf_ohc_header.php'); ?>
<table width="100%">
<tr>
<td style="font-size: 15px;"><strong style="margin-left: 400px">Diagnosis Wise Opd Report</td>
</tr>
<tr>
<td align="left" style="font-size: 12px"><strong>From:
<? echo date("d-M-Y", strtotime($from_date)); ?>&nbsp;&nbsp;&nbsp;To:
<? echo date("d-M-Y", strtotime($to_date)); ?>
</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>
<table border="1" width="100%" cellspacing="0">
<?php
if ($ailment_id == 'ALL') {
$sql = "SELECT count(*) as total FROM employee_appointment a JOIN view_patient_master b on a.emp_id=b.id WHERE a.ohc_type_id='" . $ohc_id . "' and a.ailments_new!='' and date(a.appointment_date) BETWEEN '$from_date' and '$to_date'";
} else {
$sql = "SELECT count(*) as total FROM employee_appointment a JOIN view_patient_master b on a.emp_id=b.id WHERE a.ohc_type_id='" . $ohc_id . "' and (a.ailments_new LIKE '%,$ailment_id,%' or a.ailments_new LIKE '%$ailment_id,%' or a.ailments_new LIKE '%,$ailment_id%' or a.ailments_new LIKE '%$ailment_id%' or a.ailments_new = '" . $ailment_id . "') and date(a.appointment_date) BETWEEN '$from_date' and '$to_date'";
}
$result_sql = mysqli_query($conn, $sql);
$num_rows = mysqli_num_rows($result_sql);
$row0 = mysqli_fetch_assoc($result_sql);
error_log("total sql :" . $sql);
if ($ailment_id == 'ALL') {
$sql_data = "SELECT DATE_FORMAT(a.appointment_date, '%d-%m-%y') as date, a.*,b.* FROM employee_appointment a JOIN view_patient_master b on a.emp_id=b.id WHERE a.ohc_type_id='" . $ohc_id . "' and a.ailments_new!='' and date(a.appointment_date) BETWEEN '$from_date' and '$to_date'";
} else {
$sql_data = "SELECT DATE_FORMAT(a.appointment_date, '%d-%m-%y') as date, a.*,b.* FROM employee_appointment a JOIN view_patient_master b on a.emp_id=b.id WHERE a.ohc_type_id='" . $ohc_id . "' and (a.ailments_new LIKE '%,$ailment_id,%' or a.ailments_new LIKE '%$ailment_id,%' or a.ailments_new LIKE '%,$ailment_id%' or a.ailments_new LIKE '%$ailment_id%' or a.ailments_new = '" . $ailment_id . "') and date(a.appointment_date) BETWEEN '$from_date' and '$to_date'";
}
error_log("record sql " . $sql_data);
$result_data = mysqli_query($conn, $sql_data);
?>
<tr bgcolor="#eeeeee">
<th align="left" width="2%">Sr.</th>
<th align="left" width="5%">Date</th>
<th align="left" width="5%">Time In</th>
<th align="left" width="5%">Time Out</th>
<!-- <th align="left" width="2%">Duration</td> -->
<th valign="top" align="left" width="3%">Emp. Code</th>
<th valign="top" align="left" width="8%">Name</th>
<th valign="top" align="left" width="2%">Age</th>
<th valign="top" align="left" width="2%">Sex</th>
<th valign="top" align="left" width="5%">Mobile No.</th>
<th valign="top" align="left" width="6%">Employer</th>
<th valign="top" align="left" width="6%">Designation</th>
<!-- <th valign="top" align="left" width="3%">Emp Cadre</th> -->
<th valign="top" align="left" width="5%">Department</th>
<th valign="top" align="left" width="6%">Section</th>
<th valign="top" align="left" width="3%">Complaint</th>
<!-- <th valign="top" align="left" width="3%">Chronic Illness</th> -->
<th valign="top" align="left" width="3%">Diagnosis</th>
<th valign="top" align="left" width="5%">Treatment</th>
<!-- <th valign="top" align="left" width="3%">Chronic Days</th> -->
</tr>
<?php
$count = 1;
while ($row_data = mysqli_fetch_assoc($result_data)) {
extract($row_data);
?>
<tr>
<td><?php echo $count ?></td>
<td><?php echo $row_data['date'] ?></td>
<td><?php echo date("d/M/Y H:i ", strtotime($row_data['appointment_date'])) ?></td>
<td>
<?php if ($row_data['clearance_time'] != null && $row_data['clearance_time'] != '' && $row_data['clearance_time'] != "00-00-00 00:00:00") {
echo date("d/M/Y H:i ", strtotime($row_data['clearance_time']));
} ?>
</td>
<td><?php echo $row_data['emp_code'] ?></td>
<td><?php echo $row_data['patient_name'] ?></td>
<td>
<?php
$from = new DateTime($row_data['dob']);
$to = new DateTime('today');
echo $from->diff($to)->y;
?>
</td>
<td>
<?php if ($row_data['gender'] == 'M') {
echo 'Male';
} else {
echo 'Female';
} ?>
</td>
<td><?php echo $row_data['primary_phone'] ?></td>
<td><?php echo $row_data['employer_contractor_name']; ?></td>
<td><?php echo $row_data['designation_name']; ?></td>
<td><?php echo $row_data['dept_name']; ?></td>
<td><?php echo $row_data['section_name']; ?></td>
<?php
$complaint_ids = $row_data['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><?php echo strtolower($complaints) ?></td>
<?php if ($ailment_id == 'ALL') { ?>
<td><?php echo strtolower(getCommaSeperatedValuesForInClause("select ailment_name from ailment ", "ailment_id", $row_data['ailments_new'])); ?></td>
<?php } else { ?>
<td><?php echo strtolower(getFieldFromTable('ailment_name', 'ailment', 'ailment_id', $ailment_id)) ?></td>
<?php } ?>
<td><?php echo $treatment_text = getTreatmentTextPdf($row_data['appointment_id']); ?></td>
</tr>
<?php
$count++;
}
?>
<tr Height="10px">
<td colspan="16"><b>TOTAL: &nbsp;<?php echo $row0['total'] ?></b></td>
</tr>
</table>
</body>
<script>
$(document).ready(function() {
window.print();
});
</script>