75 lines
2.8 KiB
PHP
75 lines
2.8 KiB
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>
|
|
|
|
<!-- DataTables -->
|
|
<script src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
|
|
<script src="https://cdn.datatables.net/1.10.21/js/dataTables.bootstrap4.min.js"></script>
|
|
|
|
<script src="https://cdn.ckeditor.com/ckeditor5/36.0.1/classic/ckeditor.js"></script>
|
|
<script>
|
|
ClassicEditor
|
|
.create(document.querySelector('#deskripsi'))
|
|
.catch(error => {
|
|
console.error(error);
|
|
});
|
|
</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> |