ESH/select_appointments.php

58 lines
1.9 KiB
PHP
Raw Permalink Normal View History

2024-10-23 18:28:06 +05:30
<?php
include('includes/config/config.php');
include('includes/functions.php');
include('log_entry.php');
$doc=$_REQUEST['app_doc'];
$doc_q='';
if($doc=='' || $doc==null){
$doc_q='';
}else{
$doc_q=" and doctor_id='".$doc."'";
}
$app_type=$_REQUEST['app_type'];
$app_type_q='';
if($app_type=='' || $app_type==null){
$app_type_q='';
}else{
$app_type_q=" and app_type='".$app_type."'";
}
$date=$_REQUEST['date'];
$sql = "SELECT * from appointment_details where date(date)=str_to_date('".$date."','%Y-%m-%d')".$app_type_q.$doc_q;
error_log('apps' . $sql);
$count=0;
$data=array();
$query = mysqli_query($conn, $sql);
while( $fetch = mysqli_fetch_assoc($query)){;
$count++;
if($fetch['status']=='BOOKED'){
$fetch['status'] = "<p> <font color=red>Pending</font> </p>";
}else if($fetch['status']=='DRP'){
$fetch['status'] = "<p> <font color=red>Pending</font> </p>";
}else if($fetch['status']=='DRA'){
$fetch['status'] = "<p> <font color=green>Completed</font> </p>";
}else if($fetch['status']=='CANCELLED'){
$fetch['status'] = "<p> <font color=red>Cancelled</font> </p>";
}
array_push($data ,array(
'id' => $fetch['id'],
'app_type' => $fetch['app_type'],
'status' => $fetch['status'],
'date' => date_format(date_create($fetch['date']), "d-m-Y ") ,
'patient_name' => getTableFieldValue('patient_master', 'patient_name', 'id', $fetch['emp_id']),
'doctor_name' => getTableFieldValue('patient_master', 'patient_name', 'id', $fetch['doctor_id']),
'time' => getCommaSeperatedValuesForInClause("select TIME_FORMAT(slot, '%h:%i %p') as slot from appoinment_slots ", "slot_id", $fetch['time']),
));
}
$data['count']=$count;
error_log('apps' . print_r($data, true));
echo json_encode($data);