Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
Python
:
tableau010.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tableau interactif - Jours ouvrables</title> <style> table { width: 100%; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; } th, td { border: 1px solid #ddd; text-align: left; padding: 8px; } th { background-color: #f2f2f2; text-align: center; } tr:nth-child(even) { background-color: #f9f9f9; } tr:hover { background-color: #ddd; } input[type="text"] { width: 100%; box-sizing: border-box; border: 1px solid #ccc; padding: 5px; } button { margin-top: 10px; padding: 10px 15px; background-color: #4CAF50; color: white; border: none; cursor: pointer; } button:hover { background-color: #45a049; } /* Figer la première colonne */ .sticky-col { position: sticky; left: 0; background-color: #f9f9f9; /* Assurez-vous que la couleur de fond est fixe */ z-index: 2; /* S'assurer qu'elle reste au-dessus des autres colonnes */ } /* Pour l'entête de la première colonne */ .sticky-col-header { z-index: 3; /* Priorité sur les autres lignes */ } /* Couleurs de fond alternées pour les mois */ .month-odd { background-color: #e6f7ff; } .month-even { background-color: #fff3e0; } </style> </head> <body> <h1>Tableau interactif - Jours ouvrables sur 1 an</h1> <?php $year = date("Y"); // Année en cours $dates = []; $currentDate = new DateTime("$year-01-01"); // Générer les jours ouvrables (lundi-vendredi) pour l'année while ($currentDate->format("Y") == $year) { $dayOfWeek = $currentDate->format("N"); // 1 = Lundi, 7 = Dimanche if ($dayOfWeek >= 1 && $dayOfWeek <= 5) { $dates[] = $currentDate->format("Y-m-d"); } $currentDate->modify("+1 day"); } $columns = $dates; // Calculer les numéros de semaines pour chaque colonne $weekNumbers = []; foreach ($columns as $date) { $weekNumbers[] = (new DateTime($date))->format("W"); } // Calculer les noms des jours de la semaine pour chaque colonne $dayNames = []; $frenchDayNames = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"]; foreach ($columns as $date) { $dayOfWeek = (new DateTime($date))->format("N"); // 1 = Lundi, 7 = Dimanche $dayName = $frenchDayNames[$dayOfWeek - 1]; $dayNames[] = ucfirst(substr($dayName, 0, 3)) . '.'; } // Si le formulaire est soumis, récupérer les données $submittedData = []; if ($_SERVER["REQUEST_METHOD"] === "POST" && !empty($_POST["cell"])) { $submittedData = $_POST["cell"]; } // Déterminer les mois pour chaque date $months = []; foreach ($columns as $date) { $months[] = (new DateTime($date))->format("m"); } ?> <form method="post"> <div style="overflow-x: auto;"> <table> <thead> <!-- Ligne des numéros de semaine --> <tr> <th class="sticky-col sticky-col-header">Semaine</th> <?php foreach ($weekNumbers as $weekNumber): ?> <th><?= $weekNumber ?></th> <?php endforeach; ?> </tr> <!-- Ligne des jours --> <tr> <th class="sticky-col sticky-col-header">Jours</th> <?php foreach ($columns as $colIndex => $date): ?> <th class="<?= ($months[$colIndex] % 2 == 0) ? 'month-even' : 'month-odd' ?>"><?= $date ?></th> <?php endforeach; ?> </tr> <!-- Ligne des noms des jours de la semaine --> <tr> <th class="sticky-col sticky-col-header">xxx</th> <?php foreach ($dayNames as $dayName): ?> <th><?= $dayName ?></th> <?php endforeach; ?> </tr> </thead> <tbody> <?php $daysOfWeek = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi"]; foreach ($daysOfWeek as $dayIndex => $dayName): ?> <tr> <td class="sticky-col"><?= $dayName ?></td> <?php foreach ($columns as $colIndex => $date): ?> <td class="<?= ($months[$colIndex] % 2 == 0) ? 'month-even' : 'month-odd' ?>"> <input type="text" name="cell[<?= $dayIndex ?>][<?= $colIndex ?>]" value="<?= isset($submittedData[$dayIndex][$colIndex]) ? htmlspecialchars($submittedData[$dayIndex][$colIndex]) : '' ?>"> </td> <?php endforeach; ?> </tr> <?php endforeach; ?> </tbody> </table> </div> <button type="submit">Enregistrer</button> </form> <?php if (!empty($submittedData)): ?> <h2>Valeurs saisies :</h2> <div style="overflow-x: auto;"> <table> <thead> <!-- Ligne des numéros de semaine --> <tr> <th class="sticky-col sticky-col-header">Semaine</th> <?php foreach ($weekNumbers as $weekNumber): ?> <th><?= $weekNumber ?></th> <?php endforeach; ?> </tr> <!-- Ligne des jours --> <tr> <th class="sticky-col sticky-col-header">Jours</th> <?php foreach ($columns as $colIndex => $date): ?> <th class="<?= ($months[$colIndex] % 2 == 0) ? 'month-even' : 'month-odd' ?>"><?= $date ?></th> <?php endforeach; ?> </tr> <!-- Ligne des noms des jours de la semaine --> <tr> <th class="sticky-col sticky-col-header">xxx</th> <?php foreach ($dayNames as $dayName): ?> <th><?= $dayName ?></th> <?php endforeach; ?> </tr> </thead> <tbody> <?php foreach ($daysOfWeek as $dayIndex => $dayName): ?> <tr> <td class="sticky-col"><?= $dayName ?></td> <?php foreach ($columns as $colIndex => $date): ?> <td class="<?= ($months[$colIndex] % 2 == 0) ? 'month-even' : 'month-odd' ?>"><?= isset($submittedData[$dayIndex][$colIndex]) ? htmlspecialchars($submittedData[$dayIndex][$colIndex]) : '' ?></td> <?php endforeach; ?> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php endif; ?> </body> </html>