Waiter
This commit is contained in:
parent
89bac42dfe
commit
988ada5393
115
main.py
115
main.py
@ -646,6 +646,7 @@ class App:
|
||||
self.login_frame()
|
||||
style = ttk.Style()
|
||||
style.configure("Accent.TButton", font=("Arial", 11, "bold"))
|
||||
style.configure("TButton", padding=6) # Padding tombol lebih besar
|
||||
|
||||
def login_frame(self):
|
||||
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)
|
||||
|
||||
# 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")
|
||||
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("User ID", text="User ID")
|
||||
@ -1471,34 +1475,67 @@ class App:
|
||||
self.waiter_tree.column("Promo", width=80)
|
||||
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)
|
||||
detail_frame = ttk.LabelFrame(parent, text="Detail Pesanan", padding=10)
|
||||
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)
|
||||
self.waiter_tree.pack(side='left', fill='both', expand=True)
|
||||
tree_scroll.pack(side='right', fill='y')
|
||||
|
||||
# Bind event saat pilih pesanan
|
||||
self.waiter_tree.bind("<<TreeviewSelect>>", self.on_waiter_select)
|
||||
|
||||
# Tombol aksi
|
||||
action_frame = ttk.Frame(parent)
|
||||
action_frame.pack(pady=10)
|
||||
# Detail pesanan dengan SCROLLBAR
|
||||
detail_frame = ttk.LabelFrame(parent, text="📋 Detail Pesanan Terpilih", padding=10)
|
||||
detail_frame.pack(fill='both', expand=True, padx=10, pady=6)
|
||||
|
||||
ttk.Button(action_frame, text="✅ Terima Pesanan (Pending → Menunggu)",
|
||||
command=lambda: self.update_order_status('menunggu'),
|
||||
width=35).pack(pady=3)
|
||||
ttk.Button(action_frame, text="🍳 Proses Pesanan (Menunggu → Diproses)",
|
||||
command=lambda: self.update_order_status('diproses'),
|
||||
width=35).pack(pady=3)
|
||||
ttk.Button(action_frame, text="🍽️ Selesai Disajikan (Diproses → Selesai)",
|
||||
command=lambda: self.update_order_status('selesai'),
|
||||
width=35).pack(pady=3)
|
||||
ttk.Button(action_frame, text="💰 Selesai Dilayani (Selesai → Dibayar)",
|
||||
command=lambda: self.update_order_status('dibayar'),
|
||||
width=35).pack(pady=3)
|
||||
# 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'),
|
||||
width=40
|
||||
).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'),
|
||||
width=40
|
||||
).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'),
|
||||
width=40
|
||||
).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'),
|
||||
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
|
||||
self.reload_waiter_orders()
|
||||
@ -1591,7 +1628,7 @@ class App:
|
||||
transaksi_id = item[0]
|
||||
current_status = item[4]
|
||||
|
||||
# Validasi flow status
|
||||
# Validasi flow status yang BENAR
|
||||
valid_transitions = {
|
||||
'pending': ['menunggu'],
|
||||
'menunggu': ['diproses'],
|
||||
@ -1599,30 +1636,42 @@ class App:
|
||||
'selesai': ['dibayar']
|
||||
}
|
||||
|
||||
# Cek apakah current status valid
|
||||
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
|
||||
|
||||
# Cek apakah new_status valid untuk current_status
|
||||
if new_status not in valid_transitions[current_status]:
|
||||
messagebox.showwarning("Invalid",
|
||||
f"Tidak bisa ubah dari '{current_status}' ke '{new_status}'.\n"
|
||||
f"Status berikutnya: {', '.join(valid_transitions[current_status])}")
|
||||
expected = ', '.join(valid_transitions[current_status])
|
||||
messagebox.showwarning("Status Tidak Valid",
|
||||
f"❌ Tidak bisa ubah dari '{current_status}' ke '{new_status}'.\n\n"
|
||||
f"✅ Status yang benar setelah '{current_status}' adalah:\n"
|
||||
f" → {expected}")
|
||||
return
|
||||
|
||||
# Konfirmasi
|
||||
if not messagebox.askyesno("Konfirmasi",
|
||||
f"Ubah status pesanan #{transaksi_id}\n"
|
||||
f"dari '{current_status}' ke '{new_status}'?"):
|
||||
if not messagebox.askyesno("Konfirmasi Ubah Status",
|
||||
f"Ubah status pesanan #{transaksi_id}\n\n"
|
||||
f"Dari: {current_status.upper()}\n"
|
||||
f"Ke: {new_status.upper()}\n\n"
|
||||
f"Lanjutkan?"):
|
||||
return
|
||||
|
||||
# Update status
|
||||
success = transaksi_update_status(transaksi_id, new_status)
|
||||
|
||||
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()
|
||||
# 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:
|
||||
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
|
||||
1,Americano,Minuman,20000,7,,1,0
|
||||
1,Americano,Minuman,20000,6,,1,0
|
||||
2,Latte,Minuman,25000,1,,1,10
|
||||
3,Banana Cake,Dessert,30000,0,,0,0
|
||||
4,Nasi Goreng,Makanan,35000,0,,0,0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user