Spaces:
Running
Running
Update admin.js
Browse files
admin.js
CHANGED
|
@@ -59,7 +59,7 @@ const menu = [
|
|
| 59 |
}
|
| 60 |
];
|
| 61 |
|
| 62 |
-
//
|
| 63 |
function renderMenuDropdown() {
|
| 64 |
const select = document.getElementById("add-menu");
|
| 65 |
let html = `<option value="">เลือกเมนู</option>`;
|
|
@@ -71,7 +71,7 @@ function renderMenuDropdown() {
|
|
| 71 |
select.innerHTML = html;
|
| 72 |
}
|
| 73 |
|
| 74 |
-
//
|
| 75 |
function filterOrders(data, table) {
|
| 76 |
return data.filter(
|
| 77 |
i => (i.status ?? "unpaid") === "unpaid" && String(i.table).trim() === String(table)
|
|
@@ -150,7 +150,7 @@ async function addOrder() {
|
|
| 150 |
loadOrder();
|
| 151 |
}
|
| 152 |
|
| 153 |
-
// ลบเมนู
|
| 154 |
async function removeOrder(menuName) {
|
| 155 |
const table = document.getElementById("table").value;
|
| 156 |
if (!confirm(`ต้องการลบเมนู "${menuName}" ออกจากโต๊ะ ${table} ?`)) return;
|
|
@@ -164,7 +164,7 @@ async function removeOrder(menuName) {
|
|
| 164 |
loadOrder();
|
| 165 |
}
|
| 166 |
|
| 167 |
-
// เช็กบิล (
|
| 168 |
async function checkout() {
|
| 169 |
const table = document.getElementById("table").value;
|
| 170 |
await fetch(`${scriptURL}?table=${encodeURIComponent(table)}&status=unpaid`, {
|
|
|
|
| 59 |
}
|
| 60 |
];
|
| 61 |
|
| 62 |
+
// สร้าง dropdown เมนู
|
| 63 |
function renderMenuDropdown() {
|
| 64 |
const select = document.getElementById("add-menu");
|
| 65 |
let html = `<option value="">เลือกเมนู</option>`;
|
|
|
|
| 71 |
select.innerHTML = html;
|
| 72 |
}
|
| 73 |
|
| 74 |
+
// filter ออเดอร์ที่ status=unpaid และเลขโต๊ะตรงเป๊ะ
|
| 75 |
function filterOrders(data, table) {
|
| 76 |
return data.filter(
|
| 77 |
i => (i.status ?? "unpaid") === "unpaid" && String(i.table).trim() === String(table)
|
|
|
|
| 150 |
loadOrder();
|
| 151 |
}
|
| 152 |
|
| 153 |
+
// ลบเมนู = PATCH เป็น deleted (เฉพาะ status=unpaid)
|
| 154 |
async function removeOrder(menuName) {
|
| 155 |
const table = document.getElementById("table").value;
|
| 156 |
if (!confirm(`ต้องการลบเมนู "${menuName}" ออกจากโต๊ะ ${table} ?`)) return;
|
|
|
|
| 164 |
loadOrder();
|
| 165 |
}
|
| 166 |
|
| 167 |
+
// เช็กบิล (เปลี่ยน status เป็น paid เฉพาะออเดอร์ที่ยัง unpaid)
|
| 168 |
async function checkout() {
|
| 169 |
const table = document.getElementById("table").value;
|
| 170 |
await fetch(`${scriptURL}?table=${encodeURIComponent(table)}&status=unpaid`, {
|