File "tmp0010.php"
Full Path: /home/analogde/www/Dev tableau/tmp0010.php
File size: 6.71 KB
MIME-type: text/x-php
Charset: utf-8
<?php
// Fonction pour générer les dates entre deux dates, excluant les samedis, dimanches et jours fériés
function getWorkingDays($startDate, $endDate, $holidays = []) {
$start = strtotime($startDate);
$end = strtotime($endDate);
$workingDays = [];
// Générer toutes les dates entre startDate et endDate
for ($currentDate = $start; $currentDate <= $end; $currentDate = strtotime("+1 day", $currentDate)) {
$dayOfWeek = date("N", $currentDate); // Numéro du jour de la semaine (1 = lundi, 7 = dimanche)
// Vérifier si ce jour est un week-end ou un jour férié
if ($dayOfWeek < 6 && !in_array(date("Y-m-d", $currentDate), $holidays)) {
// Ajouter la date à la liste des jours ouvrables si ce n'est pas un samedi, dimanche, ou jour férié
$workingDays[] = date("d", $currentDate); // Seulement le jour du mois
}
}
return $workingDays;
}
// Liste des jours fériés et fêtes religieuses à exclure (exemple pour la France, à compléter avec d'autres fêtes)
$holidays = [
"2025-01-01", // Jour de l'An
"2025-04-14", // Lundi de Pâques
"2025-05-01", // Fête du Travail
"2025-05-08", // Victoire 1945
"2025-07-14", // Bastille
"2025-08-15", // Assomption
"2025-11-01", // Toussaint
"2025-12-25", // Noël
"2026-01-01", // Jour de l'An
"2026-04-06", // Lundi de Pâques
// Ajouter d'autres jours fériés ici...
];
// Définir la période de début et de fin
$startDate = "2025-01-10";
$endDate = "2026-02-14";
// Appeler la fonction pour obtenir les jours ouvrés entre les deux dates
$workingDays = getWorkingDays($startDate, $endDate, $holidays);
echo "<pre>";
print_r($workingDays);
echo "</pre>";
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tableau Sticky - 3 Lignes Fixes</title>
<style>
.table-wrapper {
width: 100%;
max-height: 400px;
overflow: auto;
border: 1px solid #ccc;
position: relative;
}
table {
border-collapse: collapse;
width: max-content;
table-layout: fixed;
}
th, td {
padding: 10px;
text-align: center;
height: 40px;
border: 1px solid #ccc;
white-space: nowrap;
min-width: 120px;
position: relative;
background-color: white;
box-sizing: border-box;
}
/* Fixation des cellules d'en-tête */
th {
background-color: #f2f2f2;
position: sticky;
top: 0;
z-index: 100;
}
/* Colonnes sticky */
th:first-child, td:first-child {
position: sticky;
left: 0;
z-index: 101;
background-color: white;
}
th:nth-child(2), td:nth-child(2) {
position: sticky;
left: 120px;
z-index: 100;
background-color: white;
}
th:nth-child(3), td:nth-child(3) {
position: sticky;
left: 240px;
z-index: 99;
background-color: white;
}
/* Bordures droites persistantes */
th:first-child::after, td:first-child::after,
th:nth-child(2)::after, td:nth-child(2)::after,
th:nth-child(3)::after, td:nth-child(3)::after {
content: "";
position: absolute;
right: 0;
top: 0;
width: 2px;
height: 100%;
background-color: #ccc;
z-index: 102;
}
tbody tr:nth-child(odd) {
background-color: #f9f9f9;
}
th:nth-child(n+4), td:nth-child(n+4) {
min-width: 150px;
}
.second-header th, .third-header th {
background-color: #f2f2f2;
position: sticky;
top: 40px;
z-index: 99;
}
.second-header th:first-child, .third-header th:first-child {
left: 0;
z-index: 101;
background-color: white;
}
.second-header th:nth-child(2), .third-header th:nth-child(2) {
left: 120px;
z-index: 100;
background-color: white;
}
.second-header th:nth-child(3), .third-header th:nth-child(3) {
left: 240px;
z-index: 99;
background-color: white;
}
thead tr:first-child th,
.second-header th,
.third-header th {
box-shadow: inset 0 -2px #aaa;
background-clip: padding-box;
padding-bottom: 2px;
margin-bottom: -2px;
z-index: 100;
}
.second-header th {
top: calc(40px + 2px);
margin-top: 2px;
}
.third-header th {
top: calc(80px + 2px);
margin-top: 2px;
}
</style>
</head>
<body>
<div class="table-wrapper">
<table>
<thead>
<tr>
<th></th>
<th>plouf</th>
<th>cretin</th>
<?php foreach ($workingDays as $key => $day): ?>
<th>Jour <?php echo $key + 1; ?> (<?php echo $day; ?>)</th>
<?php endforeach; ?>
</tr>
<tr class="second-header">
<th></th>
<th>Valeur 1</th>
<th>Valeur 2</th>
<?php foreach ($workingDays as $key => $day): ?>
<th>Val <?php echo $key + 1; ?></th>
<?php endforeach; ?>
</tr>
<tr class="third-header">
<th></th>
<th>Info 1</th>
<th>Info 2</th>
<?php foreach ($workingDays as $key => $day): ?>
<th>Info <?php echo $key + 1; ?></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php for ($i = 1; $i <= 50; $i++): ?>
<tr>
<td>Row <?php echo $i; ?></td>
<td>Data <?php echo $i . "-2"; ?></td>
<td>cretin <?php echo $i; ?></td>
<?php foreach ($workingDays as $key => $day): ?>
<td>Data <?php echo $i . "-" . ($key + 1); ?></td>
<?php endforeach; ?>
</tr>
<?php endfor; ?>
</tbody>
</table>
</div>
</body>
</html>