Editando: manage_menu.php
<?php include('db.php'); $current_hour = (int)date('H'); $today = date('Y-m-d'); $default_menu_date = ($current_hour >= 15) ? date('Y-m-d', strtotime('+1 day')) : $today; $view_date = isset($_GET['date']) ? mysqli_real_escape_string($conn, $_GET['date']) : $default_menu_date; $message = ""; // 1. అప్డేట్ లాజిక్ (Curries) if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update_lunch'])) { $item1 = mysqli_real_escape_string($conn, $_POST['item1'] ?? ''); $item2 = mysqli_real_escape_string($conn, $_POST['item2'] ?? ''); $item3 = mysqli_real_escape_string($conn, $_POST['item3'] ?? ''); $item4 = mysqli_real_escape_string($conn, $_POST['item4'] ?? ''); $millets = mysqli_real_escape_string($conn, $_POST['item_millets'] ?? ''); $prasadam = mysqli_real_escape_string($conn, $_POST['item_prasadam'] ?? ''); $delivery_time = mysqli_real_escape_string($conn, $_POST['delivery_time'] ?? ''); $menu_for_date = mysqli_real_escape_string($conn, $_POST['lunch_menu_date'] ?? $view_date); if(empty($menu_for_date)) $menu_for_date = $view_date; $check = mysqli_query($conn, "SELECT id FROM daily_menu WHERE section_name='Lunch' AND menu_date='$menu_for_date'"); if (mysqli_num_rows($check) > 0) { $sql = "UPDATE daily_menu SET item_1='$item1', item_2='$item2', item_3='$item3', item_4='$item4', item_millets='$millets', item_prasadam='$prasadam', delivery_time='$delivery_time' WHERE section_name='Lunch' AND menu_date='$menu_for_date'"; } else { $sql = "INSERT INTO daily_menu (section_name, menu_date, item_1, item_2, item_3, item_4, item_millets, item_prasadam, delivery_time) VALUES ('Lunch', '$menu_for_date', '$item1', '$item2', '$item3', '$item4', '$millets', '$prasadam', '$delivery_time')"; } if (mysqli_query($conn, $sql)) { $message = "<div class='alert success'>Curries Menu Updated for " . date('d M Y', strtotime($menu_for_date)) . "! ✅</div>"; } else { $message = "<div class='alert error'>Error: " . mysqli_error($conn) . "</div>"; } } // 2. అప్డేట్ లాజిక్ (Rice) if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update_rice'])) { $item1 = mysqli_real_escape_string($conn, $_POST['rice_item1'] ?? ''); $item2 = mysqli_real_escape_string($conn, $_POST['rice_item2'] ?? ''); $item3 = mysqli_real_escape_string($conn, $_POST['rice_item3'] ?? ''); $item4 = mysqli_real_escape_string($conn, $_POST['rice_item4'] ?? ''); $item5 = mysqli_real_escape_string($conn, $_POST['rice_item_rice'] ?? ''); $millets = mysqli_real_escape_string($conn, $_POST['rice_item_millets'] ?? ''); $prasadam = mysqli_real_escape_string($conn, $_POST['rice_item_prasadam'] ?? ''); $delivery_time = mysqli_real_escape_string($conn, $_POST['delivery_time'] ?? ''); $menu_for_date = mysqli_real_escape_string($conn, $_POST['rice_menu_date'] ?? $view_date); if(empty($menu_for_date)) $menu_for_date = $view_date; $check = mysqli_query($conn, "SELECT id FROM daily_menu WHERE section_name='Rice' AND menu_date='$menu_for_date'"); if (mysqli_num_rows($check) > 0) { $sql = "UPDATE daily_menu SET item_1='$item1', item_2='$item2', item_3='$item3', item_4='$item4', item_5='$item5', item_millets='$millets', item_prasadam='$prasadam', delivery_time='$delivery_time' WHERE section_name='Rice' AND menu_date='$menu_for_date'"; } else { $sql = "INSERT INTO daily_menu (section_name, menu_date, item_1, item_2, item_3, item_4, item_5, item_millets, item_prasadam, delivery_time) VALUES ('Rice', '$menu_for_date', '$item1', '$item2', '$item3', '$item4', '$item5', '$millets', '$prasadam', '$delivery_time')"; } if (mysqli_query($conn, $sql)) { $message = "<div class='alert success'>Rice Menu Updated for " . date('d M Y', strtotime($menu_for_date)) . "! ✅</div>"; } else { $message = "<div class='alert error'>Error: " . mysqli_error($conn) . "</div>"; } } // డేటా తీసుకోవడం (Curries) $res = mysqli_query($conn, "SELECT * FROM daily_menu WHERE section_name='Lunch' AND menu_date='$view_date'"); $lunch = $res ? mysqli_fetch_assoc($res) : null; if (!$lunch) { $lunch = ['item_1'=>'','item_2'=>'','item_3'=>'','item_4'=>'','item_millets'=>'','item_prasadam'=>'','delivery_time'=>'','menu_date'=>$view_date]; } // డేటా తీసుకోవడం (Rice) $res_rice = mysqli_query($conn, "SELECT * FROM daily_menu WHERE section_name='Rice' AND menu_date='$view_date'"); $rice = $res_rice ? mysqli_fetch_assoc($res_rice) : null; if (!$rice) { $rice = ['item_1'=>'','item_2'=>'','item_3'=>'','item_4'=>'','item_5'=>'','item_millets'=>'','item_prasadam'=>'','delivery_time'=>'','menu_date'=>$view_date]; } // ── Static fallback lists ────────────────────────────────────────────────── // These are used ONLY if the database has no entries for a category yet. // Once items are saved via "Add New", the DB list takes over automatically. $static_pappu = [ 'ముద్ద పప్పు / Mudda Pappu', 'టమాటో పప్పు / Tomato Pappu', 'మామిడికాయ పప్పు / Mamidikaya Pappu', 'దోసకాయ పప్పు / Dosakaya Pappu', 'తోటకూర పప్పు / Thotakura Pappu', 'పాలకూర పప్పు / Palakura Pappu', 'చుక్కకూర పప్పు / Chukkakura Pappu', 'మెంతికూర పప్పు / MenthiKura Pappu', 'గోంగూర పప్పు / Gongura Pappu', 'చింతచిగురు పప్పు / ChinthaChiguru Pappu', 'ఆనపకాయ పప్పు / Aanapakaya Pappu', 'వక్కాయ పప్పు / Vakkaya Pappu', 'క్యాబేజీ పప్పు / Cabbage Pappu', 'సాదా ముద్ద పెసరపప్పు / Normal Mudda Pesarapappu', ]; $static_liquid = [ 'చారు / Charu', 'మిరియాలు చారు / Miriyala Charu', 'బెండకాయ చారు / Bendakaya Charu', 'రసం / Rasam', 'సాంబార్ / Sambar', 'ముక్కల పులుసు / Mukkala Pulusu', 'ఉల్లిపాయ పులుసు / Onion Pulusu', 'తోటకూర ఆవ పులుసు / Thotakura Aava Pulusu', 'మజ్జిగ పులుసు / Majjiga Pulusu', 'పెసర పునుగుల మజ్జిగ పులుసు / Pesara Punugula Majjiga Pulusu', 'మెంతి మజ్జిగ / Menthi Majjiga', 'పచ్చి పులుసు / Pachi Pulusu', ]; $static_pachadi = [ 'కొబ్బరికాయ పచ్చడి / Coconut Pachadi', 'కొబ్బరి, కొత్తిమీర పచ్చడి / Coconut, Coriander Pachadi', 'కొబ్బరి, మామిడికాయ పచ్చడి / Coconut, Raw Mango Pachadi', 'కొబ్బరి, చింతకాయ పచ్చడి / Coconut, Raw Tamarind Pachadi', 'దొండకాయ పచ్చడి / Dondakaya Pachadi', 'ఆనపకాయ పచ్చడి / Aanapakaya Pachadi', 'క్యాబేజీ పచ్చడి / Cabbage Pachadi', 'వంకాయ రోటీ పచ్చడి / Vankaya Roti Pachadi', 'టమాటో రోటీ పచ్చడి / Tomato Roti Pachadi', 'పచ్చి చింతకాయ పచ్చడి / Pachi Chinthakaya Pachadi', 'వక్కాయ రోటీ పచ్చడి / Vakkaya Roti Pachadi', 'కొత్తిమీర రోటీ పచ్చడి / Kothimeera Roti Pachadi', 'బీరకాయ రోటీ పచ్చడి / Birakaya Roti Pachadi', 'అల్లం చట్నీ / Ginger Chutney', 'పల్లీ చట్నీ / Groundnut Chutney', 'నువ్వు పప్పు పచ్చడి / Nuvvula Pachadi', ]; $static_curry = [ 'వంకాయ టమాటో ముద్ద కూర / Vankaya Tomato Mudda Curry', 'వంకాయ బంగాళాదుంప బఠాణి ముద్ద కూర / Vankaya Potato Batani Mudda Curry', 'గుత్తి వంకాయ మెంతి కారం కూర / Gutthi Vankaya Menthi Karam Curry', 'గుత్తి వంకాయ కొత్తిమీర కారం కూర / Gutthi Vankaya Kothimeera Karam Curry', 'గుత్తి వంకాయ ఉల్లికారం కూర / Gutthi Vankaya Onion Karam Curry', 'కందా బచ్చలి ఆవ కూర / Kanda Bachali Aava Curry', 'పనస పొట్టు పులిహోర పోపు కూర / Panasapottu Pulihora Popu Curry', 'పనస పొట్టు ఆవ కూర / Panasapottu Aava Curry', 'క్యాబేజీ క్యారెట్ కొబ్బరి కూర / Cabbage Carrot Coconut Curry', 'క్యాబేజీ పలుకులు పకోడీ ఫ్రై / Cabbage Groundnuts Pakodi Fry', 'క్యాలీఫ్లవర్ టమాటో కూర / Cauliflower Tomato Curry', 'క్యాలీఫ్లవర్ పలుకులు పకోడీ ఫ్రై / Cauliflower Groundnuts Pakodi Fry', 'ములక్కాడ టమాటో కూర / Mulakkada Tomato Curry', 'బర్బాటి టమాటో కూర / Barbaati Tomato Curry', 'ఆనపకాయ నువ్వు పొడి కూర / Aanapakaya Nuvvu Podi Curry', 'ఆనపకాయ ఆవ కూర / Aanapakaya Aava Curry', 'ఆనపకాయ టమాటో కూర / Aanapakaya Tomato Curry', 'బీరకాయ టమాటో కూర / Birakaya Tomato Curry', 'బీరకాయ శనగపప్పు కూర / Birakaya Sanagapappu Curry', 'బీరకాయ నువ్వు పొడి కూర / Birakaya Nuvvu Podi Curry', 'కాకరకాయ ఉల్లికారం కూర / Kakarakaya Onion Karam Curry', 'కాకరకాయ ఉల్లిపాయ వేపుడు కూర / Kakarakaya Onion Fry Curry', 'బంగాళాదుంప సాదా వేపుడు కూర / Potato Normal Fry Curry', 'బంగాళాదుంప పలుకులు పకోడీ ఫ్రై / Potato Groundnuts Pakodi Fry', 'బంగాళాదుంప ఉప్మా కూర / Potato Upma Curry', 'బంగాళాదుంప బఠాణి కుర్మా కూర / Potato Green Peas Kurma Curry', 'బంగాళాదుంప చోలే కుర్మా కూర / Potato Chole Kurma Curry', 'బీట్రూట్ క్యారెట్ కూర / Beetroot Carrot Curry', 'క్యారెట్ కొబ్బరి కూర / Carrot Coconut Curry', 'బీన్స్ కొబ్బరి కూర / Beans Coconut Curry', 'దొండకాయ టమాటో కూర / Dondakaya Tomato Curry', 'దొండకాయ కొబ్బరి కూర / Dondakaya Kobbari Curry', 'దొండకాయ కొత్తిమీర కారం కూర / Dondakaya Kothimeera Karam Curry', 'దొండకాయ పలుకులు పకోడీ ఫ్రై / Dondakaya Groundnuts Pakodi Fry', 'గోరుచిక్కుడు కాయలు కొబ్బరి కూర / Goruchikkudulu Kobbari Curry', 'గోరుచిక్కుడు కాయలు టమాటో కూర / Goruchikkudukayalu Tomato Curry', 'అరటికాయ వేపుడు కూర / Aritikaya Fry Curry', 'అరటికాయ ఆవ కూర / Aritikaya Aava Curry', 'బెండకాయ టమాటో కూర / Bendakaya Tomato Curry', 'బెండకాయ సాదా వేపుడు / Bendakaya Normal Fry', 'బెండకాయ పలుకులు పకోడీ ఫ్రై / Bendakaya Groundnuts Pakodi Fry', 'దేముడు చిక్కుడు టమాటో కూర / Demudu Chikkudu Tomato Curry', 'చామదుంపల వేపుడు / Chamadhumpalu Fry', 'పొటల్స్ టమాటో కూర / Potals Tomato Curry', 'పన్నీరు పచ్చి బఠాణి గ్రేవీ కర్రీ / Panneru Green Peas Gravy Curry', 'కాప్సికం టమాటో కూర / Capsicum Tomato Curry', 'మిక్సడ్ వెజ్ కూర / Mixed Veg Curry', 'తోటకూర వేపుడు కూర / Thotakura Fry Curry', 'పొట్లకాయ నువ్వు పొడి కూర / Potlakaya Nuvvu Podi Curry', 'తీపి గుమ్మడి నువ్వు పొడి ముద్ద కూర / Sweet Pumpkin Nuvvu Podi Mudda Curry', ]; // ── Load from DB; fall back to static arrays if DB is empty ─────────────── $lists = ['pappu'=>[],'curry'=>[],'liquid'=>[],'pachadi'=>[],'millets'=>[],'prasadam'=>[],'rice'=>[]]; $res_lists = mysqli_query($conn, "SELECT category, item_name FROM menu_categories ORDER BY item_name ASC"); if ($res_lists) { while ($row = mysqli_fetch_assoc($res_lists)) { $cat = $row['category']; if (isset($lists[$cat])) $lists[$cat][] = $row['item_name']; } } // Merge static defaults for empty categories $static_defaults = [ 'pappu' => $static_pappu, 'liquid' => $static_liquid, 'pachadi' => $static_pachadi, 'curry' => $static_curry, ]; foreach ($static_defaults as $cat => $defaults) { if (empty($lists[$cat])) $lists[$cat] = $defaults; } // Ensure 'None' stays at top foreach ($lists as $cat => &$items) { if (($key = array_search("None", $items)) !== false) { unset($items[$key]); array_unshift($items, "None"); } } $pappu_list = $lists['pappu']; $curry_list = $lists['curry']; $liquid_list = $lists['liquid']; $pachadi_list = $lists['pachadi']; $millets_list = $lists['millets']; $prasadam_list= $lists['prasadam']; $rice_list = $lists['rice']; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Mithram Admin | Manage Menu</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> :root { --primary: #fb923c; --sidebar: #1e293b; --bg: #f8fafc; } body { font-family: 'Segoe UI', sans-serif; margin: 0; display: flex; background: var(--bg); } .sidebar-container { width: 250px; } .main { flex: 1; margin-left: 250px; width: calc(100% - 250px); box-sizing: border-box; } .top-bar { background: white; padding: 15px 40px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,0.1); } .container { padding: 30px; } .card { background: white; border-radius: 12px; padding: 25px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); margin-bottom: 25px; border: 1px solid #e2e8f0; } .card-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; color: var(--primary); display: flex; align-items: center; } .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; } .field-group { margin-bottom: 15px; } label { display: block; font-size: 13px; font-weight: 600; color: #64748b; margin-bottom: 8px; } select { width: 100%; padding: 12px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 14px; background: #fff; } .btn-submit { background: var(--primary); color: white; border: none; padding: 15px; width: 100%; border-radius: 10px; font-size: 16px; font-weight: bold; cursor: pointer; transition: 0.3s; } .btn-submit:hover { background: #f97316; } .alert { padding: 15px; border-radius: 8px; margin-bottom: 20px; font-weight: 600; } .success { background: #dcfce7; color: #166534; } .error { background: #fee2e2; color: #991b1b; } .table { width: 100%; border-collapse: collapse; } .table th { text-align: left; background: #f8fafc; padding: 12px; color: #64748b; font-size: 12px; text-transform: uppercase; border-bottom: 2px solid #e2e8f0; } .table td { padding: 15px 12px; border-bottom: 1px solid #f1f5f9; font-size: 14px; } .badge { background: #f0fdf4; color: #16a34a; padding: 4px 10px; border-radius: 6px; font-weight: 800; font-size: 12px; } .btn-add-new { background: #f1f5f9; color: #3b82f6; border: 1px solid #cbd5e1; padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; cursor: pointer; transition: 0.2s; } .btn-add-new:hover { background: #e2e8f0; color: #1d4ed8; } .btn-save-new { background: #10b981; color: white; border: none; padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: bold; cursor: pointer; transition: 0.2s; white-space: nowrap; } .btn-save-new:hover { background: #059669; } .btn-delete-item { background: #fee2e2; color: #ef4444; border: 1px solid #fca5a5; border-radius: 8px; padding: 0 15px; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; } .btn-delete-item:hover { background: #fecaca; color: #dc2626; } #toast { visibility: hidden; min-width: 250px; background-color: #333; color: #fff; text-align: center; border-radius: 8px; padding: 16px; position: fixed; z-index: 1000; left: 50%; bottom: 30px; transform: translateX(-50%); font-size: 14px; font-weight: 600; box-shadow: 0 4px 12px rgba(0,0,0,0.15); opacity: 0; transition: opacity 0.3s, bottom 0.3s; } #toast.show { visibility: visible; opacity: 1; bottom: 50px; } </style> </head> <body> <?php include "navigate.php"; ?> <div class="main"> <div class="top-bar"> <h2 style="margin:0;">Manage Daily Menu 🍱</h2> <div style="font-weight: 600; color: #64748b;"><?php echo date('d M, Y'); ?></div> </div> <div class="container"> <?php echo $message; ?> <!-- ═══════════════════════════════════════════════════════════ CURRIES MENU CARD ═══════════════════════════════════════════════════════════ --> <div class="card"> <div class="card-title"><i class="fas fa-utensils" style="margin-right:10px;"></i> Curries Menu (₹90/-)</div> <form action="" method="POST"> <div class="grid"> <!-- 1. Pappu --> <div class="field-group"> <label style="display:flex; justify-content:space-between; align-items:center;"> <span>1. Pappu Selection (పప్పు)</span> <button type="button" class="btn-add-new" onclick="toggleAddNew('pappu')"><i class="fas fa-plus"></i> Add New</button> </label> <div style="display:flex; gap:10px;"> <select name="item1" id="select_pappu" required> <option value="<?= htmlspecialchars($lunch['item_1'] ?? '') ?>"><?= htmlspecialchars($lunch['item_1'] ?? '') ?: '-- Select Pappu --' ?></option> <?php foreach ($pappu_list as $p) echo "<option value='".htmlspecialchars($p)."'>".htmlspecialchars($p)."</option>"; ?> </select> <button type="button" class="btn-delete-item" onclick="deleteSelectedItem('pappu', 'select_pappu')" title="Delete selected item"><i class="fas fa-times"></i></button> </div> <div id="add_new_pappu" style="display:none; margin-top:8px; gap:8px;"> <input type="text" id="new_pappu" placeholder="Enter new item..." style="flex:1; padding:10px; border:1px solid #e2e8f0; border-radius:8px;"> <button type="button" class="btn-save-new" onclick="saveNewItem('pappu')">Save</button> </div> </div> <!-- 2. Curry --> <div class="field-group"> <label style="display:flex; justify-content:space-between; align-items:center;"> <span>2. Curry Selection (కూర)</span> <button type="button" class="btn-add-new" onclick="toggleAddNew('curry')"><i class="fas fa-plus"></i> Add New</button> </label> <div style="display:flex; gap:10px;"> <select name="item2" id="select_curry" required> <option value="<?= htmlspecialchars($lunch['item_2'] ?? '') ?>"><?= htmlspecialchars($lunch['item_2'] ?? '') ?: '-- Select Curry --' ?></option> <?php foreach ($curry_list as $c) echo "<option value='".htmlspecialchars($c)."'>".htmlspecialchars($c)."</option>"; ?> </select> <button type="button" class="btn-delete-item" onclick="deleteSelectedItem('curry', 'select_curry')" title="Delete selected item"><i class="fas fa-times"></i></button> </div> <div id="add_new_curry" style="display:none; margin-top:8px; gap:8px;"> <input type="text" id="new_curry" placeholder="Enter new item..." style="flex:1; padding:10px; border:1px solid #e2e8f0; border-radius:8px;"> <button type="button" class="btn-save-new" onclick="saveNewItem('curry')">Save</button> </div> </div> <!-- 3. Liquid --> <div class="field-group"> <label style="display:flex; justify-content:space-between; align-items:center;"> <span>3. Liquid Items (చారు/సాంబార్)</span> <button type="button" class="btn-add-new" onclick="toggleAddNew('liquid')"><i class="fas fa-plus"></i> Add New</button> </label> <div style="display:flex; gap:10px;"> <select name="item3" id="select_liquid" required> <option value="<?= htmlspecialchars($lunch['item_3'] ?? '') ?>"><?= htmlspecialchars($lunch['item_3'] ?? '') ?: '-- Select Liquid --' ?></option> <?php foreach ($liquid_list as $l) echo "<option value='".htmlspecialchars($l)."'>".htmlspecialchars($l)."</option>"; ?> </select> <button type="button" class="btn-delete-item" onclick="deleteSelectedItem('liquid', 'select_liquid')" title="Delete selected item"><i class="fas fa-times"></i></button> </div> <div id="add_new_liquid" style="display:none; margin-top:8px; gap:8px;"> <input type="text" id="new_liquid" placeholder="Enter new item..." style="flex:1; padding:10px; border:1px solid #e2e8f0; border-radius:8px;"> <button type="button" class="btn-save-new" onclick="saveNewItem('liquid')">Save</button> </div> </div> <!-- 4. Pachadi --> <div class="field-group"> <label style="display:flex; justify-content:space-between; align-items:center;"> <span>4. Pachadi Selection (పచ్చడి)</span> <button type="button" class="btn-add-new" onclick="toggleAddNew('pachadi')"><i class="fas fa-plus"></i> Add New</button> </label> <div style="display:flex; gap:10px;"> <select name="item4" id="select_pachadi" required> <option value="<?= htmlspecialchars($lunch['item_4'] ?? '') ?>"><?= htmlspecialchars($lunch['item_4'] ?? '') ?: '-- Select Pachadi --' ?></option> <?php foreach ($pachadi_list as $pc) echo "<option value='".htmlspecialchars($pc)."'>".htmlspecialchars($pc)."</option>"; ?> </select> <button type="button" class="btn-delete-item" onclick="deleteSelectedItem('pachadi', 'select_pachadi')" title="Delete selected item"><i class="fas fa-times"></i></button> </div> <div id="add_new_pachadi" style="display:none; margin-top:8px; gap:8px;"> <input type="text" id="new_pachadi" placeholder="Enter new item..." style="flex:1; padding:10px; border:1px solid #e2e8f0; border-radius:8px;"> <button type="button" class="btn-save-new" onclick="saveNewItem('pachadi')">Save</button> </div> </div> <!-- 5. Millets --> <div class="field-group"> <label style="display:flex; justify-content:space-between; align-items:center;"> <span>5. Millets Selection (చిరుధాన్యాలు - Optional)</span> <button type="button" class="btn-add-new" onclick="toggleAddNew('millets')"><i class="fas fa-plus"></i> Add New</button> </label> <div style="display:flex; gap:10px;"> <select name="item_millets" id="select_millets"> <option value="<?= htmlspecialchars($lunch['item_millets'] ?? '') ?>"><?= htmlspecialchars($lunch['item_millets'] ?? '') ?: '-- None --' ?></option> <?php foreach ($millets_list as $m) echo "<option value='".htmlspecialchars($m)."'>".htmlspecialchars($m)."</option>"; ?> </select> <button type="button" class="btn-delete-item" onclick="deleteSelectedItem('millets', 'select_millets')" title="Delete selected item"><i class="fas fa-times"></i></button> </div> <div id="add_new_millets" style="display:none; margin-top:8px; gap:8px;"> <input type="text" id="new_millets" placeholder="Enter new item..." style="flex:1; padding:10px; border:1px solid #e2e8f0; border-radius:8px;"> <button type="button" class="btn-save-new" onclick="saveNewItem('millets')">Save</button> </div> </div> <!-- 6. Prasadam --> <div class="field-group"> <label style="display:flex; justify-content:space-between; align-items:center;"> <span>6. Prasadam (ప్రసాదం - Optional)</span> <button type="button" class="btn-add-new" onclick="toggleAddNew('prasadam')"><i class="fas fa-plus"></i> Add New</button> </label> <div style="display:flex; gap:10px;"> <select name="item_prasadam" id="select_prasadam"> <option value="<?= htmlspecialchars($lunch['item_prasadam'] ?? '') ?>"><?= htmlspecialchars($lunch['item_prasadam'] ?? '') ?: '-- None --' ?></option> <?php foreach ($prasadam_list as $pr) echo "<option value='".htmlspecialchars($pr)."'>".htmlspecialchars($pr)."</option>"; ?> </select> <button type="button" class="btn-delete-item" onclick="deleteSelectedItem('prasadam', 'select_prasadam')" title="Delete selected item"><i class="fas fa-times"></i></button> </div> <div id="add_new_prasadam" style="display:none; margin-top:8px; gap:8px;"> <input type="text" id="new_prasadam" placeholder="Enter new item..." style="flex:1; padding:10px; border:1px solid #e2e8f0; border-radius:8px;"> <button type="button" class="btn-save-new" onclick="saveNewItem('prasadam')">Save</button> </div> </div> <!-- Cutoff time + Date --> <div class="field-group" style="grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 20px;"> <div> <label style="color: #ef4444;"><i class="fas fa-clock"></i> Order Cutoff Time (గడువు సమయం)</label> <input type="text" name="delivery_time" value="<?= htmlspecialchars($lunch['delivery_time'] ?? '') ?>" placeholder="Ex: 9:00 PM tonight"> </div> <div> <label style="color: #7c3aed;"><i class="fas fa-calendar-day"></i> Menu Available For Date (ఏ రోజుకు?)</label> <input type="date" name="lunch_menu_date" value="<?= htmlspecialchars($lunch['menu_date'] ?? $view_date) ?>" min="<?= $today ?>" onchange="window.location.href='manage_menu.php?date=' + this.value"> <small style="color:#64748b; font-size:11px;">Today's date by default. Change to set tomorrow's menu in advance.</small> </div> </div> </div> <button type="submit" name="update_lunch" class="btn-submit">Update Curries Menu</button> </form> </div> <hr style="border: 0; height: 1px; background: #e2e8f0; margin: 30px 0;"> <!-- ═══════════════════════════════════════════════════════════ RICE MENU CARD ═══════════════════════════════════════════════════════════ --> <div class="card"> <div class="card-title"><i class="fas fa-bowl-rice" style="margin-right:10px;"></i> Rice with Curries (₹140/-)</div> <form action="" method="POST"> <div class="grid"> <!-- Rice type --> <div class="field-group"> <label style="display:flex; justify-content:space-between; align-items:center;"> <span>Rice Selection (అన్నం)</span> <button type="button" class="btn-add-new" onclick="toggleAddNew('rice_rice')"><i class="fas fa-plus"></i> Add New</button> </label> <div style="display:flex; gap:10px;"> <select name="rice_item_rice" id="select_rice_rice" required> <option value="<?= htmlspecialchars($rice['item_5'] ?? '') ?>"><?= htmlspecialchars($rice['item_5'] ?? '') ?: '-- Select Rice --' ?></option> <option value="<?= htmlspecialchars($rice['item_5'] ?? '') ?>"><?= htmlspecialchars($rice['item_5'] ?? '') ?: '-- White Rice --' ?></option> <?php foreach ($rice_list as $r) echo "<option value='".htmlspecialchars($r)."'>".htmlspecialchars($r)."</option>"; ?> </select> <button type="button" class="btn-delete-item" onclick="deleteSelectedItem('rice', 'select_rice_rice')" title="Delete selected item"><i class="fas fa-times"></i></button> </div> <div id="add_new_rice_rice" style="display:none; margin-top:8px; gap:8px;"> <input type="text" id="new_rice_rice" placeholder="Enter new item..." style="flex:1; padding:10px; border:1px solid #e2e8f0; border-radius:8px;"> <button type="button" class="btn-save-new" onclick="saveNewItemFromCombo('rice', 'rice_rice')">Save</button> </div> </div> <!-- Rice Pappu --> <div class="field-group"> <label style="display:flex; justify-content:space-between; align-items:center;"> <span>Pappu Selection (పప్పు)</span> <button type="button" class="btn-add-new" onclick="toggleAddNew('rice_pappu')"><i class="fas fa-plus"></i> Add New</button> </label> <div style="display:flex; gap:10px;"> <select name="rice_item1" id="select_rice_pappu" required> <option value="<?= htmlspecialchars($rice['item_1'] ?? '') ?>"><?= htmlspecialchars($rice['item_1'] ?? '') ?: '-- Select Pappu --' ?></option> <?php foreach ($pappu_list as $p) echo "<option value='".htmlspecialchars($p)."'>".htmlspecialchars($p)."</option>"; ?> </select> <button type="button" class="btn-delete-item" onclick="deleteSelectedItem('pappu', 'select_rice_pappu')" title="Delete selected item"><i class="fas fa-times"></i></button> </div> <div id="add_new_rice_pappu" style="display:none; margin-top:8px; gap:8px;"> <input type="text" id="new_rice_pappu" placeholder="Enter new item..." style="flex:1; padding:10px; border:1px solid #e2e8f0; border-radius:8px;"> <button type="button" class="btn-save-new" onclick="saveNewItemFromCombo('pappu', 'rice_pappu')">Save</button> </div> </div> <!-- Rice Curry --> <div class="field-group"> <label style="display:flex; justify-content:space-between; align-items:center;"> <span>Curry Selection (కూర)</span> <button type="button" class="btn-add-new" onclick="toggleAddNew('rice_curry')"><i class="fas fa-plus"></i> Add New</button> </label> <div style="display:flex; gap:10px;"> <select name="rice_item2" id="select_rice_curry" required> <option value="<?= htmlspecialchars($rice['item_2'] ?? '') ?>"><?= htmlspecialchars($rice['item_2'] ?? '') ?: '-- Select Curry --' ?></option> <?php foreach ($curry_list as $c) echo "<option value='".htmlspecialchars($c)."'>".htmlspecialchars($c)."</option>"; ?> </select> <button type="button" class="btn-delete-item" onclick="deleteSelectedItem('curry', 'select_rice_curry')" title="Delete selected item"><i class="fas fa-times"></i></button> </div> <div id="add_new_rice_curry" style="display:none; margin-top:8px; gap:8px;"> <input type="text" id="new_rice_curry" placeholder="Enter new item..." style="flex:1; padding:10px; border:1px solid #e2e8f0; border-radius:8px;"> <button type="button" class="btn-save-new" onclick="saveNewItemFromCombo('curry', 'rice_curry')">Save</button> </div> </div> <!-- Rice Liquid --> <div class="field-group"> <label style="display:flex; justify-content:space-between; align-items:center;"> <span>Liquid Items (చారు/సాంబార్)</span> <button type="button" class="btn-add-new" onclick="toggleAddNew('rice_liquid')"><i class="fas fa-plus"></i> Add New</button> </label> <div style="display:flex; gap:10px;"> <select name="rice_item3" id="select_rice_liquid" required> <option value="<?= htmlspecialchars($rice['item_3'] ?? '') ?>"><?= htmlspecialchars($rice['item_3'] ?? '') ?: '-- Select Liquid --' ?></option> <?php foreach ($liquid_list as $l) echo "<option value='".htmlspecialchars($l)."'>".htmlspecialchars($l)."</option>"; ?> </select> <button type="button" class="btn-delete-item" onclick="deleteSelectedItem('liquid', 'select_rice_liquid')" title="Delete selected item"><i class="fas fa-times"></i></button> </div> <div id="add_new_rice_liquid" style="display:none; margin-top:8px; gap:8px;"> <input type="text" id="new_rice_liquid" placeholder="Enter new item..." style="flex:1; padding:10px; border:1px solid #e2e8f0; border-radius:8px;"> <button type="button" class="btn-save-new" onclick="saveNewItemFromCombo('liquid', 'rice_liquid')">Save</button> </div> </div> <!-- Rice Pachadi --> <div class="field-group"> <label style="display:flex; justify-content:space-between; align-items:center;"> <span>Pachadi Selection (పచ్చడి)</span> <button type="button" class="btn-add-new" onclick="toggleAddNew('rice_pachadi')"><i class="fas fa-plus"></i> Add New</button> </label> <div style="display:flex; gap:10px;"> <select name="rice_item4" id="select_rice_pachadi" required> <option value="<?= htmlspecialchars($rice['item_4'] ?? '') ?>"><?= htmlspecialchars($rice['item_4'] ?? '') ?: '-- Select Pachadi --' ?></option> <?php foreach ($pachadi_list as $pc) echo "<option value='".htmlspecialchars($pc)."'>".htmlspecialchars($pc)."</option>"; ?> </select> <button type="button" class="btn-delete-item" onclick="deleteSelectedItem('pachadi', 'select_rice_pachadi')" title="Delete selected item"><i class="fas fa-times"></i></button> </div> <div id="add_new_rice_pachadi" style="display:none; margin-top:8px; gap:8px;"> <input type="text" id="new_rice_pachadi" placeholder="Enter new item..." style="flex:1; padding:10px; border:1px solid #e2e8f0; border-radius:8px;"> <button type="button" class="btn-save-new" onclick="saveNewItemFromCombo('pachadi', 'rice_pachadi')">Save</button> </div> </div> <!-- Rice Millets --> <div class="field-group"> <label style="display:flex; justify-content:space-between; align-items:center;"> <span>Millets Selection (చిరుధాన్యాలు - Optional)</span> <button type="button" class="btn-add-new" onclick="toggleAddNew('rice_millets')"><i class="fas fa-plus"></i> Add New</button> </label> <div style="display:flex; gap:10px;"> <select name="rice_item_millets" id="select_rice_millets"> <option value="<?= htmlspecialchars($rice['item_millets'] ?? '') ?>"><?= htmlspecialchars($rice['item_millets'] ?? '') ?: '-- None --' ?></option> <?php foreach ($millets_list as $m) echo "<option value='".htmlspecialchars($m)."'>".htmlspecialchars($m)."</option>"; ?> </select> <button type="button" class="btn-delete-item" onclick="deleteSelectedItem('millets', 'select_rice_millets')" title="Delete selected item"><i class="fas fa-times"></i></button> </div> <div id="add_new_rice_millets" style="display:none; margin-top:8px; gap:8px;"> <input type="text" id="new_rice_millets" placeholder="Enter new item..." style="flex:1; padding:10px; border:1px solid #e2e8f0; border-radius:8px;"> <button type="button" class="btn-save-new" onclick="saveNewItemFromCombo('millets', 'rice_millets')">Save</button> </div> </div> <!-- Rice Prasadam --> <div class="field-group"> <label style="display:flex; justify-content:space-between; align-items:center;"> <span>Prasadam (ప్రసాదం - Optional)</span> <button type="button" class="btn-add-new" onclick="toggleAddNew('rice_prasadam')"><i class="fas fa-plus"></i> Add New</button> </label> <div style="display:flex; gap:10px;"> <select name="rice_item_prasadam" id="select_rice_prasadam"> <option value="<?= htmlspecialchars($rice['item_prasadam'] ?? '') ?>"><?= htmlspecialchars($rice['item_prasadam'] ?? '') ?: '-- None --' ?></option> <?php foreach ($prasadam_list as $pr) echo "<option value='".htmlspecialchars($pr)."'>".htmlspecialchars($pr)."</option>"; ?> </select> <button type="button" class="btn-delete-item" onclick="deleteSelectedItem('prasadam', 'select_rice_prasadam')" title="Delete selected item"><i class="fas fa-times"></i></button> </div> <div id="add_new_rice_prasadam" style="display:none; margin-top:8px; gap:8px;"> <input type="text" id="new_rice_prasadam" placeholder="Enter new item..." style="flex:1; padding:10px; border:1px solid #e2e8f0; border-radius:8px;"> <button type="button" class="btn-save-new" onclick="saveNewItemFromCombo('prasadam', 'rice_prasadam')">Save</button> </div> </div> <!-- Cutoff time + Date --> <div class="field-group" style="grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 20px;"> <div> <label style="color: #ef4444;"><i class="fas fa-clock"></i> Order Cutoff Time (గడువు సమయం)</label> <input type="text" name="delivery_time" value="<?= htmlspecialchars($rice['delivery_time'] ?? '') ?>" placeholder="Ex: 9:00 PM tonight"> </div> <div> <label style="color: #7c3aed;"><i class="fas fa-calendar-day"></i> Menu Available For Date (ఏ రోజుకు?)</label> <input type="date" name="rice_menu_date" value="<?= htmlspecialchars($rice['menu_date'] ?? $view_date) ?>" min="<?= $today ?>" onchange="window.location.href='manage_menu.php?date=' + this.value"> <small style="color:#64748b; font-size:11px;">Today's date by default. Change to set tomorrow's menu in advance.</small> </div> </div> </div> <button type="submit" name="update_rice" class="btn-submit" style="background:#3b82f6;">Update Rice Menu</button> </form> </div> <!-- ═══════════════════════════════════════════════════════════ LIVE PREVIEW ═══════════════════════════════════════════════════════════ --> <div class="card" style="background: transparent; border: none; box-shadow: none; padding: 0;"> <div class="card-title" style="color:#1e293b; font-size: 22px; font-weight: 800; margin-bottom: 25px; display: flex; align-items: center;"> <span style="background: #3b82f6; color: white; width: 35px; height: 35px; display: flex; align-items: center; justify-content: center; border-radius: 8px; margin-right: 12px;"> <i class="fas fa-globe" style="font-size: 16px;"></i> </span> Live on Website Today </div> <?php if (!empty($lunch['item_1'])): ?> <div style="display: flex; flex-direction: column; gap: 20px; margin-bottom: 30px;"> <div style="background: white; border-radius: 15px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.05); border: 1px solid #e2e8f0; display: flex; flex-direction: column;"> <div style="background: linear-gradient(135deg, #fb923c, #f97316); color: white; padding: 15px 25px; font-weight: bold; display: flex; justify-content: space-between; align-items: center;"> <span style="font-size: 16px; letter-spacing: 0.5px;">🍛 CURRIES PACK (4 ITEMS)</span> <span style="background: rgba(255,255,255,0.2); padding: 4px 12px; border-radius: 50px; font-size: 16px; font-weight: 800;">₹90/-</span> </div> <div style="padding: 20px 25px;"> <div style="display: flex; flex-wrap: wrap; gap: 10px;"> <?php for($i=1; $i<=4; $i++): if(!empty($lunch['item_'.$i])): ?> <span style="background: #fff7ed; color: #9a3412; padding: 6px 15px; border-radius: 8px; font-weight: 700; border: 1px solid #ffedd5;"><?= $i ?>. <?= htmlspecialchars($lunch['item_'.$i]) ?></span> <?php endif; endfor; ?> </div> </div> </div> <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px;"> <?php if (!empty($lunch['item_millets']) && $lunch['item_millets'] != 'None'): ?> <div style="background: #f0fdf4; border: 1px solid #bbf7d0; padding: 12px 20px; border-radius: 12px; display: flex; align-items: center; gap: 12px;"> <span style="font-size: 20px;">🌾</span> <div> <div style="font-size: 10px; font-weight: 800; color: #166534; text-transform: uppercase;">Millet Special</div> <div style="color: #14532d; font-weight: 700;"><?= htmlspecialchars($lunch['item_millets']) ?></div> </div> </div> <?php endif; ?> <?php if (!empty($lunch['item_prasadam']) && $lunch['item_prasadam'] != 'None'): ?> <div style="background: #fff1f2; border: 1px solid #fecdd3; padding: 12px 20px; border-radius: 12px; display: flex; align-items: center; gap: 12px;"> <span style="font-size: 20px;">🙏</span> <div> <div style="font-size: 10px; font-weight: 800; color: #9f1239; text-transform: uppercase;">Today's Prasadam</div> <div style="color: #881337; font-weight: 700;"><?= htmlspecialchars($lunch['item_prasadam']) ?></div> </div> </div> <?php endif; ?> </div> </div> <?php else: ?> <div style="text-align:center; padding:20px; background: white; border-radius: 15px; color:#94a3b8; border: 2px dashed #e2e8f0; margin-bottom:20px;"> <p>No curries menu updated for today.</p> </div> <?php endif; ?> <hr style="border: 0; height: 1px; background: #e2e8f0; margin: 20px 0;"> <?php if (!empty($rice['item_1'])): ?> <div style="display: flex; flex-direction: column; gap: 20px;"> <div style="background: white; border-radius: 15px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.05); border: 1px solid #e2e8f0;"> <div style="background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: white; padding: 15px 25px; font-weight: bold; display: flex; justify-content: space-between; align-items: center;"> <span style="font-size: 16px; letter-spacing: 0.5px;">🍱 RICE WITH CURRIES</span> <span style="background: rgba(255,255,255,0.2); padding: 4px 12px; border-radius: 50px; font-size: 16px; font-weight: 800;">₹140/-</span> </div> <div style="padding: 20px 25px;"> <div style="display: flex; flex-direction: column; gap: 10px;"> <?php if(!empty($rice['item_5'])): ?> <div style="color: #1e293b; font-weight: 800; font-size: 16px; margin-bottom: 5px; padding-bottom: 5px; border-bottom: 1px dashed #e2e8f0;"> <i class="fas fa-bowl-rice" style="color: #3b82f6;"></i> <?= htmlspecialchars($rice['item_5']) ?> </div> <?php endif; ?> <?php foreach([$rice['item_1'],$rice['item_2'],$rice['item_3'],$rice['item_4']] as $ri): if(!empty($ri)): ?> <div style="color: #475569; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 10px; padding-left: 10px;"> <i class="fas fa-check-circle" style="color: #10b981; font-size: 12px;"></i> <?= htmlspecialchars($ri) ?> </div> <?php endif; endforeach; ?> </div> </div> </div> <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px;"> <?php if (!empty($rice['item_millets']) && $rice['item_millets'] != 'None'): ?> <div style="background: #f0fdf4; border: 1px solid #bbf7d0; padding: 12px 20px; border-radius: 12px; display: flex; align-items: center; gap: 12px;"> <span style="font-size: 20px;">🌾</span> <div> <div style="font-size: 10px; font-weight: 800; color: #166534; text-transform: uppercase;">Millet Special</div> <div style="color: #14532d; font-weight: 700;"><?= htmlspecialchars($rice['item_millets']) ?></div> </div> </div> <?php endif; ?> <?php if (!empty($rice['item_prasadam']) && $rice['item_prasadam'] != 'None'): ?> <div style="background: #fff1f2; border: 1px solid #fecdd3; padding: 12px 20px; border-radius: 12px; display: flex; align-items: center; gap: 12px;"> <span style="font-size: 20px;">🙏</span> <div> <div style="font-size: 10px; font-weight: 800; color: #9f1239; text-transform: uppercase;">Today's Prasadam</div> <div style="color: #881337; font-weight: 700;"><?= htmlspecialchars($rice['item_prasadam']) ?></div> </div> </div> <?php endif; ?> </div> </div> <?php else: ?> <div style="text-align:center; padding:20px; background: white; border-radius: 15px; color:#94a3b8; border: 2px dashed #e2e8f0;"> <p>No rice menu updated for today.</p> </div> <?php endif; ?> </div><!-- /live preview card --> </div><!-- /container --> </div><!-- /main --> <div id="toast">Item added successfully! ✅</div> <script> function toggleAddNew(cat) { var div = document.getElementById('add_new_' + cat); if (div.style.display === 'none' || div.style.display === '') { div.style.display = 'flex'; document.getElementById('new_' + cat).focus(); } else { div.style.display = 'none'; } } function showToast(msg) { var toast = document.getElementById('toast'); toast.innerText = msg; toast.className = 'show'; setTimeout(function(){ toast.className = toast.className.replace('show', ''); }, 3000); } function saveNewItem(cat) { var inputObj = document.getElementById('new_' + cat); var selectObj = document.getElementById('select_' + cat); var itemValue = inputObj.value.trim(); if (!itemValue) { alert('Please enter an item name.'); return; } var formData = new FormData(); formData.append('category', cat); formData.append('item_name', itemValue); fetch('add_menu_item.php', { method: 'POST', body: formData }) .then(r => r.json()) .then(data => { if (data.success) { var opt = document.createElement('option'); opt.value = data.item_name; opt.text = data.item_name; selectObj.appendChild(opt); selectObj.value = data.item_name; inputObj.value = ''; document.getElementById('add_new_' + cat).style.display = 'none'; showToast('Item added successfully! ✅'); } else { alert('Error: ' + data.message); } }) .catch(err => { console.error(err); alert('Failed to add item.'); }); } function saveNewItemFromCombo(dbCat, elementId) { var inputObj = document.getElementById('new_' + elementId); var selectObj = document.getElementById('select_' + elementId); var itemValue = inputObj.value.trim(); if (!itemValue) { alert('Please enter an item name.'); return; } var formData = new FormData(); formData.append('category', dbCat); formData.append('item_name', itemValue); fetch('add_menu_item.php', { method: 'POST', body: formData }) .then(r => r.json()) .then(data => { if (data.success) { var opt = document.createElement('option'); opt.value = data.item_name; opt.text = data.item_name; selectObj.appendChild(opt); selectObj.value = data.item_name; inputObj.value = ''; document.getElementById('add_new_' + elementId).style.display = 'none'; showToast('Item added successfully! ✅'); } else { alert('Error: ' + data.message); } }) .catch(err => { console.error(err); alert('Failed to add item.'); }); } function deleteSelectedItem(cat, selectId) { var selectObj = document.getElementById(selectId); var itemValue = selectObj.value; if (!itemValue || itemValue.startsWith('--') || itemValue === 'None') { alert('Cannot delete this default option.'); return; } if (!confirm('Are you sure you want to delete "' + itemValue + '" from the list?')) return; var formData = new FormData(); formData.append('category', cat); formData.append('item_name', itemValue); fetch('delete_menu_item.php', { method: 'POST', body: formData }) .then(r => r.json()) .then(data => { if (data.success) { for (var i = 0; i < selectObj.length; i++) { if (selectObj.options[i].value == itemValue) { selectObj.remove(i); break; } } showToast('Item deleted successfully! 🗑️'); } else { alert('Error: ' + data.message); } }) .catch(err => { console.error(err); alert('Failed to delete item.'); }); } </script> </body> </html>
Cancelar
Kerym Chaeceran