114 lines
5.5 KiB
PHP
114 lines
5.5 KiB
PHP
<?php
|
|
// index.php
|
|
ob_start();
|
|
require_once __DIR__ . '/includes/db.php';
|
|
|
|
$current_month = (int)date('m');
|
|
$current_year = (int)date('Y');
|
|
$current_fy = ($current_month >= 10) ? $current_year + 1 : $current_year;
|
|
|
|
$filter_type = isset($_GET['filter_type']) ? $_GET['filter_type'] : 'fiscal';
|
|
$selected_fy = isset($_GET['fiscal_year']) ? (int)$_GET['fiscal_year'] : $current_fy;
|
|
|
|
if ($filter_type === 'fiscal') {
|
|
$start_date = ($selected_fy - 1) . '-10-01';
|
|
$end_date = $selected_fy . '-09-30';
|
|
} else {
|
|
$start_date = isset($_GET['start_date']) && !empty($_GET['start_date']) ? $_GET['start_date'] : date('Y-m-01');
|
|
$end_date = isset($_GET['end_date']) && !empty($_GET['end_date']) ? $_GET['end_date'] : date('Y-m-d');
|
|
}
|
|
|
|
// คำนวณวันที่-เวลาปัจจุบันของฝั่งเซิร์ฟเวอร์แบบไทย เพื่อโชว์ตอนหน้าแรกโหลดเสร็จ
|
|
$thai_months = [
|
|
1 => 'ม.ค.',
|
|
2 => 'ก.พ.',
|
|
3 => 'มี.ค.',
|
|
4 => 'เม.ย.',
|
|
5 => 'พ.ค.',
|
|
6 => 'มิ.ย.',
|
|
7 => 'ก.ค.',
|
|
8 => 'ส.ค.',
|
|
9 => 'ก.ย.',
|
|
10 => 'ต.ค.',
|
|
11 => 'พ.ย.',
|
|
12 => 'ธ.ค.'
|
|
];
|
|
$current_d = date('d');
|
|
$current_m = (int)date('m');
|
|
$current_y = (int)date('Y') + 543;
|
|
$current_time = date('H:i:s');
|
|
$current_datetime_text = "$current_d " . $thai_months[$current_m] . " $current_y $current_time น.";
|
|
?>
|
|
<?php include 'includes/header.php'; ?>
|
|
|
|
<body class="text-slate-800 h-screen overflow-hidden bg-[radial-gradient(ellipse_at_top_left,_var(--tw-gradient-stops))] from-slate-50 via-slate-100 to-slate-200">
|
|
|
|
<!-- Sidebar Overlay Backdrop -->
|
|
<div id="sidebar-overlay" class="fixed inset-0 bg-slate-900/60 z-40 opacity-0 pointer-events-none transition-opacity duration-300 backdrop-blur-sm hidden" onclick="window.closeSidebar()"></div>
|
|
|
|
<!-- Sidebar -->
|
|
<?php include 'includes/sidebar.php'; ?>
|
|
|
|
<div class="flex flex-col h-screen w-full transition-all duration-300" id="main-wrapper">
|
|
|
|
<!-- Top Navigation -->
|
|
<?php include 'includes/topbar.php'; ?>
|
|
|
|
<!-- Main Content Area -->
|
|
<main class="flex-1 overflow-y-auto p-3 md:p-6 lg:p-8 relative scroll-smooth bg-slate-50/50" id="main-content">
|
|
|
|
<!-- Page Title & Realtime Indicator -->
|
|
<div class="mb-4 md:mb-6 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3 border-b border-slate-200/60 pb-4">
|
|
<h2 class="text-xl md:text-2xl font-extrabold bg-gradient-to-r from-slate-900 to-blue-700 gradient-text flex items-center" id="page-title">
|
|
ภาพรวมโรงพยาบาล (Overview)
|
|
</h2>
|
|
<!-- เปลี่ยนจากการแสดงผลช่วงกรองข้อมูล เป็นนาฬิกาเรียลไทม์แสดง วันที่-เวลา ปัจจุบัน -->
|
|
<div class="flex items-center bg-white rounded-xl px-3 md:px-4 py-2 border border-emerald-100 shadow-sm w-full sm:w-auto justify-center">
|
|
<span class="relative flex h-2.5 w-2.5 mr-2 md:mr-3">
|
|
<span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"></span>
|
|
<span class="relative inline-flex rounded-full h-2.5 w-2.5 bg-emerald-500"></span>
|
|
</span>
|
|
<div>
|
|
<p class="text-[10px] md:text-xs font-bold text-slate-700 tracking-wide leading-none mb-0.5">วันที่-เวลา ปัจจุบัน</p>
|
|
<p class="text-[9px] md:text-[10px] text-emerald-600 font-semibold leading-none" id="current-clock"><?= $current_datetime_text ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Include All Tab Content Components -->
|
|
<?php include 'views/tab_overview.php'; ?>
|
|
<?php include 'views/tab_opd.php'; ?>
|
|
<?php include 'views/tab_ipd.php'; ?>
|
|
<?php include 'views/tab_stats.php'; ?>
|
|
<?php include 'views/tab_settings.php'; ?>
|
|
|
|
</main>
|
|
</div>
|
|
|
|
<!-- Script สำหรับอัปเดตเวลาบนหัวจอให้อัปเดตทุก 1 วินาทีอัตโนมัติ -->
|
|
<script>
|
|
function updateClock() {
|
|
const now = new Date();
|
|
const d = String(now.getDate()).padStart(2, '0');
|
|
const m = now.getMonth() + 1;
|
|
const y = now.getFullYear() + 543;
|
|
const h = String(now.getHours()).padStart(2, '0');
|
|
const min = String(now.getMinutes()).padStart(2, '0');
|
|
const s = String(now.getSeconds()).padStart(2, '0');
|
|
|
|
const monthsTh = ['', 'ม.ค.', 'ก.พ.', 'มี.ค.', 'เม.ย.', 'พ.ค.', 'มิ.ย.', 'ก.ค.', 'ส.ค.', 'ก.ย.', 'ต.ค.', 'พ.ย.', 'ธ.ค.'];
|
|
|
|
const timeStr = `${d} ${monthsTh[m]} ${y} ${h}:${min}:${s} น.`;
|
|
const clockEl = document.getElementById('current-clock');
|
|
if (clockEl) {
|
|
clockEl.innerText = timeStr;
|
|
}
|
|
}
|
|
setInterval(updateClock, 1000);
|
|
</script>
|
|
|
|
<!-- Initialization Scripts -->
|
|
<script src="assets/js/app.js"></script>
|
|
</body>
|
|
|
|
</html>
|