157 lines
5.5 KiB
PHP
157 lines
5.5 KiB
PHP
<?php
|
|
session_start();
|
|
// $timeout = 1; // setting timeout dalam menit
|
|
// $logout = "../login/index.php"; // redirect halaman logout
|
|
|
|
// $timeout = $timeout * 360; // menit ke detik
|
|
// if(isset($_SESSION['start_session'])){
|
|
// $elapsed_time = time()-$_SESSION['start_session'];
|
|
// if($elapsed_time >= $timeout){
|
|
// session_destroy();
|
|
// echo "<script type='text/javascript'>alert('Sesi telah berakhir');window.location='$logout'</script>";
|
|
// }
|
|
// }
|
|
|
|
// $_SESSION['start_session']=time();
|
|
|
|
include('../config.php');
|
|
// Pastikan session user sudah ada
|
|
if (!isset($_SESSION['user_global_admin'])) {
|
|
header("Location: ../login.php");
|
|
exit;
|
|
}
|
|
|
|
$base_url = "http://localhost";
|
|
|
|
// Query untuk mendapatkan profil awal
|
|
$query = mysqli_query($conn, "SELECT * FROM profil WHERE id_usaha = 1");
|
|
$profile = mysqli_fetch_assoc($query);
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta content="width=device-width, initial-scale=1.0" name="viewport">
|
|
|
|
<title>Dashboard - <?php echo $profile['nama_usaha']; ?></title>
|
|
<meta content="" name="description">
|
|
<meta content="" name="keywords">
|
|
|
|
<!-- Favicons -->
|
|
<link href="assets/img/favicon.png" rel="icon">
|
|
<link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
|
|
|
|
<!-- Google Fonts -->
|
|
<link href="https://fonts.gstatic.com" rel="preconnect">
|
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
|
|
|
|
<!-- Vendor CSS Files -->
|
|
<link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
|
|
<link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
|
|
<link href="assets/vendor/quill/quill.snow.css" rel="stylesheet">
|
|
<link href="assets/vendor/quill/quill.bubble.css" rel="stylesheet">
|
|
<link href="assets/vendor/remixicon/remixicon.css" rel="stylesheet">
|
|
<link href="assets/vendor/simple-datatables/style.css" rel="stylesheet">
|
|
|
|
<!-- Template Main CSS File -->
|
|
<link href="assets/css/style.css" rel="stylesheet">
|
|
<script src="../dist/sweetalert2.all.min.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
|
|
<!-- DataTables CSS for Bootstrap -->
|
|
<link href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap4.min.css" rel="stylesheet">
|
|
|
|
<!-- =======================================================
|
|
* Template Name: NiceAdmin
|
|
* Template URL: https://bootstrapmade.com/nice-admin-bootstrap-admin-html-template/
|
|
* Updated: Apr 20 2024 with Bootstrap v5.3.3
|
|
* Author: BootstrapMade.com
|
|
* License: https://bootstrapmade.com/license/
|
|
======================================================== -->
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<!-- header.php -->
|
|
<div id="header-placeholder">
|
|
<?php include 'template/header.php'; ?>
|
|
</div>
|
|
|
|
<!-- header.php -->
|
|
<div id="header-placeholder">
|
|
<?php include 'template/sidebar.php'; ?>
|
|
</div>
|
|
|
|
|
|
|
|
<!-- main.php -->
|
|
<?php include 'main.php'; ?>
|
|
|
|
<!-- footer.php -->
|
|
<?php include 'template/footer.php'; ?>
|
|
|
|
|
|
<a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
|
|
|
|
<!-- Vendor JS Files -->
|
|
<script src="assets/vendor/apexcharts/apexcharts.min.js"></script>
|
|
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
|
|
<script src="assets/vendor/chart.js/chart.umd.js"></script>
|
|
<script src="assets/vendor/echarts/echarts.min.js"></script>
|
|
<script src="assets/vendor/quill/quill.js"></script>
|
|
<script src="assets/vendor/simple-datatables/simple-datatables.js"></script>
|
|
<script src="assets/vendor/tinymce/tinymce.min.js"></script>
|
|
<script src="assets/vendor/php-email-form/validate.js"></script>
|
|
|
|
<!-- Template Main JS File -->
|
|
<script src="assets/js/main.js"></script>
|
|
|
|
<script>
|
|
function loadNotifikasi() {
|
|
fetch('<?php $base_url?>/admin/ajax/cek_pesanan.php')
|
|
.then(res => res.json())
|
|
.then(data => {
|
|
const notifCount = data.total;
|
|
const notifList = document.getElementById('notif-list');
|
|
const notifHeader = document.getElementById('notif-header-text');
|
|
const notifBadge = document.getElementById('notif-count');
|
|
|
|
notifBadge.textContent = notifCount;
|
|
|
|
// Clear notifikasi lama, tapi simpan header & footer
|
|
const oldItems = notifList.querySelectorAll('.notification-item, hr');
|
|
oldItems.forEach(el => el.remove());
|
|
|
|
if (notifCount > 0) {
|
|
notifHeader.textContent = `Ada ${notifCount} pesanan baru`;
|
|
|
|
data.data.forEach(pesanan => {
|
|
const item = document.createElement('li');
|
|
item.classList.add('notification-item');
|
|
item.innerHTML = `
|
|
<i class="bi bi-cart text-info"></i>
|
|
<div>
|
|
<h4>ID Order: ${pesanan.id_order}</h4>
|
|
<p>Status: <strong>${pesanan.status_order}</strong></p>
|
|
<p>${pesanan.tanggal_order}</p>
|
|
</div>
|
|
`;
|
|
notifList.insertBefore(document.createElement('hr'), notifList.children[notifList.children.length - 1]);
|
|
notifList.insertBefore(item, notifList.children[notifList.children.length - 1]);
|
|
});
|
|
} else {
|
|
notifHeader.textContent = 'Tidak ada notifikasi baru';
|
|
}
|
|
});
|
|
}
|
|
|
|
// Panggil setiap 10 detik
|
|
setInterval(loadNotifikasi, 10000);
|
|
document.addEventListener('DOMContentLoaded', loadNotifikasi);
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|