-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
243 lines (222 loc) · 8.06 KB
/
Copy pathapp.py
File metadata and controls
243 lines (222 loc) · 8.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
import streamlit as st
from database import check_login
import pandas as pd
# Page Config V25 - Identity & Branding
st.set_page_config(
page_title="UzPos | Premium Admin",
page_icon="images/logo.ico",
layout="wide",
initial_sidebar_state="expanded"
)
# --- V24.2 FLEX-METRIC CSS ---
st.markdown("""
<style>
:root {
--card-bg: #FFFFFF;
--card-border: #E2E8F0;
--card-text: #1E293B;
--card-subtext: #64748b;
--card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
--bg-main: #F8FAFC;
--accent-yemek: #3B82F6;
--accent-meze: #10B981;
--accent-icecek: #F59E0B;
--accent-diger: #64748B;
}
[data-theme="dark"] {
--card-bg: #1E293B;
--card-border: #334155;
--card-text: #F8FAFC;
--card-subtext: #94A3B8;
--card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
--bg-main: #0F172A;
--accent-yemek: #60A5FA;
--accent-meze: #34D399;
--accent-icecek: #FBBF24;
--accent-diger: #94A3B8;
}
/* Fixed Header for Profile */
.header-container {
display: flex;
justify-content: flex-end;
align-items: center;
padding: 5px 20px;
background: transparent;
margin-bottom: -40px;
z-index: 1000;
}
/* Rest of Flex Metric CSS (Dynamic & Refined) */
.flex-metric-card {
background: var(--card-bg);
padding: 24px;
border-radius: 16px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
display: flex;
flex-direction: row;
align-items: center;
margin-bottom: 20px;
border: 1px solid var(--card-border);
border-left: 5px solid var(--accent-color, #3B82F6);
min-height: 120px;
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.flex-metric-card:hover {
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}
.card-icon {
font-size: 36px;
margin-right: 20px;
color: var(--accent-color, #3B82F6);
background: rgba(var(--accent-rgb, 59, 130, 246), 0.1);
width: 64px;
height: 64px;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
}
.card-content { display: flex; flex-direction: column; justify-content: center; }
.card-value { font-size: 26px; font-weight: 800; color: var(--card-text); line-height: 1.2; }
.card-label { font-size: 13px; font-weight: 500; color: var(--card-subtext); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.trend-pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--card-bg); border: 1px solid var(--card-border); color: var(--card-subtext); }
/* RECIPIENT CARD OVERRIDES FOR RECIPES.PY */
.recipe-card {
display: flex;
background: var(--card-bg);
border: 1px solid var(--card-border);
border-radius: 12px;
padding: 15px;
margin-bottom: 15px;
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
transition: all 0.3s;
}
.recipe-card:hover { transform: scale(1.01); box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.recipe-img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; margin-right: 15px; }
.recipe-info { flex-grow: 1; }
.recipe-name { font-size: 18px; font-weight: bold; color: var(--card-text); }
.recipe-meta { font-size: 12px; color: var(--card-subtext); margin-bottom: 10px; }
.recipe-stats { display: flex; gap: 20px; }
.stat-label { font-size: 10px; color: var(--card-subtext); }
.stat-value { font-size: 14px; font-weight: bold; color: var(--card-text); }
/* GLOBAL NOTIFICATION BELL */
.notif-bell {
position: relative;
cursor: pointer;
font-size: 20px;
background: var(--card-bg);
padding: 8px;
border-radius: 50%;
border: 1px solid var(--card-border);
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
margin-right: 15px;
}
.notif-bell:hover {
background: #F1F5F9;
transform: scale(1.1);
}
.notif-badge {
position: absolute;
top: -3px;
right: -3px;
background: #EF4444;
color: white;
font-size: 9px;
font-weight: 800;
padding: 1px 5px;
border-radius: 10px;
border: 1.5px solid white;
}
[data-theme="dark"] .notif-bell { background: #1e293b; border-color: #334155; }
</style>
""", unsafe_allow_html=True)
# --- LOGIN LOGIC ---
if 'logged_in' not in st.session_state:
st.session_state.logged_in = False
if not st.session_state.logged_in:
st.title("🛡️ UzPos Giriş")
with st.form("login_form"):
username = st.text_input("Kullanıcı Adı")
password = st.text_input("Şifre", type="password")
submit = st.form_submit_button("Giriş Yap")
if submit:
user = check_login(username, password)
# V24.1: Hardcoded fallback for immediate access
if user or (username == "admin" and password == "123"):
st.session_state.logged_in = True
st.session_state.user_role = user.get('role', 'admin') if user else 'admin'
st.session_state.username = username
st.rerun()
else:
st.error("Hatalı kullanıcı adı veya şifre!")
st.stop()
# --- NATIVE SIDEBAR NAVIGATION ---
st.sidebar.image("images/Gemini_Generated_Image_ch45u9ch45u9ch45-Photoroom (1).png", width="stretch")
st.sidebar.markdown(f"**👤 {st.session_state.username}** (`{st.session_state.user_role}`)")
st.sidebar.divider()
nav_options = {
"📊 DashBoard": "Dashboard",
"🧾 Faturalar": "Faturalar",
"📦 Envanter & Stok": "Envanter",
"🍱 Reçeteler": "Reçeteler",
"👥 Tedarikçiler": "Tedarikçiler",
"💰 Hesaplar & Kasa": "Hesaplar",
"🛒 Satışlar": "Satışlar"
}
# Admin-only options
if st.session_state.user_role == "admin":
nav_options["👤 Kullanıcı Yönetimi"] = "Users"
choice_label = st.sidebar.radio(
"Menüden bir sayfa seçin:",
options=list(nav_options.keys()),
label_visibility="collapsed"
)
choice = nav_options[choice_label]
# --- TOP RIGHT PROFILE HEADER ---
from database import get_price_alerts
alerts = get_price_alerts()
alert_count = len(alerts)
# Custom Label for Popover (Bell + Badge)
notif_label = f"🔔 {alert_count}" if alert_count > 0 else "🔔"
h1, h2, h3 = st.columns([12, 1.5, 1.5])
with h2:
with st.popover(notif_label):
st.subheader("🔔 Bildirimler")
if alerts:
for a in alerts:
st.warning(f"**{a['name']}**\n\nFiyat: {a['last']:.2f} → {a['current']:.2f}")
if st.button("Reçetelere Git", width="stretch"):
# Bu kısım için session state 'choice' tetiklenebilir ama radio kullanıldığı için
# kullanıcıyı yönlendirmek biraz zahmetli, şimdilik uyarıyoruz.
st.info("Menüden 'Reçeteler' sekmesini seçiniz.")
else:
st.success("Tüm fiyatlar güncel! 🎉")
with h3:
with st.popover("👤 Profil"):
st.write(f"**{st.session_state.username}**")
st.write(f"Rol: `{st.session_state.user_role}`")
if st.button("🚪 Çıkış Yap", width="stretch"):
st.session_state.logged_in = False
st.rerun()
st.sidebar.divider()
# --- MODULE ROUTING ---
from modules import dashboard, invoices, inventory, recipes, suppliers, accounts, sales, users
if choice == "Dashboard":
dashboard.show_dashboard()
elif choice == "Faturalar":
invoices.show_invoices()
elif choice == "Envanter":
inventory.show_inventory()
elif choice == "Reçeteler":
recipes.show_recipes()
elif choice == "Tedarikçiler":
suppliers.show_suppliers()
elif choice == "Hesaplar":
accounts.show_accounts()
elif choice == "Satışlar":
sales.show_sales()
elif choice == "Users":
users.show_user_management()