Saldo Berechnung ergänzt
This commit is contained in:
parent
1238f2227d
commit
1cbfe0cfa4
@ -34,3 +34,4 @@
|
|||||||
1745391058
|
1745391058
|
||||||
1745391059
|
1745391059
|
||||||
1743660240
|
1743660240
|
||||||
|
1743685200
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
"password": "123456789",
|
"password": "123456789",
|
||||||
"workhours": {
|
"workhours": {
|
||||||
"2024-04-01": {
|
"2024-04-01": {
|
||||||
"1": "11",
|
"1": "8",
|
||||||
"2": "12",
|
"2": "8",
|
||||||
"3": "13",
|
"3": "8",
|
||||||
"4": "14",
|
"4": "8",
|
||||||
"5": "15",
|
"5": "8",
|
||||||
"6": "16",
|
"6": "0",
|
||||||
"7": "17",
|
"7": "0",
|
||||||
"vacation": "35"
|
"vacation": "35"
|
||||||
},
|
},
|
||||||
"2025-05-13": {
|
"2025-05-13": {
|
||||||
|
@ -4,23 +4,23 @@
|
|||||||
"password": "123456789",
|
"password": "123456789",
|
||||||
"workhours": {
|
"workhours": {
|
||||||
"2024-04-01": {
|
"2024-04-01": {
|
||||||
"0": "0",
|
"1": "0",
|
||||||
"1": "8",
|
|
||||||
"2": "8",
|
"2": "8",
|
||||||
"3": "8",
|
"3": "8",
|
||||||
"4": "8",
|
"4": "8",
|
||||||
"5": "8",
|
"5": "8",
|
||||||
"6": "0",
|
"6": "8",
|
||||||
|
"7": "0",
|
||||||
"vacation": "30"
|
"vacation": "30"
|
||||||
},
|
},
|
||||||
"2024-04-07": {
|
"2024-04-07": {
|
||||||
"0": "0",
|
"1": "0",
|
||||||
"1": "6",
|
|
||||||
"2": "6",
|
"2": "6",
|
||||||
"3": "6",
|
"3": "6",
|
||||||
"4": "8",
|
"4": "6",
|
||||||
"5": "6",
|
"5": "8",
|
||||||
"6": "0",
|
"6": "6",
|
||||||
|
"7": "0",
|
||||||
"vacation": "28"
|
"vacation": "28"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,33 +4,33 @@
|
|||||||
"password": "123456789",
|
"password": "123456789",
|
||||||
"workhours": {
|
"workhours": {
|
||||||
"2025-04-01": {
|
"2025-04-01": {
|
||||||
"0": "0",
|
"1": "0",
|
||||||
"1": "8",
|
|
||||||
"2": "8",
|
"2": "8",
|
||||||
"3": "8",
|
"3": "8",
|
||||||
"4": "8",
|
"4": "8",
|
||||||
"5": "8",
|
"5": "8",
|
||||||
"6": "0",
|
"6": "8",
|
||||||
|
"7": "0",
|
||||||
"vacation": "30"
|
"vacation": "30"
|
||||||
},
|
},
|
||||||
"2025-04-07": {
|
"2025-04-07": {
|
||||||
"0": "5",
|
"1": "5",
|
||||||
"1": "6",
|
|
||||||
"2": "6",
|
"2": "6",
|
||||||
"3": "6",
|
"3": "6",
|
||||||
"4": "8",
|
"4": "6",
|
||||||
"5": "6",
|
"5": "8",
|
||||||
"6": "0",
|
"6": "6",
|
||||||
|
"7": "0",
|
||||||
"vacation": "28"
|
"vacation": "28"
|
||||||
},
|
},
|
||||||
"2025-03-16": {
|
"2025-03-16": {
|
||||||
"0": 0,
|
|
||||||
"1": 0,
|
"1": 0,
|
||||||
"2": 0,
|
"2": 0,
|
||||||
"3": 0,
|
"3": 0,
|
||||||
"4": 0,
|
"4": 0,
|
||||||
"5": 0,
|
"5": 0,
|
||||||
"6": 0,
|
"6": 0,
|
||||||
|
"7": 0,
|
||||||
"vacation": 0
|
"vacation": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
61
web_ui.py
61
web_ui.py
@ -34,12 +34,17 @@ def load_adminsettings():
|
|||||||
return(-1)
|
return(-1)
|
||||||
|
|
||||||
def convert_seconds_to_hours(seconds):
|
def convert_seconds_to_hours(seconds):
|
||||||
|
if seconds < 0:
|
||||||
|
sign = "-"
|
||||||
|
seconds = seconds * (-1)
|
||||||
|
else:
|
||||||
|
sign = ""
|
||||||
hours = seconds // 3600
|
hours = seconds // 3600
|
||||||
remaining_seconds = seconds - hours * 3600
|
remaining_seconds = seconds - hours * 3600
|
||||||
minutes = remaining_seconds // 60
|
minutes = remaining_seconds // 60
|
||||||
remaining_seconds = remaining_seconds - minutes * 60
|
remaining_seconds = remaining_seconds - minutes * 60
|
||||||
if remaining_seconds > 0:
|
if remaining_seconds > 0 and sign != "-":
|
||||||
minutes += 1
|
minutes = minutes + 1
|
||||||
if hours < 10:
|
if hours < 10:
|
||||||
hours = "0" + str(hours)
|
hours = "0" + str(hours)
|
||||||
else:
|
else:
|
||||||
@ -48,7 +53,12 @@ def convert_seconds_to_hours(seconds):
|
|||||||
minutes = "0" + str(minutes)
|
minutes = "0" + str(minutes)
|
||||||
else:
|
else:
|
||||||
minutes = str(minutes)
|
minutes = str(minutes)
|
||||||
return(f"{hours}:{minutes}")
|
|
||||||
|
if sign == "-":
|
||||||
|
return(f"-{hours}:{minutes}")
|
||||||
|
else:
|
||||||
|
return(f"{hours}:{minutes}")
|
||||||
|
|
||||||
|
|
||||||
@ui.page('/login')
|
@ui.page('/login')
|
||||||
def page_login():
|
def page_login():
|
||||||
@ -80,7 +90,6 @@ def page_login():
|
|||||||
ui.button(text="Login", on_click=lambda: login())
|
ui.button(text="Login", on_click=lambda: login())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ui.page('/admin')
|
@ui.page('/admin')
|
||||||
def page_admin():
|
def page_admin():
|
||||||
data = load_adminsettings()
|
data = load_adminsettings()
|
||||||
@ -112,19 +121,6 @@ def page_admin():
|
|||||||
with ui.tab_panel(time_overview):
|
with ui.tab_panel(time_overview):
|
||||||
ui.markdown("##Übersichten")
|
ui.markdown("##Übersichten")
|
||||||
|
|
||||||
# Basisstruktur
|
|
||||||
with ui.card():
|
|
||||||
with ui.row():
|
|
||||||
|
|
||||||
|
|
||||||
userlist = list_users()
|
|
||||||
ui.markdown("Benutzer:")
|
|
||||||
time_user = ui.select(options=userlist)
|
|
||||||
time_user.value = userlist[0]
|
|
||||||
def update_user():
|
|
||||||
pass
|
|
||||||
ui.button("Aktualisieren", on_click=update_user)
|
|
||||||
|
|
||||||
# Tabelle konstruieren
|
# Tabelle konstruieren
|
||||||
with ui.card():
|
with ui.card():
|
||||||
|
|
||||||
@ -141,6 +137,11 @@ def page_admin():
|
|||||||
select_month.set_options(available_months_dict)
|
select_month.set_options(available_months_dict)
|
||||||
select_month.value = list(available_months)[0]
|
select_month.value = list(available_months)[0]
|
||||||
|
|
||||||
|
userlist = list_users()
|
||||||
|
ui.markdown("Benutzer:")
|
||||||
|
time_user = ui.select(options=userlist)
|
||||||
|
|
||||||
|
time_user.value = userlist[0]
|
||||||
current_year = datetime.datetime.now().year
|
current_year = datetime.datetime.now().year
|
||||||
current_month = datetime.datetime.now().month
|
current_month = datetime.datetime.now().month
|
||||||
|
|
||||||
@ -181,6 +182,8 @@ 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)
|
||||||
|
|
||||||
|
general_saldo = 0
|
||||||
|
|
||||||
for day in range(1, monthrange(int(select_year.value), int(select_month.value))[1] + 1):
|
for day in range(1, monthrange(int(select_year.value), int(select_month.value))[1] + 1):
|
||||||
day_in_list = datetime.datetime(int(select_year.value), int(select_month.value), day)
|
day_in_list = datetime.datetime(int(select_year.value), int(select_month.value), day)
|
||||||
|
|
||||||
@ -272,23 +275,33 @@ def page_admin():
|
|||||||
timestamps_of_this_day.append(i)
|
timestamps_of_this_day.append(i)
|
||||||
|
|
||||||
timestamps_of_this_day.sort()
|
timestamps_of_this_day.sort()
|
||||||
|
time_sum = 0
|
||||||
if len(timestamps_of_this_day) > 1:
|
if len(timestamps_of_this_day) > 1:
|
||||||
time_sum = 0
|
|
||||||
|
|
||||||
if len(timestamps_of_this_day) % 2 == 0:
|
if len(timestamps_of_this_day) % 2 == 0:
|
||||||
for i in range(0, len(timestamps_of_this_day), 2):
|
for i in range(0, len(timestamps_of_this_day), 2):
|
||||||
time_delta = int(timestamps_of_this_day[i+1]) - int(timestamps_of_this_day[i])
|
time_delta = int(timestamps_of_this_day[i+1]) - int(timestamps_of_this_day[i])
|
||||||
time_sum += time_delta
|
time_sum = time_sum + time_delta
|
||||||
else:
|
else:
|
||||||
for i in range(0, len(timestamps_of_this_day) - 1, 2):
|
for i in range(0, len(timestamps_of_this_day) - 1, 2):
|
||||||
time_delta = int(timestamps_of_this_day[i+1]) - int(timestamps_of_this_day[i])
|
time_delta = int(timestamps_of_this_day[i+1]) - int(timestamps_of_this_day[i])
|
||||||
time_sum += time_delta
|
time_sum = time_sum + time_delta
|
||||||
|
|
||||||
ui.markdown(convert_seconds_to_hours(time_sum))
|
ui.markdown(convert_seconds_to_hours(time_sum))
|
||||||
else:
|
else:
|
||||||
ui.markdown("Kein")
|
ui.markdown("Kein")
|
||||||
|
|
||||||
# ui.markdown("Ist")
|
# Plus und Minuszeit für den Tag berechnen
|
||||||
ui.markdown("+/-")
|
if time.time() > day_in_list.timestamp():
|
||||||
|
time_duty = int(current_user.workhours[entry][str(weekday_index)]) * 3600
|
||||||
|
|
||||||
|
saldo = int(time_sum) - int(time_duty)
|
||||||
|
general_saldo = general_saldo + saldo
|
||||||
|
ui.markdown(convert_seconds_to_hours(saldo))
|
||||||
|
else:
|
||||||
|
ui.markdown("-")
|
||||||
|
|
||||||
|
|
||||||
def add_entry(day):
|
def add_entry(day):
|
||||||
with ui.dialog() as add_dialog, ui.card():
|
with ui.dialog() as add_dialog, ui.card():
|
||||||
@ -315,6 +328,10 @@ 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
|
||||||
|
for i in range(4):
|
||||||
|
ui.space()
|
||||||
|
ui.markdown(f"<ins>{convert_seconds_to_hours(general_saldo)}</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