diff --git a/admin.py b/admin.py index 077ab47..1d1d4fc 100644 --- a/admin.py +++ b/admin.py @@ -1,12 +1,13 @@ from datetime import datetime -from nicegui import ui, app +from nicegui import ui, app, events from users import * from definitions import * from calendar import monthrange from web_ui import * +import os.path import hashlib import calendar import locale @@ -67,7 +68,14 @@ def page_admin(): available_years = current_user.get_years() select_year.clear() select_year.set_options(available_years) - select_year.value = list(available_years)[0] + try: + select_year.value = str(datetime.datetime.now().year) + except: + select_year.value = list(available_years)[0] + try: + select_month.value = datetime.datetime.now().month + except: + select_month.value = list(available_months)[0] userlist = list_users() ui.markdown("Benutzer:") @@ -349,8 +357,15 @@ Dies kann nicht rückgägig gemacht werden!''') if isinstance(absence_dates.value, str): absence_date = absence_dates.value.split("-") current_user.update_absence(absence_date[0], absence_date[1], absence_date[2], absence_type) + current_sel_month = select_month.value + current_sel_year = select_year.value + update_user() + update_months() + select_year.value = current_sel_year + select_month.value = current_sel_month calendar_card.clear() update_month_and_year() + # Bei Zeitbereich, aufteilen elif isinstance(absence_dates.value, dict): start_date = absence_dates.value["from"] @@ -371,6 +386,11 @@ Dies kann nicht rückgägig gemacht werden!''') while actual_date <= end_date: current_user.workhours + absences = current_user.get_absence(actual_date.year, actual_date.month) + + if str(actual_date.day) in list(absences): + current_user.del_absence(actual_date.year, actual_date.month, actual_date.day) + ui.notify(f"Eintrag {absence_entries[absences[str(actual_date.day)]]['name']} am {actual_date.day}.{actual_date.month}.{actual_date.year} überschrieben.") current_user.update_absence(actual_date.year, actual_date.month, actual_date.day, absence_type) actual_date = actual_date + datetime.timedelta(days=1) @@ -449,7 +469,9 @@ Dies kann nicht rückgägig gemacht werden!''') userlist = list_users() userlist.sort() workhours = [ ] + with ui.row(): + def user_selection_changed(): try: if user_selection.value != None: @@ -465,6 +487,8 @@ Dies kann nicht rückgägig gemacht werden!''') workhours_select.set_options(workhour_list) workhours_select.value = workhour_list[0] workinghourscard.visible = True + + except: pass @@ -591,12 +615,14 @@ Dies kann nicht rückgägig gemacht werden!''') ui.markdown("**Benutzereinstellungen**") with ui.grid(columns=2): - ui.label("Benutzername:") + ui.markdown("Benutzername:") username_input = ui.input() - ui.label("Voller Name:") + ui.markdown("Voller Name:") fullname_input = ui.input() - ui.label("Passwort") + ui.markdown("Passwort") password_input = ui.input(password=True) + + with ui.grid(columns=2): ui.button("Speichern", on_click=save_user_settings) ui.button("Löschen", on_click=del_user) @@ -638,6 +664,7 @@ Dies kann nicht rückgägig gemacht werden!''') with ui.row(): ui.button("Speichern", on_click=save_workhours) ui.button("Löschen", on_click=delete_workhour_entry) + def new_workhours_entry(): current_user = user(user_selection.value) diff --git a/definitions.py b/definitions.py index a5c63cf..7cee06d 100644 --- a/definitions.py +++ b/definitions.py @@ -31,4 +31,6 @@ absence_entries = {"U": { "name": "Urlaub", "UU": { "name": "Urlaub aus Überstunden", "color": "green"}, "F": { "name": "Fortbildung", - "color": "black"}} + "color": "black"}, + "EZ": { "name": "Elternzeit", + "color": "purple"}} diff --git a/main.py b/main.py index 1af117a..de351e1 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,5 @@ +# Zeiterfassung + from web_ui import * from admin import * from login import * diff --git a/photo.jpg b/photo.jpg new file mode 100644 index 0000000..dcaa401 Binary files /dev/null and b/photo.jpg differ diff --git a/users.py b/users.py index 855213f..73b507e 100644 --- a/users.py +++ b/users.py @@ -288,6 +288,9 @@ class user: hours_to_work = -1 return hours_to_work + def delete_photo(self): + os.remove(self.photofile) + # Benutzer auflisten def list_users(): users = [d for d in os.listdir(userfolder) if os.path.isdir(os.path.join(userfolder, d))] diff --git a/users/testuser1/2025-11.json b/users/testuser1/2025-11.json new file mode 100644 index 0000000..b951d02 --- /dev/null +++ b/users/testuser1/2025-11.json @@ -0,0 +1,5 @@ +{ + "archived": 0, + "overtime": 0, + "absence": {} +} \ No newline at end of file diff --git a/users/testuser1/2025-12.json b/users/testuser1/2025-12.json new file mode 100644 index 0000000..fe93723 --- /dev/null +++ b/users/testuser1/2025-12.json @@ -0,0 +1,37 @@ +{ + "archived": 0, + "overtime": 0, + "absence": { + "1": "EZ", + "2": "EZ", + "3": "EZ", + "4": "EZ", + "5": "EZ", + "6": "EZ", + "7": "EZ", + "8": "EZ", + "9": "EZ", + "10": "EZ", + "11": "EZ", + "12": "EZ", + "13": "EZ", + "14": "EZ", + "15": "EZ", + "16": "EZ", + "17": "EZ", + "18": "EZ", + "19": "EZ", + "20": "EZ", + "21": "EZ", + "22": "EZ", + "23": "EZ", + "24": "EZ", + "25": "EZ", + "26": "EZ", + "27": "EZ", + "28": "EZ", + "29": "EZ", + "30": "EZ", + "31": "EZ" + } +} \ No newline at end of file diff --git a/users/testuser1/2025-4.json b/users/testuser1/2025-4.json index 7ce53cc..0eb538b 100644 --- a/users/testuser1/2025-4.json +++ b/users/testuser1/2025-4.json @@ -2,8 +2,9 @@ "archived": 0, "overtime": 0, "absence": { - "7": "K", - "8": "UU", - "9": "KK" + "7": "U", + "8": "U", + "9": "U", + "10": "U" } } \ No newline at end of file diff --git a/users/testuser1/2026-1.json b/users/testuser1/2026-1.json new file mode 100644 index 0000000..ed17121 --- /dev/null +++ b/users/testuser1/2026-1.json @@ -0,0 +1,34 @@ +{ + "archived": 0, + "overtime": 0, + "absence": { + "1": "EZ", + "2": "EZ", + "3": "EZ", + "4": "EZ", + "5": "EZ", + "6": "EZ", + "7": "EZ", + "8": "EZ", + "9": "EZ", + "10": "EZ", + "11": "EZ", + "12": "EZ", + "13": "EZ", + "14": "EZ", + "15": "EZ", + "16": "EZ", + "17": "EZ", + "18": "EZ", + "19": "EZ", + "20": "EZ", + "21": "EZ", + "22": "EZ", + "23": "EZ", + "24": "EZ", + "25": "EZ", + "26": "EZ", + "27": "EZ", + "28": "EZ" + } +} \ No newline at end of file diff --git a/users/testuser3/2025-4.json b/users/testuser3/2025-4.json new file mode 100644 index 0000000..b7881be --- /dev/null +++ b/users/testuser3/2025-4.json @@ -0,0 +1,4 @@ +{ + "archived": 0, + "total_hours": 0 +} \ No newline at end of file