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

78 lines
2.6 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=habit_excel.xls");
header("Pragma: no-cache");
header("Expires: 0");
error_reporting(E_ERROR | E_PARSE);
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);
}
?>
<body>
<?php include('excel_ohc_header.php'); ?>
<table width="100%">
<tr>
<td style="font-size: 15px;"><strong style="margin-left: 400px"><?= $habit_name ?> Habit Report</strong></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>