- Add source maps and license files for compiled assets - Add debug and test files for development - Complete Git repository with all necessary files for MoneyFlix project
539 lines
31 KiB
PHP
539 lines
31 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use App\Core\View;
|
|
use App\Core\Auth;
|
|
use App\Core\InputSanitizer;
|
|
use App\Core\DatabaseManager;
|
|
|
|
// Garantir base correta
|
|
DatabaseManager::getInstance()->useDatabase('crm');
|
|
|
|
// Get current user info (supports absence of Users module)
|
|
$currentUser = null;
|
|
if (class_exists('App\\Modules\\Users\\Models\\UserModel')) {
|
|
$userModelClass = 'App\\Modules\\Users\\Models\\UserModel';
|
|
$userModel = new $userModelClass();
|
|
if (Auth::check()) {
|
|
$userData = $userModel->find(Auth::id());
|
|
if ($userData) {
|
|
$currentUser = [
|
|
'username' => $userData['first_name'] . ' ' . $userData['last_name'],
|
|
'email' => $userData['email'] ?? '',
|
|
'role' => $userData['role'] ?? 'user',
|
|
'avatar' => $userData['avatar'] ?? '/assets/images/users/avatar-1.jpg'
|
|
];
|
|
}
|
|
}
|
|
} elseif (Auth::check()) {
|
|
$userData = Auth::user();
|
|
if ($userData) {
|
|
$currentUser = [
|
|
'username' => ($userData['first_name'] ?? '') . ' ' . ($userData['last_name'] ?? ''),
|
|
'email' => $userData['email'] ?? '',
|
|
'role' => $userData['role'] ?? 'user',
|
|
'avatar' => $userData['avatar'] ?? '/assets/images/users/avatar-1.jpg'
|
|
];
|
|
}
|
|
}
|
|
|
|
$alertStats = $alertStats ?? [];
|
|
|
|
// Branding dinâmico
|
|
if (!isset($branding)) {
|
|
$branding = \App\Core\Branding::get();
|
|
}
|
|
|
|
$menu_final = \App\Core\MenuManager::getFinalMenu();
|
|
$currentUrl = $_SERVER['REQUEST_URI'] ?? '';
|
|
$editmenuValue = InputSanitizer::get('editmenu', 'GET');
|
|
$editMode = (null !== $editmenuValue) && $editmenuValue == 1;
|
|
?>
|
|
|
|
<header id="page-topbar">
|
|
<div class="layout-width">
|
|
<div class="navbar-header">
|
|
<div class="d-flex">
|
|
<!-- LOGO -->
|
|
<div class="navbar-brand-box horizontal-logo">
|
|
<?php if (in_array($branding['client_id'] ?? '', ['wdmi', 'moneyflix'])): ?>
|
|
<!-- WDMI/MoneyFlix: Só um logo (ícone + texto), nunca duplicado -->
|
|
<a href="/" class="logo logo-<?php echo $branding['client_id']; ?>" style="display: flex; align-items: center;">
|
|
<img src="<?php echo htmlspecialchars($branding['logo_url']); ?>" alt="<?php echo htmlspecialchars($branding['company_name']); ?> Logo" height="22">
|
|
</a>
|
|
<?php else: ?>
|
|
<!-- Outros clientes: comportamento padrão -->
|
|
<a href="/" class="logo logo-dark">
|
|
<span class="logo-sm">
|
|
<img src="<?php echo htmlspecialchars($branding['logo_url']); ?>" alt="<?php echo htmlspecialchars($branding['company_name']); ?> Logo" height="22">
|
|
</span>
|
|
<span class="logo-lg">
|
|
<img src="<?php echo htmlspecialchars($branding['logo_url']); ?>" alt="<?php echo htmlspecialchars($branding['company_name']); ?> Logo" height="17">
|
|
</span>
|
|
</a>
|
|
|
|
<a href="/" class="logo logo-light">
|
|
<span class="logo-sm">
|
|
<img src="<?php echo htmlspecialchars($branding['logo_url']); ?>" alt="<?php echo htmlspecialchars($branding['company_name']); ?> Logo" height="22">
|
|
</span>
|
|
<span class="logo-lg">
|
|
<img src="<?php echo htmlspecialchars($branding['logo_url']); ?>" alt="<?php echo htmlspecialchars($branding['company_name']); ?> Logo" height="17">
|
|
</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<button type="button" class="btn btn-sm px-3 fs-16 header-item vertical-menu-btn topnav-hamburger" id="topnav-hamburger-icon">
|
|
<span class="hamburger-icon">
|
|
<span></span>
|
|
<span></span>
|
|
<span></span>
|
|
</span>
|
|
</button>
|
|
|
|
<!-- App Search-->
|
|
<form class="app-search d-none d-md-block">
|
|
<div class="position-relative">
|
|
<input type="text" class="form-control" x-bind:placeholder="$t('placeholders-search')" autocomplete="off" id="search-options" value="">
|
|
<span class="mdi mdi-magnify search-widget-icon"></span>
|
|
<span class="mdi mdi-close-circle search-widget-icon search-widget-icon-close d-none" id="search-close-options"></span>
|
|
</div>
|
|
<div class="dropdown-menu dropdown-menu-lg" id="search-dropdown">
|
|
<div data-simplebar style="max-height: 320px;">
|
|
<!-- item-->
|
|
<div class="dropdown-header">
|
|
<h6 class="text-overflow text-muted mb-0 text-uppercase">Recent Searches</h6>
|
|
</div>
|
|
|
|
<div class="dropdown-item bg-transparent text-wrap">
|
|
<a href="/" class="btn btn-soft-secondary btn-sm rounded-pill">How to setup <i class="mdi mdi-magnify ms-1"></i></a>
|
|
<a href="/" class="btn btn-soft-secondary btn-sm rounded-pill">Buttons <i class="mdi mdi-magnify ms-1"></i></a>
|
|
</div>
|
|
<!-- item-->
|
|
<div class="dropdown-header mt-2">
|
|
<h6 class="text-overflow text-muted mb-1 text-uppercase">Pages</h6>
|
|
</div>
|
|
|
|
<!-- item-->
|
|
<?php if (\App\Core\ModuleConfig::getInstance()->isModuleActive('Analytics', \App\Core\Branding::getClientId())): ?>
|
|
<a href="javascript:void(0);" class="dropdown-item notify-item">
|
|
<i class="ri-bubble-chart-line align-middle fs-18 text-muted me-2"></i>
|
|
<span>Analytics Dashboard</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
|
|
<!-- item-->
|
|
<a href="javascript:void(0);" class="dropdown-item notify-item">
|
|
<i class="ri-lifebuoy-line align-middle fs-18 text-muted me-2"></i>
|
|
<span>Help Center</span>
|
|
</a>
|
|
|
|
<!-- item-->
|
|
<a href="javascript:void(0);" class="dropdown-item notify-item">
|
|
<i class="ri-user-settings-line align-middle fs-18 text-muted me-2"></i>
|
|
<span>My Account Settings</span>
|
|
</a>
|
|
|
|
<!-- item-->
|
|
<div class="dropdown-header mt-2">
|
|
<h6 class="text-overflow text-muted mb-2 text-uppercase">Members</h6>
|
|
</div>
|
|
|
|
<div class="notification-list">
|
|
<?php
|
|
// Load real notifications from database
|
|
$db = \App\Core\DatabaseManager::getInstance();
|
|
$notifications = $db->fetchAll("
|
|
SELECT
|
|
n.id,
|
|
n.title,
|
|
n.message,
|
|
n.type,
|
|
n.created_at,
|
|
u.first_name,
|
|
u.last_name,
|
|
u.avatar
|
|
FROM notifications n
|
|
LEFT JOIN users u ON n.user_id = u.id
|
|
WHERE n.status = 1
|
|
ORDER BY n.created_at DESC
|
|
LIMIT 5
|
|
") ?: [];
|
|
|
|
if (empty($notifications)): ?>
|
|
<div class="text-center p-3">
|
|
<h6 class="text-muted">Nenhuma notificação</h6>
|
|
<p class="text-muted mb-0">Não há notificações recentes</p>
|
|
</div>
|
|
<?php else: ?>
|
|
<?php foreach ($notifications as $notification): ?>
|
|
<a href="javascript:void(0);" class="dropdown-item notify-item py-2">
|
|
<div class="d-flex">
|
|
<img src="<?php echo View::asset($notification['avatar'] ?: '/assets/images/users/avatar-1.jpg'); ?>" class="me-3 rounded-circle avatar-xs" alt="user-pic">
|
|
<div class="flex-grow-1">
|
|
<h6 class="m-0"><?php echo htmlspecialchars($notification['title']); ?></h6>
|
|
<span class="fs-11 mb-0 text-muted"><?php echo htmlspecialchars($notification['message']); ?></span>
|
|
<small class="text-muted"><?php echo date('H:i', strtotime($notification['created_at'])); ?></small>
|
|
</div>
|
|
</div>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
// Load recent system notifications
|
|
$systemNotifications = $db->fetchAll("
|
|
SELECT
|
|
n.id,
|
|
n.title,
|
|
n.message,
|
|
n.type,
|
|
n.created_at
|
|
FROM notifications n
|
|
WHERE n.status = 1 AND n.type = 'system'
|
|
ORDER BY n.created_at DESC
|
|
LIMIT 3
|
|
") ?: [];
|
|
|
|
foreach ($systemNotifications as $notification): ?>
|
|
<div class="text-reset notification-item d-block dropdown-item position-relative">
|
|
<div class="d-flex">
|
|
<div class="avatar-xs me-3">
|
|
<span class="avatar-title bg-soft-info text-info rounded-circle fs-16">
|
|
<i class="bx bx-badge-check"></i>
|
|
</span>
|
|
</div>
|
|
<div class="flex-grow-1">
|
|
<a href="#!" class="stretched-link">
|
|
<h6 class="mt-0 mb-2 lh-base"><?php echo htmlspecialchars($notification['title']); ?></h6>
|
|
</a>
|
|
<p class="mb-0 fs-11 fw-medium text-uppercase text-muted">
|
|
<span><i class="mdi mdi-clock-outline"></i> <?php echo date('H:i', strtotime($notification['created_at'])); ?></span>
|
|
</p>
|
|
</div>
|
|
<div class="px-2 fs-15">
|
|
<div class="form-check notification-check">
|
|
<input class="form-check-input" type="checkbox" value="" id="all-notification-check<?php echo $notification['id']; ?>">
|
|
<label class="form-check-label" for="all-notification-check<?php echo $notification['id']; ?>"></label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<?php
|
|
// Load recent user notifications
|
|
$userNotifications = $db->fetchAll("
|
|
SELECT
|
|
n.id,
|
|
n.title,
|
|
n.message,
|
|
n.type,
|
|
n.created_at,
|
|
u.first_name,
|
|
u.last_name,
|
|
u.avatar
|
|
FROM notifications n
|
|
LEFT JOIN users u ON n.user_id = u.id
|
|
WHERE n.status = 1 AND n.type = 'user'
|
|
ORDER BY n.created_at DESC
|
|
LIMIT 3
|
|
") ?: [];
|
|
|
|
foreach ($userNotifications as $notification): ?>
|
|
<div class="text-reset notification-item d-block dropdown-item position-relative">
|
|
<div class="d-flex">
|
|
<img src="<?php echo View::asset($notification['avatar'] ?: '/assets/images/users/avatar-1.jpg'); ?>" class="me-3 rounded-circle avatar-xs" alt="user-pic">
|
|
<div class="flex-grow-1">
|
|
<a href="#!" class="stretched-link">
|
|
<h6 class="mt-0 mb-1 fs-13 fw-semibold"><?php echo htmlspecialchars(($notification['first_name'] ?? '') . ' ' . ($notification['last_name'] ?? '')); ?></h6>
|
|
</a>
|
|
<div class="fs-13 text-muted">
|
|
<p class="mb-1"><?php echo htmlspecialchars($notification['message']); ?></p>
|
|
</div>
|
|
<p class="mb-0 fs-11 fw-medium text-uppercase text-muted">
|
|
<span><i class="mdi mdi-clock-outline"></i> <?php echo date('H:i', strtotime($notification['created_at'])); ?></span>
|
|
</p>
|
|
</div>
|
|
<div class="px-2 fs-15">
|
|
<div class="form-check notification-check">
|
|
<input class="form-check-input" type="checkbox" value="" id="all-notification-check<?php echo $notification['id']; ?>">
|
|
<label class="form-check-label" for="all-notification-check<?php echo $notification['id']; ?>"></label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<?php
|
|
// Load recent chat messages
|
|
$chatMessages = $db->fetchAll("
|
|
SELECT
|
|
COUNT(*) as message_count,
|
|
MAX(created_at) as last_message_time
|
|
FROM chat_messages
|
|
WHERE status = 1 AND created_at >= DATE_SUB(NOW(), INTERVAL 24 HOUR)
|
|
") ?: [];
|
|
|
|
$messageCount = $chatMessages[0]['message_count'] ?? 0;
|
|
$lastMessageTime = $chatMessages[0]['last_message_time'] ?? null;
|
|
|
|
if ($messageCount > 0): ?>
|
|
<div class="text-reset notification-item d-block dropdown-item position-relative">
|
|
<div class="d-flex">
|
|
<div class="avatar-xs me-3">
|
|
<span class="avatar-title bg-soft-danger text-danger rounded-circle fs-16">
|
|
<i class='bx bx-message-square-dots'></i>
|
|
</span>
|
|
</div>
|
|
<div class="flex-grow-1">
|
|
<a href="#!" class="stretched-link">
|
|
<h6 class="mt-0 mb-2 fs-13 lh-base">Tem <b class="text-success"><?php echo $messageCount; ?></b> mensagens novas na conversa
|
|
</h6>
|
|
</a>
|
|
<p class="mb-0 fs-11 fw-medium text-uppercase text-muted">
|
|
<span><i class="mdi mdi-clock-outline"></i> <?php echo $lastMessageTime ? date('H:i', strtotime($lastMessageTime)) : 'Agora'; ?></span>
|
|
</p>
|
|
</div>
|
|
<div class="px-2 fs-15">
|
|
<div class="form-check notification-check">
|
|
<input class="form-check-input" type="checkbox" value="" id="all-notification-check03">
|
|
<label class="form-check-label" for="all-notification-check03"></label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
// Load recent activity notifications
|
|
$activityNotifications = $db->fetchAll("
|
|
SELECT
|
|
n.id,
|
|
n.title,
|
|
n.message,
|
|
n.type,
|
|
n.created_at,
|
|
u.first_name,
|
|
u.last_name,
|
|
u.avatar
|
|
FROM notifications n
|
|
LEFT JOIN users u ON n.user_id = u.id
|
|
WHERE n.status = 1 AND n.type = 'activity'
|
|
ORDER BY n.created_at DESC
|
|
LIMIT 2
|
|
") ?: [];
|
|
|
|
foreach ($activityNotifications as $notification): ?>
|
|
<div class="text-reset notification-item d-block dropdown-item position-relative">
|
|
<div class="d-flex">
|
|
<img src="<?php echo View::asset($notification['avatar'] ?: '/assets/images/users/avatar-1.jpg'); ?>" class="me-3 rounded-circle avatar-xs" alt="user-pic">
|
|
<div class="flex-grow-1">
|
|
<a href="#!" class="stretched-link">
|
|
<h6 class="mt-0 mb-1 fs-13 fw-semibold"><?php echo htmlspecialchars(($notification['first_name'] ?? '') . ' ' . ($notification['last_name'] ?? '')); ?></h6>
|
|
</a>
|
|
<div class="fs-13 text-muted">
|
|
<p class="mb-1"><?php echo htmlspecialchars($notification['message']); ?></p>
|
|
</div>
|
|
<p class="mb-0 fs-11 fw-medium text-uppercase text-muted">
|
|
<span><i class="mdi mdi-clock-outline"></i> <?php echo date('H:i', strtotime($notification['created_at'])); ?></span>
|
|
</p>
|
|
</div>
|
|
<div class="px-2 fs-15">
|
|
<div class="form-check notification-check">
|
|
<input class="form-check-input" type="checkbox" value="" id="all-notification-check<?php echo $notification['id']; ?>">
|
|
<label class="form-check-label" for="all-notification-check<?php echo $notification['id']; ?>"></label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<div class="my-3 text-center view-all">
|
|
<button type="button" class="btn btn-soft-success waves-effect waves-light">View All Notifications <i class="ri-arrow-right-line align-middle"></i></button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="d-flex align-items-center">
|
|
|
|
<div class="dropdown d-md-none topbar-head-dropdown header-item">
|
|
<button type="button" class="btn btn-icon btn-topbar btn-ghost-secondary rounded-circle" id="page-header-search-dropdown" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
<i class="bx bx-search fs-22"></i>
|
|
</button>
|
|
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-end p-0" aria-labelledby="page-header-search-dropdown">
|
|
<form class="p-3">
|
|
<div class="form-group m-0">
|
|
<div class="input-group">
|
|
<input type="text" class="form-control" x-bind:placeholder="$t('placeholders-search')" aria-label="Recipient's username">
|
|
<button class="btn btn-primary" type="submit"><i class="mdi mdi-magnify"></i></button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="dropdown ms-1 topbar-head-dropdown header-item">
|
|
<button type="button" class="btn btn-icon btn-topbar btn-ghost-secondary rounded-circle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
<img id="header-lang-img" src="/assets/images/flags/pt.svg" alt="Header Language" height="20" class="rounded">
|
|
</button>
|
|
<div class="dropdown-menu dropdown-menu-end">
|
|
<!-- item-->
|
|
<a href="#" class="dropdown-item notify-item language py-2" data-lang="en" title="English">
|
|
<img src="<?php echo View::asset('/assets/images/flags/us.svg'); ?>" alt="user-image" class="me-2 rounded" height="18">
|
|
<span class="align-middle">English</span>
|
|
</a>
|
|
<!-- item-->
|
|
<a href="#" class="dropdown-item notify-item language" data-lang="pt" title="Portuguese">
|
|
<img src="<?php echo View::asset('/assets/images/flags/pt.svg'); ?>" alt="user-image" class="me-2 rounded" height="18">
|
|
<span class="align-middle">Português</span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="ms-1 header-item d-none d-sm-flex">
|
|
<button type="button" class="btn btn-icon btn-topbar btn-ghost-secondary rounded-circle" data-toggle="fullscreen">
|
|
<i class='bx bx-fullscreen fs-22'></i>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="ms-1 header-item d-none d-sm-flex">
|
|
<button type="button" class="btn btn-icon btn-topbar btn-ghost-secondary rounded-circle light-dark-mode">
|
|
<i class='bx bx-moon fs-22'></i>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- CRM Notification Bell -->
|
|
<?php if (\App\Core\ModuleConfig::getInstance()->isModuleActive('Crm', \App\Core\Branding::getClientId())): ?>
|
|
<?php View::render('components/notification-bell.php', ['alertStats' => $alertStats]); ?>
|
|
<?php endif; ?>
|
|
|
|
<!-- Settings Button -->
|
|
<div class="ms-1 header-item d-none d-sm-flex">
|
|
<button type="button" class="btn btn-icon btn-topbar btn-ghost-secondary rounded-circle" data-bs-toggle="offcanvas" data-bs-target="#theme-settings-offcanvas" aria-controls="theme-settings-offcanvas">
|
|
<i class='mdi mdi-cog-outline fs-22'></i>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="dropdown ms-sm-3 header-item topbar-user">
|
|
<button type="button" class="btn" id="page-header-user-dropdown" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
<span class="d-flex align-items-center">
|
|
<img class="rounded-circle header-profile-user" src="<?php echo $currentUser ? $currentUser['avatar'] : View::asset('/assets/images/users/avatar-1.jpg'); ?>" alt="Header Avatar">
|
|
<span class="text-start ms-xl-2">
|
|
<span class="d-none d-xl-inline-block ms-1 fw-medium user-name-text"><?php echo $currentUser ? htmlspecialchars($currentUser['username']) : 'Guest'; ?></span>
|
|
<span class="d-none d-xl-block ms-1 fs-12 user-name-sub-text"><?php echo $currentUser ? ucfirst($currentUser['role']) : ''; ?></span>
|
|
</span>
|
|
</span>
|
|
</button>
|
|
<div class="dropdown-menu dropdown-menu-end">
|
|
<!-- item-->
|
|
<h6 class="dropdown-header">Welcome <?php echo $currentUser ? htmlspecialchars($currentUser['username']) : 'Guest'; ?>!</h6>
|
|
<a class="dropdown-item" href="/apps/pages/profile"><i class="mdi mdi-account-circle text-muted fs-16 align-middle me-1"></i> <span class="align-middle">Profile</span></a>
|
|
<?php if (\App\Core\ModuleConfig::getInstance()->isModuleActive('Chat', \App\Core\Branding::getClientId())): ?>
|
|
<a class="dropdown-item" href="/apps/chat/"><i class="mdi mdi-message-text-outline text-muted fs-16 align-middle me-1"></i> <span class="align-middle">Messages</span></a>
|
|
<?php endif; ?>
|
|
<?php if (\App\Core\ModuleConfig::getInstance()->isModuleActive('Crm', \App\Core\Branding::getClientId())): ?>
|
|
<a class="dropdown-item" href="/apps/crm/tasks"><i class="mdi mdi-calendar-check-outline text-muted fs-16 align-middle me-1"></i> <span class="align-middle">Tasks</span></a>
|
|
<?php endif; ?>
|
|
<a class="dropdown-item" href="/apps/pages/faqs"><i class="mdi mdi-lifebuoy text-muted fs-16 align-middle me-1"></i> <span class="align-middle">Help</span></a>
|
|
<div class="dropdown-divider"></div>
|
|
<a class="dropdown-item" href="/apps/pages/profile"><i class="mdi mdi-cog-outline text-muted fs-16 align-middle me-1"></i> <span class="align-middle">Settings</span></a>
|
|
<a class="dropdown-item" href="/auth/lock-screen"><i class="mdi mdi-lock text-muted fs-16 align-middle me-1"></i> <span class="align-middle">Lock screen</span></a>
|
|
<a class="dropdown-item" href="/logout" id="logoutBtn"><i class="mdi mdi-logout text-muted fs-16 align-middle me-1"></i> <span class="align-middle" x-text="$t('t-logout')">Logout</span></a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- removeNotificationModal -->
|
|
<div id="removeNotificationModal" class="modal fade zoomIn" tabindex="-1" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" id="NotificationModalbtn-close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="mt-2 text-center">
|
|
<lord-icon src="/assets/lordicon/gsqxdxog.json" trigger="loop" colors="primary:#f7b84b,secondary:#f06548" style="width:100px;height:100px"></lord-icon>
|
|
<div class="mt-4 pt-2 fs-15 mx-4 mx-sm-5">
|
|
<h4>Are you sure ?</h4>
|
|
<p class="text-muted mx-4 mb-0">Are you sure you want to remove this Notification ?</p>
|
|
</div>
|
|
</div>
|
|
<div class="d-flex gap-2 justify-content-center mt-4 mb-2">
|
|
<button type="button" class="btn w-sm btn-light" data-bs-dismiss="modal">Close</button>
|
|
<button type="button" class="btn w-sm btn-danger" id="delete-notification">Yes, Delete It!</button>
|
|
</div>
|
|
</div>
|
|
|
|
</div><!-- /.modal-content -->
|
|
</div><!-- /.modal-dialog -->
|
|
</div><!-- /.modal -->
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Logout functionality
|
|
const logoutBtn = document.getElementById('logoutBtn');
|
|
|
|
if (logoutBtn) {
|
|
logoutBtn.addEventListener('click', async function(e) {
|
|
e.preventDefault();
|
|
|
|
// Show confirmation dialog
|
|
const result = await Swal.fire({
|
|
title: 'Logout',
|
|
text: 'Are you sure you want to logout?',
|
|
icon: 'question',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#3085d6',
|
|
cancelButtonColor: '#d33',
|
|
confirmButtonText: 'Yes, logout!',
|
|
cancelButtonText: 'Cancel'
|
|
});
|
|
|
|
if (result.isConfirmed) {
|
|
try {
|
|
const response = await fetch('/api/auth/logout', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
}
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (data.success) {
|
|
Swal.fire({
|
|
title: 'Logged out!',
|
|
text: data.message,
|
|
icon: 'success',
|
|
timer: 2000,
|
|
timerProgressBar: true
|
|
}).then(() => {
|
|
window.location.href = '/login';
|
|
});
|
|
} else {
|
|
Swal.fire({
|
|
title: 'Error!',
|
|
text: data.message || 'Logout failed',
|
|
icon: 'error'
|
|
});
|
|
}
|
|
} catch (error) {
|
|
console.error('Logout error:', error);
|
|
Swal.fire({
|
|
title: 'Error!',
|
|
text: 'Network error. Please try again.',
|
|
icon: 'error'
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
</script>
|