ESH/delete_booked_appointment.php

37 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2024-10-23 18:28:06 +05:30
<?php
include('includes/config/config.php');
$app_id=$_REQUEST['app_id'];
$status=$_REQUEST['status'];
if(!empty($app_id)){
$query_appointment="select *, DATE_FORMAT(date, '%Y-%m-%d') as date from appointment_details where id='".$app_id."' ";
$result_stock = @mysqli_query($conn,$query_appointment);
while($row_app=@mysqli_fetch_array($result_stock)){
$query_cancelled = "insert into cancelled_appointment_details set status='".$status."' , emp_id='".$row_app['emp_id']."' , doctor_id='".$row_app['doctor_id']."' , date=str_to_date('".$row_app['date']."','%Y-%m-%d') , time='".$row_app['time']."', ohc_type_id='".$row_app['ohc_type_id']."',app_type='".$row_app['app_type']."',modified_by = '".$_SESSION['user_id']."' ";
error_log('slote_cancelled '.$query_cancelled);
@mysqli_query($conn,$query_cancelled);
$query_slot = "update doc_slots set status='' where emp_id='".$row_app['doctor_id']."' and slot_date=str_to_date('".$row_app['date']."','%Y-%m-%d') and slot_id='".$row_app['time']."' and ohc_type_id='".$row_app['ohc_type_id']."' ";
error_log('slote_update '.$query_slot);
@mysqli_query($conn,$query_slot);
}
$query1="DELETE from appointment_details where id='".$app_id."'";
$result1 = @mysqli_query($conn,$query1);
if (!$result1) {
exit(mysqli_error($conn));
echo json_encode("FAILURE");
}else{
echo json_encode("SUCCESS");
}
}
?>