| Server IP : 104.21.80.248 / Your IP : 172.71.28.156 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : E:/Inetpub/www/school_budget/template/ |
Upload File : |
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
// [ตรวจสอบสิทธิ์การใช้งาน Session] ป้องกันการข้ามระบบจาก Server เดียวกัน
if (isset($_SESSION['user_id'])) {
if (!isset($_SESSION['sys_token']) || $_SESSION['sys_token'] !== 'SCHOOL_BUDGET_SECURE_TOKEN') {
session_destroy();
header("Location: /school_budget/login.php");
exit();
}
}
// ตรวจสอบหาไฟล์ db.php ให้เจออย่างแม่นยำ ไม่ว่าจะถูกเรียกจากโฟลเดอร์ใด
if (file_exists(__DIR__ . '/../db.php')) {
include_once(__DIR__ . '/../db.php');
} elseif (file_exists(__DIR__ . '/../../db.php')) {
include_once(__DIR__ . '/../../db.php');
} elseif (file_exists('db.php')) {
include_once('db.php');
}
// ป้องกันการแก้ไขหรือใส่รหัสค่า GET ใน URL (ความปลอดภัยขั้นสูง)
if (isset($_GET['set_global_year'])) {
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') {
die("สิทธิ์การเข้าถึงไม่ถูกต้อง หรือตรวจพบความพยายามแก้ไข URL");
}
}
// --- บันทึกการเลือกปีงบประมาณของ Admin ลงฐานข้อมูล ---
if (isset($_GET['set_global_year']) && isset($_SESSION['role']) && $_SESSION['role'] == 'admin') {
$chosen_year = mysqli_real_escape_string($conn, $_GET['set_global_year']);
// อัปเดตค่าลงในตารางฐานข้อมูลโดยตรงเพื่อความถาวร
$update_setting_sql = "UPDATE system_settings SET setting_value = '$chosen_year' WHERE setting_key = 'active_budget_year'";
mysqli_query($conn, $update_setting_sql);
// ส่งกลับหน้าเดิมเพื่อล้าง Query String ออกจาก URL ป้องกันค่าค้าง
$current_uri = strtok($_SERVER["REQUEST_URI"], '?');
header("Location: " . $current_uri);
exit();
}
// --- ดึงค่าปีงบประมาณปัจจุบันที่แอดมินกำหนดไว้ในฐานข้อมูลมาใช้งาน ---
$global_budget_year = 'all'; // ค่าเริ่มต้น
$get_setting_res = mysqli_query($conn, "SELECT setting_value FROM system_settings WHERE setting_key = 'active_budget_year'");
if ($get_setting_res && mysqli_num_rows($get_setting_res) > 0) {
$setting_row = mysqli_fetch_assoc($get_setting_res);
$global_budget_year = $setting_row['setting_value'];
}
// ฟังก์ชันดึงชื่อไฟล์ปัจจุบันเพื่อตรวจสอบคลาส Active บนเมนู
$current_page = basename($_SERVER['PHP_SELF']);
?>
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ระบบบริหารงบประมาณและข้อมูลการเบิกจ่าย</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');
body {
font-family: 'Sarabun', sans-serif;
background-color: #f4f6f9;
color: #333333;
}
/* สไตล์ Navbar โฉมใหม่ */
.custom-navbar {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
padding: 0.75rem 0;
}
.navbar-brand-custom {
display: flex;
align-items: center;
gap: 12px;
text-decoration: none;
color: #1e293b;
transition: transform 0.2s ease;
}
.navbar-brand-custom:hover {
transform: scale(1.02);
}
.brand-logo-box {
background: linear-gradient(135deg, #0d6efd, #0a58ca);
color: #ffffff;
width: 45px;
height: 45px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 12px;
font-size: 1.5rem;
box-shadow: 0 4px 8px rgba(13, 110, 253, 0.3);
}
.brand-title-text {
font-size: 1.05rem;
font-weight: 700;
line-height: 1.2;
color: #0f172a;
}
.brand-subtitle-text {
font-size: 0.8rem;
color: #64748b;
font-weight: 400;
}
/* เอฟเฟกต์เมนูเด่นชัดขึ้น */
.custom-navbar .nav-link {
color: #475569;
font-weight: 500;
font-size: 0.95rem;
padding: 0.5rem 1rem !important;
border-radius: 8px;
transition: all 0.2s ease;
display: flex;
align-items: center;
gap: 6px;
}
.custom-navbar .nav-link:hover {
color: #0d6efd;
background-color: rgba(13, 110, 253, 0.06);
}
.custom-navbar .nav-item.active .nav-link {
color: #0d6efd;
background-color: rgba(13, 110, 253, 0.08);
font-weight: 600;
}
/* ส่วนแสดงโปรไฟล์ผู้ใช้ */
.user-profile-badge {
background-color: #f1f5f9;
padding: 6px 14px;
border-radius: 50px;
display: inline-flex;
align-items: center;
gap: 8px;
font-size: 0.9rem;
font-weight: 500;
color: #334155;
border: 1px solid #e2e8f0;
}
.admin-badge {
background-color: rgba(220, 53, 69, 0.1);
color: #dc3545;
border: 1px solid rgba(220, 53, 69, 0.2);
}
/* ปรับดีไซน์ Dropdown */
.dropdown-menu {
border: none;
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
border-radius: 12px;
padding: 0.5rem;
}
.dropdown-item {
border-radius: 8px;
padding: 0.5rem 1rem;
font-size: 0.92rem;
color: #334155;
transition: all 0.15s ease;
}
.dropdown-item:hover {
background-color: rgba(13, 110, 253, 0.06);
color: #0d6efd;
}
.dropdown-item.active, .dropdown-item.active:hover {
background-color: #0d6efd;
color: #ffffff;
}
.container-main {
max-width: 1240px;
padding-top: 1.5rem;
padding-bottom: 3rem;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg custom-navbar sticky-top mb-4">
<div class="container-fluid px-lg-5">
<a class="navbar-brand-custom" href="/school_budget/index.php">
<div class="brand-logo-box">
<i class="bi bi-mortarboard-fill"></i>
</div>
<div>
<div class="brand-title-text">School Budget Management System</div>
<div class="brand-subtitle-text">ระบบเบิกจ่ายงบประมาณโรงเรียน</div>
</div>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto align-items-center gap-1">
<li class="nav-item <?php echo ($current_page == 'index.php' && !strpos($_SERVER['REQUEST_URI'], '/admin/') && !strpos($_SERVER['REQUEST_URI'], '/school/')) ? 'active' : ''; ?>">
<a class="nav-link" href="/school_budget/index.php">
<i class="bi bi-house-door-fill"></i> หน้าแรก
</a>
</li>
<?php if (isset($_SESSION['user_id'])): ?>
<?php if ($_SESSION['role'] == 'admin'): ?>
<li class="nav-item <?php echo (strpos($_SERVER['REQUEST_URI'], '/admin/index.php')) ? 'active' : ''; ?>">
<a class="nav-link" href="/school_budget/admin/index.php">
<i class="bi bi-grid-1x2-fill"></i> แดชบอร์ด
</a>
</li>
<li class="nav-item <?php echo ($current_page == 'manage_schools.php') ? 'active' : ''; ?>">
<a class="nav-link" href="/school_budget/admin/manage_schools.php">
<i class="bi bi-building-fill"></i> โรงเรียน
</a>
</li>
<li class="nav-item <?php echo ($current_page == 'manage_types.php') ? 'active' : ''; ?>">
<a class="nav-link" href="/school_budget/admin/manage_types.php">
<i class="bi bi-tags-fill"></i> ประเภทงบ
</a>
</li>
<li class="nav-item <?php echo ($current_page == 'manage_plans.php') ? 'active' : ''; ?>">
<a class="nav-link" href="/school_budget/admin/manage_plans.php">
<i class="bi bi-journal-bookmark-fill"></i> แผนงาน
</a>
</li>
<li class="nav-item <?php echo ($current_page == 'manage_allocations.php') ? 'active' : ''; ?>">
<a class="nav-link" href="/school_budget/admin/manage_allocations.php">
<i class="bi bi-cash-coin"></i> จัดสรรงบประมาณ
</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle fw-bold text-primary" href="#" id="yearDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi bi-calendar-event-fill text-primary"></i>
<?php echo ($global_budget_year != 'all') ? 'พ.ศ. '.$global_budget_year : 'ทุกปีงบประมาณ'; ?>
</a>
<ul class="dropdown-menu dropdown-menu-end shadow" aria-labelledby="yearDropdown">
<li>
<a class="dropdown-item <?php echo ($global_budget_year == 'all') ? 'active' : ''; ?>" href="?set_global_year=all">
<i class="bi bi-globe me-1"></i> แสดงทุกปีงบประมาณ
</a>
</li>
<li><hr class="dropdown-divider"></li>
<?php
$get_years_sql = "SELECT DISTINCT budget_year FROM allocations ORDER BY budget_year DESC";
$res_years_sql = mysqli_query($conn, $get_years_sql);
if ($res_years_sql) {
while ($yr_row = mysqli_fetch_assoc($res_years_sql)) {
$y_val = $yr_row['budget_year'];
$is_active = ($global_budget_year == $y_val) ? 'active' : '';
echo "<li>
<a class='dropdown-item $is_active' href='?set_global_year=$y_val'>
<i class='bi bi-calendar3 me-1'></i> ปีงบประมาณ พ.ศ. $y_val
</a>
</li>";
}
}
?>
</ul>
</li>
<?php elseif ($_SESSION['role'] == 'school'): ?>
<li class="nav-item <?php echo (strpos($_SERVER['REQUEST_URI'], '/school/')) ? 'active' : ''; ?>">
<a class="nav-link" href="/school_budget/school/index.php">
<i class="bi bi-wallet2"></i> งบประมาณของฉัน
</a>
</li>
<?php endif; ?>
<li class="nav-item ms-lg-2 my-2 my-lg-0">
<span class="user-profile-badge <?php echo ($_SESSION['role'] == 'admin') ? 'admin-badge' : ''; ?>">
<?php if ($_SESSION['role'] == 'admin'): ?>
<i class="bi bi-shield-lock-fill"></i>
<span>ผู้ดูแลระบบ: <?php echo htmlspecialchars($_SESSION['username']); ?></span>
<?php else: ?>
<i class="bi bi-building-check text-primary"></i>
<span><?php echo (isset($_SESSION['school_name']) && !empty($_SESSION['school_name'])) ? htmlspecialchars($_SESSION['school_name']) : htmlspecialchars($_SESSION['username']); ?></span>
<?php endif; ?>
</span>
</li>
<li class="nav-item ms-lg-1">
<a class="btn btn-outline-danger btn-sm px-3 rounded-pill" href="/school_budget/logout.php">
<i class="bi bi-box-arrow-right"></i> ออกจากระบบ
</a>
</li>
<?php else: ?>
<li class="nav-item ms-lg-2">
<a class="btn btn-primary btn-sm px-4 rounded-pill shadow-sm" href="/school_budget/login.php">
<i class="bi bi-box-arrow-in-right"></i> เข้าสู่ระบบ
</a>
</li>
<?php endif; ?>
</ul>
</div>
</div>
</nav>
<div class="container container-main">