File "config01.php"
Full Path: /home/analogde/www/Dev tableau/config01.php
File size: 4.92 KB
MIME-type: text/html
Charset: utf-8
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Configuration des Dates</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h2>Configurer les Dates</h2>
<form id="configForm">
<div class="form-group">
<label for="startDate">Date de Début</label>
<input type="date" class="form-control" id="startDate" name="startDate" required>
</div>
<div class="form-group">
<label for="endDate">Date de Fin</label>
<input type="date" class="form-control" id="endDate" name="endDate" required>
</div>
<button type="submit" class="btn btn-primary">Générer le Tableau</button>
</form>
<div id="holidaysList" class="mt-3">
<h3>Jours Fériés :</h3>
<ul id="holidays"></ul>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
document.getElementById('configForm').addEventListener('submit', function(event) {
event.preventDefault();
const startDate = document.getElementById('startDate').value;
const endDate = document.getElementById('endDate').value;
// Calculer les jours fériés dynamiquement
const holidays = calculateHolidays(startDate, endDate);
// Afficher les jours fériés
const holidaysList = document.getElementById('holidays');
holidaysList.innerHTML = '';
holidays.forEach(holiday => {
const li = document.createElement('li');
li.textContent = holiday;
holidaysList.appendChild(li);
});
// Rediriger vers la page principale avec les paramètres dans l'URL
const url = `index02.html?startDate=${startDate}&endDate=${endDate}&holidays=${holidays.join(',')}`;
window.location.href = url;
});
function calculateHolidays(startDate, endDate) {
const holidays = [];
const start = new Date(startDate);
const end = new Date(endDate);
const currentYear = start.getFullYear();
// Liste des jours fériés fixes en France
const fixedHolidays = [
'01-01', // Jour de l'an
'05-01', // Fête du Travail
'05-08', // Victoire 1945
'07-14', // Fête Nationale
'08-15', // Assomption
'11-01', // Toussaint
'11-11', // Armistice 1918
'12-25' // Noël
];
// Ajouter les jours fériés fixes
fixedHolidays.forEach(date => {
const holiday = new Date(`${currentYear}-${date}`);
if (holiday >= start && holiday <= end) {
holidays.push(holiday.toISOString().split('T')[0]);
}
});
// Ajouter les jours fériés mobiles (Pâques et jours associés)
const easter = calculateEaster(currentYear);
const easterMonday = new Date(easter);
easterMonday.setDate(easterMonday.getDate() + 1);
const ascension = new Date(easter);
ascension.setDate(ascension.getDate() + 39);
const pentecote = new Date(easter);
pentecote.setDate(pentecote.getDate() + 49);
const pentecoteMonday = new Date(pentecote);
pentecoteMonday.setDate(pentecoteMonday.getDate() + 1);
const mobileHolidays = [easterMonday, ascension, pentecoteMonday];
mobileHolidays.forEach(holiday => {
if (holiday >= start && holiday <= end) {
holidays.push(holiday.toISOString().split('T')[0]);
}
});
return holidays;
}
function calculateEaster(year) {
const f = Math.floor,
G = year % 19,
C = f(year / 100),
H = f(C / 4),
J = f((C - f(C / 4) + f(8 * C + 13) / 25) / 3) + (15 - 30 * C + f(C / 4) - f(C / 4 / 4)) % 30,
L = J - f(J / 28 * (1 - f(29 / (J + 1)) * f((21 - G) / 11))),
I = L - (year + f(year / 4) + 6 - H) % 7,
P = L - I,
d = 1 + (P + 27 + f(P / 26) * (29 - P % 29)) % 31,
m = 3 + f((P + 26) / 30);
return new Date(year, m - 1, d);
}
</script>
</body>
</html>