Init Git Prod Mars 2026
This commit is contained in:
commit
d81efe93b1
362 files changed
+86627
No files matched your search
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../includes/bootstrap_global.php';
|
||||
|
||||
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
|
||||
http_response_code(400);
|
||||
exit('ID praticien invalide.');
|
||||
}
|
||||
|
||||
$praticien_id = intval($_GET['id']);
|
||||
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT rv.*, c.prenom, c.nom
|
||||
FROM rendez_vous rv
|
||||
JOIN client c ON rv.client_id = c.id
|
||||
WHERE rv.praticien_id = ? AND rv.statut IN ('confirmé', 'prévu')
|
||||
ORDER BY rv.date_rdv
|
||||
");
|
||||
$stmt->execute([$praticien_id]);
|
||||
$rdvs = $stmt->fetchAll();
|
||||
|
||||
header('Content-Type: text/calendar; charset=utf-8');
|
||||
header('Content-Disposition: inline; filename="agenda.ics"');
|
||||
|
||||
echo "BEGIN:VCALENDAR
|
||||
";
|
||||
echo "VERSION:2.0
|
||||
";
|
||||
echo "CALSCALE:GREGORIAN
|
||||
";
|
||||
echo "METHOD:PUBLISH
|
||||
";
|
||||
echo "X-WR-CALNAME:Agenda Praticien
|
||||
";
|
||||
echo "X-WR-TIMEZONE:Europe/Paris
|
||||
";
|
||||
|
||||
foreach ($rdvs as $r) {
|
||||
// Génération et stockage d’un UUID stable pour éviter les doublons
|
||||
if (empty($r['uuid_ical'])) {
|
||||
$uuid = bin2hex(random_bytes(16));
|
||||
$update = $pdo->prepare("UPDATE rendez_vous SET uuid_ical = ? WHERE id = ?");
|
||||
$update->execute([$uuid, $r['id']]);
|
||||
} else {
|
||||
$uuid = $r['uuid_ical'];
|
||||
}
|
||||
|
||||
$start = new DateTime($r['date_rdv'], new DateTimeZone('Europe/Paris'));
|
||||
$end = clone $start;
|
||||
$end->modify("+" . intval($r['duree_minutes'] ?? 60) . " minutes");
|
||||
|
||||
$summary = "RDV avec {$r['prenom']} {$r['nom']}";
|
||||
|
||||
echo "BEGIN:VEVENT
|
||||
";
|
||||
echo "UID:$uuid
|
||||
";
|
||||
echo "DTSTAMP:" . gmdate('Ymd\THis\Z') . "
|
||||
";
|
||||
echo "DTSTART;TZID=Europe/Paris:" . $start->format('Ymd\THis') . "
|
||||
";
|
||||
echo "DTEND;TZID=Europe/Paris:" . $end->format('Ymd\THis') . "
|
||||
";
|
||||
echo "SUMMARY:$summary
|
||||
";
|
||||
echo "STATUS:CONFIRMED
|
||||
";
|
||||
echo "END:VEVENT
|
||||
";
|
||||
}
|
||||
|
||||
echo "END:VCALENDAR
|
||||
";
|
||||
exit;
|
||||
?>
|
||||
Reference in new issue
Block a user