Logik für Abwesenheitstage implementiert
This commit is contained in:
parent
a7cf012d41
commit
b3de2d2b9e
@ -19,3 +19,16 @@ photofilename = "photo.jpg"
|
|||||||
|
|
||||||
status_in = "eingestempelt"
|
status_in = "eingestempelt"
|
||||||
status_out = "ausgestempelt"
|
status_out = "ausgestempelt"
|
||||||
|
|
||||||
|
# Abesenheiten
|
||||||
|
|
||||||
|
absence_entries = {"U": { "name": "Urlaub",
|
||||||
|
"color": "green"},
|
||||||
|
"K": { "name": "Krankheit",
|
||||||
|
"color": "red"},
|
||||||
|
"KK": { "name": "Krankheit Kind",
|
||||||
|
"color": "orange"},
|
||||||
|
"UU": { "name": "Urlaub aus Überstunden",
|
||||||
|
"color": "green"},
|
||||||
|
"F": { "name": "Fortbildung",
|
||||||
|
"color": "black"}}
|
||||||
|
32
users.py
32
users.py
@ -171,11 +171,6 @@ class user:
|
|||||||
|
|
||||||
return(available_months)
|
return(available_months)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return available_months
|
|
||||||
|
|
||||||
def get_timestamps(self, year, month):
|
def get_timestamps(self, year, month):
|
||||||
try:
|
try:
|
||||||
with open(f"{self.userfolder}/{year}-{month}.txt", "r") as file:
|
with open(f"{self.userfolder}/{year}-{month}.txt", "r") as file:
|
||||||
@ -193,6 +188,33 @@ class user:
|
|||||||
def archive_hours(self, year, month):
|
def archive_hours(self, year, month):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def get_last_months_overtime(self, year, month):
|
||||||
|
try:
|
||||||
|
if int(month) == 1:
|
||||||
|
year = str(int(year) - 1)
|
||||||
|
month = str(12)
|
||||||
|
else:
|
||||||
|
month = str(int(month) - 1)
|
||||||
|
with open(f"{self.userfolder}/{year}-{month}.json", "r") as json_file:
|
||||||
|
json_data = json.load(json_file)
|
||||||
|
|
||||||
|
if json_data["archived"] == 1:
|
||||||
|
overtime = int(json_data["overtime"])
|
||||||
|
return overtime
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
except:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def get_absence(self, year, month):
|
||||||
|
try:
|
||||||
|
print(f"{self.userfolder}/{year}-{month}.json")
|
||||||
|
with open(f"{self.userfolder}/{year}-{month}.json", "r") as json_file:
|
||||||
|
json_data = json.load(json_file)
|
||||||
|
absence = json_data["absence"]
|
||||||
|
return absence
|
||||||
|
except:
|
||||||
|
return 0
|
||||||
|
|
||||||
# Benutzer auflisten
|
# Benutzer auflisten
|
||||||
def list_users():
|
def list_users():
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"archived": 1,
|
"archived": 1,
|
||||||
"total_hours": 28
|
"overtime": 3950
|
||||||
}
|
}
|
@ -1,4 +1,12 @@
|
|||||||
{
|
{
|
||||||
"archived": 0,
|
"archived": 0,
|
||||||
"total_hours": 0
|
"total_hours": 0,
|
||||||
|
"absence": {
|
||||||
|
"1": "U",
|
||||||
|
"4": "U",
|
||||||
|
"7": "K",
|
||||||
|
"8": "UU",
|
||||||
|
"9": "KK",
|
||||||
|
"3": "K"
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,4 +1,7 @@
|
|||||||
{
|
{
|
||||||
"archived": 0,
|
"archived": 0,
|
||||||
"total_hours": 0
|
"total_hours": 0,
|
||||||
|
"absence": {
|
||||||
|
"1": "U"
|
||||||
|
}
|
||||||
}
|
}
|
32
web_ui.py
32
web_ui.py
@ -96,6 +96,7 @@ def page_login():
|
|||||||
|
|
||||||
@ui.page('/admin')
|
@ui.page('/admin')
|
||||||
def page_admin():
|
def page_admin():
|
||||||
|
ui.page_title(f"{app_title} {app_version}")
|
||||||
data = load_adminsettings()
|
data = load_adminsettings()
|
||||||
active_login = cookie_hash(data["admin_user"], data["admin_password"])
|
active_login = cookie_hash(data["admin_user"], data["admin_password"])
|
||||||
try:
|
try:
|
||||||
@ -191,6 +192,7 @@ def page_admin():
|
|||||||
|
|
||||||
current_user = user(time_user.value)
|
current_user = user(time_user.value)
|
||||||
timestamps = current_user.get_timestamps(year=select_year.value, month=select_month.value)
|
timestamps = current_user.get_timestamps(year=select_year.value, month=select_month.value)
|
||||||
|
user_absent = current_user.get_absence(year=select_year.value, month=select_month.value)
|
||||||
# Dictionary für sortierte Timestamps
|
# Dictionary für sortierte Timestamps
|
||||||
timestamps_dict = { }
|
timestamps_dict = { }
|
||||||
# Dictionary mit zunächst leeren Tageinträgen befüllen
|
# Dictionary mit zunächst leeren Tageinträgen befüllen
|
||||||
@ -213,6 +215,12 @@ def page_admin():
|
|||||||
# Buchungen
|
# Buchungen
|
||||||
|
|
||||||
with ui.row():
|
with ui.row():
|
||||||
|
try:
|
||||||
|
for i in list(user_absent):
|
||||||
|
if int(i) == day:
|
||||||
|
ui.button(absence_entries[user_absent[i]]["name"]).props(f'color={absence_entries[user_absent[i]]["color"]}')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
if len(timestamps_dict[day]) > 0:
|
if len(timestamps_dict[day]) > 0:
|
||||||
timestamps_dict[day].sort()
|
timestamps_dict[day].sort()
|
||||||
@ -332,11 +340,19 @@ def page_admin():
|
|||||||
ui.markdown(f"{current_user.workhours[entry][str(weekday_index)]} h")
|
ui.markdown(f"{current_user.workhours[entry][str(weekday_index)]} h")
|
||||||
found_match = True
|
found_match = True
|
||||||
|
|
||||||
# Plus und Minuszeit für den Tag berechnen
|
# Saldo für den Tag berechnen
|
||||||
if time.time() > day_in_list.timestamp():
|
if time.time() > day_in_list.timestamp():
|
||||||
time_duty = int(current_user.workhours[entry][str(weekday_index)]) * 3600
|
time_duty = int(current_user.workhours[entry][str(weekday_index)]) * 3600
|
||||||
|
|
||||||
saldo = int(time_sum) - int(time_duty)
|
saldo = int(time_sum) - int(time_duty)
|
||||||
|
# Nach Abwesenheitseinträgen suchen
|
||||||
|
try:
|
||||||
|
for i in list(user_absent):
|
||||||
|
if int(i) == day:
|
||||||
|
saldo = 0
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
general_saldo = general_saldo + saldo
|
general_saldo = general_saldo + saldo
|
||||||
ui.markdown(convert_seconds_to_hours(saldo))
|
ui.markdown(convert_seconds_to_hours(saldo))
|
||||||
else:
|
else:
|
||||||
@ -369,10 +385,20 @@ def page_admin():
|
|||||||
ui.button("Abbrechen", on_click=add_dialog.close)
|
ui.button("Abbrechen", on_click=add_dialog.close)
|
||||||
add_dialog.open()
|
add_dialog.open()
|
||||||
ui.button("Eintrag hinzufügen", on_click=lambda day=day: add_entry(day))
|
ui.button("Eintrag hinzufügen", on_click=lambda day=day: add_entry(day))
|
||||||
#4x leer und dann Gesamtsald
|
|
||||||
|
#4x leer und dann Gesamtsaldo
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
ui.space()
|
ui.space()
|
||||||
ui.markdown(f"<ins>{convert_seconds_to_hours(general_saldo)}</ins>")
|
ui.markdown(f"{convert_seconds_to_hours(general_saldo)}")
|
||||||
|
for i in range(4):
|
||||||
|
ui.space()
|
||||||
|
ui.markdown("Stunden aus Vormonat")
|
||||||
|
last_months_overtime = current_user.get_last_months_overtime(select_year.value, select_month.value)
|
||||||
|
ui.markdown(f"{convert_seconds_to_hours(last_months_overtime)}")
|
||||||
|
for i in range(4):
|
||||||
|
ui.space()
|
||||||
|
ui.markdown("Gesamtsaldo")
|
||||||
|
ui.markdown(f"**<ins>{convert_seconds_to_hours(general_saldo + last_months_overtime)}</ins>**")
|
||||||
table_grid.move(calendar_card)
|
table_grid.move(calendar_card)
|
||||||
update_month_and_year()
|
update_month_and_year()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user