241 lines
8.5 KiB
PHP
241 lines
8.5 KiB
PHP
<?php
|
||
require_once __DIR__ . '/securite.php';
|
||
require_once __DIR__ . '/db.php';
|
||
require_once __DIR__ . '/verifier_abonnement.php';
|
||
require_once __DIR__ . '/../contact_admin.php'; // ← depuis /public/includes/header.php
|
||
require_once __DIR__ . '/../includes/lang.php';
|
||
require_once __DIR__ . '/../../includes/pretty_urls.php';
|
||
require_once __DIR__ . '/../../includes/mailer.php'; // uslugi_mail()
|
||
|
||
if (!isset($_SESSION)) session_start();
|
||
|
||
// Charger les données client ou praticien
|
||
$nom = $prenom = '';
|
||
if ($_SESSION['role'] === 'client') {
|
||
$stmt = $pdo->prepare("SELECT nom, prenom FROM client WHERE id = ?");
|
||
} else {
|
||
$stmt = $pdo->prepare("SELECT nom, prenom FROM praticien WHERE id = ?");
|
||
}
|
||
$stmt->execute([$_SESSION['reference_id']]);
|
||
$user = $stmt->fetch();
|
||
|
||
if ($user) {
|
||
$nom = htmlspecialchars($user['nom']);
|
||
$prenom = htmlspecialchars($user['prenom']);
|
||
}
|
||
|
||
//Initiales pour Avatar
|
||
|
||
$initiales = mb_strtoupper(
|
||
mb_substr((string)$prenom, 0, 1, 'UTF-8') .
|
||
mb_substr((string)$nom, 0, 1, 'UTF-8'),
|
||
'UTF-8'
|
||
);
|
||
//Function pour gerer hystorique de la navigation
|
||
//*************************************************
|
||
|
||
$ref = $_SERVER['HTTP_REFERER'] ?? '';
|
||
$host = $_SERVER['HTTP_HOST'] ?? '';
|
||
$safeRef = '';
|
||
if ($ref) {
|
||
$u = parse_url($ref);
|
||
if (!empty($u['host']) && $u['host'] === $host) {
|
||
$safeRef = $ref; // referer même origine uniquement
|
||
}
|
||
}
|
||
// Mets ici ta route par défaut si pas d'historique / referer externe
|
||
$fallbackBack = $safeRef ?: '/';
|
||
//********************FIN********************************
|
||
?>
|
||
|
||
<head>
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||
|
||
|
||
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
||
<link rel="stylesheet" href="../../includes/site_style.css">
|
||
<link rel="stylesheet" href="../../includes/mobil_style.css">
|
||
</head>
|
||
|
||
<body>
|
||
<header class="site-header">
|
||
<div class="container">
|
||
<div class="brand">
|
||
|
||
<!--Bouton hystory qui fait retour en arriere-->
|
||
<a href="<?= htmlspecialchars($fallbackBack, ENT_QUOTES, 'UTF-8') ?>"
|
||
id="btnBack"
|
||
class="btn btn-light btn-circle me-2" style="border-radius: 5px; box-shadow: 0 1px 2px rgba(0,0,0,.08);"
|
||
aria-label="<?= htmlspecialchars($translations['retour'] ?? 'Retour', ENT_QUOTES, 'UTF-8') ?>">
|
||
<!-- inline SVG, compatible partout -->
|
||
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" aria-hidden="true">
|
||
<path d="M15 6l-6 6 6 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||
</svg>
|
||
</a>
|
||
<!-- *************************FIN*************************-->
|
||
|
||
<a href="https://uslugi.fr/index.php"><img src="/public/uploads/img/logo.png" width="130"></a>
|
||
|
||
</div>
|
||
|
||
<?php if (isset($alerte_abonnement) && $alerte_abonnement): ?>
|
||
<div class="alert alert-warning m-0 py-1 px-2 rounded text-dark" role="alert" style="background:#fff3cd; border: 1px solid #ffeeba; font-size: 14px;">
|
||
<?= htmlspecialchars($alerte_abonnement) ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<nav class="header-actions">
|
||
<div class="avatar"><?= $initiales ?></div>
|
||
|
||
<!--**************************Bouton message conv*************************************************-->
|
||
<a href="/messages/" class="nav-msg" style="position:relative; display:inline-block; margin-left:12px;">
|
||
<span aria-hidden="true"><img src="/public/uploads/img/message.png" width="20px"></span>
|
||
<span id="msg-badge" style="
|
||
position:absolute; top:-6px; right:-8px;
|
||
background:#e11d48; color:#fff; font-size:12px; min-width:18px; height:18px; line-height:18px;
|
||
text-align:center; border-radius:999px; padding:0 5px; display:none;">0</span>
|
||
</a>
|
||
<script>
|
||
(function(){
|
||
async function tick(){
|
||
try{
|
||
const r = await fetch('/messages/api/unread_count.php', { credentials:'same-origin' });
|
||
if(!r.ok) throw 0;
|
||
const j = await r.json();
|
||
const b = document.getElementById('msg-badge');
|
||
const n = Number(j.total||0);
|
||
if(n>0){ b.style.display='inline-block'; b.textContent = String(n); }
|
||
else { b.style.display='none'; }
|
||
}catch(e){}
|
||
}
|
||
tick();
|
||
setInterval(tick, 5000);
|
||
})();
|
||
</script>
|
||
|
||
<!--*************************************FIN BOUTON**********************************************
|
||
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK-->
|
||
|
||
|
||
<div class="lang-switch">
|
||
<?php require_once __DIR__ .'/../../includes/menu_langue.php'; ?>
|
||
</div>
|
||
<div class="menu-wrap">
|
||
<button
|
||
type="button"
|
||
id="btnMenu"
|
||
class="btn btn-light btn-circle me-2" style="border-radius: 5px; box-shadow: 0 1px 2px rgba(0,0,0,.08);"
|
||
aria-label="<?= htmlspecialchars($translations['menu'] ?? 'Menu', ENT_QUOTES, 'UTF-8') ?>"
|
||
onclick="toggleMenu()">
|
||
<!-- icône hamburger 20x20, même style que la flèche -->
|
||
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" aria-hidden="true">
|
||
<path d="M4 6h16M4 12h16M4 18h16"
|
||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||
</svg>
|
||
</button>
|
||
|
||
|
||
<!-- Menu -->
|
||
<ul class="dropdown-menu-custom" id="menu">
|
||
<li onclick="location.href='/public/<?= $_SESSION['role'] ?>/informations.php'">
|
||
<?= htmlspecialchars($translations['menu_mes_informations']) ?>
|
||
</li>
|
||
<li onclick="location.href='/public/<?= $_SESSION['role'] ?>/compte.php'">
|
||
<?= htmlspecialchars($translations['menu_infos_connexion']) ?>
|
||
</li>
|
||
|
||
<?php if ($_SESSION['role'] === 'client'): ?>
|
||
<li onclick="location.href='/public/client/list_praticien.php'">
|
||
<?= htmlspecialchars($translations['menu_liste_specialistes']) ?>
|
||
</li>
|
||
<li onclick="location.href='/public/client/mes_favori.php'">
|
||
<?= htmlspecialchars($translations['menu_mes_favoris']) ?>
|
||
</li>
|
||
<li onclick="location.href='/public/client/mes_rendez_vous.php'">
|
||
<?= htmlspecialchars($translations['menu_mes_rendez_vous']) ?>
|
||
</li>
|
||
<?php else: ?>
|
||
<li onclick="location.href='/public/praticien/disponibilites.php'">
|
||
<?= htmlspecialchars($translations['menu_mes_disponibilites']) ?>
|
||
</li>
|
||
<li onclick="location.href='/public/praticien/rendez_vous.php'">
|
||
<?= htmlspecialchars($translations['menu_mes_rendez_vous']) ?>
|
||
</li>
|
||
<li onclick="location.href='/public/praticien/agenda.php'">
|
||
<?= htmlspecialchars($translations['menu_mon_agenda']) ?>
|
||
</li>
|
||
<li onclick="location.href='/public/praticien/synchronisation.php'">
|
||
<?= htmlspecialchars($translations['menu_sync_agendas']) ?>
|
||
</li>
|
||
<li onclick="location.href='/public/praticien/resiliation.php'">
|
||
<?= htmlspecialchars($translations['menu_gerer_abonnement']) ?>
|
||
</li>
|
||
<li onclick="location.href='/public/praticien/factures.php'">
|
||
<?= htmlspecialchars($translations['menu_mes_factures']) ?>
|
||
</li>
|
||
|
||
<?php endif; ?>
|
||
<li onclick="closeMenu(); openContactAdmin()" class="text-primary">
|
||
<?= htmlspecialchars($translations['contact_admin']) ?>
|
||
</li>
|
||
<li onclick="location.href='/public/deconnexion.php'" class="text-danger">
|
||
<?= htmlspecialchars($translations['menu_deconnexion']) ?>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</nav>
|
||
</div>
|
||
</header>
|
||
|
||
<!-- JS -->
|
||
<script>
|
||
function toggleMenu() {
|
||
const menu = document.getElementById('menu');
|
||
if (!menu) return;
|
||
menu.style.display = (menu.style.display === 'block') ? 'none' : 'block';
|
||
}
|
||
|
||
document.addEventListener('click', function(e) {
|
||
const toggle = document.getElementById('btnMenu');
|
||
const menu = document.getElementById('menu');
|
||
if (!menu) return;
|
||
const clickOnToggle = toggle ? toggle.contains(e.target) : false;
|
||
const clickInMenu = menu.contains(e.target);
|
||
if (!clickOnToggle && !clickInMenu) {
|
||
menu.style.display = 'none';
|
||
}
|
||
});
|
||
</script>
|
||
<script>
|
||
// --- déjà présent ---
|
||
// function toggleMenu() { ... }
|
||
// document.addEventListener('click', ...);
|
||
|
||
// 1) Petite utilitaire pour fermer le menu
|
||
function closeMenu() {
|
||
const menu = document.getElementById('menu');
|
||
if (menu) menu.style.display = 'none';
|
||
// (optionnel) retire un flag si tu l'ajoutes ailleurs
|
||
document.body.classList.remove('menu-open');
|
||
}
|
||
|
||
// 2) Si ta popup est ouverte par une fonction JS (ex: openContactAdmin)
|
||
// on injecte la fermeture du menu AVANT l’ouverture
|
||
// -> Si openContactAdmin existe, on la “wrap”
|
||
if (typeof window.openContactAdmin === 'function') {
|
||
const _origOpenContactAdmin = window.openContactAdmin;
|
||
window.openContactAdmin = function(...args){
|
||
closeMenu();
|
||
return _origOpenContactAdmin.apply(this, args);
|
||
};
|
||
}
|
||
|
||
// 3) Bonus : touche Échap ferme le menu
|
||
document.addEventListener('keydown', (e) => {
|
||
if (e.key === 'Escape') closeMenu();
|
||
});
|
||
</script>
|
||
|
||
|
||
|