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

144 lines
6.4 KiB
PHP

<?php //include('pdf_header.php');
include('includes/config/config.php');
include('includes/functions.php');
//include('pop_up_top.php');
header('Content-Type: application/force-download');
header('Content-disposition: attachment; filename=Pre_post_wellness_report.xls');
$emp_id = $_POST['empName'];
$pro_schedule_id = $_POST['pro_id'];
error_log("emp id " . $emp_id . " program schedule id " . $pro_schedule_id);
?>
<html>
<head>
<style>
* {
font-family: sans-serif;
}
</style>
<link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include('excel_ohc_header.php') ?>
<table width="100%">
<tr>
<th colspan="4">
<h1>Pre & Post Wellness Program comparison Report</h1>
</th>
</tr>
</table>
<br>
<?php
$param_name = array();
$pre_param_value = array();
$post_param_value = array();
?>
<div class="container">
<div class="row">
<div class="col-sm-4">
<?php
// $query = "select * from checkup_form where emp_id = '" . $emp_id . "' and program_id='" . $pro_schedule_id . "'";
// $result = @mysqli_query($conn, $query);
// $row = @mysqli_fetch_assoc($result);
// $param_query = "select checkup_form_key from checkup_form_key_value where checkup_form_id='" . $row['checkup_id'] . "' order by checkup_form_key";
// $param_result = @mysqli_query($conn, $param_query);
// while ($row_param = @mysqli_fetch_assoc($param_result)) {
// array_push($param_name, getFieldFromTable('parameter_name', 'checkup_parameter', 'column_name', $row_param['checkup_form_key']));
// }
?>
</div>
<div class="col-sm-4">
<?php
$query = "select * from checkup_form where emp_id = '" . $emp_id . "' and program_id='" . $pro_schedule_id . "' and program_status='N'";
$result = @mysqli_query($conn, $query);
$row = @mysqli_fetch_assoc($result);
$checkup_section_ids = $row['checkup_section_ids'];
$param_present = (explode(',', $row['checkup_section_ids']));
$param_present = array_unique($param_present);
foreach ($param_present as $x => $val) {
$param_query = "select a.*,b.* from checkup_form_key_value a left join checkup_parameter b on a.checkup_form_key = b.column_name where a.checkup_form_id = '" . $row['checkup_id'] . "' and checkup_form_section_id = '$val'";
$param_result = @mysqli_query($conn, $param_query);
while ($row_param = @mysqli_fetch_assoc($param_result)) {
array_push($param_name, $row_param['parameter_name']);
if ($row_param['input_type'] == 'select') {
array_push($pre_param_value, getFieldFromTable('parameter_value_name', 'checkup_parameter_value', 'parameter_value_id', $row_param['checkup_form_value']));
} else if ($row_param['input_type'] == 'multiselect') {
array_push($pre_param_value, getCommaSeperatedValuesForInClause("select parameter_value_name from checkup_parameter_value", 'parameter_value_id', $row_param['checkup_form_value']));
} else {
array_push($pre_param_value, $row_param['checkup_form_value']);
}
}
}
?>
</div>
<div class="col-sm-4">
<?php
$query = "select * from checkup_form where emp_id = '" . $emp_id . "' and program_id='" . $pro_schedule_id . "' and program_status='Y'";
$result = @mysqli_query($conn, $query);
$row = @mysqli_fetch_assoc($result);
$checkup_section_ids = $row['checkup_section_ids'];
$param_present = (explode(',', $row['checkup_section_ids']));
$param_present = array_unique($param_present);
foreach ($param_present as $x => $val) {
$param_query = "select a.*,b.* from checkup_form_key_value a left join checkup_parameter b on a.checkup_form_key = b.column_name where a.checkup_form_id = '" . $row['checkup_id'] . "' and checkup_form_section_id = '$val'";
$param_result = @mysqli_query($conn, $param_query);
while ($row_param = @mysqli_fetch_assoc($param_result)) {
if ($row_param['input_type'] == 'select') {
array_push($post_param_value, getFieldFromTable('parameter_value_name', 'checkup_parameter_value', 'parameter_value_id', $row_param['checkup_form_value']));
} else if ($row_param['input_type'] == 'multiselect') {
array_push($post_param_value, getCommaSeperatedValuesForInClause("select parameter_value_name from checkup_parameter_value", 'parameter_value_id', $row_param['checkup_form_value']));
} else {
array_push($post_param_value, $row_param['checkup_form_value']);
}
}
}
?>
</div>
<table border="1" width="100%">
<tr>
<th>Sr No.</th>
<th>Key Parameter Name</th>
<th>
Pre Program Parameter Value
</th>
<th>
Post Program Parameter Value
</th>
</tr>
<?php
error_log("name " . print_r($param_name, true));
error_log("name " . print_r($pre_param_value, true));
error_log("name " . print_r($post_param_value, true));
for ($i = 0; $i < sizeof($param_name); $i++) {
?>
<tr>
<td width="4%"><?= ++$count ?></td>
<td width="40%"><?= $param_name[$i] ?></td>
<td width="28%"><?= $pre_param_value[$i] ?></td>
<td width="28%"><?= $post_param_value[$i] ?></td>
</tr>
<?php
}
?>
</table>
</div>
</div>
</body>
</html>