calendar storage

This commit is contained in:
2026-01-08 17:25:42 +01:00
parent b7533a4d05
commit 796d3b3fcc
7 changed files with 421 additions and 60 deletions
@@ -24,3 +24,10 @@
[2026-01-07T14:26:31+01:00] RAW INPUT: [{"date":"2025-09-08","type":"OFF_CAROLE","person":"Carole","duration":1}]
[2026-01-07T14:26:36+01:00] RAW INPUT: [{"date":"2025-09-08","type":"OFF_CAROLE","person":"Carole","duration":1},{"date":"2025-09-09","type":"OFF_CAROLE","person":"Carole","duration":1}]
[2026-01-07T14:30:24+01:00] RAW INPUT: [{"date":"2025-10-06","type":"CENTRE","duration":1},{"date":"2025-10-07","type":"CENTRE","duration":1}]
[2026-01-08T09:21:34+01:00] RAW INPUT: [{"date":"2025-09-15","type":"EXTRA_OFF_CAROLE","person":"Carole","duration":1}]
[2026-01-08T09:21:38+01:00] RAW INPUT: [{"date":"2025-09-17","type":"EXTRA_OFF_CAROLE","person":"Carole","duration":1}]
[2026-01-08T09:21:58+01:00] RAW INPUT: [{"date":"2025-10-20","type":"CENTRE","duration":1},{"date":"2025-10-21","type":"CENTRE","duration":1},{"date":"2025-10-22","type":"CENTRE","duration":1},{"date":"2025-10-23","type":"CENTRE","duration":1},{"date":"2025-10-24","type":"CENTRE","duration":1}]
[2026-01-08T09:22:43+01:00] RAW INPUT: [{"date":"2025-12-22","type":"EXTRA_OFF_CAROLE","person":"Carole","duration":1},{"date":"2025-12-23","type":"EXTRA_OFF_CAROLE","person":"Carole","duration":1},{"date":"2025-12-24","type":"EXTRA_OFF_CAROLE","person":"Carole","duration":1}]
[2026-01-08T09:23:59+01:00] RAW INPUT: [{"date":"2025-12-22","type":"CENTRE","duration":1}]
[2026-01-08T09:24:00+01:00] RAW INPUT: [{"date":"2025-12-23","type":"CENTRE","duration":1}]
[2026-01-08T09:24:02+01:00] RAW INPUT: [{"date":"2025-12-24","type":"CENTRE","duration":1}]
@@ -0,0 +1,68 @@
<?php
header('Content-Type: application/json');
require __DIR__ . '/../../../../includes/db.php';
/**
* Paramètre: school_year_start (optionnel)
* - année de début d'année scolaire (ex: 2025 pour 09/2025 -> 08/2026)
* - défaut: année courante si non fourni
*/
$schoolYearStart = isset($_GET['school_year_start'])
? (int)$_GET['school_year_start']
: (int)date('Y');
if ($schoolYearStart < 2000 || $schoolYearStart > 2100) {
http_response_code(400);
echo json_encode(['status' => 'error', 'message' => 'Année scolaire invalide.']);
exit;
}
$yearStart = $schoolYearStart;
$yearEnd = $schoolYearStart + 1;
// On veut toutes les semaines:
// - de septembre (month >= 9) de yearStart
// - à août (month <= 8) de yearEnd
try {
$sql = "
SELECT
year,
week_iso_year,
week_iso_number,
week_label,
month,
month_name,
week_start_date,
mon_date,
tue_date,
wed_date,
thu_date,
fri_date
FROM pf_calendar_weeks
WHERE
(year = :year_start AND month >= 9)
OR (year = :year_end AND month <= 8)
ORDER BY week_start_date ASC
";
$stmt = $pdo->prepare($sql);
$stmt->execute([
':year_start' => $yearStart,
':year_end' => $yearEnd,
]);
$weeks = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode([
'status' => 'success',
'school_year' => $schoolYearStart,
'weeks' => $weeks,
]);
} catch (PDOException $e) {
http_response_code(500);
echo json_encode([
'status' => 'error',
'message' => $e->getMessage(),
]);
}
@@ -0,0 +1,36 @@
<?php
header('Content-Type: application/json');
require __DIR__ . '/../../../../includes/db.php';
$year = isset($_GET['year']) ? (int)$_GET['year'] : (int)date('Y');
try {
$stmt = $pdo->prepare("
SELECT
year,
week_iso_year,
week_iso_number,
week_label,
month,
month_name,
week_start_date,
mon_date,
tue_date,
wed_date,
thu_date,
fri_date
FROM pf_calendar_weeks
WHERE year = :year
ORDER BY week_start_date ASC
");
$stmt->execute([':year' => $year]);
$weeks = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode(['weeks' => $weeks]);
} catch (PDOException $e) {
http_response_code(500);
echo json_encode([
'status' => 'error',
'message' => $e->getMessage(),
]);
}