97 lines
4.6 KiB
PHP
97 lines
4.6 KiB
PHP
<?php
|
||
require_once __DIR__ . '/../includes/init_secretaire.php';
|
||
|
||
|
||
|
||
if (!function_exists('h')) { function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); } }
|
||
|
||
$sec_uid = (int)($_SESSION['compte_id'] ?? 0);
|
||
if ($sec_uid<=0) { header('Location:/index.php'); exit; }
|
||
|
||
// Liste praticiens
|
||
$q = $pdo->prepare("
|
||
SELECT sp.id as spid, sp.praticien_id, sp.can_manage_rdv, sp.can_edit_slots, sp.is_active,
|
||
p.nom, p.prenom, p.specialite, p.ville
|
||
FROM secretaire_praticien sp
|
||
JOIN praticien p ON p.id = sp.praticien_id
|
||
WHERE sp.secretaire_user_id = :u AND sp.is_active=1
|
||
ORDER BY p.nom, p.prenom
|
||
");
|
||
$q->execute(['u'=>$sec_uid]);
|
||
$rows = $q->fetchAll(PDO::FETCH_ASSOC);
|
||
|
||
// Compteurs simples Today/Tomorrow par praticien
|
||
$today = (new DateTime('today'))->format('Y-m-d 00:00:00');
|
||
$tomorrow = (new DateTime('tomorrow'))->format('Y-m-d 00:00:00');
|
||
|
||
$counts = [];
|
||
if ($rows) {
|
||
$ids = array_column($rows,'praticien_id');
|
||
$in = implode(',', array_fill(0, count($ids), '?'));
|
||
$s = $pdo->prepare("
|
||
SELECT praticien_id,
|
||
SUM(date_rdv >= ? AND date_rdv < ?) AS today_count,
|
||
SUM(date_rdv >= ? AND date_rdv < DATE_ADD(?, INTERVAL 1 DAY)) AS tomorrow_count
|
||
FROM rendez_vous
|
||
WHERE praticien_id IN ($in) AND statut IN ('prévu','confirmé')
|
||
GROUP BY praticien_id
|
||
");
|
||
$params = [$today,(new DateTime('tomorrow'))->format('Y-m-d 00:00:00'), (new DateTime('tomorrow'))->format('Y-m-d 00:00:00'), (new DateTime('tomorrow'))->format('Y-m-d 00:00:00')];
|
||
$s->execute(array_merge($params, $ids));
|
||
foreach($s->fetchAll(PDO::FETCH_ASSOC) as $r){ $counts[(int)$r['praticien_id']] = $r; }
|
||
}
|
||
require_once __DIR__ . '/../includes/header_cabinet.php';
|
||
?>
|
||
<div class="main1">
|
||
<div class="shadow p-4 rounded bg-light">
|
||
<h1 class="h4 mb-3"><?= h($translations['sec_dashboard_titre'] ?? 'Secrétariat — Tableau de bord') ?></h1>
|
||
|
||
<?php if(!$rows): ?>
|
||
<div class="alert alert-info"><?= h($translations['sec_aucun_praticien'] ?? "Aucun praticien lié pour l’instant.") ?></div>
|
||
<?php else: ?>
|
||
<div class="row g-4">
|
||
<?php foreach($rows as $r):
|
||
$pid = (int)$r['praticien_id'];
|
||
$c = $counts[$pid] ?? ['today_count'=>0,'tomorrow_count'=>0];
|
||
?>
|
||
<div class="col-12 col-md-6 col-lg-6">
|
||
<div class="card h-100">
|
||
<div class="card-body">
|
||
<div class="d-flex justify-content-between align-items-start mb-2">
|
||
<div>
|
||
<div class="fw-semibold"><?= h($r['prenom'].' '.$r['nom']) ?></div>
|
||
<div class="text-muted small"><?= h(trim(($r['specialite']??'').' · '.($r['ville']??''), ' · ')) ?></div>
|
||
</div>
|
||
<span class="badge bg-secondary"><?= h($translations['sec_actif'] ?? 'Actif') ?></span>
|
||
</div>
|
||
<div class="d-flex gap-3 mb-3">
|
||
<div><span class="fw-bold"><?= (int)$c['today_count'] ?></span> <span class="text-muted small"><?= h($translations['sec_aujourdhui'] ?? 'aujourd’hui') ?></span></div>
|
||
<div><span class="fw-bold"><?= (int)$c['tomorrow_count'] ?></span> <span class="text-muted small"><?= h($translations['sec_demain'] ?? 'demain') ?></span></div>
|
||
</div>
|
||
<div class="d-flex flex-wrap gap-2">
|
||
<a class="btn btn-primary btn-sm" href="agenda.php?praticien_id=<?= $pid ?>"><?= h($translations['choisir'] ?? 'Choisir') ?></a>
|
||
<?php if ($r['can_manage_rdv']): ?>
|
||
<!--<a class="btn btn-outline-secondary btn-sm" href="agenda.php?praticien_id=<?= $pid ?>"><?= h($translations['choisir'] ?? 'Choisir') ?></a>
|
||
<a class="btn btn-outline-secondary btn-sm" href="rendez_vous_du_jour.php?praticien_id=<?= $pid ?>"><?= h($translations['sec_btn_rdv'] ?? 'Rendez-vous') ?></a>
|
||
<a class="btn btn-outline-secondary btn-sm" href="rendez_vous.php?praticien_id=<?= $pid ?>"><?= h($translations['sec_btn_rdv_jour'] ?? 'Les rendez-vous') ?></a>
|
||
<a class="btn btn-outline-secondary btn-sm" href="reserver_rdv.php?praticien_id=<?= $pid ?>"><?= h($translations['sec_btn_prendre'] ?? 'Prendre un RDV') ?></a>-->
|
||
<?php endif; ?>
|
||
<?php if ($r['can_edit_slots']): ?>
|
||
<!--<a class="btn btn-outline-secondary btn-sm" href="disponibilites.php?praticien_id=<?= $pid ?>"><?= h($translations['sec_btn_dispos'] ?? 'Disponibilités') ?></a>-->
|
||
<?php endif; ?>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
</div>
|
||
</div>
|
||
|
||
<footer class="site-footer">
|
||
<div class="container">
|
||
<p><?= $translations['copyr'] ?? '© '.date('Y') ?></p>
|
||
</div>
|
||
</footer>
|