zenityx commited on
Commit
3bd567e
·
verified ·
1 Parent(s): 9163d00

Update admin.js

Browse files
Files changed (1) hide show
  1. admin.js +4 -4
admin.js CHANGED
@@ -59,7 +59,7 @@ const menu = [
59
  }
60
  ];
61
 
62
- // Render dropdown เมนู
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
- // Filter เฉพาะเลขโต๊ะตรงเป๊ะและยังไม่เช็กบิล/ไม่ถูกลบ
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
- // เช็กบิล (mark paid) PATCH ทีละโต๊ะ เฉพาะ status=unpaid
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`, {