This commit is contained in:
Nathan 2025-12-07 18:19:21 +07:00
parent 7daa9875a5
commit 3d622c56e2
10 changed files with 229 additions and 0 deletions

10
cafe app.css Normal file
View File

@ -0,0 +1,10 @@
Projek UAS/
main.py
database.py
screens/
login_screen.py
admin_dashboard.py
kasir_dashboard.py

56
database.py Normal file
View File

@ -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()

1
laporan_screen.py Normal file
View File

@ -0,0 +1 @@
import matplotlib.pyplot as plt

28
main.py Normal file
View File

@ -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()

37
order_screen.py Normal file
View File

@ -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!")

Binary file not shown.

Binary file not shown.

57
screens/login_screen.py Normal file
View File

@ -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()

27
screens/menu_crud.py Normal file
View File

@ -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)

13
screens/payment_screen.py Normal file
View File

@ -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)