80 lines
2.2 KiB
PHP
80 lines
2.2 KiB
PHP
<?php
|
|
include('log_entry.php');
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
$label = array();
|
|
$data = array();
|
|
$v = array();
|
|
$colors = array(
|
|
"#FF7733",
|
|
"#F6FF33",
|
|
"#33FFDF",
|
|
"#334BFF"
|
|
);
|
|
$backColor = array();
|
|
function isBinary(string $string): bool
|
|
{
|
|
if (strpos($string, ".") === FALSE) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
$date = date("Y-m-d");
|
|
|
|
$default_start_date = date('Y-m-d', strtotime($date . ' -30 days'));
|
|
|
|
$default_end_date = date('Y-m-d', strtotime($date));
|
|
$dept_id = "";
|
|
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);
|
|
|
|
$sql = "select * from ailment";
|
|
$result = mysqli_query($conn, $sql);
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$ailment_id = $row['ailment_id'];
|
|
|
|
$sql_query = "select count(appointment_id) as count from employee_appointment where date(appointment_date) >= '" . $default_start_date . "' and date(appointment_date) <= '" . $default_end_date . "' and (ailments_new='$ailment_id' or ailments_new like '%,$ailment_id%' or ailments_new like '%$ailment_id,%' or ailments_new like '%,$ailment_id,%') ";
|
|
|
|
|
|
$result_query = mysqli_query($conn, $sql_query);
|
|
|
|
$row_query = mysqli_fetch_assoc($result_query);
|
|
|
|
$data[$ailment_id] = $row_query['count'];
|
|
array_push($backColor, $colors[$i]);
|
|
|
|
|
|
// error_log("in diagnosis chart" . $data . " " . ($row_query['count']));
|
|
// $v = $data;
|
|
}
|
|
arsort($data);
|
|
$val = array();
|
|
|
|
$keys = array_keys($data);
|
|
|
|
error_log("all keys ." . print_r($keys, true));
|
|
|
|
for ($i = 0; $i < 10; $i++) {
|
|
// $val[$i] = $data[$keys[$i]];
|
|
array_push($val, $data[$keys[$i]]);
|
|
$label[$i] = getFieldFromTable('ailment_name', 'ailment', 'ailment_id', $keys[$i]);
|
|
}
|
|
error_log("whole data " . print_r($data, true));
|
|
|
|
error_log("refined data " . print_r($val, true));
|
|
|
|
$data = array(
|
|
'checkup_data' => ($val),
|
|
'diag_name' => ($label),
|
|
);
|
|
echo json_encode($data);
|