Ist-Zeit Berechnung für Tage ergänzt
This commit is contained in:
parent
99f1ba9336
commit
1238f2227d
48
web_ui.py
48
web_ui.py
@ -33,6 +33,23 @@ def load_adminsettings():
|
|||||||
except:
|
except:
|
||||||
return(-1)
|
return(-1)
|
||||||
|
|
||||||
|
def convert_seconds_to_hours(seconds):
|
||||||
|
hours = seconds // 3600
|
||||||
|
remaining_seconds = seconds - hours * 3600
|
||||||
|
minutes = remaining_seconds // 60
|
||||||
|
remaining_seconds = remaining_seconds - minutes * 60
|
||||||
|
if remaining_seconds > 0:
|
||||||
|
minutes += 1
|
||||||
|
if hours < 10:
|
||||||
|
hours = "0" + str(hours)
|
||||||
|
else:
|
||||||
|
hours = str(hours)
|
||||||
|
if minutes < 10:
|
||||||
|
minutes = "0" + str(minutes)
|
||||||
|
else:
|
||||||
|
minutes = str(minutes)
|
||||||
|
return(f"{hours}:{minutes}")
|
||||||
|
|
||||||
@ui.page('/login')
|
@ui.page('/login')
|
||||||
def page_login():
|
def page_login():
|
||||||
|
|
||||||
@ -173,6 +190,7 @@ def page_admin():
|
|||||||
|
|
||||||
with ui.row():
|
with ui.row():
|
||||||
counter = 0
|
counter = 0
|
||||||
|
|
||||||
for i in timestamps:
|
for i in timestamps:
|
||||||
actual_timestamp = datetime.datetime.fromtimestamp(int(i))
|
actual_timestamp = datetime.datetime.fromtimestamp(int(i))
|
||||||
timestamp_day = actual_timestamp.strftime('%-d')
|
timestamp_day = actual_timestamp.strftime('%-d')
|
||||||
@ -220,7 +238,7 @@ def page_admin():
|
|||||||
edit_dialog.open()
|
edit_dialog.open()
|
||||||
counter += 1
|
counter += 1
|
||||||
|
|
||||||
current_button = ui.button(actual_timestamp.strftime('%H:%M'), on_click=lambda t_stamp=i, day=day: edit_entry(t_stamp, day))
|
ui.button(actual_timestamp.strftime('%H:%M'), on_click=lambda t_stamp=i, day=day: edit_entry(t_stamp, day))
|
||||||
#if counter % 2 == 0:
|
#if counter % 2 == 0:
|
||||||
# current_button.props('color=red')
|
# current_button.props('color=red')
|
||||||
#else:
|
#else:
|
||||||
@ -242,10 +260,34 @@ def page_admin():
|
|||||||
ui.markdown(f"{current_user.workhours[entry][str(weekday_index)]} h")
|
ui.markdown(f"{current_user.workhours[entry][str(weekday_index)]} h")
|
||||||
found_match = True
|
found_match = True
|
||||||
|
|
||||||
|
# Arbeitszeit Ist bestimmen
|
||||||
|
timestamps_of_this_day = [ ]
|
||||||
|
|
||||||
# ui.markdown("Soll")
|
# 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')
|
||||||
|
|
||||||
ui.markdown("Ist")
|
if int(timestamp_day) == int(day):
|
||||||
|
timestamps_of_this_day.append(i)
|
||||||
|
|
||||||
|
timestamps_of_this_day.sort()
|
||||||
|
if len(timestamps_of_this_day) > 1:
|
||||||
|
time_sum = 0
|
||||||
|
if len(timestamps_of_this_day) % 2 == 0:
|
||||||
|
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_sum += time_delta
|
||||||
|
else:
|
||||||
|
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_sum += time_delta
|
||||||
|
|
||||||
|
ui.markdown(convert_seconds_to_hours(time_sum))
|
||||||
|
else:
|
||||||
|
ui.markdown("Kein")
|
||||||
|
|
||||||
|
# ui.markdown("Ist")
|
||||||
ui.markdown("+/-")
|
ui.markdown("+/-")
|
||||||
|
|
||||||
def add_entry(day):
|
def add_entry(day):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user