137 lines
7.4 KiB
PHP
137 lines
7.4 KiB
PHP
<?php
|
|
require_once 'config.php';
|
|
checkLogin();
|
|
|
|
$topbar_text = getSystemSetting('topbar_text', 'ระบบตรวจสอบข้อมูล HOSxP');
|
|
$footer_text = getSystemSetting('footer_text', 'หน่วยงานสุขภาพดิจิทัล โรงพยาบาลเกาะสมุย');
|
|
|
|
// Fetch history
|
|
try {
|
|
$log_db = getDB(DB_LOG_HOST, DB_LOG_NAME, DB_LOG_USER, DB_LOG_PASS);
|
|
$stmt = $log_db->query("SELECT l.*, p.profile_name FROM export_logs l LEFT JOIN export_profiles p ON l.profile_id = p.id ORDER BY l.upload_datetime DESC");
|
|
$logs = $stmt->fetchAll();
|
|
} catch (Exception $e) {
|
|
$logs = [];
|
|
$error = "ไม่สามารถเชื่อมต่อฐานข้อมูลประวัติได้ (อาจจะยังไม่ได้สร้างตาราง)";
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="th">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>ประวัติการทำงาน - <?php echo htmlspecialchars($topbar_text); ?></title>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<link href="https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600&display=swap" rel="stylesheet">
|
|
<!-- DataTables CSS -->
|
|
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css">
|
|
<link rel="icon" href="assets/img/logo.png" type="image/png">
|
|
<style>
|
|
body { font-family: 'Sarabun', sans-serif; }
|
|
|
|
/* Custom DataTables Styling */
|
|
.dataTables_wrapper { padding: 1rem 0; }
|
|
.dataTables_wrapper .dataTables_filter input {
|
|
border: 1px solid #d1d5db; border-radius: 0.5rem; padding: 0.35rem 0.75rem; margin-left: 0.5rem; outline: none; transition: all 0.2s;
|
|
}
|
|
.dataTables_wrapper .dataTables_filter input:focus {
|
|
border-color: #10b981; box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
|
|
}
|
|
.dataTables_wrapper .dataTables_length select {
|
|
border: 1px solid #d1d5db; border-radius: 0.5rem; padding: 0.25rem 1.5rem 0.25rem 0.75rem; margin: 0 0.5rem; outline: none;
|
|
}
|
|
.dataTables_wrapper .dataTables_filter,
|
|
.dataTables_wrapper .dataTables_length {
|
|
margin-bottom: 1rem;
|
|
}
|
|
table.dataTable.no-footer { border-bottom: 1px solid #e5e7eb; margin-top: 1rem !important; margin-bottom: 1rem !important; }
|
|
table.dataTable thead th {
|
|
border-bottom: 2px solid #e5e7eb; background-color: #f3f4f6; color: #374151; font-weight: 600; padding: 0.75rem 1rem; white-space: nowrap; text-align: center;
|
|
}
|
|
table.dataTable tbody td {
|
|
border-bottom: 1px solid #f3f4f6; padding: 1rem; color: #4b5563; vertical-align: top;
|
|
}
|
|
table.dataTable tbody tr:hover { background-color: #f9fafb; }
|
|
.dataTables_wrapper .dataTables_paginate .paginate_button {
|
|
padding: 0.35rem 0.85rem; margin-left: 0.25rem; border: 1px solid #d1d5db; border-radius: 0.5rem; background: white; color: #374151 !important; transition: all 0.2s; font-size: 0.875rem;
|
|
}
|
|
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
|
|
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
|
|
background: #10b981 !important; color: white !important; border-color: #10b981; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
}
|
|
.dataTables_wrapper .dataTables_paginate .paginate_button:not(.current):hover {
|
|
background: #f3f4f6 !important; border-color: #d1d5db; color: #111827 !important;
|
|
}
|
|
.dataTables_wrapper .dataTables_info { color: #6b7280; font-size: 0.875rem; padding-top: 0.85rem; }
|
|
</style>
|
|
</head>
|
|
<body class="bg-gray-100 flex flex-col min-h-screen">
|
|
|
|
<!-- Top Navigation -->
|
|
<?php include 'topbar.php'; ?>
|
|
|
|
<div class="max-w-7xl mx-auto py-8 px-4 sm:px-6 lg:px-8">
|
|
|
|
<div class="bg-white shadow rounded-lg mb-8">
|
|
<div class="px-6 py-5 border-b border-gray-200">
|
|
<h3 class="text-lg font-medium text-gray-900">ประวัติการทำงาน</h3>
|
|
<p class="mt-1 text-sm text-gray-500">แสดงประวัติการนำเข้าไฟล์และค้นหาข้อมูลทั้งหมด</p>
|
|
</div>
|
|
<div class="px-6 py-5 overflow-x-auto">
|
|
<?php if(isset($error)): ?>
|
|
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4 text-sm" role="alert">
|
|
<span class="block sm:inline"><?php echo htmlspecialchars($error); ?></span>
|
|
</div>
|
|
<?php else: ?>
|
|
<table id="historyTable" class="display w-full text-sm">
|
|
<thead>
|
|
<tr>
|
|
<th>ลำดับ</th>
|
|
<th>ชุดข้อมูล</th>
|
|
<th>ผู้ใช้งาน</th>
|
|
<th>ชื่อไฟล์</th>
|
|
<th>จำนวนที่นำเข้า</th>
|
|
<th>จำนวนที่พบ</th>
|
|
<th>วัน-เวลาที่อัปโหลด</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach($logs as $log): ?>
|
|
<tr>
|
|
<td class="text-center align-middle"><?php echo htmlspecialchars($log['id']); ?></td>
|
|
<td class="align-middle"><?php echo htmlspecialchars($log['profile_name'] ?? 'ไม่มีข้อมูล'); ?></td>
|
|
<td class="text-center align-middle"><?php echo htmlspecialchars($log['username']); ?></td>
|
|
<td class="align-middle"><?php echo htmlspecialchars($log['file_name']); ?></td>
|
|
<td class="text-center align-middle"><?php echo htmlspecialchars($log['total_rows']); ?></td>
|
|
<td class="text-center align-middle"><?php echo htmlspecialchars($log['found_rows']); ?></td>
|
|
<td class="text-center align-middle">
|
|
<?php echo htmlspecialchars(formatThaiDate($log['upload_datetime'])); ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php include 'footer.php'; ?>
|
|
|
|
<!-- jQuery and DataTables -->
|
|
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
|
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#historyTable').DataTable({
|
|
"language": {
|
|
"url": "//cdn.datatables.net/plug-ins/1.13.6/i18n/th.json"
|
|
},
|
|
"order": [[ 6, "desc" ]] // เรียงตามวันที่ล่าสุด (คอลัมน์ที่ 7, index 6)
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|