Files

326 lines
16 KiB
PHP
Raw Permalink Normal View History

2024-12-02 01:18:34 +07:00
<!DOCTYPE html>
<html lang="en" style="height: auto;" class="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="{{ asset('templates/dist/img/logo.ico') }}">
<link rel="shortcut icon" type="image/x-icon" href="{{ asset('templates/dist/img/logo.ico') }}">
<title>{{ config('app.app_name') }} - @yield('title')</title>
@include('layouts.partials.styles')
@yield('styles')
</head>
<body>
<body class="sidebar-mini layout-fixed layout-navbar-fixed" style="height: auto;">
<div class="wrapper">
<div class="preloader flex-column justify-content-center align-items-center" style="height: 0px;">
<img class="animation__shake" src="{{ asset('templates/dist/img/small-logo.png') }}" alt="Logo"
height="60" width="60" style="display: none;">
</div>
<nav class="main-header navbar navbar-expand navbar-dark bg-primary">
<ul class="navbar-nav">
<li class="nav-item">
2025-01-15 14:50:53 +07:00
<a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
2024-12-02 01:18:34 +07:00
</li>
2026-06-01 15:01:03 +07:00
<!-- <li class="nav-item">
2025-01-19 15:11:21 +07:00
{{-- periode --}}
<a class="nav-link" href="{{ route('dashboard.index') }}" role="button">
2025-01-19 18:59:14 +07:00
<span class="ml-2 text-white">Periode: <span id="periode"></span></span>
2025-01-19 15:11:21 +07:00
</a>
2026-06-01 15:01:03 +07:00
</li> -->
2024-12-02 01:18:34 +07:00
</ul>
2025-01-15 14:50:53 +07:00
<div class="navbar-center text-white m-auto">
2025-01-19 18:57:38 +07:00
{{-- <span id="date-time" class="font-weight-bold"></span> --}}
2025-01-15 14:50:53 +07:00
</div>
2025-01-19 19:11:29 +07:00
<ul class="navbar-nav" style="margin-top: 0px;">
<li class="nav-item dropdown" style="margin-top: 0px;">
<a class="nav-link" data-toggle="dropdown" href="#" role="button" data-widget="notification" style="margin-top: 0px;">
2025-01-17 16:17:53 +07:00
<i class="fas fa-bell"></i>
2025-01-19 15:22:17 +07:00
<span id="notification-dot" class="badge badge-danger" style="display: none; position: absolute; top: 8px; right: 10px; font-size: 0.6rem;"></span>
2025-01-17 16:17:53 +07:00
</a>
<div class="dropdown-menu dropdown-menu-xl dropdown-menu-right">
<div id="notification">
<span class="dropdown-item dropdown-header" id="notification_title">Notifications</span>
<div id="loading-bar" style="text-align: center; padding: 10px; display: none;">
<div class="spinner-border text-primary" style="width: 2rem; height: 2rem;" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div id="notification-list"></div>
<div class="dropdown-divider"></div>
2025-01-23 17:46:38 +07:00
<form action="{{ route('dashboard.mark_all_read') }}" method="POST">
2025-01-17 16:17:53 +07:00
@csrf
@include('backend.layouts.partials.messages')
<button type="submit" class="dropdown-item dropdown-footer" id="notification_mark">Mark all as read</button>
</form>
</div>
</div>
</li>
<!-- Profile Section -->
2024-12-02 01:18:34 +07:00
<li class="nav-item dropdown" title="Account Profile">
<a class="nav-link" data-toggle="dropdown" href="#">
2025-01-15 14:50:53 +07:00
{{ Auth::guard('admin')->user()->name }} <i class="far fa-user"></i>
2024-12-02 01:18:34 +07:00
</a>
@include('layouts.partials.logout')
</li>
</ul>
</nav>
<aside class="main-sidebar elevation-1 sidebar-light-danger">
<a href="#" class="brand-link bg-light">
<img src="{{ asset('templates/dist/img/logo-app.png') }}" alt="App Logo Text" class="brand-text brand-image">
</a>
<div
class="sidebar os-host os-host-overflow os-host-overflow-y os-host-resize-disabled os-host-scrollbar-horizontal-hidden os-host-transition os-theme-dark">
<div class="os-resize-observer-host observed">
<div class="os-resize-observer" style="left: 0px; right: auto;"></div>
</div>
<div class="os-size-auto-observer observed" style="height: calc(100% + 1px); float: left;">
<div class="os-resize-observer"></div>
</div>
<div class="os-content-glue" style="margin: 0px -8px; width: 249px; height: 676px;"></div>
<div class="os-padding">
<div class="os-viewport os-viewport-native-scrollbars-invisible" style="overflow-y: scroll;">
<div class="os-content" style="padding: 0px 8px; height: 100%; width: 100%;">
2024-12-27 13:03:19 +07:00
<div class="user-panel mt-3 pb-3 mb-3 d-flex align-items-center">
2024-12-02 01:18:34 +07:00
<div class="image">
2024-12-27 13:03:19 +07:00
<img src="{{ Avatar::create(Auth::guard('admin')->user()->name)->toBase64() }}"
2024-12-02 01:18:34 +07:00
class="img-circle" alt="User Image">
</div>
<div class="info">
<a class="d-block">{{ Auth::guard('admin')->user()->name }}</a>
2024-12-27 13:03:19 +07:00
<a class="d-block font-weight-bold" style="font-size: 11px;">
{{ Auth::guard('admin')->user()->getRoleNames()[0] }}
</a>
2025-01-19 14:57:01 +07:00
@if(
auth()->user()->getMyCabangAndRegion()['cabang'] != '-' &&
in_array(Auth::guard('admin')->user()->getRoleNames()[0], ['Medical Representatif', 'Area Manager Cabang'])
)
2025-01-07 17:23:42 +07:00
<a class="d-block" style="font-size: 14px;">
<span class="badge badge-primary">
{{ auth()->user()->getMyCabangAndRegion()['cabang'] }}
</span>
</a>
2025-01-19 18:57:38 +07:00
@elseif(Auth::guard('admin')->user()->getRoleNames()[0] != 'Superadmin')
2025-01-15 14:50:53 +07:00
<a class="d-block" style="font-size: 14px;">
<span class="badge badge-primary">
Head Office
</span>
</a>
2025-01-07 17:23:42 +07:00
@endif
2025-01-19 18:57:38 +07:00
<span id="date-time" class="font-weight-bold" style="font-size: 12px;"></span>
2024-12-02 01:18:34 +07:00
</div>
</div>
@include('layouts.partials.sidebar')
</div>
</div>
</div>
<div class="os-scrollbar os-scrollbar-horizontal os-scrollbar-unusable os-scrollbar-auto-hidden">
<div class="os-scrollbar-track">
<div class="os-scrollbar-handle" style="width: 100%; transform: translate(0px, 0px);"></div>
</div>
</div>
<div class="os-scrollbar os-scrollbar-vertical os-scrollbar-auto-hidden">
<div class="os-scrollbar-track">
<div class="os-scrollbar-handle" style="height: 57.5686%; transform: translate(0px, 0px);">
</div>
</div>
</div>
<div class="os-scrollbar-corner"></div>
</div>
</aside>
<div class="content-wrapper" style="min-height: 677.4px;">
@yield('admin-content')
</div>
@include('layouts.partials.footer')
@include('layouts.partials.scripts')
@yield('scripts')
</body>
</html>
2025-01-15 14:50:53 +07:00
<script>
function updateDateTime() {
const dateTimeElement = document.getElementById('date-time');
const now = new Date();
const options = {
timeZone: 'Asia/Jakarta',
year: 'numeric',
2025-01-19 18:51:59 +07:00
month: 'short',
2025-01-15 14:50:53 +07:00
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
hour12: false // Use 24-hour format
};
2025-01-19 18:51:59 +07:00
dateTimeElement.textContent = new Intl.DateTimeFormat('en-US', options).format(now) + ' WIB';
2025-01-15 14:50:53 +07:00
}
// Update the clock every second
setInterval(updateDateTime, 1000);
// Initialize the clock on page load
updateDateTime();
2025-01-17 16:17:53 +07:00
document.querySelector('[data-widget="notification"]').addEventListener('click', function (e) {
e.preventDefault();
const loadingBar = document.getElementById('loading-bar');
const notificationList = document.getElementById('notification-list');
// Show loading bar and hide notification list
loadingBar.style.display = 'block';
notificationList.classList.add('d-none');
2025-01-23 17:46:38 +07:00
2025-01-17 16:17:53 +07:00
fetch('/api/notifications')
.then(response => response.json())
.then(data => {
notificationList.innerHTML = ''; // Clear existing notifications
2025-01-19 15:22:17 +07:00
data.data.forEach(notification => {
2025-01-17 16:17:53 +07:00
const item = document.createElement('a');
item.href = notification.link || '#';
item.classList.add('dropdown-item');
2025-01-23 17:46:38 +07:00
item.dataset.notificationId = notification.id; // Store notification ID for later use
const notifLink = `/forms/${notification.expense_type}/view/${notification.expense_id}`;
2025-01-17 16:17:53 +07:00
item.innerHTML = `
<div style="display: flex; justify-content: space-between; align-items: center;">
<div style="display: flex; align-items: center;">
<i class="fas fa-bell" style="font-size: 16px; margin-right: 5px;"></i>
<strong style="font-size: 12px;">${notification.title}</strong>
</div>
<span class="text-muted text-sm" style="font-size: 12px !important;">
${new Date(notification.created_at).toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
2025-05-05 19:40:38 +07:00
minute: '2-digit',
2025-01-17 16:17:53 +07:00
})}
</span>
</div>
<span class="text-muted text-sm" style="font-size: 12px !important;">${notification.content || ''}</span>
`;
2025-01-23 17:46:38 +07:00
// Add click event listener
item.addEventListener('click', (e) => {
e.preventDefault(); // Prevent default navigation
// Call the mark_read API
fetch(`/api/mark_read/${notification.id}`)
.then(markReadResponse => {
if (!markReadResponse.ok) {
throw new Error('Failed to mark notification as read');
}
// Optionally handle UI changes here (e.g., mark notification visually as read)
console.log(`Notification ${notification.id} marked as read`);
// Redirect to the notification link
window.location.href = notifLink;
})
.catch(error => {
console.error('Error marking notification as read:', error);
});
});
2025-01-17 16:17:53 +07:00
notificationList.appendChild(item);
});
// Hide loading bar and show notification list
loadingBar.style.display = 'none';
notificationList.classList.remove('d-none');
})
.catch(error => {
console.error('Error fetching notifications:', error);
loadingBar.style.display = 'none';
notificationList.innerHTML = '<span class="dropdown-item text-danger">Failed to load notifications.</span>';
notificationList.classList.remove('d-none');
});
2025-01-23 17:46:38 +07:00
2025-01-17 16:17:53 +07:00
});
2025-01-19 15:22:17 +07:00
fetch('/api/notifications')
.then(response => response.json())
.then(data => {
const notificationDot = document.getElementById('notification-dot');
if (data.count > 0) {
// Show red dot if there are notifications
// show the number of notifications
notificationDot.textContent = data.count;
notificationDot.style.display = 'block';
} else {
// Hide red dot if there are no notifications
notificationDot.style.display = 'none';
}
})
.catch(error => {
console.error('Error checking notifications:', error);
});
2025-01-15 14:50:53 +07:00
</script>
2025-03-05 13:44:58 +07:00
2025-05-09 18:39:17 +07:00
{{-- <script>
2025-03-05 13:44:58 +07:00
let logoutTimer;
function resetLogoutTimer() {
clearTimeout(logoutTimer);
logoutTimer = setTimeout(() => {
fetch("{{ route('admin.logout.submit') }}", {
method: "POST",
headers: {
"X-CSRF-TOKEN": "{{ csrf_token() }}",
"Content-Type": "application/json"
},
body: JSON.stringify({})
}).then(() => {
window.location.href = "{{ url('/login') }}";
});
}, 30 * 60 * 1000); // 30 minutes
}
document.addEventListener('mousemove', resetLogoutTimer);
document.addEventListener('keydown', resetLogoutTimer);
resetLogoutTimer();
2025-05-09 18:39:17 +07:00
</script> --}}
2025-05-05 19:40:38 +07:00
<script>
const periode = document.getElementById('periode');
const date = new Date();
const currentYear = date.getFullYear();
const currentMonthIndex = date.getMonth(); // 0 = Jan, 11 = Dec
const currentDay = date.getDate();
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
let startMonthIndex, closingMonthIndex, closingYear;
if (currentDay >= 11) {
startMonthIndex = currentMonthIndex;
closingMonthIndex = (currentMonthIndex + 1) % 12;
closingYear = currentMonthIndex === 11 ? currentYear + 1 : currentYear;
} else {
startMonthIndex = (currentMonthIndex - 1 + 12) % 12;
closingMonthIndex = currentMonthIndex;
closingYear = currentYear;
}
const startMonth = months[startMonthIndex];
const closingMonth = months[closingMonthIndex];
periode.textContent = `${startMonth} (11 ${startMonth} - 10 ${closingMonth} ${closingYear})`;
</script>