51 lines
2.0 KiB
PHP
51 lines
2.0 KiB
PHP
<?php
|
|
// includes/header.php
|
|
?>
|
|
<header class="navbar" style="margin-bottom: 24px; border-radius: 16px; margin-top: 20px; margin-right: 20px;">
|
|
<div class="navbar-brand">
|
|
<span id="date_time" style="font-size: 0.95rem; font-weight: 500; color: var(--text-light);"></span>
|
|
</div>
|
|
|
|
<div class="navbar-menu">
|
|
<div class="user-info-card">
|
|
<div style="text-align: right;">
|
|
<div style="font-weight: 600; color: var(--text-dark);"><?php echo htmlspecialchars($name ?? $account ?? 'User'); ?></div>
|
|
<div style="font-size: 0.8rem; color: var(--primary);"><?php echo htmlspecialchars($position ?? 'เจ้าหน้าที่'); ?></div>
|
|
</div>
|
|
<div class="user-avatar" style="width: 48px; height: 48px; font-size: 18px;">
|
|
<?php echo mb_substr(htmlspecialchars($name ?? 'U'), 0, 1, 'UTF-8'); ?>
|
|
</div>
|
|
</div>
|
|
|
|
<a href="logout.php" class="btn btn-danger" style="margin-left: 16px; border-radius: 20px; padding: 8px 16px;">
|
|
ออกจากระบบ
|
|
</a>
|
|
</div>
|
|
</header>
|
|
|
|
<script>
|
|
function date_time(id) {
|
|
let date = new Date();
|
|
let year = date.getFullYear() + 543;
|
|
let month = date.getMonth();
|
|
let months = ['ม.ค.', 'ก.พ.', 'มี.ค.', 'เม.ย.', 'พ.ค.', 'มิ.ย.', 'ก.ค.', 'ส.ค.', 'ก.ย.', 'ต.ค.', 'พ.ย.', 'ธ.ค.'];
|
|
let d = date.getDate();
|
|
let h = date.getHours();
|
|
if(h<10) h = "0"+h;
|
|
let m = date.getMinutes();
|
|
if(m<10) m = "0"+m;
|
|
let s = date.getSeconds();
|
|
if(s<10) s = "0"+s;
|
|
|
|
let result = d + ' ' + months[month] + ' ' + year + ' เวลา ' + h + ':' + m + ':' + s + ' น.';
|
|
let el = document.getElementById(id);
|
|
if(el) {
|
|
el.innerHTML = result;
|
|
setTimeout(function(){ date_time(id); }, 1000);
|
|
}
|
|
}
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
date_time('date_time');
|
|
});
|
|
</script>
|