feat(heures) : colonne nom -25% et statut sur la couleur de l'absence en BDD

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-08 17:59:32 +02:00
parent 818e085657
commit 4cc7747fd7
3 changed files with 21 additions and 14 deletions
@@ -110,7 +110,7 @@ class YearlyHoursExportBuilder
* *
* @param list<Employee> $employees * @param list<Employee> $employees
* *
* @return list<array{employeeId:int, employeeName:string, statut:?string, * @return list<array{employeeId:int, employeeName:string, statut:?string, statutColor:?string,
* morningFrom:string, morningTo:string, afternoonFrom:string, afternoonTo:string, * morningFrom:string, morningTo:string, afternoonFrom:string, afternoonTo:string,
* eveningFrom:string, eveningTo:string, dayHours:string, nightHours:string, * eveningFrom:string, eveningTo:string, dayHours:string, nightHours:string,
* total:string, isWeekend:bool, isHoliday:bool}> * total:string, isWeekend:bool, isHoliday:bool}>
@@ -159,14 +159,18 @@ class YearlyHoursExportBuilder
); );
$statut = $absenceData['labels'][$ymd] ?? null; $statut = $absenceData['labels'][$ymd] ?? null;
$statutColor = ($absenceData['colors'][$ymd] ?? '') ?: null;
if (null === $statut && null !== $holidayLabel) { if (null === $statut && null !== $holidayLabel) {
// Férié sans absence : badge bleu clair, comme la vue Jour.
$statut = $holidayLabel; $statut = $holidayLabel;
$statutColor = '#b3e5fc';
} }
$row = [ $row = [
'employeeId' => $employeeId, 'employeeId' => $employeeId,
'employeeName' => trim(($employee->getLastName() ?? '').' '.($employee->getFirstName() ?? '')), 'employeeName' => trim(($employee->getLastName() ?? '').' '.($employee->getFirstName() ?? '')),
'statut' => $statut, 'statut' => $statut,
'statutColor' => $statutColor,
'morningFrom' => '', 'morningFrom' => '',
'morningTo' => '', 'morningTo' => '',
'afternoonFrom' => '', 'afternoonFrom' => '',
@@ -292,12 +296,13 @@ class YearlyHoursExportBuilder
} }
/** /**
* @return array{credited: array<string, int>, labels: array<string, string>, absentMorning: array<string, bool>, absentAfternoon: array<string, bool>, hasDayAbsence: array<string, bool>} * @return array{credited: array<string, int>, labels: array<string, string>, colors: array<string, string>, absentMorning: array<string, bool>, absentAfternoon: array<string, bool>, hasDayAbsence: array<string, bool>}
*/ */
private function resolveAbsenceDataForEmployee(array $absences, array $days, Employee $employee): array private function resolveAbsenceDataForEmployee(array $absences, array $days, Employee $employee): array
{ {
$credited = []; $credited = [];
$labels = []; $labels = [];
$colors = [];
$absentMorning = []; $absentMorning = [];
$absentAfternoon = []; $absentAfternoon = [];
$hasDayAbsence = []; $hasDayAbsence = [];
@@ -318,6 +323,7 @@ class YearlyHoursExportBuilder
$absentAfternoon[$date] = ($absentAfternoon[$date] ?? false) || $isAfternoon; $absentAfternoon[$date] = ($absentAfternoon[$date] ?? false) || $isAfternoon;
if (!isset($labels[$date])) { if (!isset($labels[$date])) {
$labels[$date] = $absence->getType()?->getLabel() ?? ''; $labels[$date] = $absence->getType()?->getLabel() ?? '';
$colors[$date] = $absence->getType()?->getColor() ?? '';
} }
} }
@@ -329,6 +335,7 @@ class YearlyHoursExportBuilder
return [ return [
'credited' => $credited, 'credited' => $credited,
'labels' => $labels, 'labels' => $labels,
'colors' => $colors,
'absentMorning' => $absentMorning, 'absentMorning' => $absentMorning,
'absentAfternoon' => $absentAfternoon, 'absentAfternoon' => $absentAfternoon,
'hasDayAbsence' => $hasDayAbsence, 'hasDayAbsence' => $hasDayAbsence,
+9 -10
View File
@@ -16,7 +16,6 @@
td.name { text-align: left; } td.name { text-align: left; }
tr.site-title td { font-weight: bold; font-size: 11px; text-transform: uppercase; text-align: left; padding: 2px 6px; white-space: nowrap; } tr.site-title td { font-weight: bold; font-size: 11px; text-transform: uppercase; text-align: left; padding: 2px 6px; white-space: nowrap; }
tr.weekend td { background: #c0c0c0; } tr.weekend td { background: #c0c0c0; }
td.statut { background: #b3e5fc; }
</style> </style>
</head> </head>
<body> <body>
@@ -28,14 +27,14 @@
<table> <table>
<thead> <thead>
<tr> <tr>
<th style="width: 28%;">Nom</th> <th style="width: 21%;">Nom</th>
<th style="width: 12%;">Statut</th> <th style="width: 13%;">Statut</th>
<th style="width: 7%;">Début matin</th> <th style="width: 8%;">Début matin</th>
<th style="width: 7%;">Fin matin</th> <th style="width: 8%;">Fin matin</th>
<th style="width: 7%;">Début après-midi</th> <th style="width: 8%;">Début après-midi</th>
<th style="width: 7%;">Fin après-midi</th> <th style="width: 8%;">Fin après-midi</th>
<th style="width: 7%;">Début soir</th> <th style="width: 8%;">Début soir</th>
<th style="width: 7%;">Fin soir</th> <th style="width: 8%;">Fin soir</th>
<th style="width: 6%;">Jour</th> <th style="width: 6%;">Jour</th>
<th style="width: 6%;">Nuit</th> <th style="width: 6%;">Nuit</th>
<th style="width: 6%;">Total</th> <th style="width: 6%;">Total</th>
@@ -49,7 +48,7 @@
{% for row in group.rows %} {% for row in group.rows %}
<tr class="{{ row.isWeekend ? 'weekend' : '' }}"> <tr class="{{ row.isWeekend ? 'weekend' : '' }}">
<td class="name">{{ row.employeeName }}</td> <td class="name">{{ row.employeeName }}</td>
<td class="{{ row.statut ? 'statut' : '' }}">{{ row.statut }}</td> <td{% if row.statutColor %} style="background: {{ row.statutColor }};"{% endif %}>{{ row.statut }}</td>
<td>{{ row.morningFrom }}</td> <td>{{ row.morningFrom }}</td>
<td>{{ row.morningTo }}</td> <td>{{ row.morningTo }}</td>
<td>{{ row.afternoonFrom }}</td> <td>{{ row.afternoonFrom }}</td>
@@ -100,6 +100,7 @@ final class YearlyHoursDayRowsTest extends TestCase
self::assertSame('8h', $rows[0]['dayHours']); self::assertSame('8h', $rows[0]['dayHours']);
self::assertSame('', $rows[0]['nightHours']); self::assertSame('', $rows[0]['nightHours']);
self::assertNull($rows[0]['statut']); self::assertNull($rows[0]['statut']);
self::assertNull($rows[0]['statutColor']);
self::assertFalse($rows[0]['isWeekend']); self::assertFalse($rows[0]['isWeekend']);
} }