<?php
 error_reporting(E_ERROR | E_PARSE);
 include ('includes/config/config.php');
 include ('includes/functions.php');
 include('log_entry.php');

begin();

    $query = "select * from employee_appointment where `ticket_no` like 'OPD%'and date(appointment_date)=CURRENT_DATE() ";


error_log("sql " . $query);
if (!$result = @mysqli_query($conn,$query)) {
    rollback();
    die(mysqli_error($conn));
}
$data = array();
$i=13418;
if(mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
   $i++;
    $sql =" update  employee_appointment  SET ticket_no=concat('OPD-','".$i."','-2023') where appointment_id='".$row['appointment_id']."' ";
    error_log('----'.$sql);
    if (!$result_sql = @mysqli_query($conn,$sql)) {
        rollback();
        die(mysqli_error($conn));
}

}
$data['status'] = "succes";
$data['message'] = "Assign menu done!";
}
else
{
$data['status'] = 200;
$data['message'] = "Data not found!";
}

commit();
echo json_encode($data);

?>