Zeitbereichsupdates

This commit is contained in:
Alexander Malzkuhn 2025-04-26 22:30:31 +02:00
parent cf2e8e3ab9
commit ac57af88b3
10 changed files with 124 additions and 9 deletions

View File

@ -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)

View File

@ -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"}}

View File

@ -1,3 +1,5 @@
# Zeiterfassung
from web_ui import *
from admin import *
from login import *

BIN
photo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 KiB

View File

@ -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))]

View File

@ -0,0 +1,5 @@
{
"archived": 0,
"overtime": 0,
"absence": {}
}

View File

@ -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"
}
}

View File

@ -2,8 +2,9 @@
"archived": 0,
"overtime": 0,
"absence": {
"7": "K",
"8": "UU",
"9": "KK"
"7": "U",
"8": "U",
"9": "U",
"10": "U"
}
}

View File

@ -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"
}
}

View File

@ -0,0 +1,4 @@
{
"archived": 0,
"total_hours": 0
}