89 lines
4.0 KiB
PHP
89 lines
4.0 KiB
PHP
<?php
|
|
session_start();
|
|
if (empty($_SESSION['sess_userid']) || $_SESSION['sess_userid'] !== session_id()) {
|
|
header("Location: index.php");
|
|
exit();
|
|
}
|
|
$account = $_SESSION['account'];
|
|
$name = $_SESSION['name'];
|
|
$position = $_SESSION['position'];
|
|
$ip = $_SESSION['ip'];
|
|
$page_link = "search_hn.php";
|
|
|
|
require_once("config/db.php");
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="th">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>HOSxP Web Service | ค้นหาจาก HN</title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/style.css" type="text/css" />
|
|
<style>
|
|
.search-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
|
|
.search-table th, .search-table td { border: 1px solid var(--border); padding: 0.75rem; text-align: center; }
|
|
.search-table th { background-color: rgba(37, 99, 235, 0.05); color: var(--text-main); font-weight: 600; }
|
|
.search-table tr:hover { background-color: rgba(0,0,0,0.02); }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="app-container">
|
|
<?php require_once("includes/sidebar.php"); ?>
|
|
|
|
<main class="main-content">
|
|
<?php require_once("includes/header.php"); ?>
|
|
|
|
<div class="content-wrapper animate-fade-in">
|
|
<div class="card">
|
|
<div class="card-title">ค้นหาข้อมูลผู้รับบริการ จาก HN</div>
|
|
|
|
<form id="searchForm" style="display:flex; gap:1rem; margin-bottom: 2rem; align-items:center;">
|
|
<input type="text" id="hn" class="form-control" placeholder="ระบุเลข HN ที่ต้องการค้นหา" style="max-width: 300px;" required>
|
|
<button type="submit" class="btn btn-primary">
|
|
<svg style="width:16px;height:16px;display:inline;vertical-align:middle;margin-right:0.25rem;" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg>
|
|
ค้นหาข้อมูล
|
|
</button>
|
|
</form>
|
|
|
|
<h3 style="font-size:1.1rem; margin-bottom:0.5rem; color:var(--text-main);">ผลการค้นหา (จำกัด 5 รายการ)</h3>
|
|
<div style="overflow-x:auto;">
|
|
<table class="search-table">
|
|
<thead>
|
|
<tr>
|
|
<th>ลำดับที่</th>
|
|
<th>HN</th>
|
|
<th>ชื่อ - สกุล</th>
|
|
<th>เลขบัตรประชาชน</th>
|
|
<th>ดูข้อมูล</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="resultTableBody">
|
|
<tr><td colspan="5" style="color:var(--text-muted); padding:2rem;">กรุณากรอก HN และกดค้นหา</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
|
|
<script>
|
|
document.getElementById('searchForm').addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
const hn = document.getElementById('hn').value;
|
|
const tbody = document.getElementById('resultTableBody');
|
|
tbody.innerHTML = '<tr><td colspan="5">กำลังค้นหา...</td></tr>';
|
|
|
|
fetch('search_hn2.php?hn=' + encodeURIComponent(hn))
|
|
.then(response => response.text())
|
|
.then(html => {
|
|
tbody.innerHTML = html;
|
|
})
|
|
.catch(err => {
|
|
tbody.innerHTML = '<tr><td colspan="5" class="text-danger">เกิดข้อผิดพลาดในการค้นหา</td></tr>';
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|