From dfc182a8a987b67315f38f8a0b6d72f41d05bb6b Mon Sep 17 00:00:00 2001 From: root Date: Thu, 20 Aug 2026 20:59:29 +0000 Subject: [PATCH] Ajouter les totaux mensuels au calendrier --- app_new/planning/schedules.py | 13 ++++++++++++- app_new/templates/planning/calendar.html | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app_new/planning/schedules.py b/app_new/planning/schedules.py index 445754a..c7bfd07 100644 --- a/app_new/planning/schedules.py +++ b/app_new/planning/schedules.py @@ -139,6 +139,9 @@ def index(): first_weekday = date(actual_year, month, 1).weekday() weeks = [] + month_planned_minutes = 0 + month_overtime_minutes = 0 + month_delay_minutes = 0 week = [None] * first_weekday # Cases vides avant le 1er jour for day in range(1, days_in_month + 1): @@ -161,6 +164,11 @@ def index(): planned_minutes -= (source.lunch_end.hour * 60 + source.lunch_end.minute) - (source.lunch_start.hour * 60 + source.lunch_start.minute) entry = time_entries.get(d) actual_minutes = entry.actual_minutes if entry else 0 + month_planned_minutes += planned_minutes + if entry and entry.entry_type == 'supplementaire': + month_overtime_minutes += actual_minutes or 0 + elif entry and entry.entry_type == 'retard': + month_delay_minutes += actual_minutes or 0 fmt = lambda minutes: f"{minutes // 60}h{minutes % 60:02d}" deviation_hours = None deviation_class = None @@ -197,7 +205,10 @@ def index(): months_data.append({ 'name': months_names[month - 1], 'year': actual_year, - 'weeks': weeks + 'weeks': weeks, + 'planned_hours': fmt(month_planned_minutes), + 'overtime_hours': fmt(month_overtime_minutes), + 'delay_hours': fmt(month_delay_minutes), }) # Statistiques diff --git a/app_new/templates/planning/calendar.html b/app_new/templates/planning/calendar.html index 8e24783..29f2787 100644 --- a/app_new/templates/planning/calendar.html +++ b/app_new/templates/planning/calendar.html @@ -81,7 +81,7 @@
- {{ month.name }} {{ month.year }} + {{ month.name }} {{ month.year }}
Prévu {{ month.planned_hours }}{% if month.overtime_hours != '0h00' %} · +{{ month.overtime_hours }} sup.{% endif %}{% if month.delay_hours != '0h00' %} · -{{ month.delay_hours }} dû{% endif %}