feat: rôles admin/user, page Utilisateurs, lien Vision dans navbar, filtre courriers par compte

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jules
2026-05-06 00:01:39 +02:00
parent d11e6aec5e
commit 3f73421fd3
8 changed files with 305 additions and 28 deletions

View File

@@ -5,15 +5,30 @@ require_once __DIR__ . '/../includes/auth.php';
auth_check();
header('Content-Type: application/json');
$rows = db()->query(
'SELECT sf.id, sf.title, sf.sender, sf.date_processing, a.username,
GROUP_CONCAT(f.id, ":", f.file_name, ":", f.path ORDER BY f.id SEPARATOR "|") as files
FROM source_file sf
LEFT JOIN accounts a ON sf.account_id = a.id
LEFT JOIN files f ON sf.id = f.source_file_id
GROUP BY sf.id
ORDER BY sf.date_processing DESC'
)->fetchAll();
// Filtre par compte si user non-admin avec compte associé
$accountFilter = current_account_id();
if ($accountFilter) {
$st = db()->prepare(
'SELECT sf.id, sf.title, sf.sender, sf.date_processing, a.username,
GROUP_CONCAT(f.id, ":", f.file_name, ":", f.path ORDER BY f.id SEPARATOR "|") as files
FROM source_file sf
LEFT JOIN accounts a ON sf.account_id = a.id
LEFT JOIN files f ON sf.id = f.source_file_id
WHERE sf.account_id = ?
GROUP BY sf.id ORDER BY sf.date_processing DESC'
);
$st->execute([$accountFilter]);
$rows = $st->fetchAll();
} else {
$rows = db()->query(
'SELECT sf.id, sf.title, sf.sender, sf.date_processing, a.username,
GROUP_CONCAT(f.id, ":", f.file_name, ":", f.path ORDER BY f.id SEPARATOR "|") as files
FROM source_file sf
LEFT JOIN accounts a ON sf.account_id = a.id
LEFT JOIN files f ON sf.id = f.source_file_id
GROUP BY sf.id ORDER BY sf.date_processing DESC'
)->fetchAll();
}
$toDelete = []; // source_file ids à supprimer