Compare commits
No commits in common. "3dc145beaebc9cfaae27581144f7c3e0267acb33" and "984b1ecba5796ce03eb531d92d1605c449849468" have entirely different histories.
3dc145beae
...
984b1ecba5
@ -6,120 +6,61 @@ class WaiterDashboard:
|
|||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.frame = tk.Frame(parent)
|
self.frame = tk.Frame(parent)
|
||||||
self.frame.pack(fill="both", expand=True, padx=20, pady=10)
|
self.frame.pack(fill="both", expand=True)
|
||||||
|
|
||||||
# =====================
|
tk.Label(self.frame, text="DASHBOARD WAITER (Dapur)", font=("Arial", 18, "bold")).pack(pady=10)
|
||||||
# HEADER
|
|
||||||
# =====================
|
|
||||||
tk.Label(
|
|
||||||
self.frame,
|
|
||||||
text="DASHBOARD WAITER (DAPUR)",
|
|
||||||
font=("Arial", 18, "bold")
|
|
||||||
).pack(pady=10)
|
|
||||||
|
|
||||||
top_btn = tk.Frame(self.frame)
|
tk.Button(self.frame, text="Logout", command=self.logout).pack(pady=5)
|
||||||
top_btn.pack(pady=5)
|
tk.Button(self.frame, text="Refresh Data", bg="#cfe2ff", command=self.load_orders).pack(pady=5)
|
||||||
|
|
||||||
tk.Button(top_btn, text="Refresh Data", bg="#cfe2ff",
|
# List Pesanan Masuk
|
||||||
width=15, command=self.load_orders).grid(row=0, column=0, padx=5)
|
self.listbox = tk.Listbox(self.frame, width=80, height=15)
|
||||||
|
self.listbox.pack(pady=10)
|
||||||
|
|
||||||
tk.Button(top_btn, text="Logout", bg="#f8d7da",
|
tk.Button(self.frame, text="Selesai Disajikan / Validasi", bg="#d1e7dd", command=self.validasi_layanan).pack(pady=10)
|
||||||
width=10, command=self.logout).grid(row=0, column=1, padx=5)
|
|
||||||
|
|
||||||
# =====================
|
self.order_ids = [] # Untuk menyimpan ID transaksi sesuai urutan listbox
|
||||||
# LIST PESANAN + SCROLL
|
|
||||||
# =====================
|
|
||||||
list_frame = tk.Frame(self.frame)
|
|
||||||
list_frame.pack(pady=10)
|
|
||||||
|
|
||||||
scrollbar = tk.Scrollbar(list_frame)
|
|
||||||
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
|
|
||||||
|
|
||||||
self.listbox = tk.Listbox(
|
|
||||||
list_frame,
|
|
||||||
width=90,
|
|
||||||
height=15,
|
|
||||||
yscrollcommand=scrollbar.set
|
|
||||||
)
|
|
||||||
self.listbox.pack(side=tk.LEFT)
|
|
||||||
|
|
||||||
scrollbar.config(command=self.listbox.yview)
|
|
||||||
|
|
||||||
# =====================
|
|
||||||
# BUTTON VALIDASI
|
|
||||||
# =====================
|
|
||||||
tk.Button(
|
|
||||||
self.frame,
|
|
||||||
text="✔ Pesanan Selesai Disajikan",
|
|
||||||
bg="#d1e7dd",
|
|
||||||
font=("Arial", 11, "bold"),
|
|
||||||
width=30,
|
|
||||||
command=self.validasi_layanan
|
|
||||||
).pack(pady=10)
|
|
||||||
|
|
||||||
self.order_ids = []
|
|
||||||
self.load_orders()
|
self.load_orders()
|
||||||
|
|
||||||
# =====================
|
|
||||||
# LOAD DATA
|
|
||||||
# =====================
|
|
||||||
def load_orders(self):
|
def load_orders(self):
|
||||||
self.listbox.delete(0, tk.END)
|
self.listbox.delete(0, tk.END)
|
||||||
self.order_ids = []
|
self.order_ids = []
|
||||||
|
|
||||||
db = connect()
|
db = connect()
|
||||||
cur = db.cursor()
|
cur = db.cursor()
|
||||||
|
# Ambil pesanan yang statusnya 'Pending'
|
||||||
cur.execute(
|
cur.execute("SELECT id, meja_id, total, status FROM transaksi WHERE status='Pending'")
|
||||||
"SELECT id, meja_id, total FROM transaksi WHERE status='Pending'"
|
|
||||||
)
|
|
||||||
rows = cur.fetchall()
|
rows = cur.fetchall()
|
||||||
|
|
||||||
for t_id, meja, total in rows:
|
for row in rows:
|
||||||
cur.execute(
|
t_id, meja, total, status = row
|
||||||
"SELECT menu_nama, jumlah FROM detail_transaksi WHERE transaksi_id=?",
|
# Ambil detail menu untuk ditampilkan
|
||||||
(t_id,)
|
cur.execute("SELECT menu_nama FROM detail_transaksi WHERE transaksi_id=?", (t_id,))
|
||||||
)
|
menus = [r[0] for r in cur.fetchall()]
|
||||||
details = cur.fetchall()
|
menu_str = ", ".join(menus)
|
||||||
|
|
||||||
self.listbox.insert(tk.END, f"Meja {meja} | ID Transaksi: {t_id}")
|
|
||||||
for menu, qty in details:
|
|
||||||
self.listbox.insert(tk.END, f" - {menu} x{qty}")
|
|
||||||
|
|
||||||
self.listbox.insert(tk.END, f"Total : Rp {total:,.0f}")
|
|
||||||
self.listbox.insert(tk.END, "-" * 70)
|
|
||||||
|
|
||||||
|
display_text = f"[Meja {meja}] ID:{t_id} | Menu: {menu_str} | Status: {status}"
|
||||||
|
self.listbox.insert(tk.END, display_text)
|
||||||
self.order_ids.append(t_id)
|
self.order_ids.append(t_id)
|
||||||
|
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
# =====================
|
|
||||||
# VALIDASI
|
|
||||||
# =====================
|
|
||||||
def validasi_layanan(self):
|
def validasi_layanan(self):
|
||||||
idx = self.listbox.curselection()
|
idx = self.listbox.curselection()
|
||||||
if not idx:
|
if not idx:
|
||||||
messagebox.showwarning("Pilih", "Pilih pesanan yang sudah disajikan")
|
messagebox.showwarning("Pilih", "Pilih pesanan yang sudah disajikan")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Cari ID terdekat ke atas
|
selected_id = self.order_ids[idx[0]]
|
||||||
selected_index = idx[0]
|
|
||||||
transaksi_index = selected_index // 5
|
|
||||||
transaksi_id = self.order_ids[transaksi_index]
|
|
||||||
|
|
||||||
db = connect()
|
db = connect()
|
||||||
cur = db.cursor()
|
cur = db.cursor()
|
||||||
cur.execute(
|
# Ubah status jadi 'Disajikan' agar muncul di kasir
|
||||||
"UPDATE transaksi SET status='Disajikan' WHERE id=?",
|
cur.execute("UPDATE transaksi SET status='Disajikan' WHERE id=?", (selected_id,))
|
||||||
(transaksi_id,)
|
|
||||||
)
|
|
||||||
db.commit()
|
db.commit()
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
messagebox.showinfo(
|
messagebox.showinfo("Sukses", "Pesanan selesai disajikan. Pelanggan bisa bayar di kasir.")
|
||||||
"Sukses",
|
|
||||||
"Pesanan ditandai selesai.\nKasir bisa memproses pembayaran."
|
|
||||||
)
|
|
||||||
self.load_orders()
|
self.load_orders()
|
||||||
|
|
||||||
def logout(self):
|
def logout(self):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user