104 lines
3.4 KiB
PHP
104 lines
3.4 KiB
PHP
<?php
|
|
// include('includes/config/config.php');
|
|
// include('includes/functions.php');
|
|
$xaxis = array();
|
|
|
|
$date = date("Y-m-d");
|
|
|
|
$default_start_date = date('Y-m-d', strtotime($date . ' -7 days'));
|
|
|
|
$default_end_date = date('Y-m-d', strtotime($date));
|
|
|
|
$dept_id = '1';
|
|
error_log("date ." . $default_start_date . " " . $default_end_date);
|
|
|
|
if (!empty($_POST['start_date'])) {
|
|
$default_start_date = date('Y-m-d', strtotime($_POST['start_date']));
|
|
}
|
|
if (!empty($_POST['end_date'])) {
|
|
$default_end_date = date('Y-m-d', strtotime($_POST['end_date']));
|
|
}
|
|
|
|
error_log("date after filter ." . $default_start_date . " " . $default_end_date);
|
|
|
|
$total_abnormality_name = array();
|
|
$total_abnormality_count = array();
|
|
|
|
$sql = "select * from abnormality";
|
|
$result = mysqli_query($conn, $sql);
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
array_push($total_abnormality_name, '"' . $row['abnormality_name'] . '"');
|
|
array_push($total_abnormality_count, $row['abnormality_id']);
|
|
// $total_abnormality_name[$row['checkup_type_name']] = $row['checkup_type_id'];
|
|
}
|
|
|
|
error_log("total medical " . print_r($total_abnormality_count, true));
|
|
|
|
$checkup_data = array();
|
|
$date_data = array();
|
|
for ($i = 0; $i < sizeof($total_abnormality_count); $i++) {
|
|
|
|
$query = "select count(appointment_id) from employee_appointment where date(appointment_date) >= '" . $default_start_date . "' and date(appointment_date) <= '" . $default_end_date . "' and (abnormalitys='$total_abnormality_count[$i]' or abnormalitys like '%,$total_abnormality_count[$i]%' or abnormalitys like '%,$total_abnormality_count[$i],%' or abnormalitys='%$total_abnormality_count[$i],%' ) and appointment_type='O' and department='" . $dept_id . "'";
|
|
|
|
error_log("error in opd chart abnormality with dept " . $query);
|
|
|
|
if (!$result = @mysqli_query($conn, $query)) {
|
|
error_log("error in opd chart abnormality with dept " . mysqli_error($conn));
|
|
exit();
|
|
}
|
|
if (mysqli_num_rows($result) > 0) {
|
|
while ($row = @mysqli_fetch_array($result)) {
|
|
array_push($checkup_data, $row[0]);
|
|
// array_push($date_data, $row[1]);
|
|
}
|
|
} else {
|
|
array_push($checkup_data, 0);
|
|
}
|
|
}
|
|
error_log("opd abnormality data trend " . print_r($checkup_data, true));
|
|
?>
|
|
|
|
|
|
<script>
|
|
var ctx = document.getElementById('opdAbnDeptChart').getContext('2d');
|
|
var chartData = [<?php echo join(',', $checkup_data); ?>];
|
|
var xaxis = [<?php echo join(',', $total_abnormality_name); ?>];
|
|
// var label = [<?php echo join(',', $date_data); ?>];
|
|
|
|
var colors = [];
|
|
for (var i = 0; i < chartData.length; i++) {
|
|
colors.push("#" + Math.floor(Math.random() * 16777215).toString(16));
|
|
}
|
|
var dataset = [];
|
|
// for (var i = 0; i < chartData.length; i++) {
|
|
dataset.push({
|
|
label: "count",
|
|
data: chartData,
|
|
borderColor: colors,
|
|
backgroundColor: colors,
|
|
fill: false,
|
|
});
|
|
// }
|
|
|
|
var data = {
|
|
labels: xaxis,
|
|
datasets: dataset
|
|
}
|
|
var myChart = new Chart(ctx, {
|
|
type: 'horizontalBar',
|
|
data: data,
|
|
options: {
|
|
legend: {
|
|
display: false
|
|
},
|
|
scales: {
|
|
xAxes: [{
|
|
ticks: {
|
|
beginAtZero: true,
|
|
precision: 0,
|
|
}
|
|
}]
|
|
}
|
|
}
|
|
});
|
|
</script>
|