Zusätzliche Übersichtsansicht im Adminbereich

Genehmigungsfunktion für Urlaube mit automatischer Eintragung
This commit is contained in:
Alexander Malzkuhn 2025-05-28 12:32:48 +02:00
parent 57eec6d4f1
commit a12bd1e15a
5 changed files with 634 additions and 522 deletions

File diff suppressed because it is too large Load Diff

View File

@ -525,7 +525,7 @@ def json_info(api_key: str):
data["time"]["overall"] = time_saldo
data["vacation"] = { }
data["vacation"]["claim"] = current_user.get_vacation_claim(now_dt.year, now_dt.month, now_dt.day)
data["vacation"]["used"] = current_user.count_vacation_days(now_dt.year)
data["vacation"]["used"] = current_user.count_absence_days("U", now_dt.year)
data["vacation"]["remaining"] = data["vacation"]["claim"] - data["vacation"]["used"]
return data
break

View File

@ -262,9 +262,10 @@ def homepage():
va_table = ui.table(columns=va_columns, rows=va_rows, selection="single", row_key="index").classes('w-full')
def retract_va():
try:
current_user.revoke_vacation_application(va_table.selected[0]["index"])
retract_result = current_user.revoke_vacation_application(va_table.selected[0]["index"])
open_vacation_applications.refresh()
ui.notify("Urlaubsantrag zurückgezogen")
if retract_result == 0:
ui.notify("Urlaubsantrag zurückgezogen")
except IndexError:
ui.notify("Kein Urlaubsanstrag ausgewählt")
ui.button("Zurückziehen", on_click=retract_va).tooltip("Hiermit wird der oben gewählte Urlaubsantrag zurückgezogen.").classes('w-full')

View File

@ -5,6 +5,8 @@ import hashlib
import os
from calendar import monthrange
from stat import S_IREAD, S_IWUSR
from nicegui import ui
import datetime
import time
import json
@ -61,7 +63,6 @@ class user:
with open(filename, 'a') as file:
# Schreibe den Timestamp in die Datei und füge einen Zeilenumbruch hinzu
file.write(f"{timestamp}\n")
file.close()
except FileNotFoundError:
# Fehlende Verzeichnisse anlegen
folder_path = os.path.dirname(filename)
@ -263,7 +264,7 @@ class user:
filename_txt = os.path.join(self.userfolder, f"{year}-{month}.txt")
os.chmod(filename_txt, S_IREAD)
def get_last_months_overtime(self, year, month):
def get_last_months_overtime(self, year=datetime.datetime.now().year, month=datetime.datetime.now().month):
try:
if int(month) == 1:
year = str(int(year) - 1)
@ -387,7 +388,7 @@ class user:
hours_to_work = -1
return hours_to_work
def get_vacation_claim(self, year, month, day):
def get_vacation_claim(self, year=datetime.datetime.now().year, month=datetime.datetime.now().month, day=datetime.datetime.now().day):
workhour_entries = list(self.workhours)
workhour_entries.sort()
day_to_check = datetime.datetime(int(year), int(month), int(day))
@ -405,18 +406,18 @@ class user:
return int(claim)
def count_vacation_days(self, year):
vacation_used = 0
def count_absence_days(self, absence_code: str, year=datetime.datetime.now().year):
absence_days = 0
for month in range(0, 13):
try:
absence_dict = self.get_absence(year, month)
for entry, absence_type in absence_dict.items():
if absence_type == "U":
vacation_used += 1
if absence_type == absence_code:
absence_days += 1
except:
pass
return vacation_used
return absence_days
def delete_photo(self):
os.remove(self.photofile)
@ -477,14 +478,19 @@ class user:
application_file = os.path.join(self.userfolder, va_file)
with open(application_file, 'r') as json_file:
applications = json.load(json_file)
del(applications[index])
new_applications = { }
new_index = 0
for index, dates in applications.items():
new_applications[new_index] = dates
new_index += 1
with open(application_file, 'w') as json_file:
json_file.write(json.dumps(new_applications, indent=4))
try:
del(applications[index])
new_applications = { }
new_index = 0
for index, dates in applications.items():
new_applications[new_index] = dates
new_index += 1
with open(application_file, 'w') as json_file:
json_file.write(json.dumps(new_applications, indent=4))
return 0
except KeyError:
ui.notify("Urlaubsantrag wurde schon bearbeitet")
return -1
# Benutzer auflisten
def list_users():

View File

@ -71,6 +71,7 @@
"2030-10-03": "Tag der deutschen Einheit",
"2030-10-30": "Reformationstag",
"2030-12-25": "1. Weihnachtsfeiertag",
"2030-12-26": "2. Weihnachtsfeiertag"
"2030-12-26": "2. Weihnachtsfeiertag",
"2025-06-11": "Testeintrag"
}
}