82 lines
2.9 KiB
PHP
82 lines
2.9 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
$id = $_REQUEST['id'];
|
|
$ailment= getTableFieldValue('ailment_system', 'ailment_sys_name', 'ailment_sys_id',$id);
|
|
$xaxis = array('');
|
|
$xaxis1 = array('');
|
|
$xaxis2 = array('');
|
|
$opd = array('');
|
|
$opd1 = array('');
|
|
$opd2 = array('');
|
|
error_log("fff".$id);
|
|
$data= array();
|
|
for($i=15;$i>=0;$i--){
|
|
$query="SELECT COUNT(appointment_id) as count,date(NOW()-INTERVAL $i DAY) as date FROM employee_appointment WHERE DATE(appointment_date) = date(NOW()-INTERVAL $i DAY) AND APPOINTMENT_TYPE='O' and ailment_systems_new='".$id."'";
|
|
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
if(mysqli_num_rows($result) > 0) {
|
|
while ($row = @mysqli_fetch_array($result)) {
|
|
array_push($xaxis,date('d-m-Y',strtotime($row["date"])));
|
|
array_push($opd,$row['count']);
|
|
// error_log('dd2'.$row["date"]) ;
|
|
}
|
|
}
|
|
}
|
|
|
|
for($j=1;$j<=15;$j++){
|
|
$month=date('m')-$j;
|
|
|
|
if($month>0){
|
|
$query1="SELECT COUNT(appointment_id) , date(now()- INTERVAL $j month) FROM employee_appointment WHERE month(appointment_date) = '".$month."' and year(appointment_date) = year(now()) AND appointment_type='O' and ailment_systems_new='".$id."'";}
|
|
else {
|
|
$month= 12+$month;
|
|
$query1="SELECT COUNT(appointment_id) , date(now()- INTERVAL $j month) FROM employee_appointment WHERE month(appointment_date) = '".$month."' and year(appointment_date) = year(now())-1 AND appointment_type='O' and ailment_system_ids='".$id."' ";
|
|
}
|
|
error_log('mm'.$query1) ;
|
|
if (!$result1 = @mysqli_query($conn,$query1)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
if(mysqli_num_rows($result1) > 0) {
|
|
while ($row1 = @mysqli_fetch_array($result1)) {
|
|
|
|
$newDate = date("M-Y", strtotime($row1[1]));
|
|
array_push($xaxis1,$newDate);
|
|
|
|
array_push($opd1,$row1[0]);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
for($k=1;$k<=15;$k++){
|
|
$query2="SELECT COUNT(appointment_id) as count,date(NOW()-INTERVAL ($k*7) DAY) as date FROM employee_appointment WHERE DATE(appointment_date) BETWEEN date(NOW()-INTERVAL ($k*7) DAY) and date(NOW()-INTERVAL (($k-1)*7) DAY) AND APPOINTMENT_TYPE='O' and ailment_systems_new='".$id."'";
|
|
error_log('ww'.$query2) ;
|
|
if (!$result2 = @mysqli_query($conn,$query2)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
if(mysqli_num_rows($result2) > 0) {
|
|
while ($row2 = @mysqli_fetch_array($result2)) {
|
|
array_push($xaxis2,date('d-m-Y',strtotime($row2[1])));
|
|
array_push($opd2,$row2[0]);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$data = array(
|
|
'xaxis_day' => ($xaxis),
|
|
'opd_day' => ($opd),
|
|
'xaxis_month' => ($xaxis1),
|
|
'opd_month' => ($opd1),
|
|
'xaxis_week' => ($xaxis2),
|
|
'opd_week' => ($opd2),
|
|
'ailment'=>($ailment),
|
|
);
|
|
error_log("final data " . print_r($data, true));
|
|
$data=json_encode($data);
|
|
echo $data;
|
|
error_log("final data typr".print_r(gettype($data), true)); |