271 lines
8.5 KiB
PHP
271 lines
8.5 KiB
PHP
<?php
|
|
|
|
$checkUpTypeid = getFieldFromTable("checkup_type_id", "checkup_type", "checkup_type_code", "Statutory_Medical_Checkup");
|
|
|
|
if (isset($_REQUEST['health_index_year'])) {
|
|
|
|
$first_array = array();
|
|
$second_array = array();
|
|
$three_array = array();
|
|
$four_array = array();
|
|
$five_array = array();
|
|
$six_array = array();
|
|
|
|
$FirstCheckupId = array();
|
|
$SecondCheckupId = array();
|
|
$ThirdCheckupId = array();
|
|
$FourthCheckupId = array();
|
|
$FiveCheckupId = array();
|
|
$SixCheckupId = array();
|
|
|
|
$Gender_Array = array();
|
|
$AllEmpid = array();
|
|
|
|
for ($i = 1; $i <= 12; $i++) {
|
|
|
|
$sqlCheckUpForm = "SELECT score as health_index , emp_id , checkup_id FROM health_index WHERE checkup_type_id = '" . $checkUpTypeid . "' AND MONTH(date) = '" . $i . "' AND YEAR(date) = '" . $_REQUEST['health_index_year'] . "' AND (score != '' AND score != '0') ";
|
|
|
|
|
|
error_log("Fetch Health Index YEAR " . $sqlCheckUpForm);
|
|
|
|
|
|
$resultCheckUpForm = mysqli_query($conn, $sqlCheckUpForm);
|
|
$first = 0;
|
|
$second = 0;
|
|
$third = 0;
|
|
$fourth = 0;
|
|
$five = 0;
|
|
$six = 0;
|
|
|
|
while ($row = mysqli_fetch_array($resultCheckUpForm)) {
|
|
|
|
$healthIndexArray[] = $row['health_index'];
|
|
// if ($row['health_index'] >= 0) {
|
|
|
|
// $AllEmpid[] = $row['emp_id'];
|
|
// }
|
|
|
|
|
|
// $Gender_Array[$row['emp_id']] = getFieldFromTable('gender' , 'patient_master' , 'id' , $row['emp_id']);
|
|
|
|
if ($row['health_index'] >= 0 && $row['health_index'] <= 1) {
|
|
$first++;
|
|
$first_array[] = $row['emp_id'];
|
|
$FirstCheckupId[] = $row['checkup_id'];
|
|
|
|
} elseif ($row['health_index'] > 1 && $row['health_index'] <= 2) {
|
|
|
|
$second++;
|
|
$second_array[] = $row['emp_id'];
|
|
$SecondCheckupId[] = $row['checkup_id'];
|
|
|
|
} elseif ($row['health_index'] > 2 && $row['health_index'] <= 3) {
|
|
|
|
$third++;
|
|
$three_array[] = $row['emp_id'];
|
|
$ThirdCheckupId[] = $row['checkup_id'];
|
|
|
|
} elseif ($row['health_index'] > 3 && $row['health_index'] <= 4) {
|
|
|
|
$fourth++;
|
|
$four_array[] = $row['emp_id'];
|
|
$FourthCheckupId[] = $row['checkup_id'];
|
|
|
|
} elseif ($row['health_index'] > 4 && $row['health_index'] <= 5) {
|
|
|
|
$five++;
|
|
$five_array[] = $row['emp_id'];
|
|
$FiveCheckupId[] = $row['checkup_id'];
|
|
|
|
} elseif ($row['health_index'] > 6 && $row['health_index'] <= 7) {
|
|
$six++;
|
|
$six_array[] = $row['emp_id'];
|
|
$SixCheckupId[] = $row['checkup_id'];
|
|
|
|
} else {
|
|
continue;
|
|
}
|
|
|
|
// error_log("HEALTH 3 " . $third);
|
|
// error_log("HEALTH 4 " . $fourth);
|
|
|
|
}
|
|
error_log("HEALTH FIRST " . $first);
|
|
error_log("HEALTH 2 " . $second);
|
|
$month = date("F", mktime(0, 0, 0, $i, 10));
|
|
|
|
$healthIndexTrendData[$month] = ['1' => $first, '2' => $second, '3' => $third, '4' => $fourth, '5' => $five, '6' => $six];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
<style>
|
|
.cardDushant {
|
|
background-color: #fff;
|
|
/* White background */
|
|
border-radius: 8px;
|
|
/* Rounded corners */
|
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
|
/* Shadow */
|
|
|
|
|
|
/* Maximum width */
|
|
transition: box-shadow 0.3s ease;
|
|
/* Smooth transition for hover effect */
|
|
}
|
|
|
|
.cardDushant:hover {
|
|
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
|
|
/* Darker shadow on hover */
|
|
}
|
|
</style>
|
|
|
|
<div class="cardDushant">
|
|
<canvas id="healthIndexAllDataChart" width="100%" height="70%"></canvas>
|
|
<?php
|
|
|
|
|
|
// Process trend data for Chart.js
|
|
$Labels = json_encode(array_keys($healthIndexTrendData));
|
|
$trendData1 = json_encode(array_column($healthIndexTrendData, '1'));
|
|
$trendData2 = json_encode(array_column($healthIndexTrendData, '2'));
|
|
$trendData3 = json_encode(array_column($healthIndexTrendData, '3'));
|
|
$trendData4 = json_encode(array_column($healthIndexTrendData, '4'));
|
|
$trendData5 = json_encode(array_column($healthIndexTrendData, '5'));
|
|
$trendData6 = json_encode(array_column($healthIndexTrendData, '6'));
|
|
?>
|
|
|
|
<script>
|
|
var ctx = document.getElementById('healthIndexAllDataChart').getContext('2d');
|
|
var gradient = ctx.createLinearGradient(0, 0, 0, 400);
|
|
gradient.addColorStop(0, 'rgba(255, 0, 0, 0.5)');
|
|
gradient.addColorStop(1, 'rgba(255, 0, 0, 0)');
|
|
|
|
var healthIndexAllDataChart = new Chart(ctx, {
|
|
type: 'line',
|
|
data: {
|
|
labels: <?php echo $Labels; ?>,
|
|
datasets: [
|
|
{
|
|
label: 'Very poor health',
|
|
data: <?php echo $trendData1; ?>,
|
|
borderColor: '#ff0000',
|
|
backgroundColor: gradient,
|
|
fill: false,
|
|
tension: 0.4,
|
|
pointStyle: 'circle',
|
|
pointRadius: 5,
|
|
pointHoverRadius: 7
|
|
},
|
|
{
|
|
label: 'Poor health',
|
|
data: <?php echo $trendData2; ?>,
|
|
borderColor: '#ff5733',
|
|
backgroundColor: 'rgba(255, 87, 51, 0.2)',
|
|
fill: false,
|
|
tension: 0.4,
|
|
pointStyle: 'circle',
|
|
pointRadius: 5,
|
|
pointHoverRadius: 7
|
|
},
|
|
{
|
|
label: 'Below average health',
|
|
data: <?php echo $trendData3; ?>,
|
|
borderColor: '#f4b183',
|
|
backgroundColor: 'rgba(244, 177, 131, 0.2)',
|
|
fill: false,
|
|
tension: 0.4,
|
|
pointStyle: 'circle',
|
|
pointRadius: 5,
|
|
pointHoverRadius: 7
|
|
},
|
|
{
|
|
label: 'Average health',
|
|
data: <?php echo $trendData4; ?>,
|
|
borderColor: '#9dc3e6',
|
|
backgroundColor: 'rgba(157, 195, 230, 0.2)',
|
|
fill: false,
|
|
tension: 0.4,
|
|
pointStyle: 'circle',
|
|
pointRadius: 5,
|
|
pointHoverRadius: 7
|
|
},
|
|
{
|
|
label: 'Good Health',
|
|
data: <?php echo $trendData5; ?>,
|
|
borderColor: '#92d050',
|
|
backgroundColor: 'rgba(146, 208, 80, 0.2)',
|
|
fill: false,
|
|
tension: 0.4,
|
|
pointStyle: 'circle',
|
|
pointRadius: 5,
|
|
pointHoverRadius: 7
|
|
},
|
|
{
|
|
label: 'Excellent health',
|
|
data: <?php echo $trendData6; ?>,
|
|
borderColor: '#00b050',
|
|
backgroundColor: 'rgba(0, 176, 80, 0.2)',
|
|
fill: false,
|
|
tension: 0.4,
|
|
pointStyle: 'circle',
|
|
pointRadius: 5,
|
|
pointHoverRadius: 7
|
|
}
|
|
]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
plugins: {
|
|
legend: {
|
|
position: 'top',
|
|
labels: {
|
|
font: {
|
|
size: 14
|
|
},
|
|
padding: 20
|
|
}
|
|
},
|
|
tooltip: {
|
|
backgroundColor: 'rgba(0,0,0,0.7)',
|
|
titleFont: {
|
|
size: 16
|
|
},
|
|
bodyFont: {
|
|
size: 14
|
|
},
|
|
padding: 10,
|
|
cornerRadius: 5
|
|
}
|
|
},
|
|
scales: {
|
|
x: {
|
|
grid: {
|
|
display: false
|
|
},
|
|
ticks: {
|
|
font: {
|
|
size: 12
|
|
}
|
|
}
|
|
},
|
|
y: {
|
|
grid: {
|
|
color: 'rgba(200, 200, 200, 0.2)'
|
|
},
|
|
ticks: {
|
|
font: {
|
|
size: 12
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
</div>
|