require('config.php'); require('auth.php'); // Date Configuration $ramadanStart = '2026-02-17'; $ramadanEnd = date('Y-m-d', strtotime($ramadanStart . ' + 30 days')); $today = date('Y-m-d'); // If today is past the start date, users can't book yesterday. // If today is before start date, booking starts from Ramadan start. $minDate = ($today > $ramadanStart) ? $today : $ramadanStart; $maxDate = $ramadanEnd; $menu_items = ORM::for_table('menu_items')->find_many(); $items = []; foreach ($menu_items as $item) { $items[$item->category][] = $item->name; } if (isset($items['Dips'])) { if (!in_array('two', $items['Dips'])) { $items['Dips'][] = 'two'; } } if (!empty($_POST)) { if (!empty($_POST['name'])) { $order = ORM::for_table('orders')->create(); $order->name = $_POST['name']; $order->email = $_POST['email']; $order->branch = $_POST['Branch']; // $order->location = $_POST['location']; $order->date = str_replace('T', ' ', $_POST['date']); $order->phone = $_POST['phone']; $order->pax = $_POST['pax']; $order->staff_name = $_POST['staff_name'] ?? 'Other'; $order->created_at = date("Y-m-d H:i"); $order->save(); log_activity('create_order', "Order #{$order->id} created for {$_POST['name']}", $_POST['staff_name']); } else { $order_id = $_POST['id']; $order = ORM::for_table('orders')->where('id', $_POST['id'])->find_one(); //$_POST['id'] if ($order) { $data = []; foreach ($_POST as $type => $item) { if (is_array($item)) { foreach ($item as $name) { $data[$type][$name] = [ 'count' => $_POST[str_replace(" ", "_", $name) . '_count'], 'comment' => $_POST[str_replace(" ", "_", $name) . '_comment'], ]; } } } $order->items = json_encode($data); $order->note = $_POST['note']; $order->save(); log_activity('update_menu', "Menu items updated for Order #{$order->id}"); $sucess = true; $mail_success = mail($mailTo, utf8_decode($subject), utf8_decode($body), $headers); } else { $err = "Sorry Cant Get Your Information Please Try Again From the Start"; } } } $final_pax = 0; if (@$order) { if (@$order->pax) { $final_pax = $order->pax; } } ?>