diff --git a/assets/css/style.css b/assets/css/style.css index 82402d6..6a3197f 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -375,6 +375,13 @@ input[type="number"] { border: 1px solid #d9e2ec; } +.fc-calendar-and-summary { + display: grid; + grid-template-columns: 1fr auto; + gap: 24px; + align-items: start; +} + .fc-month-header { display: flex; align-items: center; @@ -548,6 +555,69 @@ input[type="number"] { cursor: pointer; } +/* === TABLEAU RÉCAPITULATIF === */ +.fc-month-summary { + min-width: 300px; +} + +.fc-summary-table-wrapper { + background: #f8fafc; + border-radius: 6px; + padding: 12px; + border: 1px solid #d9e2ec; +} + +.fc-summary-table { + width: 100%; + border-collapse: collapse; + font-size: 13px; +} + +.fc-summary-table thead th { + background: #f0f4f8; + padding: 8px 6px; + text-align: center; + font-weight: 600; + color: #243b53; + border: 1px solid #d9e2ec; + white-space: nowrap; +} + +.fc-summary-table tbody td { + border: 1px solid #d9e2ec; + padding: 6px 8px; + text-align: center; + background: #fff; +} + +.fc-summary-table tbody td:first-child { + text-align: left; + font-weight: 500; + color: #243b53; +} + +.fc-summary-total-row { + background: #f0f4f8 !important; + border-top: 2px solid #243b53; +} + +.fc-summary-total-row td { + background: #f0f4f8 !important; + font-weight: 600; + color: #243b53; +} + +/* Responsive pour le calendrier et le récapitulatif */ +@media (max-width: 1200px) { + .fc-calendar-and-summary { + grid-template-columns: 1fr; + } + + .fc-month-summary { + min-width: 100%; + } +} + /* === VUE 2 MOIS === */ .fc-two-months-container { display: grid; diff --git a/assets/js/family-calendar.js b/assets/js/family-calendar.js index 0dabd3e..899bd87 100644 --- a/assets/js/family-calendar.js +++ b/assets/js/family-calendar.js @@ -910,6 +910,9 @@ document.addEventListener("DOMContentLoaded", () => { } else { this.renderSingleMonthView(); } + + // Afficher le tableau récapitulatif + this.renderMonthSummary(); } renderSingleMonthView() { @@ -918,6 +921,191 @@ document.addEventListener("DOMContentLoaded", () => { this.monthCalendar.innerHTML = this.generateMonthHTML(year, month); } + calculateMonthTotals(year, month) { + // Calculer le premier et dernier jour du mois (uniquement jours de semaine) + const firstDay = new Date(year, month, 1); + const lastDay = new Date(year, month + 1, 0); + const totals = { + offCarole: 0, + extraOffCarole: 0, + centre: 0, + avis: 0, + }; + + // Parcourir tous les jours du mois + for (let day = 1; day <= lastDay.getDate(); day++) { + const date = new Date(year, month, day); + const dayOfWeek = date.getDay(); + + // Ignorer les samedi (6) et dimanche (0) + if (dayOfWeek === 0 || dayOfWeek === 6) { + continue; + } + + const isoDate = `${year}-${String(month + 1).padStart(2, "0")}-${String( + day + ).padStart(2, "0")}`; + + // Trouver les événements pour ce jour + const dayEvents = this.dbEvents.filter((evt) => evt.date === isoDate); + + dayEvents.forEach((evt) => { + const dur = parseFloat(evt.duration) || 1; + switch (evt.type) { + case "OFF_CAROLE": + totals.offCarole += dur; + break; + case "EXTRA_OFF_CAROLE": + totals.extraOffCarole += dur; + break; + case "CENTRE": + totals.centre += dur; + break; + case "AVIS": + totals.avis += dur; + break; + } + }); + } + + return totals; + } + + renderMonthSummary() { + const summaryDiv = document.getElementById("fc-month-summary"); + if (!summaryDiv) return; + + let html = '
| Mois | "; + html += "# Off Carole | "; + html += "# Extra off Carole | "; + html += "# Centre | "; + html += "# Avis | "; + html += "
|---|---|---|---|---|
| ${getMonthNameFr(month)} ${monthYear} | `; + html += `${formatTotal(totals.offCarole)} | `; + html += `${formatTotal(totals.extraOffCarole)} | `; + html += `${formatTotal(totals.centre)} | `; + html += `${formatTotal(totals.avis)} | `; + html += "
| Total ${year}-${year + 1} | `; + html += `${formatTotal( + yearTotals.offCarole + )} | `; + html += `${formatTotal( + yearTotals.extraOffCarole + )} | `; + html += `${formatTotal(yearTotals.centre)} | `; + html += `${formatTotal(yearTotals.avis)} | `; + html += "
| ${getMonthNameFr(month)} ${ + month >= 8 ? year : year + 1 + } | `; + html += `${formatTotal(totals1.offCarole)} | `; + html += `${formatTotal(totals1.extraOffCarole)} | `; + html += `${formatTotal(totals1.centre)} | `; + html += `${formatTotal(totals1.avis)} | `; + html += "
| ${getMonthNameFr(nextMonthIndex)} ${ + nextMonthIndex >= 8 ? nextYear : nextYear + 1 + } | `; + html += `${formatTotal(totals2.offCarole)} | `; + html += `${formatTotal(totals2.extraOffCarole)} | `; + html += `${formatTotal(totals2.centre)} | `; + html += `${formatTotal(totals2.avis)} | `; + html += "
| Total | "; + html += `${formatTotal( + combinedTotals.offCarole + )} | `; + html += `${formatTotal( + combinedTotals.extraOffCarole + )} | `; + html += `${formatTotal( + combinedTotals.centre + )} | `; + html += `${formatTotal(combinedTotals.avis)} | `; + html += "
| ${getMonthNameFr(month)} ${ + month >= 8 ? year : year + 1 + } | `; + html += `${formatTotal(totals.offCarole)} | `; + html += `${formatTotal(totals.extraOffCarole)} | `; + html += `${formatTotal(totals.centre)} | `; + html += `${formatTotal(totals.avis)} | `; + html += "