API Tabelle vervollständigt
This commit is contained in:
parent
2b9bad6ad3
commit
df81a05a7f
94
api.py
94
api.py
@ -57,7 +57,7 @@ def page(username: str, year: int, month: int):
|
||||
# Gehe jeden einzelnen Tag des Dictionaries für die Timestamps durch
|
||||
for day in list(timestamps_dict):
|
||||
booking_text = ""
|
||||
current_day_date = f"{day}.{month}.{year}"
|
||||
current_day_date = f"{datetime(year, month, day).strftime('%a')}, {day}.{month}.{year}"
|
||||
|
||||
# Abwesenheitseinträge
|
||||
try:
|
||||
@ -65,22 +65,87 @@ def page(username: str, year: int, month: int):
|
||||
for i in list(user_absent):
|
||||
if int(i) == day:
|
||||
booking_text += absence_entries[user_absent[i]]["name"] + " "
|
||||
|
||||
# Buchungen behandeln
|
||||
for i in range(len(timestamps_dict[day])):
|
||||
try:
|
||||
temp_pair = [timestamps_dict[day][i], timestamps_dict[day][i + 1]]
|
||||
booking_text = booking_text + str(datetime.fromtimestamp(temp_pair[0]).strftime('%H:%M')) + "-" + str(datetime.fromtimestamp(temp_pair[1]).strftime('%H:%M')) + "\n"
|
||||
|
||||
except:
|
||||
if len(timestamps_dict[day]) % 2 != 0:
|
||||
booking_text += datetime.fromtimestamp(int(timestamps_dict[day][i])).strftime('%H:%M')
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
pass
|
||||
|
||||
rows.append({'date': current_day_date, 'bookings': booking_text, 'is_time': 0, 'target_time': 0, 'total': 0})
|
||||
# Buchungen behandeln
|
||||
for i in range(len(timestamps_dict[day])):
|
||||
try:
|
||||
temp_pair = [timestamps_dict[day][i], timestamps_dict[day][i + 1]]
|
||||
booking_text = booking_text + str(datetime.fromtimestamp(temp_pair[0]).strftime('%H:%M')) + "-" + str(datetime.fromtimestamp(temp_pair[1]).strftime('%H:%M')) + "\n"
|
||||
|
||||
except:
|
||||
if len(timestamps_dict[day]) % 2 != 0:
|
||||
booking_text += datetime.fromtimestamp(int(timestamps_dict[day][i])).strftime('%H:%M')
|
||||
|
||||
# Ist-Zeiten berechnen
|
||||
timestamps_of_this_day = []
|
||||
|
||||
# Suche mir alle timestamps für diesen Tag
|
||||
for i in timestamps:
|
||||
actual_timestamp = datetime.fromtimestamp(int(i))
|
||||
timestamp_day = actual_timestamp.strftime('%-d')
|
||||
|
||||
if int(timestamp_day) == int(day):
|
||||
timestamps_of_this_day.append(i)
|
||||
|
||||
timestamps_of_this_day.sort()
|
||||
time_sum = 0
|
||||
if len(timestamps_of_this_day) > 1:
|
||||
|
||||
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_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_sum + time_delta
|
||||
|
||||
is_time = convert_seconds_to_hours(time_sum) + " h"
|
||||
else:
|
||||
is_time = "Kein"
|
||||
|
||||
# Sollzeit bestimmen
|
||||
|
||||
hours_to_work = int(current_user.get_day_workhours(year, month, day))
|
||||
|
||||
if hours_to_work < 0:
|
||||
target_time = ""
|
||||
else:
|
||||
target_time = f"{convert_seconds_to_hours(int(hours_to_work) * 3600)} h"
|
||||
if int(hours_to_work) == 0:
|
||||
booking_text = "Kein Arbeitstag"
|
||||
|
||||
# Saldo für den Tag berechnen
|
||||
day_in_list = datetime(year, month, day)
|
||||
if time.time() > day_in_list.timestamp():
|
||||
|
||||
time_duty = int(current_user.get_day_workhours(year, month, day)) * 3600
|
||||
if time_duty < 0:
|
||||
saldo = 0
|
||||
total = ""
|
||||
else:
|
||||
saldo = int(time_sum) - int(time_duty)
|
||||
# Nach Abwesenheitseinträgen suchen
|
||||
try:
|
||||
for i in list(user_absent):
|
||||
if int(i) == day and user_absent[i] != "UU":
|
||||
saldo = 0
|
||||
except:
|
||||
pass
|
||||
|
||||
general_saldo = general_saldo + saldo
|
||||
total = f"{convert_seconds_to_hours(saldo)} h"
|
||||
else:
|
||||
total = "-"
|
||||
|
||||
rows.append({'date': current_day_date, 'bookings': booking_text, 'is_time': is_time, 'target_time': target_time, 'total': total})
|
||||
|
||||
|
||||
|
||||
@ -90,8 +155,7 @@ def page(username: str, year: int, month: int):
|
||||
#]
|
||||
|
||||
overview_table = ui.table(columns=columns, rows=rows).classes('w-120')
|
||||
|
||||
|
||||
# Zeilenumbruch umsetzen
|
||||
overview_table.add_slot('body-cell', r'''
|
||||
<td :props="props" :style="{'white-space':'pre-line'}">{{ props.value }}</td>
|
||||
''')
|
||||
|
2
users.py
2
users.py
@ -276,8 +276,10 @@ class user:
|
||||
day_to_check = datetime.datetime(int(year), int(month), int(day))
|
||||
|
||||
for entry in reversed(workhour_entries):
|
||||
|
||||
entry_split = entry.split("-")
|
||||
entry_dt = datetime.datetime(int(entry_split[0]), int(entry_split[1]), int(entry_split[2]))
|
||||
|
||||
if entry_dt <= day_to_check:
|
||||
weekday = day_to_check.strftime("%w")
|
||||
if int(weekday) == 0:
|
||||
|
Loading…
x
Reference in New Issue
Block a user