Init Git Prod Mars 2026
This commit is contained in:
commit
d81efe93b1
362 files changed
+86627
No files matched your search
@@ -0,0 +1,252 @@
|
||||
<?php
|
||||
// admin/tools/ajax_fiche_user.php
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
require_once __DIR__ . '/../../public/includes/init_admin.php';
|
||||
|
||||
// ID "super admin"
|
||||
const ADMIN_PRACTICIEN_ID = 88888888;
|
||||
$me = (int)($_SESSION['reference_id'] ?? 0);
|
||||
if ($me !== ADMIN_PRACTICIEN_ID) {
|
||||
http_response_code(403);
|
||||
echo json_encode(['ok'=>false, 'error'=>'Доступ запрещён.'], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
$mustReauth=function(int $ttl=600){$t=(int)($_SESSION['admin_reauth_at']??0);return ($t===0||(time()-$t)>$ttl);};
|
||||
if ($mustReauth()){ $qs=http_build_query(['page'=>'reauth','redir'=>($_SERVER['REQUEST_URI']??'index.php?page=maintenance')]); header('Location:?'.$qs); exit; }
|
||||
|
||||
|
||||
function jerr(string $msg, int $code = 400): void {
|
||||
http_response_code($code);
|
||||
echo json_encode(['ok'=>false, 'error'=>$msg], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
function h($s) {
|
||||
return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
// CSRF
|
||||
$csrf = $_POST['csrf'] ?? '';
|
||||
if (empty($_SESSION['csrf_token']) || !hash_equals($_SESSION['csrf_token'], $csrf)) {
|
||||
jerr('Ошибка CSRF. Обновите страницу.', 400);
|
||||
}
|
||||
|
||||
$id = (int)($_POST['id'] ?? 0);
|
||||
if ($id <= 0) {
|
||||
jerr('Неверный идентификатор пользователя.', 400);
|
||||
}
|
||||
|
||||
// Загружаем запись из compte
|
||||
$st = $pdo->prepare("SELECT * FROM compte WHERE id = ?");
|
||||
$st->execute([$id]);
|
||||
$c = $st->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$c) {
|
||||
jerr('Аккаунт не найден.', 404);
|
||||
}
|
||||
|
||||
$role = $c['role'] ?? '';
|
||||
|
||||
$client = null;
|
||||
$prat = null;
|
||||
$secBase = null; // если для секретаря будет отдельная таблица в будущем
|
||||
|
||||
if ($role === 'client') {
|
||||
$refId = (int)($c['reference_id'] ?? 0);
|
||||
if ($refId > 0) {
|
||||
$st2 = $pdo->prepare("SELECT * FROM client WHERE id = ?");
|
||||
$st2->execute([$refId]);
|
||||
$client = $st2->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
} elseif ($role === 'praticien' || $role === 'secretaire') {
|
||||
$refId = (int)($c['reference_id'] ?? 0);
|
||||
if ($refId > 0) {
|
||||
$st2 = $pdo->prepare("SELECT * FROM praticien WHERE id = ?");
|
||||
$st2->execute([$refId]);
|
||||
$prat = $st2->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
// Строим HTML
|
||||
ob_start();
|
||||
?>
|
||||
<div class="text-start">
|
||||
<h5 class="mb-3">Основная информация аккаунта</h5>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tr>
|
||||
<th style="width:180px;">ID аккаунта</th>
|
||||
<td><?= (int)$c['id'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>E-mail</th>
|
||||
<td><?= h($c['email']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Роль</th>
|
||||
<td>
|
||||
<?php
|
||||
if ($role === 'client') echo 'Клиент';
|
||||
elseif ($role === 'praticien') echo 'Практик';
|
||||
elseif ($role === 'secretaire') echo 'Секретарь';
|
||||
else echo h($role);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Дата создания</th>
|
||||
<td>
|
||||
<?php
|
||||
if (!empty($c['cree_le'])) {
|
||||
echo h((new DateTime($c['cree_le']))->format('d.m.Y H:i'));
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Дата изменения</th>
|
||||
<td>
|
||||
<?php
|
||||
if (!empty($c['modifie_le'])) {
|
||||
echo h((new DateTime($c['modifie_le']))->format('d.m.Y H:i'));
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Статус e-mail</th>
|
||||
<td>
|
||||
<?php if ((int)($c['email_valide'] ?? 0) === 1): ?>
|
||||
<span class="badge bg-success">Подтверждён</span>
|
||||
<?php else: ?>
|
||||
<span class="badge bg-warning text-dark">Не подтверждён</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>ID в связанной таблице (reference_id)</th>
|
||||
<td><?= (int)($c['reference_id'] ?? 0) ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php if ($role === 'client'): ?>
|
||||
<h5 class="mt-4 mb-3">Данные клиента</h5>
|
||||
<?php if (!$client): ?>
|
||||
<div class="alert alert-warning">Запись клиента не найдена.</div>
|
||||
<?php else: ?>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tr><th style="width:180px;">ID клиента</th><td><?= (int)$client['id'] ?></td></tr>
|
||||
<tr><th>Фамилия</th><td><?= h($client['nom']) ?></td></tr>
|
||||
<tr><th>Имя</th><td><?= h($client['prenom']) ?></td></tr>
|
||||
<tr><th>E-mail</th><td><?= h($client['email']) ?></td></tr>
|
||||
<tr><th>Телефон</th><td><?= h($client['telephone']) ?></td></tr>
|
||||
<tr><th>Дата рождения</th><td><?= h($client['date_naissance']) ?></td></tr>
|
||||
<tr><th>Адрес</th><td><?= nl2br(h($client['adresse'])) ?></td></tr>
|
||||
<tr><th>Город</th><td><?= h($client['ville']) ?></td></tr>
|
||||
<tr><th>Индекс</th><td><?= h($client['code_postal']) ?></td></tr>
|
||||
<tr><th>Пол</th><td><?= h($client['genre']) ?></td></tr>
|
||||
<tr>
|
||||
<th>CGU (accepted_cgu)</th>
|
||||
<td>
|
||||
<?php if ((int)($client['accepted_cgu'] ?? 0) === 1): ?>
|
||||
<span class="badge bg-success">Принял(а)</span>
|
||||
<?php else: ?>
|
||||
<span class="badge bg-danger">Не принял(а) или не указано</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php elseif ($role === 'praticien' || $role === 'secretaire'): ?>
|
||||
<h5 class="mt-4 mb-3">
|
||||
<?= $role === 'praticien' ? 'Данные практика' : 'Данные, связанные с секретарём' ?>
|
||||
</h5>
|
||||
<?php if (!$prat): ?>
|
||||
<div class="alert alert-warning">Запись практика не найдена.</div>
|
||||
<?php else: ?>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tr><th style="width:200px;">ID практика</th><td><?= (int)$prat['id'] ?></td></tr>
|
||||
<tr>
|
||||
<th>Фото (файл)</th>
|
||||
<td>
|
||||
<div style="width:120px; height:120px; overflow:hidden; border-radius:10px;">
|
||||
<img src="/../public/uploads/<?= h($prat['photo']) ?>"
|
||||
alt="Фото практика"
|
||||
style="width:100%; height:100%; object-fit:cover;">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><th>Тариф</th><td><?= h($prat['titre']) ?></td></tr>
|
||||
<tr><th>Длительность приёма (мин)</th><td><?= (int)$prat['duree_rdv'] ?></td></tr>
|
||||
<tr><th>Фамилия</th><td><?= h($prat['nom']) ?></td></tr>
|
||||
<tr><th>Имя</th><td><?= h($prat['prenom']) ?></td></tr>
|
||||
<tr><th>E-mail</th><td><?= h($prat['email']) ?></td></tr>
|
||||
<tr><th>Телефон</th><td><?= h($prat['telephone']) ?></td></tr>
|
||||
<tr><th>Специальность</th><td><?= h($prat['specialite']) ?></td></tr>
|
||||
<tr><th>Адрес</th><td><?= nl2br(h($prat['adresse'])) ?></td></tr>
|
||||
<tr><th>Город</th><td><?= h($prat['ville']) ?></td></tr>
|
||||
<tr><th>Индекс</th><td><?= h($prat['code_postal']) ?></td></tr>
|
||||
<tr><th>SIRET</th><td><?= h($prat['siret']) ?></td></tr>
|
||||
<tr>
|
||||
<th>CGU (accepted_cgu)</th>
|
||||
<td>
|
||||
<?php if ((int)($prat['accepted_cgu'] ?? 0) === 1): ?>
|
||||
<span class="badge bg-success">Принял(а)</span>
|
||||
<?php else: ?>
|
||||
<span class="badge bg-danger">Не принял(а) или не указано</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><th>Презентация</th><td><?= nl2br(h($prat['presentation'])) ?></td></tr>
|
||||
<tr><th>Основное видео (URL)</th><td><?= h($prat['video']) ?></td></tr>
|
||||
<tr><th>Доступность (сырой текст)</th><td><?= nl2br(h($prat['disponibilite'])) ?></td></tr>
|
||||
<tr><th>Тип календаря</th><td><?= h($prat['calendrier_type']) ?></td></tr>
|
||||
|
||||
<tr><th>Абонемент ID</th><td><?= h($prat['abonnement_id']) ?></td></tr>
|
||||
<tr><th>Дата окончания абонемента</th><td><?= h($prat['date_expiration']) ?></td></tr>
|
||||
<tr>
|
||||
<th>Синхронизация активна</th>
|
||||
<td>
|
||||
<?php if ((int)($prat['synchronisation_active'] ?? 0) === 1): ?>
|
||||
<span class="badge bg-success">Да</span>
|
||||
<?php else: ?>
|
||||
<span class="badge bg-secondary">Нет</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Создан</th>
|
||||
<td>
|
||||
<?php
|
||||
if (!empty($prat['created_at'])) {
|
||||
echo h((new DateTime($prat['created_at']))->format('d.m.Y H:i'));
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Изменён</th>
|
||||
<td>
|
||||
<?php
|
||||
if (!empty($prat['updated_at'])) {
|
||||
echo h((new DateTime($prat['updated_at']))->format('d.m.Y H:i'));
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php else: ?>
|
||||
<div class="alert alert-info mt-3">
|
||||
Для этой роли подробная карточка ещё не настроена.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
$html = ob_get_clean();
|
||||
|
||||
echo json_encode([
|
||||
'ok' => true,
|
||||
'html' => $html
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
Reference in new issue
Block a user