<?php
include __DIR__ . '/config/koneksi.php';
date_default_timezone_set('Asia/Jakarta');
$now = date('Y-m-d H:i:s');
$sql = "SELECT * FROM pemesanan WHERE status='pending' AND batas_bayar < '$now'";
$q = mysqli_query($conn, $sql);
while($row = mysqli_fetch_assoc($q)) {
    $id_pemesanan = $row['id'];
    $id_kamar = $row['id_kamar'];
    // Update status pemesanan
    mysqli_query($conn, "UPDATE pemesanan SET status='expired' WHERE id=$id_pemesanan");
    // Update status kamar
    mysqli_query($conn, "UPDATE kamar SET status='tersedia' WHERE id=$id_kamar");
} 