Waiter
This commit is contained in:
parent
89bac42dfe
commit
988ada5393
107
main.py
107
main.py
@ -646,6 +646,7 @@ class App:
|
|||||||
self.login_frame()
|
self.login_frame()
|
||||||
style = ttk.Style()
|
style = ttk.Style()
|
||||||
style.configure("Accent.TButton", font=("Arial", 11, "bold"))
|
style.configure("Accent.TButton", font=("Arial", 11, "bold"))
|
||||||
|
style.configure("TButton", padding=6) # Padding tombol lebih besar
|
||||||
|
|
||||||
def login_frame(self):
|
def login_frame(self):
|
||||||
for w in self.root.winfo_children():
|
for w in self.root.winfo_children():
|
||||||
@ -1452,8 +1453,11 @@ class App:
|
|||||||
ttk.Button(filter_frame, text="Selesai", command=lambda: self.reload_waiter_orders('selesai')).pack(side='left', padx=3)
|
ttk.Button(filter_frame, text="Selesai", command=lambda: self.reload_waiter_orders('selesai')).pack(side='left', padx=3)
|
||||||
|
|
||||||
# Treeview pesanan
|
# Treeview pesanan
|
||||||
|
tree_frame = ttk.Frame(parent)
|
||||||
|
tree_frame.pack(fill='x', padx=10, pady=6)
|
||||||
|
|
||||||
cols = ("ID", "User ID", "No.Meja", "Total", "Status", "Promo", "Tanggal")
|
cols = ("ID", "User ID", "No.Meja", "Total", "Status", "Promo", "Tanggal")
|
||||||
self.waiter_tree = ttk.Treeview(parent, columns=cols, show='headings', height=12)
|
self.waiter_tree = ttk.Treeview(tree_frame, columns=cols, show='headings', height=10)
|
||||||
|
|
||||||
self.waiter_tree.heading("ID", text="ID")
|
self.waiter_tree.heading("ID", text="ID")
|
||||||
self.waiter_tree.heading("User ID", text="User ID")
|
self.waiter_tree.heading("User ID", text="User ID")
|
||||||
@ -1471,34 +1475,67 @@ class App:
|
|||||||
self.waiter_tree.column("Promo", width=80)
|
self.waiter_tree.column("Promo", width=80)
|
||||||
self.waiter_tree.column("Tanggal", width=140)
|
self.waiter_tree.column("Tanggal", width=140)
|
||||||
|
|
||||||
self.waiter_tree.pack(fill='both', expand=True, padx=10, pady=6)
|
# Scrollbar untuk tree
|
||||||
|
tree_scroll = ttk.Scrollbar(tree_frame, orient='vertical', command=self.waiter_tree.yview)
|
||||||
|
self.waiter_tree.configure(yscrollcommand=tree_scroll.set)
|
||||||
|
|
||||||
# Detail pesanan (muncul saat pilih row)
|
self.waiter_tree.pack(side='left', fill='both', expand=True)
|
||||||
detail_frame = ttk.LabelFrame(parent, text="Detail Pesanan", padding=10)
|
tree_scroll.pack(side='right', fill='y')
|
||||||
detail_frame.pack(fill='x', padx=10, pady=6)
|
|
||||||
|
|
||||||
self.waiter_detail_text = tk.Text(detail_frame, height=8, width=80)
|
|
||||||
self.waiter_detail_text.pack(fill='both', expand=True)
|
|
||||||
|
|
||||||
# Bind event saat pilih pesanan
|
# Bind event saat pilih pesanan
|
||||||
self.waiter_tree.bind("<<TreeviewSelect>>", self.on_waiter_select)
|
self.waiter_tree.bind("<<TreeviewSelect>>", self.on_waiter_select)
|
||||||
|
|
||||||
# Tombol aksi
|
# Detail pesanan dengan SCROLLBAR
|
||||||
action_frame = ttk.Frame(parent)
|
detail_frame = ttk.LabelFrame(parent, text="📋 Detail Pesanan Terpilih", padding=10)
|
||||||
action_frame.pack(pady=10)
|
detail_frame.pack(fill='both', expand=True, padx=10, pady=6)
|
||||||
|
|
||||||
ttk.Button(action_frame, text="✅ Terima Pesanan (Pending → Menunggu)",
|
# Frame untuk text + scrollbar
|
||||||
|
text_frame = ttk.Frame(detail_frame)
|
||||||
|
text_frame.pack(fill='both', expand=True)
|
||||||
|
|
||||||
|
self.waiter_detail_text = tk.Text(text_frame, height=8, width=100, font=("Courier New", 9), wrap='word')
|
||||||
|
detail_scroll = ttk.Scrollbar(text_frame, orient='vertical', command=self.waiter_detail_text.yview)
|
||||||
|
self.waiter_detail_text.configure(yscrollcommand=detail_scroll.set)
|
||||||
|
|
||||||
|
self.waiter_detail_text.pack(side='left', fill='both', expand=True)
|
||||||
|
detail_scroll.pack(side='right', fill='y')
|
||||||
|
|
||||||
|
# Tombol aksi - PASTI KELIHATAN
|
||||||
|
action_frame = ttk.LabelFrame(parent, text="🎯 Ubah Status Pesanan", padding=15)
|
||||||
|
action_frame.pack(fill='x', padx=10, pady=10)
|
||||||
|
|
||||||
|
# Grid 2x2 untuk 4 tombol
|
||||||
|
ttk.Button(
|
||||||
|
action_frame,
|
||||||
|
text="✅ Terima Pesanan (Pending → Menunggu)",
|
||||||
command=lambda: self.update_order_status('menunggu'),
|
command=lambda: self.update_order_status('menunggu'),
|
||||||
width=35).pack(pady=3)
|
width=40
|
||||||
ttk.Button(action_frame, text="🍳 Proses Pesanan (Menunggu → Diproses)",
|
).grid(row=0, column=0, padx=5, pady=5, sticky='ew')
|
||||||
|
|
||||||
|
ttk.Button(
|
||||||
|
action_frame,
|
||||||
|
text="🍳 Proses Pesanan (Menunggu → Diproses)",
|
||||||
command=lambda: self.update_order_status('diproses'),
|
command=lambda: self.update_order_status('diproses'),
|
||||||
width=35).pack(pady=3)
|
width=40
|
||||||
ttk.Button(action_frame, text="🍽️ Selesai Disajikan (Diproses → Selesai)",
|
).grid(row=0, column=1, padx=5, pady=5, sticky='ew')
|
||||||
|
|
||||||
|
ttk.Button(
|
||||||
|
action_frame,
|
||||||
|
text="🍽️ Selesai Disajikan (Diproses → Selesai)",
|
||||||
command=lambda: self.update_order_status('selesai'),
|
command=lambda: self.update_order_status('selesai'),
|
||||||
width=35).pack(pady=3)
|
width=40
|
||||||
ttk.Button(action_frame, text="💰 Selesai Dilayani (Selesai → Dibayar)",
|
).grid(row=1, column=0, padx=5, pady=5, sticky='ew')
|
||||||
|
|
||||||
|
ttk.Button(
|
||||||
|
action_frame,
|
||||||
|
text="💰 Selesai Dilayani (Selesai → Dibayar)",
|
||||||
command=lambda: self.update_order_status('dibayar'),
|
command=lambda: self.update_order_status('dibayar'),
|
||||||
width=35).pack(pady=3)
|
width=40
|
||||||
|
).grid(row=1, column=1, padx=5, pady=5, sticky='ew')
|
||||||
|
|
||||||
|
# Buat kolom responsive
|
||||||
|
action_frame.columnconfigure(0, weight=1)
|
||||||
|
action_frame.columnconfigure(1, weight=1)
|
||||||
|
|
||||||
# Load data
|
# Load data
|
||||||
self.reload_waiter_orders()
|
self.reload_waiter_orders()
|
||||||
@ -1591,7 +1628,7 @@ class App:
|
|||||||
transaksi_id = item[0]
|
transaksi_id = item[0]
|
||||||
current_status = item[4]
|
current_status = item[4]
|
||||||
|
|
||||||
# Validasi flow status
|
# Validasi flow status yang BENAR
|
||||||
valid_transitions = {
|
valid_transitions = {
|
||||||
'pending': ['menunggu'],
|
'pending': ['menunggu'],
|
||||||
'menunggu': ['diproses'],
|
'menunggu': ['diproses'],
|
||||||
@ -1599,30 +1636,42 @@ class App:
|
|||||||
'selesai': ['dibayar']
|
'selesai': ['dibayar']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Cek apakah current status valid
|
||||||
if current_status not in valid_transitions:
|
if current_status not in valid_transitions:
|
||||||
messagebox.showerror("Error", f"Status '{current_status}' tidak bisa diubah lagi")
|
messagebox.showerror("Error", f"Status '{current_status}' sudah final, tidak bisa diubah lagi")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Cek apakah new_status valid untuk current_status
|
||||||
if new_status not in valid_transitions[current_status]:
|
if new_status not in valid_transitions[current_status]:
|
||||||
messagebox.showwarning("Invalid",
|
expected = ', '.join(valid_transitions[current_status])
|
||||||
f"Tidak bisa ubah dari '{current_status}' ke '{new_status}'.\n"
|
messagebox.showwarning("Status Tidak Valid",
|
||||||
f"Status berikutnya: {', '.join(valid_transitions[current_status])}")
|
f"❌ Tidak bisa ubah dari '{current_status}' ke '{new_status}'.\n\n"
|
||||||
|
f"✅ Status yang benar setelah '{current_status}' adalah:\n"
|
||||||
|
f" → {expected}")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Konfirmasi
|
# Konfirmasi
|
||||||
if not messagebox.askyesno("Konfirmasi",
|
if not messagebox.askyesno("Konfirmasi Ubah Status",
|
||||||
f"Ubah status pesanan #{transaksi_id}\n"
|
f"Ubah status pesanan #{transaksi_id}\n\n"
|
||||||
f"dari '{current_status}' ke '{new_status}'?"):
|
f"Dari: {current_status.upper()}\n"
|
||||||
|
f"Ke: {new_status.upper()}\n\n"
|
||||||
|
f"Lanjutkan?"):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Update status
|
# Update status
|
||||||
success = transaksi_update_status(transaksi_id, new_status)
|
success = transaksi_update_status(transaksi_id, new_status)
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
messagebox.showinfo("Sukses", f"Status diubah menjadi '{new_status}'")
|
messagebox.showinfo("✅ Berhasil", f"Status berhasil diubah menjadi '{new_status.upper()}'")
|
||||||
self.reload_waiter_orders()
|
self.reload_waiter_orders()
|
||||||
|
# Auto select row yang sama setelah reload
|
||||||
|
for item_id in self.waiter_tree.get_children():
|
||||||
|
if self.waiter_tree.item(item_id)['values'][0] == transaksi_id:
|
||||||
|
self.waiter_tree.selection_set(item_id)
|
||||||
|
self.waiter_tree.see(item_id)
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
messagebox.showerror("Error", "Gagal update status")
|
messagebox.showerror("❌ Gagal", "Gagal mengubah status pesanan")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
menu.csv
2
menu.csv
@ -1,5 +1,5 @@
|
|||||||
id,nama,kategori,harga,stok,foto,tersedia,item_discount_pct
|
id,nama,kategori,harga,stok,foto,tersedia,item_discount_pct
|
||||||
1,Americano,Minuman,20000,7,,1,0
|
1,Americano,Minuman,20000,6,,1,0
|
||||||
2,Latte,Minuman,25000,1,,1,10
|
2,Latte,Minuman,25000,1,,1,10
|
||||||
3,Banana Cake,Dessert,30000,0,,0,0
|
3,Banana Cake,Dessert,30000,0,,0,0
|
||||||
4,Nasi Goreng,Makanan,35000,0,,0,0
|
4,Nasi Goreng,Makanan,35000,0,,0,0
|
||||||
|
|||||||
|
Loading…
x
Reference in New Issue
Block a user