Merge branch 'main' of https://git-eng.ukwms.ac.id/5803025001/Python-Menu
This commit is contained in:
commit
1af2ad68ad
Binary file not shown.
10
cafe app.css
10
cafe app.css
@ -1,10 +0,0 @@
|
|||||||
Python-Menu/
|
|
||||||
│
|
|
||||||
├── main.py
|
|
||||||
├── database.py
|
|
||||||
│
|
|
||||||
├── screens/
|
|
||||||
│ ├── login_screen.py
|
|
||||||
│ ├── admin_dashboard.py
|
|
||||||
│ ├── kasir_dashboard.py
|
|
||||||
│ └──
|
|
||||||
56
database.py
56
database.py
@ -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()
|
|
||||||
@ -1 +0,0 @@
|
|||||||
import matplotlib.pyplot as plt
|
|
||||||
28
main.py
28
main.py
@ -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()
|
|
||||||
@ -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!")
|
|
||||||
BIN
project/__pycache__/admin_dashboard.cpython-313.pyc
Normal file
BIN
project/__pycache__/admin_dashboard.cpython-313.pyc
Normal file
Binary file not shown.
BIN
project/__pycache__/database.cpython-313.pyc
Normal file
BIN
project/__pycache__/database.cpython-313.pyc
Normal file
Binary file not shown.
BIN
project/__pycache__/kasir_dashboard.cpython-313.pyc
Normal file
BIN
project/__pycache__/kasir_dashboard.cpython-313.pyc
Normal file
Binary file not shown.
BIN
project/__pycache__/pembeli_menu.cpython-313.pyc
Normal file
BIN
project/__pycache__/pembeli_menu.cpython-313.pyc
Normal file
Binary file not shown.
BIN
project/__pycache__/pemilik_dashboard.cpython-313.pyc
Normal file
BIN
project/__pycache__/pemilik_dashboard.cpython-313.pyc
Normal file
Binary file not shown.
BIN
project/__pycache__/waiter_dashboard.cpython-313.pyc
Normal file
BIN
project/__pycache__/waiter_dashboard.cpython-313.pyc
Normal file
Binary file not shown.
7
project/admin_dashboard.py
Normal file
7
project/admin_dashboard.py
Normal file
@ -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()
|
||||||
44
project/database.py
Normal file
44
project/database.py
Normal file
@ -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()
|
||||||
7
project/kasir_dashboard.py
Normal file
7
project/kasir_dashboard.py
Normal file
@ -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()
|
||||||
94
project/main.py
Normal file
94
project/main.py
Normal file
@ -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()
|
||||||
7
project/pembeli_menu.py
Normal file
7
project/pembeli_menu.py
Normal file
@ -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()
|
||||||
7
project/pemilik_dashboard.py
Normal file
7
project/pemilik_dashboard.py
Normal file
@ -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()
|
||||||
8
project/project.css
Normal file
8
project/project.css
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
project/
|
||||||
|
│ main.py
|
||||||
|
│ database.py
|
||||||
|
│ admin_dashboard.py
|
||||||
|
│ kasir_dashboard.py
|
||||||
|
│ waiter_dashboard.py
|
||||||
|
│ pembeli_menu.py
|
||||||
|
│ pemilik_dashboard.py
|
||||||
7
project/waiter_dashboard.py
Normal file
7
project/waiter_dashboard.py
Normal file
@ -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()
|
||||||
Binary file not shown.
@ -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()
|
|
||||||
@ -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)
|
|
||||||
@ -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)
|
|
||||||
Loading…
x
Reference in New Issue
Block a user