85 lines
3.3 KiB
PHP
85 lines
3.3 KiB
PHP
</main>
|
|
|
|
<?php
|
|
// Fetch footer text
|
|
$footer_text_display = 'ระบบแจ้งเตือนส่งงาน';
|
|
if (isset($pdo)) {
|
|
try {
|
|
$stmt_footer = $pdo->prepare("SELECT setting_value FROM settings WHERE setting_key = 'footer_text'");
|
|
$stmt_footer->execute();
|
|
if ($row_footer = $stmt_footer->fetch()) {
|
|
$footer_text_display = $row_footer['setting_value'];
|
|
}
|
|
} catch (Exception $e) {}
|
|
}
|
|
?>
|
|
<footer class="bg-white border-t border-gray-200 p-4 text-center text-sm text-gray-600 shrink-0">
|
|
© <?= date('Y') ?> <?= htmlspecialchars($footer_text_display) ?>
|
|
</footer>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- DataTables JS -->
|
|
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
|
|
<script src="https://cdn.datatables.net/responsive/2.5.0/js/dataTables.responsive.min.js"></script>
|
|
|
|
<script>
|
|
// Initialize DataTables globally if table exists and not already initialized
|
|
$(document).ready(function() {
|
|
if ($('.dataTable').length > 0) {
|
|
$('.dataTable').each(function() {
|
|
if (!$.fn.dataTable.isDataTable(this)) {
|
|
$(this).DataTable({
|
|
responsive: true,
|
|
columnDefs: [{ className: "dt-head-center", targets: "_all" }],
|
|
language: {
|
|
url: '//cdn.datatables.net/plug-ins/1.13.6/i18n/th.json',
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<?php if (isset($_SESSION['login_notified']) && $_SESSION['login_notified'] === false): ?>
|
|
<script>
|
|
// Show notification only once after login
|
|
$(document).ready(function() {
|
|
$.ajax({
|
|
url: 'api/get_notifications.php',
|
|
method: 'GET',
|
|
dataType: 'json',
|
|
success: function(response) {
|
|
if(response.status === 'success' && response.data.length > 0) {
|
|
let htmlList = '<div style="max-height: 200px; overflow-y: auto;" class="custom-scrollbar"><ul class="text-left mt-2 pr-2">';
|
|
response.data.forEach(function(item) {
|
|
htmlList += `<li class="mb-2 pb-2 border-b border-gray-200">
|
|
<strong>${item.title}</strong><br>
|
|
<span class="text-sm text-red-500">กำหนดส่ง: ${item.due_date} (เหลือ ${item.days_left} วัน)</span>
|
|
</li>`;
|
|
});
|
|
htmlList += '</ul></div>';
|
|
|
|
Swal.fire({
|
|
title: 'คุณมีงานใกล้ถึงกำหนดส่ง!',
|
|
html: htmlList,
|
|
icon: 'warning',
|
|
confirmButtonText: 'รับทราบ',
|
|
confirmButtonColor: '#3085d6'
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
<?php
|
|
// Mark as notified so it doesn't show again in this session
|
|
$_SESSION['login_notified'] = true;
|
|
endif;
|
|
?>
|
|
|
|
<script src="assets/js/app.js"></script>
|
|
</body>
|
|
</html>
|