diff --git a/__pycache__/database.cpython-313.pyc b/__pycache__/database.cpython-313.pyc deleted file mode 100644 index 3520dd4..0000000 Binary files a/__pycache__/database.cpython-313.pyc and /dev/null differ diff --git a/cafe app.css b/cafe app.css deleted file mode 100644 index addc845..0000000 --- a/cafe app.css +++ /dev/null @@ -1,10 +0,0 @@ -Python-Menu/ -│ -├── main.py -├── database.py -│ -├── screens/ -│ ├── login_screen.py -│ ├── admin_dashboard.py -│ ├── kasir_dashboard.py -│ └── \ No newline at end of file diff --git a/cafe.db b/cafe.db new file mode 100644 index 0000000..050d817 Binary files /dev/null and b/cafe.db differ diff --git a/database.py b/database.py deleted file mode 100644 index 4d8418e..0000000 --- a/database.py +++ /dev/null @@ -1,56 +0,0 @@ -import sqlite3 - -def connect(): - return sqlite3.connect("cafe.db") - -def setup(): - db = connect() - cursor = db.cursor() - - cursor.execute(""" - CREATE TABLE IF NOT EXISTS users ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - username TEXT, - password TEXT, - role TEXT - )""") - - cursor.execute(""" - CREATE TABLE IF NOT EXISTS menu ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - nama TEXT, - kategori TEXT, - harga INTEGER, - stok INTEGER, - foto TEXT - )""") - - cursor.execute(""" - CREATE TABLE IF NOT EXISTS meja ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - nomor INTEGER, - status TEXT - )""") - - cursor.execute(""" - CREATE TABLE IF NOT EXISTS transaksi ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - tanggal TEXT, - total INTEGER, - metode_pembayaran TEXT, - meja_id INTEGER, - status TEXT - )""") - - cursor.execute(""" - CREATE TABLE IF NOT EXISTS detail_transaksi ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - transaksi_id INTEGER, - menu_id INTEGER, - jumlah INTEGER, - subtotal INTEGER, - diskon INTEGER - )""") - - db.commit() - db.close() diff --git a/laporan_screen.py b/laporan_screen.py deleted file mode 100644 index 6cd9cb0..0000000 --- a/laporan_screen.py +++ /dev/null @@ -1 +0,0 @@ -import matplotlib.pyplot as plt \ No newline at end of file diff --git a/main.py b/main.py deleted file mode 100644 index ceb8393..0000000 --- a/main.py +++ /dev/null @@ -1,28 +0,0 @@ -import tkinter as tk -from database import setup -from screens.login_screen import LoginScreen - -# Setup database saat awal run -setup() - -class CafeApp(tk.Tk): - def __init__(self): - super().__init__() - self.title("Cafe Application - Tkinter") - self.geometry("900x600") - self.resizable(False, False) - - # Frame container - self.container = tk.Frame(self) - self.container.pack(fill="both", expand=True) - - self.show_login() - - def show_login(self): - for widget in self.container.winfo_children(): - widget.destroy() - LoginScreen(self.container, self) - -if __name__ == "__main__": - app = CafeApp() - app.mainloop() \ No newline at end of file diff --git a/order_screen.py b/order_screen.py deleted file mode 100644 index 7fba832..0000000 --- a/order_screen.py +++ /dev/null @@ -1,37 +0,0 @@ -import tkinter as tk -from tkinter import ttk, messagebox -from database import connect - -class PembeliMenu(tk.Frame): - def __init__(self, parent, controller): - super().__init__(parent) - self.controller = controller - self.pack(fill="both", expand=True) - - tk.Label(self, text="MENU CAFE", font=("Arial", 18, "bold")).pack(pady=20) - - self.tree = ttk.Treeview(self, columns=("nama","kategori","harga","stok"), show="headings") - self.tree.heading("nama", text="Nama") - self.tree.heading("kategori", text="Kategori") - self.tree.heading("harga", text="Harga") - self.tree.heading("stok", text="Stok") - self.tree.pack(fill="both", expand=True) - - tk.Button(self, text="Pesan", command=self.pesan).pack(pady=10) - - self.load_menu() - - def load_menu(self): - db = connect() - cur = db.cursor() - cur.execute("SELECT nama, kategori, harga, stok FROM menu") - for row in cur.fetchall(): - self.tree.insert("", tk.END, values=row) - db.close() - - def pesan(self): - item = self.tree.selection() - if not item: - messagebox.showwarning("Pilih Item", "Pilih menu yang ingin dipesan") - return - messagebox.showinfo("Pesanan", "Menu berhasil ditambahkan ke pesanan!") diff --git a/project/__pycache__/admin_dashboard.cpython-313.pyc b/project/__pycache__/admin_dashboard.cpython-313.pyc new file mode 100644 index 0000000..5435bed Binary files /dev/null and b/project/__pycache__/admin_dashboard.cpython-313.pyc differ diff --git a/project/__pycache__/database.cpython-313.pyc b/project/__pycache__/database.cpython-313.pyc new file mode 100644 index 0000000..30a0d09 Binary files /dev/null and b/project/__pycache__/database.cpython-313.pyc differ diff --git a/project/__pycache__/kasir_dashboard.cpython-313.pyc b/project/__pycache__/kasir_dashboard.cpython-313.pyc new file mode 100644 index 0000000..e1ca0aa Binary files /dev/null and b/project/__pycache__/kasir_dashboard.cpython-313.pyc differ diff --git a/project/__pycache__/pembeli_menu.cpython-313.pyc b/project/__pycache__/pembeli_menu.cpython-313.pyc new file mode 100644 index 0000000..88746e1 Binary files /dev/null and b/project/__pycache__/pembeli_menu.cpython-313.pyc differ diff --git a/project/__pycache__/pemilik_dashboard.cpython-313.pyc b/project/__pycache__/pemilik_dashboard.cpython-313.pyc new file mode 100644 index 0000000..17b5c3f Binary files /dev/null and b/project/__pycache__/pemilik_dashboard.cpython-313.pyc differ diff --git a/project/__pycache__/waiter_dashboard.cpython-313.pyc b/project/__pycache__/waiter_dashboard.cpython-313.pyc new file mode 100644 index 0000000..6596aeb Binary files /dev/null and b/project/__pycache__/waiter_dashboard.cpython-313.pyc differ diff --git a/project/admin_dashboard.py b/project/admin_dashboard.py new file mode 100644 index 0000000..26d8710 --- /dev/null +++ b/project/admin_dashboard.py @@ -0,0 +1,7 @@ +import tkinter as tk + +class AdminDashboard(tk.Frame): + def __init__(self, parent, controller): + super().__init__(parent) + tk.Label(self, text="ADMIN DASHBOARD", font=("Arial", 20, "bold")).pack(pady=20) + tk.Button(self, text="Logout", command=lambda: controller.show_frame("Login")).pack() diff --git a/project/database.py b/project/database.py new file mode 100644 index 0000000..3836f4e --- /dev/null +++ b/project/database.py @@ -0,0 +1,44 @@ +import sqlite3 + +def connect(): + return sqlite3.connect("cafe.db") + +def setup_database(): + db = connect() + cur = db.cursor() + + # Table users + cur.execute(""" + CREATE TABLE IF NOT EXISTS users ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + username TEXT, + password TEXT, + role TEXT + ) + """) + + # Table menu (buat nanti) + cur.execute(""" + CREATE TABLE IF NOT EXISTS menu ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + nama TEXT, + kategori TEXT, + harga REAL, + stok INTEGER + ) + """) + + # Tambah user default + cur.execute("SELECT COUNT(*) FROM users") + if cur.fetchone()[0] == 0: + users = [ + ("admin", "admin", "admin"), + ("kasir", "kasir", "kasir"), + ("waiter", "waiter", "waiter"), + ("pembeli", "pembeli", "pembeli"), + ("pemilik", "pemilik", "pemilik cafe") + ] + cur.executemany("INSERT INTO users(username,password,role) VALUES (?,?,?)", users) + db.commit() + + db.close() diff --git a/project/kasir_dashboard.py b/project/kasir_dashboard.py new file mode 100644 index 0000000..bd10ca7 --- /dev/null +++ b/project/kasir_dashboard.py @@ -0,0 +1,7 @@ +import tkinter as tk + +class KasirDashboard(tk.Frame): + def __init__(self, parent, controller): + super().__init__(parent) + tk.Label(self, text="KASIR DASHBOARD", font=("Arial", 20, "bold")).pack(pady=20) + tk.Button(self, text="Logout", command=lambda: controller.show_frame("Login")).pack() diff --git a/project/main.py b/project/main.py new file mode 100644 index 0000000..78b340c --- /dev/null +++ b/project/main.py @@ -0,0 +1,94 @@ +import tkinter as tk +from tkinter import messagebox +from database import setup_database, connect + +from admin_dashboard import AdminDashboard +from kasir_dashboard import KasirDashboard +from waiter_dashboard import WaiterDashboard +from pembeli_menu import PembeliMenu +from pemilik_dashboard import PemilikDashboard + + +class App(tk.Tk): + def __init__(self): + super().__init__() + self.title("Sistem Cafe") + self.geometry("500x400") + + self.container = tk.Frame(self) + self.container.pack(fill="both", expand=True) + + self.frames = {} + + # Register screens + for name, FrameClass in { + "Login": LoginScreen, + "Admin": AdminDashboard, + "Kasir": KasirDashboard, + "Waiter": WaiterDashboard, + "Pembeli": PembeliMenu, + "Pemilik": PemilikDashboard + }.items(): + frame = FrameClass(self.container, self) + self.frames[name] = frame + frame.grid(row=0, column=0, sticky="nsew") + + self.show_frame("Login") + + def show_frame(self, name): + frame = self.frames[name] + frame.tkraise() + + +class LoginScreen(tk.Frame): + def __init__(self, parent, controller): + super().__init__(parent) + self.controller = controller + + tk.Label(self, text="LOGIN SISTEM CAFE", font=("Arial", 20, "bold")).pack(pady=20) + + tk.Label(self, text="Username").pack() + self.username_entry = tk.Entry(self, width=30) + self.username_entry.pack() + + tk.Label(self, text="Password").pack() + self.password_entry = tk.Entry(self, width=30, show="*") + self.password_entry.pack() + + tk.Button(self, text="Login", width=20, command=self.login).pack(pady=15) + + def login(self): + username = self.username_entry.get() + password = self.password_entry.get() + + db = connect() + cur = db.cursor() + + cur.execute("SELECT role FROM users WHERE username=? AND password=?", (username, password)) + result = cur.fetchone() + + if result: + role = result[0] + + if role == "admin": + self.controller.show_frame("Admin") + elif role == "kasir": + self.controller.show_frame("Kasir") + elif role == "waiter": + self.controller.show_frame("Waiter") + elif role == "pembeli": + self.controller.show_frame("Pembeli") + elif role == "pemilik cafe": + self.controller.show_frame("Pemilik") + + else: + messagebox.showerror("Error", "Username atau password salah") + + db.close() + + +# RUN PROGRAM +if __name__ == "__main__": + setup_database() + app = App() + app.mainloop() diff --git a/project/pembeli_menu.py b/project/pembeli_menu.py new file mode 100644 index 0000000..6a8e161 --- /dev/null +++ b/project/pembeli_menu.py @@ -0,0 +1,7 @@ +import tkinter as tk + +class PembeliMenu(tk.Frame): + def __init__(self, parent, controller): + super().__init__(parent) + tk.Label(self, text="MENU PEMBELI", font=("Arial", 20, "bold")).pack(pady=20) + tk.Button(self, text="Logout", command=lambda: controller.show_frame("Login")).pack() diff --git a/project/pemilik_dashboard.py b/project/pemilik_dashboard.py new file mode 100644 index 0000000..aa445e7 --- /dev/null +++ b/project/pemilik_dashboard.py @@ -0,0 +1,7 @@ +import tkinter as tk + +class PemilikDashboard(tk.Frame): + def __init__(self, parent, controller): + super().__init__(parent) + tk.Label(self, text="PEMILIK CAFE DASHBOARD", font=("Arial", 20, "bold")).pack(pady=20) + tk.Button(self, text="Logout", command=lambda: controller.show_frame("Login")).pack() diff --git a/project/project.css b/project/project.css new file mode 100644 index 0000000..e4cb90d --- /dev/null +++ b/project/project.css @@ -0,0 +1,8 @@ +project/ +│ main.py +│ database.py +│ admin_dashboard.py +│ kasir_dashboard.py +│ waiter_dashboard.py +│ pembeli_menu.py +│ pemilik_dashboard.py diff --git a/project/waiter_dashboard.py b/project/waiter_dashboard.py new file mode 100644 index 0000000..0a5549a --- /dev/null +++ b/project/waiter_dashboard.py @@ -0,0 +1,7 @@ +import tkinter as tk + +class WaiterDashboard(tk.Frame): + def __init__(self, parent, controller): + super().__init__(parent) + tk.Label(self, text="WAITER DASHBOARD", font=("Arial", 20, "bold")).pack(pady=20) + tk.Button(self, text="Logout", command=lambda: controller.show_frame("Login")).pack() diff --git a/screens/__pycache__/login_screen.cpython-313.pyc b/screens/__pycache__/login_screen.cpython-313.pyc deleted file mode 100644 index ba781b3..0000000 Binary files a/screens/__pycache__/login_screen.cpython-313.pyc and /dev/null differ diff --git a/screens/login_screen.py b/screens/login_screen.py deleted file mode 100644 index 5a9922c..0000000 --- a/screens/login_screen.py +++ /dev/null @@ -1,57 +0,0 @@ -import tkinter as tk -from tkinter import messagebox -import sqlite3 -from database import connect -from screens.admin_dashboard import AdminDashboard -from screens.kasir_dashboard import KasirDashboard -from screens.waiter_dashboard import WaiterDashboard -from screens.pembeli_menu import PembeliMenu - -class LoginScreen(tk.Frame): - def __init__(self, parent, controller): - super().__init__(parent) - self.controller = controller - self.pack(fill="both", expand=True) - - tk.Label(self, text="LOGIN SISTEM CAFE", font=("Arial", 22, "bold")).pack(pady=30) - - tk.Label(self, text="Username").pack() - self.username_entry = tk.Entry(self, width=30) - self.username_entry.pack() - - tk.Label(self, text="Password").pack() - self.password_entry = tk.Entry(self, width=30, show="*") - self.password_entry.pack() - - tk.Button(self, text="Login", width=20, command=self.login).pack(pady=10) - - def login(self): - username = self.username_entry.get() - password = self.password_entry.get() - - db = connect() - cur = db.cursor() - - cur.execute("SELECT role FROM users WHERE username=? AND password=?", - (username, password)) - result = cur.fetchone() - - if result: - role = result[0] - messagebox.showinfo("Success", f"Login sebagai {role}") - - if role == "pemilik cafe": - AdminDashboard(self.controller.container, self.controller) - elif role == "admin": - AdminDashboard(self.controller.container, self.controller) - elif role == "kasir": - KasirDashboard(self.controller.container, self.controller) - elif role == "waiter": - WaiterDashboard(self.controller.container, self.controller) - elif role == "pembeli": - PembeliMenu(self.controller.container, self.controller) - - else: - messagebox.showerror("Error", "Username atau password salah") - - db.close() \ No newline at end of file diff --git a/screens/menu_crud.py b/screens/menu_crud.py deleted file mode 100644 index 56a930e..0000000 --- a/screens/menu_crud.py +++ /dev/null @@ -1,27 +0,0 @@ -import tkinter as tk -from tkinter import ttk, messagebox -from database import connect - -class AdminDashboard(tk.Frame): - def __init__(self, parent, controller): - super().__init__(parent) - self.controller = controller - self.pack(fill="both", expand=True) - - tk.Label(self, text="ADMIN DASHBOARD", font=("Arial", 20, "bold")).pack(pady=20) - - tk.Button(self, text="Kelola Menu", command=self.open_menu_crud).pack(pady=5) - tk.Button(self, text="Lihat Laporan", command=self.open_laporan).pack(pady=5) - tk.Button(self, text="Logout", command=self.logout).pack(pady=5) - - def open_menu_crud(self): - from screens.menu_crud import MenuCRUD - MenuCRUD(self.controller.container, self.controller) - - def open_laporan(self): - from screens.laporan_screen import LaporanScreen - LaporanScreen(self.controller.container, self.controller) - - def logout(self): - from screens.login_screen import LoginScreen - LoginScreen(self.controller.container, self.controller) diff --git a/screens/payment_screen.py b/screens/payment_screen.py deleted file mode 100644 index 8133667..0000000 --- a/screens/payment_screen.py +++ /dev/null @@ -1,13 +0,0 @@ -class KasirDashboard(tk.Frame): - def __init__(self, parent, controller): - super().__init__(parent) - self.controller = controller - self.pack(fill="both", expand=True) - - tk.Label(self, text="KASIR DASHBOARD", font=("Arial", 18, "bold")).pack(pady=20) - - tk.Button(self, text="Proses Pembayaran", command=self.open_payment).pack(pady=10) - - def open_payment(self): - from screens.payment_screen import PaymentScreen - PaymentScreen(self.controller.container, self.controller)