Umschalter für Zeitübersicht Benutzer hinzugefügt
This commit is contained in:
parent
076a21ca97
commit
6f831bc419
4
admin.py
4
admin.py
@ -192,7 +192,7 @@ def page_admin():
|
||||
|
||||
# Alle Timestamps durchgehen und sie den Dictionaryeinträgen zuordnen:
|
||||
for stamp in timestamps:
|
||||
day_of_month_of_timestamp = int(datetime.datetime.fromtimestamp(int(stamp)).strftime("%-d"))
|
||||
day_of_month_of_timestamp = int(datetime.datetime.fromtimestamp(int(stamp)).day)
|
||||
timestamps_dict[day_of_month_of_timestamp].append(int(stamp))
|
||||
|
||||
general_saldo = 0
|
||||
@ -338,7 +338,7 @@ Dies kann nicht rückgängig gemacht werden!''')
|
||||
# Suche mir alle timestamps für diesen Tag
|
||||
for i in timestamps:
|
||||
actual_timestamp = datetime.datetime.fromtimestamp(int(i))
|
||||
timestamp_day = actual_timestamp.strftime('%-d')
|
||||
timestamp_day = actual_timestamp.day
|
||||
|
||||
if int(timestamp_day) == int(day):
|
||||
timestamps_of_this_day.append(i)
|
||||
|
23
homepage.py
23
homepage.py
@ -26,6 +26,12 @@ def homepage():
|
||||
pageheader(f"Willkommen, {current_user.fullname}")
|
||||
|
||||
today = datetime.datetime.now()
|
||||
def yesterdays_overtime():
|
||||
last_months_overtime = current_user.get_last_months_overtime(today.year, today.month)
|
||||
overtime_this_month = 0
|
||||
for i in range(1, today.day):
|
||||
overtime_this_month += (int(current_user.get_worked_time(today.year, today.month, i)[0]) - int(current_user.get_day_workhours(today.year, today.month, i)))
|
||||
return last_months_overtime + overtime_this_month
|
||||
|
||||
@ui.refreshable
|
||||
def stamp_interface():
|
||||
@ -38,6 +44,16 @@ def homepage():
|
||||
|
||||
with ui.grid(columns='20% auto 20%').classes('w-full justify-center'):
|
||||
ui.space()
|
||||
|
||||
def update_timer():
|
||||
additional_time = 0
|
||||
if time_toggle.value == "total":
|
||||
additional_time = yesterdays_overtime()
|
||||
if current_user.get_worked_time(today.year, today.month, today.day)[1] > 0:
|
||||
time_in_total = additional_time + time_so_far + int((datetime.datetime.now().timestamp() - current_user.get_worked_time(today.year, today.month, today.day)[1]))
|
||||
else:
|
||||
time_in_total = additional_time + time_so_far
|
||||
working_hours.set_content(convert_seconds_to_hours(time_in_total))
|
||||
with ui.grid(columns='1fr 1fr'):
|
||||
if current_user.stamp_status() == status_in:
|
||||
bg_color = 'green'
|
||||
@ -46,10 +62,8 @@ def homepage():
|
||||
working_hours = ui.markdown(convert_seconds_to_hours(time_so_far)).classes(f'col-span-2 rounded-3xl text-center text-white text-bold text-2xl border-4 border-gray-600 bg-{bg_color}')
|
||||
in_button = ui.button("Einstempeln", on_click=stamp_and_refresh).classes('bg-green')
|
||||
out_button = ui.button("Ausstempeln", on_click=stamp_and_refresh).classes('bg-red')
|
||||
|
||||
def update_timer():
|
||||
time_in_total = time_so_far + int((datetime.datetime.now().timestamp() - current_user.get_worked_time(today.year, today.month, today.day)[1]))
|
||||
working_hours.set_content(convert_seconds_to_hours(time_in_total))
|
||||
time_toggle = ui.toggle({"day": "Tagesarbeitszeit", "total": "Gesamtzeit"}, value="day",
|
||||
on_change=update_timer).classes('w-full justify-center col-span-2')
|
||||
|
||||
working_timer = ui.timer(1.0, update_timer)
|
||||
working_timer.active = False
|
||||
@ -93,7 +107,6 @@ def homepage():
|
||||
month_month_select.enable()
|
||||
|
||||
with ui.grid(columns='1fr auto 1fr').classes('w-full justify-center'):
|
||||
|
||||
ui.space()
|
||||
with ui.expansion("Tagesnotiz", icon='o_description'):
|
||||
with ui.grid(columns=2):
|
||||
|
@ -12,3 +12,5 @@
|
||||
1747214813
|
||||
1747216800
|
||||
1747220619
|
||||
1747301302
|
||||
1747301459
|
||||
|
Loading…
x
Reference in New Issue
Block a user