ohctech_p8/select_appointment_slots.php
2024-10-16 19:18:52 +05:30

39 lines
1.4 KiB
PHP

<?php
error_log("hello");
include('includes/config/config.php');
include('includes/functions.php');
include_once('log_entry.php');
$doc=$_REQUEST['doc'];
$date = $_REQUEST['appointment_book_date'];
$app_type=$_REQUEST["app_type"];
// $day= var_dump($date);
$sql = "SELECT DISTINCT(d.slot_id),TIME_FORMAT(slot, '%h:%i %p') as slot,TIME_FORMAT(slot_end, '%h:%i %p') as slot_end,d.status from doc_slots d left join appoinment_slots p on d.slot_id=p.slot_id where p.app_type='".$app_type."' and slot_date=str_to_date('".$date."','%Y-%m-%d') and d.ohc_type_id='".$_SESSION['current_ohcttype']."' and emp_id='".$doc."' ";
error_log($sql."select_slot");
if (!$result = @mysqli_query($conn,$sql)) {
exit(mysqli_error($conn));
}
$data = array();
while ($row = mysqli_fetch_assoc($result)) {
$sql_app = "SELECT count(*) as booked from appointment_details where date(date)=str_to_date('".$date."','%Y-%m-%d') and ohc_type_id='".$_SESSION['current_ohcttype']."' and time ='".$row['slot_id']."' and doctor_id='".$doc."'";
error_log($sql_app."select_slot");
if (!$result_app = @mysqli_query($conn,$sql_app)) {
exit(mysqli_error($conn));
}
while ($row_app = mysqli_fetch_assoc($result_app)) {
$row['slot_available']=getTableFieldValue('appoinment_slots','slot_count','slot_id',$row['slot_id'])-$row_app['booked'];
}
array_push($data, $row);
}
$data['count']=mysqli_num_rows($result);
error_log('data '.print_r($data,true));
echo json_encode($data);
?>