Urlaubsübersicht hinzugefügt

This commit is contained in:
Alexander Malzkuhn 2025-04-29 10:55:21 +02:00
parent 415582e084
commit 3e3537c8b8
2 changed files with 44 additions and 3 deletions

45
api.py
View File

@ -15,7 +15,7 @@ import calendar
# Überblicksseite zum Ausdrucken oder als PDF speichern
@ui.page('/api/overview/month/{username}/{year}-{month}')
def page(username: str, year: int, month: int):
def page_overview_month(username: str, year: int, month: int):
try:
current_user = user(username)
@ -224,3 +224,46 @@ def page(username: str, year: int, month: int):
ui.markdown('#Fehler')
ui.markdown(str(type(e)))
ui.markdown(str(e))
@ui.page('/api/overview/vacation/{username}/{year}-{month}-{day}')
def page_overview_vacation(username: str, year: int, month: int, day: int):
try:
current_user = user(username)
ui.page_title(f"Urlaubsanspruch für {current_user.fullname} für {year}")
ui.label(datetime.now().strftime('%d.%m.%Y')).classes('absolute top-5 right-5')
ui.space()
ui.markdown(f'#Urlaubsanspruch für {current_user.fullname} für {year}')
pad_x = 4
pad_y = 0
with ui.grid(columns='auto auto').classes(f'gap-0 border px-0 py-0'):
ui.markdown(f"Urlaubsübersicht für {year}:").classes(f'border px-{pad_x} py-{pad_y}')
vacationclaim = int(current_user.get_vacation_claim(year, month, day))
ui.markdown(f"{vacationclaim} Tage").classes(f'text-right border px-{pad_x} py-{pad_y}')
ui.markdown("Registrierte Urlaubstage").classes(f'border px-{pad_x} py-{pad_y} col-span-2')
vacation_counter = 0
try:
for i in range(1, 13):
absence_entries = current_user.get_absence(year, i)
for day, absence_type in absence_entries.items():
print(day + "." + str(i) + " " + absence_type)
if absence_type == "U":
day_in_list = datetime(int(year), int(i), int(day)).strftime("%d.%m.%Y")
ui.markdown(day_in_list).classes(f'border px-{pad_x} py-{pad_y}')
ui.markdown("-1 Tag").classes(f'border px-{pad_x} py-{pad_y} text-center')
vacation_counter += 1
except Exception as e:
print(str(type(e).__name__) + " " + str(e))
ui.markdown("**Resturlaub:**").classes(f'border px-{pad_x} py-{pad_y}')
ui.markdown(f'**{str(vacationclaim - vacation_counter)} Tage**').classes(f'border px-{pad_x} py-{pad_y} text-center')
except Exception as e:
print(str(type(e).__name__) + " " + str(e))
if type(e) == UnboundLocalError:
ui.markdown('#Fehler')
ui.markdown('Benutzer existiert nicht')
else:
ui.markdown('#Fehler')
ui.markdown(str(type(e)))
ui.markdown(str(e))

View File

@ -10,8 +10,6 @@ from api import *
import json
def main():
# Einstellungen einlesen