diff --git a/__pycache__/database.cpython-313.pyc b/__pycache__/database.cpython-313.pyc new file mode 100644 index 0000000..3520dd4 Binary files /dev/null and b/__pycache__/database.cpython-313.pyc differ diff --git a/cafe app.css b/cafe app.css new file mode 100644 index 0000000..620f21f --- /dev/null +++ b/cafe app.css @@ -0,0 +1,10 @@ +Projek UAS/ +│ +├── main.py +├── database.py +│ +├── screens/ +│ ├── login_screen.py +│ ├── admin_dashboard.py +│ ├── kasir_dashboard.py +│ └── \ No newline at end of file diff --git a/database.py b/database.py new file mode 100644 index 0000000..4d8418e --- /dev/null +++ b/database.py @@ -0,0 +1,56 @@ +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 new file mode 100644 index 0000000..6cd9cb0 --- /dev/null +++ b/laporan_screen.py @@ -0,0 +1 @@ +import matplotlib.pyplot as plt \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..ceb8393 --- /dev/null +++ b/main.py @@ -0,0 +1,28 @@ +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 new file mode 100644 index 0000000..7fba832 --- /dev/null +++ b/order_screen.py @@ -0,0 +1,37 @@ +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/screens/__pycache__/database.cpython-313.pyc b/screens/__pycache__/database.cpython-313.pyc new file mode 100644 index 0000000..42a936b Binary files /dev/null and b/screens/__pycache__/database.cpython-313.pyc differ diff --git a/screens/__pycache__/login_screen.cpython-313.pyc b/screens/__pycache__/login_screen.cpython-313.pyc new file mode 100644 index 0000000..ba781b3 Binary files /dev/null and b/screens/__pycache__/login_screen.cpython-313.pyc differ diff --git a/screens/login_screen.py b/screens/login_screen.py new file mode 100644 index 0000000..5a9922c --- /dev/null +++ b/screens/login_screen.py @@ -0,0 +1,57 @@ +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 new file mode 100644 index 0000000..56a930e --- /dev/null +++ b/screens/menu_crud.py @@ -0,0 +1,27 @@ +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 new file mode 100644 index 0000000..8133667 --- /dev/null +++ b/screens/payment_screen.py @@ -0,0 +1,13 @@ +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) diff --git a/test.py b/test.py deleted file mode 100644 index ce47b77..0000000 --- a/test.py +++ /dev/null @@ -1 +0,0 @@ -print("hello") \ No newline at end of file