diff --git a/admin.py b/admin.py index aa0c66f..82a21f8 100644 --- a/admin.py +++ b/admin.py @@ -243,6 +243,7 @@ Dies kann nicht rückgägig gemacht werden!''') ui.button(datetime.datetime.fromtimestamp(int(timestamps_dict[day][i])).strftime('%H:%M'), on_click=lambda t_stamp=timestamps_dict[day][i], day=day: edit_entry(t_stamp, day)) # Arbeitszeit Ist bestimmen + timestamps_of_this_day = [] # Suche mir alle timestamps für diesen Tag @@ -254,6 +255,7 @@ Dies kann nicht rückgägig gemacht werden!''') timestamps_of_this_day.append(i) timestamps_of_this_day.sort() + time_sum = 0 if len(timestamps_of_this_day) > 1: diff --git a/api.py b/api.py index 66610f2..88debe9 100644 --- a/api.py +++ b/api.py @@ -12,13 +12,14 @@ import calendar # Überblicksseite zum Ausdrucken oder als PDF speichern -@ui.page('/api/overview/month/{username}-{year}-{month}') +@ui.page('/api/overview/month/{username}/{year}-{month}') def page(username: str, year: int, month: int): try: current_user = user(username) ui.page_title(f"Bericht für {current_user.fullname} für {calendar.month_name[month]} {year}") ui.label(datetime.now().strftime('%d.%m.%Y')).classes('absolute top-5 right-5') + ui.space() ui.markdown(f'#Bericht für {current_user.fullname} für {calendar.month_name[month]} {year}') columns = [ @@ -147,12 +148,12 @@ def page(username: str, year: int, month: int): rows.append({'date': current_day_date, 'bookings': booking_text, 'is_time': is_time, 'target_time': target_time, 'total': total}) - overview_table = ui.table(columns=columns, rows=rows).classes('w-120') + overview_table = ui.table(columns=columns, rows=rows, row_key='date').classes('w-full') + # Zeilenumbruch umsetzen overview_table.add_slot('body-cell', r''' {{ props.value }} ''') - # Überstundenzusammenfassung with ui.grid(columns=2).classes('w-full gap-0'): @@ -165,6 +166,36 @@ def page(username: str, year: int, month: int): overtime_overall = last_months_overtime + general_saldo ui.markdown(f"**{convert_seconds_to_hours(overtime_overall)} h**") + absences_this_month = current_user.get_absence(year, month) + absence_dict = { } + + for abbr in list(absence_entries): + absence_dict[abbr] = 0 + + for key, value in absences_this_month.items(): + if value in list(absence_dict): + absence_dict[value] += 1 + + total_absence_days = 0 + for key, value in absence_dict.items(): + total_absence_days += absence_dict[key] + + if total_absence_days > 0: + ui.markdown("###Abwesenheitstage diesen Monat:") + a_columns = [ + {'name': 'type', 'label': 'Typ', 'field': 'type', 'required': True, 'align': 'left'}, + {'name': 'sum', 'label': 'Tage', 'field': 'sum', 'required': True, 'align': 'left'}, + ] + + a_row = [ ] + + for key,value in absence_dict.items(): + if value > 0: + a_row.append({'type': absence_entries[key]['name'], 'sum': value}) + + absence_table = ui.table(columns=a_columns, rows=a_row) + + except Exception as e: print(str(type(e).__name__) + " " + str(e)) if type(e) == UnboundLocalError: diff --git a/users.py b/users.py index 70e549c..8dae9f2 100644 --- a/users.py +++ b/users.py @@ -156,7 +156,6 @@ class user: years.append(year) years.sort() - print(years) return years def get_months(self, year): @@ -183,7 +182,7 @@ class user: elif int(year) < year_now: for i in range(1, 13): available_months.append(i) - print(available_months) + for file in os.listdir(self.userfolder): if re.match(r"\d{4}-\d{1,2}\.json", file): @@ -254,8 +253,6 @@ class user: except: json_data.update({ "absence": { str(int(day)): absence_type}}) json_dict = json.dumps(json_data, indent=4) - print(json_dict) - print(f"{self.userfolder}/{year}-{month}.json") with open(f"{self.userfolder}/{int(year)}-{int(month)}.json", "w") as json_file: json_file.write(json_dict) @@ -285,6 +282,7 @@ class user: if int(weekday) == 0: weekday = str(7) hours_to_work = self.workhours[entry][weekday] + break else: # Wenn vor Einstellungsdatum -1 ausgeben hours_to_work = -1