134 lines
5.4 KiB
PHP
134 lines
5.4 KiB
PHP
<?php
|
|
// /messages/index.php
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/_bootstrap.php';
|
|
|
|
// Récupère conv depuis l'URL si présent
|
|
$currentConv = isset($_GET['conv']) ? (int)$_GET['conv'] : 0;
|
|
|
|
// Traductions (fallback FR)
|
|
// après avoir chargé les traductions (lang) :
|
|
$t = function(string $k, string $fallback = '') use (&$translations): string {
|
|
$val = $translations[$k] ?? null;
|
|
return ($val === null || $val === '') ? $fallback : (string)$val;
|
|
};
|
|
|
|
|
|
require_once APP_HTDOCS . '/public/includes/header.php';
|
|
?>
|
|
<script>
|
|
(() => {
|
|
function setHeaderVar() {
|
|
const header = document.querySelector('.site-header');
|
|
if (!header) return;
|
|
const h = Math.round(header.getBoundingClientRect().height || 64);
|
|
document.documentElement.style.setProperty('--app-header-h', h + 'px');
|
|
}
|
|
|
|
window.addEventListener('load', setHeaderVar);
|
|
window.addEventListener('resize', setHeaderVar);
|
|
})();
|
|
</script>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="stylesheet" href="/messages/messages.css">
|
|
<div class="main1">
|
|
<div class="container py-4">
|
|
<div class="shadow p-3 p-md-4 rounded bg-light chat-frame">
|
|
<div class="msg-app">
|
|
<!-- COLONNE LISTE (mobile: visible, desktop: visible) -->
|
|
<aside class="msg-list-panel" id="msg-list-panel" aria-label="<?= $t('msg_conversations','Conversations') ?>">
|
|
<header class="list-header">
|
|
<h1 class="list-title"><?= h($t('msg_conversations','Conversations')) ?></h1>
|
|
<a class="list-new" href="/messages/"><?= h($t('msg_titre','Messagerie')) ?></a>
|
|
</header>
|
|
<div class="list-scroll" id="conv-list" role="list">
|
|
<!-- Conversations injectées en JS -->
|
|
</div>
|
|
</aside>
|
|
|
|
<!-- COLONNE FIL (mobile: plein écran si conv ouverte) -->
|
|
<main class="msg-thread-panel" id="msg-thread-panel" data-conv-id="<?= (int)$currentConv ?>">
|
|
<header class="thread-header">
|
|
<button class="btn-back" id="btn-back" aria-label="Retour">←</button>
|
|
<div class="thread-title" id="thread-title">
|
|
<?= $currentConv ? ('#'.(int)$currentConv) : $t('msg_aucune_conversation','Sélectionner une conversation') ?>
|
|
</div>
|
|
<div class="thread-actions">
|
|
<!--<button type="button" class="th-btn" id="btn-archive"></button>-->
|
|
<button type="button" class="th-btn" id="btn-close"></button>
|
|
</div>
|
|
</header>
|
|
|
|
<section class="thread-body" id="messages" aria-live="polite">
|
|
<!-- Messages injectés en JS -->
|
|
</section>
|
|
|
|
<footer class="thread-footer">
|
|
<form id="send-form" class="send-form" enctype="multipart/form-data" autocomplete="off">
|
|
<input type="hidden" name="_csrf" value="<?= h($_SESSION['_csrf']) ?>">
|
|
|
|
<label class="file-btn">
|
|
<input type="file" name="file" id="msg-file" class="hidden-file" accept=".jpg,.jpeg,.png,.pdf,.doc,.docx">
|
|
<!-- Paperclip — Outline -->
|
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none"
|
|
xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Pièce jointe">
|
|
<path d="M8.2 12.4l5.9-5.9a3.6 3.6 0 115.1 5.1l-7.2 7.2a5.2 5.2 0 11-7.4-7.4l7.4-7.4"
|
|
stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
|
|
</svg>
|
|
</label>
|
|
<textarea name="body" id="msg-input" class="msg-input"
|
|
placeholder="<?= $t('msg_taper','Écrire un message…') ?>"
|
|
rows="2"></textarea>
|
|
<button type="submit" class="send-btn" aria-label="<?= $t('msg_envoyer','Envoyer') ?>">
|
|
<!-- Avion en papier -->
|
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none"
|
|
xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Envoyer">
|
|
<path d="M2 21l19-9L2 3v7l13 2-13 2v7z"
|
|
fill="currentColor"/>
|
|
</svg>
|
|
</button>
|
|
</form>
|
|
<div class="send-hint" id="send-hint"></div>
|
|
</footer>
|
|
</main>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<script>
|
|
window.MESSAGING_CFG = {
|
|
role: <?= json_encode($GLOBALS['MESSAGES_CTX']['role']) ?>, // 'praticien' | 'client'
|
|
meId: <?= (int)$GLOBALS['MESSAGES_CTX']['me_id'] ?>,
|
|
csrf: <?= json_encode($GLOBALS['MESSAGES_CTX']['csrf_token']) ?>,
|
|
initialConv: <?= (int)$currentConv ?>,
|
|
|
|
i18n: {
|
|
conversation: <?= json_encode($t('msg_conversation', 'Conversation')) ?>,
|
|
noConversations: <?= json_encode($t('msg_aucune_conversation', 'Sélectionner une conversation')) ?>,
|
|
send: <?= json_encode($t('msg_envoyer', 'Envoyer')) ?>,
|
|
placeholder: <?= json_encode($t('msg_taper', 'Écrire un message…')) ?>,
|
|
|
|
hide: <?= json_encode($t('msg_action_hide', 'Masquer')) ?>,
|
|
hideConfirm: <?= json_encode($t('msg_action_hide_confirm', 'Masquer ce message pour vous ?')) ?>,
|
|
hideOk: <?= json_encode($t('msg_action_hidden_ok', 'Message masqué.')) ?>,
|
|
hideFail: <?= json_encode($t('msg_action_hidden_fail', 'Suppression impossible pour le moment.')) ?>,
|
|
|
|
archive: <?= json_encode($t('msg_archiver', 'Archiver')) ?>,
|
|
desarchiver: <?= json_encode($t('msg_desarchiver', 'Désarchiver')) ?>,
|
|
unarchive: <?= json_encode($t('msg_desarchiver', 'Désarchiver')) ?>, // alias utilisé par le JS
|
|
|
|
close: <?= json_encode($t('msg_clore', 'Clôturer')) ?>,
|
|
reopen: <?= json_encode($t('msg_rouvrir', 'Rouvrir')) ?>,
|
|
closedBanner: <?= json_encode($t('msg_conv_cloturee', 'Cette conversation est clôturée.')) ?>
|
|
|
|
|
|
}
|
|
};
|
|
</script>
|
|
|
|
</div>
|
|
<script src="/messages/messages.js"></script>
|
|
|