Version stable, aprelic, connexion CFRS et autres corrections

This commit is contained in:
Oleg Barykin committed 2026-04-17 20:18:11 +02:00
1 parent 865de8a976
commit e9d0010451
62 files changed
+17483 -7256

No files matched your search

@@ -0,0 +1,80 @@
<?php
declare (strict_types = 1);
require_once __DIR__ . '/../includes/init_praticien.php';
header('Content-Type: application/json; charset=utf-8');
if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') {
echo json_encode([
'ok' => false,
'message' => 'Méthode non autorisée.',
], JSON_UNESCAPED_UNICODE);
exit;
}
require_post_csrf();
$praticien_id = (int) ($_SESSION['reference_id'] ?? 0);
if ($praticien_id <= 0) {
echo json_encode([
'ok' => false,
'message' => 'Praticien non autorisé.',
], JSON_UNESCAPED_UNICODE);
exit;
}
$id = (int) ($_POST['id'] ?? 0);
if ($id <= 0) {
echo json_encode([
'ok' => false,
'message' => 'ID invalide.',
], JSON_UNESCAPED_UNICODE);
exit;
}
try {
$check = $pdo->prepare("
SELECT id, praticien_id
FROM disponibilite
WHERE id = ?
LIMIT 1
");
$check->execute([$id]);
$slot = $check->fetch(PDO::FETCH_ASSOC);
if (! $slot) {
echo json_encode([
'ok' => false,
'message' => 'Créneau introuvable.',
], JSON_UNESCAPED_UNICODE);
exit;
}
if ((int) $slot['praticien_id'] !== $praticien_id) {
echo json_encode([
'ok' => false,
'message' => 'Ce créneau ne vous appartient pas.',
], JSON_UNESCAPED_UNICODE);
exit;
}
$stmt = $pdo->prepare("DELETE FROM disponibilite WHERE id = ? AND praticien_id = ?");
$stmt->execute([$id, $praticien_id]);
echo json_encode([
'ok' => ($stmt->rowCount() > 0),
'message' => $stmt->rowCount() > 0
? 'Créneau supprimé.'
: 'Aucune ligne supprimée.',
], JSON_UNESCAPED_UNICODE);
exit;
} catch (Throwable $e) {
error_log('supprimer_disponibilite.php: ' . $e->getMessage());
echo json_encode([
'ok' => false,
'message' => 'Erreur serveur.',
], JSON_UNESCAPED_UNICODE);
exit;
}