<?php
    date_default_timezone_set("Asia/Riyadh");
    $conn = mysqli_connect("localhost","nuvento_timeout","Golden_123","nuvento_timeout");
    if($conn->connect_error){
        return;
    }
    $todate = date('Y-m-d');
    $date_time = date('Y-m-d H:i:s',strtotime('- 15 minutes'));

    $sql = "UPDATE booking
            INNER JOIN event_date_time ON event_date_time.id = booking.event_date_id
            SET booking.status = '2'
            WHERE event_date_time.date < '$todate' and event_date_time.time < 'now()' and booking.status='1'";
    $result = mysqli_query($conn, $sql);


    $sql = "UPDATE booking
            INNER JOIN transaction ON transaction.booking_id = booking.bookId
            SET booking.status = '5',transaction.status='3'
            WHERE transaction.datetime<'$date_time'";
    mysqli_query($conn, $sql);

    $conn->close();
?>
