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

107 lines
3.2 KiB
PHP

<?php //include('pdf_header_reverse.php');
include('includes/config/config.php');
include('includes/functions.php');
//include('pop_up_top.php');
error_log("habit id " . $_REQUEST['habit_id']);
$habit_id = implode(",", $_REQUEST['habit_id']);
error_log("habit ids " . $habit_id);
if ($habit_id != 'All') {
$habit_name = ucwords(strtolower(getCommaSeperatedValuesForInClause("select habit from habits", 'habit_id', $habit_id)));
error_log("habit names " . $habit_name);
}
?>
<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"><?= $habit_name ?> Habit Report</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>
<br>
<table width="100%" cellspacing="0" border="1">
<tr>
<th>Sr No.</th>
<th>
Employee Names
</th>
<th>Emp Code</th>
<th>
Habit(s)
</th>
</tr>
<?php
$pid = getTableFieldValue('problem_master', 'pid', 'pcode', "'HBT'");
$sql = "";
if ($habit_id == 'All') {
$sql = "select group_concat(b.rvalue) as val, a.pid, a.patient_id,a.rid, group_concat(b.diagnosis_date) as diagnosis_dates from
problem_response a left join problem_response_details b ON a.rid = b.rid where
a.pid = '" . $pid . "' group by a.pid, a.patient_id, a.rid";
} else {
$sql = "select group_concat(b.rvalue) as val, a.pid, a.patient_id,a.rid, group_concat(b.diagnosis_date) as diagnosis_dates from
problem_response a left join problem_response_details b ON a.rid = b.rid where
a.pid = '" . $pid . "' and b.rvalue in ($habit_id) group by a.pid, a.patient_id, a.rid";
}
error_log("query to get habit " . $sql);
$result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($result)) {
?>
<tr>
<td><?= ++$count ?></td>
<td><?= getFieldFromTable('patient_name', 'patient_master', 'id', $row['patient_id']) ?></td>
<td><?= getFieldFromTable('emp_code', 'patient_master', 'id', $row['patient_id']) ?></td>
<td><?= ucwords(strtolower(getCommaSeperatedValuesForInClause("select habit from habits", 'habit_id', $row['val']))); ?></td>
</tr>
<?php } ?>
</table>
</body>
<script>
$(document).ready(function() {
window.print();
});
</script>