|
Server : LiteSpeed System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64 User : outerorb ( 1091) PHP Version : 8.1.34 Disable Function : mail Directory : /home2/outerorb/assetradar.outerorbittech.com/inc/ | |
|
Path: /home2/outerorb/assetradar.outerorbittech.com/inc/header.php
Size: 7.28 KB
Permissions: 0666
<?php
require_once __DIR__ . '/auth.php';
require_once __DIR__ . '/csrf.php';
$user = current_user();
?>
<!doctype html>
<head>
<meta charset="utf-8">
<title>IT Asset Tracker</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap 5 CDN -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700;800&display=swap" rel="stylesheet">
<style>
:root { --brand:#4f46e5; --accent:#06b6d4; --muted:#6b7280; }
body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial; }
.brand { font-weight:800; color:var(--brand); letter-spacing:0.4px; }
.card-hero { border-radius:12px; box-shadow: 0 10px 30px rgba(15,23,42,0.06); }
.nav-badge { font-size:0.72rem; }
.bg-soft { background: linear-gradient(90deg, rgba(99,102,241,0.06), rgba(14,165,233,0.03)); }
.hero { background: linear-gradient(180deg, rgba(79,70,229,0.06), rgba(6,182,212,0.02)); border-radius:14px; padding:28px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Roboto Mono', monospace; }
.notif-dropdown { min-width: 320px; max-height: 420px; overflow:auto; }
</style>
</head>
<body class="bg-light">
<nav class="navbar navbar-expand-lg navbar-white bg-white shadow-sm">
<div class="<?php echo defined('ADMIN_PAGE') ? 'container-fluid' : 'container'; ?>">
<a class="navbar-brand d-flex align-items-center" href="<?php echo BASE_URL; ?>/">
<?php if (!defined('ADMIN_PAGE')): ?>
<img src="<?php echo BASE_URL; ?>/assets/assetradar_logo.svg" alt="AssetRadar Logo" style="height:64px;width:auto;">
<?php endif; ?>
</a>
<?php if (!defined('ADMIN_PAGE')): ?>
<div class="d-flex align-items-center">
<?php if ($user): ?>
<div class="me-3 position-relative">
<button id="notifBtn" class="btn btn-light btn-sm position-relative" data-bs-toggle="dropdown" aria-expanded="false">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" class="bi bi-bell" viewBox="0 0 16 16">
<path d="M8 16a2 2 0 0 0 1.985-1.75H6.015A2 2 0 0 0 8 16z"/>
<path fill-rule="evenodd" d="M8 1.018a4 4 0 0 0-4 4V8.5l-.9 1.6A1 1 0 0 0 4 12h8a1 1 0 0 0 .8-1.9L12 8.5V5.018a4 4 0 0 0-4-4z"/>
</svg>
<span id="notifCount" class="badge bg-danger rounded-pill nav-badge position-absolute top-0 start-100 translate-middle">0</span>
</button>
<ul class="dropdown-menu dropdown-menu-end notif-dropdown p-2" aria-labelledby="notifBtn" id="notifMenu">
<li class="text-center small text-muted">Loading...</li>
</ul>
</div>
<span class="me-3">Hello, <strong><?php echo esc($user['name']); ?></strong> (<?php echo esc($user['role_name']); ?>)</span>
<a class="btn btn-outline-secondary btn-sm" href="<?php echo BASE_URL; ?>/logout.php">Logout</a>
<?php else: ?>
<a class="btn btn-outline-info btn-sm" href="<?php echo BASE_URL; ?>/DOCUMENTATION.html" target="_blank">Documentation</a>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</nav>
<?php if (!defined('ADMIN_PAGE')): ?>
<div class="container py-4">
<?php if ($user): ?>
<div class="row mb-4">
<div class="col-12 hero card-hero p-4">
<div class="d-flex justify-content-between align-items-center">
<div>
<h2 class="mb-1">Welcome back, <?php echo esc($user['name']); ?> 👋</h2>
<p class="mb-0 text-muted">Manage inventory, assign assets, and resolve tickets — all in one modern tool.</p>
</div>
<div class="text-end">
<a class="btn btn-sm btn-success" href="<?php echo BASE_URL; ?>/user/report_general_issue.php">Create Ticket</a>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($user && !defined('ADMIN_PAGE')): ?>
<script>
function updateNotifBellAndMenu() {
fetch('<?php echo BASE_URL; ?>/api/notifications.php')
.then(r => r.json())
.then(data => {
let unread = data.filter(n => n.is_read == 0);
let read = data.filter(n => n.is_read != 0);
let notifCount = document.getElementById('notifCount');
notifCount.textContent = unread.length;
notifCount.style.display = unread.length > 0 ? 'inline-block' : 'none';
let menu = document.getElementById('notifMenu');
menu.innerHTML = '';
if (data.length === 0) {
menu.innerHTML = '<li class="text-center small text-muted">No notifications</li>';
return;
}
// Unread notifications first
unread.forEach(n => {
let url = n.ticket_id && n.ticket_id !== 'null' ? '<?php echo BASE_URL; ?>/user/ticket_view.php?id=' + n.ticket_id : '';
let li = document.createElement('li');
li.className = 'mb-2 bg-warning-subtle';
if (url) {
li.innerHTML = `<a href='${url}' class='fw-bold text-dark text-decoration-none notif-link' target='_blank'>${n.message}</a><div class='small text-muted'>${n.created_at}</div>`;
} else {
li.innerHTML = `<span class='fw-bold text-dark'>${n.message}</span><div class='small text-muted'>${n.created_at}</div>`;
}
// Add mark as read button
let markBtn = document.createElement('button');
markBtn.className = 'btn btn-xs btn-link text-primary ms-2';
markBtn.textContent = 'Mark as read';
markBtn.onclick = function() {
fetch('<?php echo BASE_URL; ?>/api/notifications.php?mark=' + n.id)
.then(() => updateNotifBellAndMenu());
};
li.appendChild(markBtn);
menu.appendChild(li);
});
// Divider
if (unread.length && read.length) {
let divider = document.createElement('li');
divider.innerHTML = '<hr class="my-1">';
menu.appendChild(divider);
}
// Read notifications
read.forEach(n => {
let url = n.ticket_id && n.ticket_id !== 'null' ? '<?php echo BASE_URL; ?>/user/ticket_view.php?id=' + n.ticket_id : '';
let li = document.createElement('li');
li.className = 'mb-2';
if (url) {
li.innerHTML = `<a href='${url}' class='text-muted text-decoration-none notif-link' target='_blank'>${n.message}</a><div class='small text-muted'>${n.created_at}</div>`;
} else {
li.innerHTML = `<span class='text-muted'>${n.message}</span><div class='small text-muted'>${n.created_at}</div>`;
}
menu.appendChild(li);
});
// Make notification links open in a new tab
menu.querySelectorAll('.notif-link').forEach(link => {
link.setAttribute('target', '_blank');
});
// Mark all as read
let markAll = document.createElement('li');
markAll.className = 'text-center mt-2';
markAll.innerHTML = '<button class="btn btn-sm btn-outline-primary" onclick="markAllNotifications()">Mark all as read</button>';
menu.appendChild(markAll);
});
}
function markAllNotifications() {
fetch('<?php echo BASE_URL; ?>/api/notifications.php?mark=all')
.then(() => updateNotifBellAndMenu());
}
document.getElementById('notifBtn').addEventListener('click', updateNotifBellAndMenu);
updateNotifBellAndMenu();
setInterval(updateNotifBellAndMenu, 30000); // auto-refresh every 30s
</script>
<?php endif; ?>