Files
gravity/hosxp-webservice/_OLD/v2_blue/search_hn.php
T
2026-09-16 23:20:08 +07:00

109 lines
4.5 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 rel="icon" type="image/png" sizes="16x16" href="favicon1.ico">
<link rel="stylesheet" href="css/styles.css" type="text/css" />
<style>
.app-layout { display: flex; min-height: 100vh; }
.main-content { flex: 1; padding: 0 20px 20px 20px; overflow-y: auto; height: 100vh; }
.search-box { display:flex; gap: 16px; align-items:center; margin-bottom: 24px; }
</style>
</head>
<body>
<div class="app-layout">
<?php require_once("includes/sidebar.php"); ?>
<main class="main-content">
<?php require_once("includes/header.php"); ?>
<div class="content-wrapper">
<div class="glass-panel" style="animation: slideUp 0.5s ease;">
<div class="glass-header">
<h2>ค้นหาข้อมูลผู้รับบริการ จาก HN</h2>
</div>
<form id="searchForm" class="search-box">
<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.5rem;" 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="margin-bottom:16px; color:var(--text-dark);">ผลการค้นหา</h3>
<div class="table-responsive">
<table class="modern-table">
<thead>
<tr>
<th style="width: 80px;">ลำดับที่</th>
<th>HN</th>
<th>ชื่อ - สกุล</th>
<th>เลขบัตรประชาชน</th>
<th style="width: 120px; text-align: center;">ดูข้อมูล</th>
</tr>
</thead>
<tbody id="resultBody">
<tr>
<td colspan="5" style="text-align:center; color:var(--text-muted);">กรุณาระบุคำค้นหา</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</main>
</div>
<script src="js/app.js"></script>
<style>
@keyframes slideUp {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
</style>
<script>
document.getElementById('searchForm').addEventListener('submit', function(e) {
e.preventDefault();
const hn = document.getElementById('hn').value;
const resultBody = document.getElementById('resultBody');
resultBody.innerHTML = '<tr><td colspan="5" style="text-align:center; color:var(--primary);">กำลังค้นหา...</td></tr>';
// Since we dropped jQuery, use fetch
fetch('search_hn2.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: 'hn=' + encodeURIComponent(hn)
})
.then(response => response.text())
.then(html => {
// Because the original search_hn2.php returned raw TR elements, we can just dump it
resultBody.innerHTML = html;
})
.catch(error => {
console.error('Error:', error);
resultBody.innerHTML = '<tr><td colspan="5" style="text-align:center; color:var(--danger);">เกิดข้อผิดพลาดในการเชื่อมต่อ</td></tr>';
});
});
</script>
</body>
</html>