Initial commit

This commit is contained in:
Porawit Dongwang
2026-09-16 23:20:08 +07:00
commit 0041668dbb
32577 changed files with 3687927 additions and 0 deletions
+95
View File
@@ -0,0 +1,95 @@
<?php
session_start();
require_once("config/db.php");
require_once('inc/rfc6238.php');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header("Location: index.php");
exit();
}
$user = $_POST['username'] ?? '';
$pass = $_POST['password'] ?? '';
$currentcode = $_POST['2fa_auth'] ?? '';
$ip = $_POST['show_ip'] ?? $_SERVER['REMOTE_ADDR'];
$os = $_POST['user_os'] ?? 'Unknown';
$browser = $_POST['user_browser'] ?? 'Unknown';
$md5_pass = md5($pass);
$timezone = "Asia/Bangkok";
date_default_timezone_set($timezone);
$thistime = date("Y-m-d H:i:s");
// Helper function to log auth
function log_auth($conn2, $user, $ip, $os, $browser, $thistime, $status) {
try {
// Use the exact insert structure from the original code
$sql = "INSERT INTO login_authen VALUES (null, ?, ?, ?, ?, ?, ?)";
$stmt = $conn2->prepare($sql);
if ($stmt) {
$stmt->bind_param("ssssss", $user, $ip, $os, $browser, $thistime, $status);
$stmt->execute();
$stmt->close();
}
} catch (Exception $e) {
// Ignore logging errors so they don't break the login flow
error_log("Login Auth Log Error: " . $e->getMessage());
}
}
try {
//------- Check Block IP ----------
$stmt_block = $conn2->prepare("SELECT block_ip_number FROM block_ip WHERE block_ip_number = ?");
$stmt_block->bind_param("s", $ip);
$stmt_block->execute();
$stmt_block->store_result();
if ($stmt_block->num_rows >= 1) {
$stmt_block->close();
echo '<div style="display:flex; justify-content:center; align-items:center; height:100vh; font-family:sans-serif; color:red; font-size:1.5rem;"><b>Your IP is Blocked !!!</b></div>';
exit();
}
$stmt_block->close();
//------- Check User Credentials ----------
$stmt_user = $conn1->prepare("SELECT loginname, name, entryposition, two_fa_secret_key_samui FROM opduser WHERE loginname = ? AND passweb = ? AND two_fa_secret_key_samui IS NOT NULL AND account_disable='N'");
$stmt_user->bind_param("ss", $user, $md5_pass);
$stmt_user->execute();
$result_user = $stmt_user->get_result();
if ($result_user->num_rows === 1) {
$row = $result_user->fetch_assoc();
$account = $row['loginname'];
$name = $row['name'];
$position = $row['entryposition'];
$fa_secretkey = $row['two_fa_secret_key_samui'];
if (TokenAuth6238::verify($fa_secretkey, $currentcode)) {
session_regenerate_id(true); // Prevent session fixation
$_SESSION['sess_userid'] = session_id();
$_SESSION['account'] = $account;
$_SESSION['name'] = $name;
$_SESSION['position'] = $position;
$_SESSION['ip'] = $ip;
log_auth($conn2, $user, $ip, $os, $browser, $thistime, "Login Success");
header("Location: main.php");
exit();
} else {
log_auth($conn2, $user, $ip, $os, $browser, $thistime, "2FA Authen Fail");
header("Location: error.php?message=Pass+Code");
exit();
}
} else {
log_auth($conn2, $user, $ip, $os, $browser, $thistime, "User/Pass Fail");
header("Location: error.php?message=" . urlencode("บัญชีผู้ใช้ / รหัสผ่าน"));
exit();
}
} catch (Exception $e) {
// If something crashes completely, show error
error_log("Authen Error: " . $e->getMessage());
header("Location: error.php?message=" . urlencode("ระบบฐานข้อมูลขัดข้อง"));
exit();
}
?>
@@ -0,0 +1,86 @@
<?php
$user_agent = $_SERVER['HTTP_USER_AGENT'];
function getOS()
{
global $user_agent;
$os_platform = "Unknown OS Platform";
$os_array = array(
'/windows nt 10.0/i' => 'Windows 10/11',
'/windows nt 6.3/i' => 'Windows 8.1',
'/windows nt 6.2/i' => 'Windows 8',
'/windows nt 6.1/i' => 'Windows 7',
'/windows nt 6.0/i' => 'Windows Vista',
'/windows nt 5.2/i' => 'Windows Server 2003/XP x64',
'/windows nt 5.1/i' => 'Windows XP',
'/windows xp/i' => 'Windows XP',
'/windows nt 5.0/i' => 'Windows 2000',
'/windows me/i' => 'Windows ME',
'/win98/i' => 'Windows 98',
'/win95/i' => 'Windows 95',
'/win16/i' => 'Windows 3.11',
'/macintosh|mac os x/i' => 'Mac OS X',
'/mac_powerpc/i' => 'Mac OS 9',
'/linux/i' => 'Linux',
'/ubuntu/i' => 'Ubuntu',
'/iphone/i' => 'iPhone',
'/ipod/i' => 'iPod',
'/ipad/i' => 'iPad',
'/android/i' => 'Android',
'/blackberry/i' => 'BlackBerry',
'/webos/i' => 'Mobile'
);
foreach ($os_array as $regex => $value) {
if (preg_match($regex, $user_agent)) {
$os_platform = $value;
}
}
return $os_platform;
}
function getBrowser()
{
global $user_agent;
$browser = "Unknown Browser";
$browser_array = array(
'/edg/i' => 'Microsoft Edge',
'/msie/i' => 'Internet Explorer',
'/firefox/i' => 'Firefox',
'/safari/i' => 'Safari',
'/chrome/i' => 'Chrome',
'/opera/i' => 'Opera',
'/netscape/i' => 'Netscape',
'/maxthon/i' => 'Maxthon',
'/konqueror/i' => 'Konqueror',
'/mobile/i' => 'Handheld Browser'
);
foreach ($browser_array as $regex => $value) {
if (preg_match($regex, $user_agent)) {
$browser = $value;
}
}
return $browser;
}
$user_os = getOS();
$user_browser = getBrowser();
$show_ip = $_SERVER['REMOTE_ADDR'];
//$device_details = "<strong>Browser: </strong>".$user_browser."<br /><strong>Operating System: </strong>".$user_os."";
//print_r($device_details);
//echo("<br /><br /><br />".$_SERVER['HTTP_USER_AGENT']."");
@@ -0,0 +1,340 @@
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
:root {
--bg-gradient: linear-gradient(135deg, #f0f9ff 0%, #cffafe 100%);
--glass-bg: rgba(255, 255, 255, 0.7);
--glass-border: rgba(255, 255, 255, 0.5);
--glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
--text-dark: #1e293b;
--text-light: #64748b;
--primary: #0284c7;
--primary-hover: #0369a1;
--danger: #ef4444;
--success: #10b981;
--warning: #f59e0b;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'Inter', sans-serif;
background: var(--bg-gradient);
background-attachment: fixed;
color: var(--text-dark);
min-height: 100vh;
display: flex;
flex-direction: column;
overflow-x: hidden;
}
a {
text-decoration: none;
color: var(--primary);
transition: color 0.3s ease;
}
a:hover {
color: var(--primary-hover);
}
/* Glassmorphism Classes */
.glass-panel {
background: var(--glass-bg);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid var(--glass-border);
box-shadow: var(--glass-shadow);
border-radius: 16px;
padding: 24px;
margin-bottom: 24px;
}
.glass-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
border-bottom: 1px solid rgba(0,0,0,0.05);
padding-bottom: 16px;
}
.glass-header h2, .glass-header h3, .glass-header h4 {
color: var(--primary);
font-weight: 600;
margin: 0;
}
/* Typography */
h1, h2, h3, h4, h5 {
color: var(--text-dark);
font-weight: 600;
}
.text-muted {
color: var(--text-light);
font-size: 0.9rem;
}
/* Buttons */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 10px 20px;
border-radius: 8px;
border: none;
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s ease;
outline: none;
text-decoration: none;
}
.btn:active {
transform: scale(0.96);
}
.btn-primary {
background: var(--primary);
color: white;
box-shadow: 0 4px 12px rgba(2, 132, 199, 0.2);
}
.btn-primary:hover {
background: var(--primary-hover);
color: white;
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(2, 132, 199, 0.3);
}
.btn-danger {
background: var(--danger);
color: white;
}
.btn-danger:hover { background: #dc2626; }
.btn-success {
background: var(--success);
color: white;
}
/* Forms */
.form-group {
margin-bottom: 20px;
}
.form-label {
display: block;
font-size: 0.9rem;
font-weight: 500;
margin-bottom: 8px;
color: var(--text-dark);
}
.form-control {
width: 100%;
padding: 12px 16px;
border-radius: 8px;
border: 1px solid rgba(0,0,0,0.1);
background: rgba(255,255,255,0.8);
font-size: 1rem;
transition: all 0.3s ease;
font-family: 'Inter', sans-serif;
}
.form-control:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
background: #fff;
}
/* Layouts */
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
width: 100%;
}
.flex-center {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
.grid-2 {
display: grid;
grid-template-columns: 1fr 2fr;
gap: 24px;
}
@media (max-width: 768px) {
.grid-2 {
grid-template-columns: 1fr;
}
}
/* Tables */
.table-responsive {
overflow-x: auto;
border-radius: 8px;
}
.modern-table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
text-align: left;
}
.modern-table th {
background: rgba(0,0,0,0.03);
padding: 14px 16px;
font-weight: 600;
font-size: 0.85rem;
color: var(--text-light);
text-transform: uppercase;
letter-spacing: 0.5px;
border-bottom: 1px solid rgba(0,0,0,0.1);
}
.modern-table td {
padding: 14px 16px;
border-bottom: 1px solid rgba(0,0,0,0.05);
font-size: 0.95rem;
}
.modern-table tbody tr {
transition: background 0.2s ease;
}
.modern-table tbody tr:hover {
background: rgba(255,255,255,0.5);
}
.modern-table tbody tr:last-child td {
border-bottom: none;
}
/* Badges */
.badge {
display: inline-block;
padding: 4px 10px;
border-radius: 20px;
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
}
.badge-info {
background: rgba(2, 132, 199, 0.1);
color: var(--primary);
}
.badge-warning {
background: rgba(245, 158, 11, 0.1);
color: #d97706;
}
.badge-danger {
background: rgba(239, 68, 68, 0.1);
color: #dc2626;
}
/* Utility */
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.text-danger { color: var(--danger); }
/* Navbar */
.navbar {
background: var(--glass-bg);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border-bottom: 1px solid var(--glass-border);
padding: 16px 24px;
display: flex;
justify-content: space-between;
align-items: center;
position: sticky;
top: 0;
z-index: 100;
}
.navbar-brand {
font-size: 1.25rem;
font-weight: 700;
color: var(--primary);
display: flex;
align-items: center;
gap: 10px;
}
.navbar-menu {
display: flex;
gap: 16px;
align-items: center;
}
/* User Card */
.user-info-card {
display: flex;
align-items: center;
gap: 16px;
}
.user-avatar {
width: 60px;
height: 60px;
border-radius: 50%;
background: var(--primary);
color: white;
display: flex;
align-items: center;
justify-content: center;
font-size: 24px;
font-weight: 600;
box-shadow: 0 4px 10px rgba(2,132,199,0.3);
}
/* Search Box */
.search-box {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
.search-box input {
flex: 1;
}
/* Patient Details Layout */
.top-info { display: flex; gap: 24px; }
.top-info-left { width: 140px; flex-shrink: 0; }
.top-info-left img { width: 100%; height: auto; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.top-info-right { flex-grow: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 768px) {
.top-info { flex-direction: column; }
.top-info-right { grid-template-columns: 1fr; }
}
h4.widgettitle {
font-size: 1.15rem;
color: var(--primary);
margin-top: 0;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 1px solid rgba(0,0,0,0.05);
display: flex;
align-items: center;
gap: 8px;
}
@@ -0,0 +1,489 @@
<?php
//--------------------------------------ฟังก์ชันแปลงวันเป็นภาษาไทยแบบเต็ม------------------------------------------------//
function thai_date($date)
{
list($year, $month, $day) = explode('-', $date);
if ($day < 10) {
$day = substr($day, 1, 1);
}
$thMonth = array("ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
if ($month < 10) {
$month = substr($month, 1, 1);
}
$year += 543;
return $day . "&nbsp;" . $thMonth[$month - 1] . "&nbsp;" . $year;
}
//---------------------------------ฟังก์ชันแปลงวันเป็นภาษาไทยแบบเต็ม-----------------------------------------------------//
//--------------------------------------ฟังก์ชันแปลงเดือนเป็นภาษาไทยแบบเต็ม------------------------------------------------//
function thai_month($date)
{
list($year, $month, $day) = explode('-', $date);
if ($day < 10) {
$day = substr($day, 1, 1);
}
$thMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
if ($month < 10) {
$month = substr($month, 1, 1);
}
$year += 543;
return $thMonth[$month - 1] . "&nbsp;" . $year;
}
//---------------------------------ฟังก์ชันแปลงเดือนเป็นภาษาไทยแบบเต็ม-----------------------------------------------------//
//--------------------------------------ฟังก์ชันแปลงวันเป็นภาษาไทย2------------------------------------------------//
function thai_date2($date)
{
list($year, $month, $day) = explode('-', $date);
$year += 543;
return $day . "-" . $month . "-" . $year;
}
function thai_date3($date)
{
list($year, $month, $day) = explode('-', $date);
return $day . "-" . $month . "-" . $year;
}
function thai_date5($date)
{
list($day, $month, $year) = explode('-', $date);
if ($day < 10) {
$day = substr($day, 1, 1);
}
$thMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
if ($month < 10) {
$month = substr($month, 1, 1);
}
return $day . "&nbsp;" . $thMonth[$month - 1] . "&nbsp;พ.ศ.&nbsp;" . $year;
}
function thai_date6($date)
{
list($year, $month, $day) = explode('-', $date);
if ($day < 10) {
$day = substr($day, 1, 1);
}
$thMonth = array("ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
if ($month < 10) {
$month = substr($month, 1, 1);
}
$year = $year + 543;
return $day . "&nbsp;" . $thMonth[$month - 1] . "&nbsp;" . $year;
}
function thai_date7($date)
{
list($year, $month, $day) = explode('-', $date);
if ($day < 10) {
$day = substr($day, 1, 1);
}
$thMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
if ($month < 10) {
$month = substr($month, 1, 1);
}
$year = $year + 543;
return "วันที่ " . $day . "&nbsp;" . $thMonth[$month - 1] . "&nbsp;พ.ศ.&nbsp;" . $year;
}
function thai_date8($date)
{
list($day, $month, $year) = explode('-', $date);
if ($day < 10) {
$day = substr($day, 1, 1);
}
$thMonth = array("ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
if ($month < 10) {
$month = substr($month, 1, 1);
}
return $day . "&nbsp;" . $thMonth[$month - 1] . "&nbsp;" . $year;
}
function novel_date1($date)
{
list($year, $month, $day) = explode('-', $date);
return $day . "/" . $month . "/" . $year;
}
function thai_date9($date)
{
list($year, $month, $day) = explode('-', $date);
$year += 543;
return $day . "/" . $month . "/" . $year;
}
//---------------------------------ฟังก์ชันแปลงวันเป็นภาษาไทย2-----------------------------------------------------//
//--------------------------------------ฟังก์ชันแปลงวันเป็นรูปแบบของ mysql------------------------------------------------//
function mysql_date1($date)
{
list($day, $month, $year) = explode('-', $date);
switch ($month) {
case "ม.ค.":
$thMonth = "01";
break;
case "ก.พ.":
$thMonth = "02";
break;
case "มี.ค.":
$thMonth = "03";
break;
case "เม.ย.":
$thMonth = "04";
break;
case "พ.ค.":
$thMonth = "05";
break;
case "มิ.ย.":
$thMonth = "06";
break;
case "ก.ค.":
$thMonth = "07";
break;
case "ส.ค.":
$thMonth = "08";
break;
case "ก.ย.":
$thMonth = "09";
break;
case "ต.ค.":
$thMonth = "10";
break;
case "พ.ย.":
$thMonth = "11";
break;
case "ธ.ค.":
$thMonth = "12";
break;
}
$year = $year - 543;
return $year . "-" . $thMonth . "-" . $day;
}
function mysql_date2($date)
{
list($null, $day, $month, $year) = explode('-', $date);
switch ($month) {
case "ม.ค.":
$thMonth = "01";
break;
case "ก.พ.":
$thMonth = "02";
break;
case "มี.ค.":
$thMonth = "03";
break;
case "เม.ย.":
$thMonth = "04";
break;
case "พ.ค.":
$thMonth = "05";
break;
case "มิ.ย.":
$thMonth = "06";
break;
case "ก.ค.":
$thMonth = "07";
break;
case "ส.ค.":
$thMonth = "08";
break;
case "ก.ย.":
$thMonth = "09";
break;
case "ต.ค.":
$thMonth = "10";
break;
case "พ.ย.":
$thMonth = "11";
break;
case "ธ.ค.":
$thMonth = "12";
break;
}
$year = $year - 543;
return $year . "-" . $thMonth . "-" . $day;
}
function mysql_date3($date)
{
@list($day, $month, $year) = @explode('-', $date);
return $year . "-" . $month . "-" . $day;
}
//--------------------------------ฟังก์ชันแปลงวันเป็นรูปแบบของ mysql------------------------------------------------------//
//--------------------------------------ฟังก์ชันแบ่งช่วงของวัน------------------------------------------------//
function explode_date1($date)
{
list($date1, $date2) = explode('-', $date);
return mysql_date1($date1);
}
function explode_date2($date)
{
list($date1, $date2) = explode('-', $date);
$new_date2 = mysql_date2($date2);
if ($new_date2 == "-543--") {
echo "";
} else {
return $new_date2;
}
}
//---------------------------------ฟังก์ชันแบ่งช่วงของวัน-----------------------------------------------------//
//--------------------------------------ฟังก์ชันแปลงวันเป็นรูปแบบเลขที่ใบสมัคร------------------------------------------------//
function code_date($date)
{
list($year, $month, $day) = explode('-', $date);
$Month = $month;
$year += 543;
$sYear = substr($year, 2, 2);
return $sYear . $day . $Month;
}
//---------------------------------ฟังก์ชันแปลงวันเป็นรูปแบบเลขที่ใบสมัคร-----------------------------------------------------//
//--------------------------------------ฟังก์ชันแยกชื่อ-นามสกุลไฟล์------------------------------------------------//
function explode_filename($filename)
{
list($name, $ext) = explode('.', $filename);
return $name;
}
function explode_extname($filename)
{
list($name, $ext) = explode('.', $filename);
return $ext;
}
//---------------------------------ฟังก์ชันแยกชื่อ-นามสกุลไฟล์-----------------------------------------------------//
//--------------------------------------ฟังก์ชันแบ่งชื่อ------------------------------------------------//
function split_fname($name)
{
list($fname, $lname) = explode(' ', $name);
return $fname;
}
function split_lname($name)
{
list($fname, $lname) = explode(' ', $name);
return $lname;
}
//---------------------------------ฟังก์ชันแบ่งชื่อ-----------------------------------------------------//
//--------------------------------------ฟังก์ชันแปลงวันเวลาเป็นวัน------------------------------------------------//
function datetime_to_date($date)
{
list($date1, $time) = explode(' ', $date);
list($year, $month, $day) = explode('-', $date1);
$year += 543;
return $day . "-" . $month . "-" . $year;
}
function datetime_to_date2($date)
{
list($date1, $time) = explode('-', $date);
return $date1;
}
//---------------------------------ฟังก์ชันแปลงวันเวลาเป็นวัน-----------------------------------------------------//
//--------------------------------------ฟังก์ชันแปลงวันเวลาเป็นเวลา------------------------------------------------//
function datetime_to_time($date)
{
list($date1, $time) = explode(' ', $date);
list($hh, $mm, $ss) = explode(':', $time);
return $hh . ":" . $mm;
}
//---------------------------------ฟังก์ชันแปลงวันเวลาเป็นเวลา-----------------------------------------------------//
//------------------------ตัดคำ----------------------------------------------------//
//------------------------------ฟังก์ชั่นตั้งชื่อไฟล์จากวันเวลา------------------------------------------------//
function gen_filename($date)
{
list($date1, $time) = explode(' ', $date);
list($year, $month, $day) = explode('-', $date1);
list($hh, $mm, $ss) = explode(':', $time);
$year += 543;
$year2 = substr($year, 2, 2);
return $year2 . "" . $month . "" . $day . "" . $hh . "" . $mm . "" . $ss;
}
//---------------------------------ฟังก์ชันแปลงวันเวลาเป็นเวลา-----------------------------------------------------//
//------------------------ตัดคำ----------------------------------------------------//
function cutStr($str, $maxChars = '', $holder = '')
{
if (strlen($str) > $maxChars) {
$str = iconv_substr($str, 0, $maxChars, "UTF-8") . $holder;
}
return $str;
}
//--------------------------------------ฟังก์ชันแยกเดือน-ปี------------------------------------------------//
function showDate($today)
{
list($year, $month, $date) = explode('-', $today);
return $date;
}
function showDate2($today)
{
list($year, $month, $date) = explode('-', $today);
return $date;
}
function showMonth($today)
{
list($year, $month, $date) = explode('-', $today);
return $month;
}
function showMonth2($today)
{
list($year, $month, $date) = explode('-', $today);
return $month;
}
function showYear($today, $date)
{
list($year, $month, $date) = explode('-', $today);
return $year;
}
function showYear2($today, $date)
{
list($year, $month, $date) = explode('-', $today);
return $year;
}
function showAll($today)
{
list($year, $month, $date) = explode('-', $today);
$thMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
if ($month < 10) {
$month = substr($month, 1, 1);
}
$year += 543;
return $thMonth[$month - 1] . "&nbsp;พ.ศ.&nbsp;" . $year;
}
function showAll2($today)
{
list($year, $month, $date) = explode('-', $today);
$thMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
if ($month < 10) {
$month = substr($month, 1, 1);
}
$year += 543;
return $date . " " . $thMonth[$month - 1] . "&nbsp;พ.ศ.&nbsp;" . $year;
}
function typeFile($name)
{
list($f, $l) = explode('.', $name);
return $l;
}
//--------------------------------------ฟังก์ชันแยกเดือน-ปี------------------------------------------------//
//--------------------------------------ฟังก์ชันแยกชื่อ-นามสกุล------------------------------------------------//
function explode_fname($data)
{
list($fname, $lname) = explode(' ', $data);
return $fname;
}
function explode_lname($data)
{
list($fname, $lname) = explode(' ', $data);
return $lname;
}
//---------------------------------ฟังก์ชันแยกชื่อ-นามสกุล-----------------------------------------------------//
//------------------ วันนี้ แยก วัน เดือน ปี -------------------------------------
function today_date($date)
{
list($year, $month, $day) = explode('-', $date);
if ($day < 10) {
$day = substr($day, 1, 1);
}
return $day;
}
function today_month($date)
{
list($year, $month, $day) = explode('-', $date);
$thMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
if ($month < 10) {
$month = substr($month, 1, 1);
}
return $thMonth[$month - 1];
}
function today_year($date)
{
list($year, $month, $day) = explode('-', $date);
$year = $year + 543;
return $year;
}
+75
View File
@@ -0,0 +1,75 @@
<?php
$error_message = $_GET['message'] ?? 'ข้อผิดพลาดที่ไม่ทราบสาเหตุ';
$error_message = htmlspecialchars($error_message);
?>
<!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 | ERROR</title>
<link rel="icon" type="image/png" sizes="16x16" href="favicon1.ico">
<link rel="stylesheet" href="css/styles.css" type="text/css" />
<style>
body.error-page {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
.error-card {
width: 100%;
max-width: 400px;
padding: 40px;
text-align: center;
border-top: 4px solid var(--danger);
}
.error-logo {
margin-bottom: 24px;
color: var(--danger);
animation: shake 0.5s;
}
@keyframes shake {
0%, 100% { transform: translateX(0); }
25% { transform: translateX(-10px); }
75% { transform: translateX(10px); }
}
</style>
<script>
function coolRedirect(url) {
let timerEl = document.getElementById("COOL_REDIRECT");
let cTicks = 5;
let timer = setInterval(function() {
cTicks--;
if (cTicks > 0) {
timerEl.innerHTML = cTicks;
} else {
clearInterval(timer);
timerEl.innerHTML = "กำลังกลับไปที่หน้าล็อกอิน...";
location.href = url;
}
}, 1000);
}
</script>
</head>
<body class="error-page" onload="coolRedirect('index.php')">
<div class="glass-panel error-card">
<div class="error-logo">
<svg style="width:64px;height:64px; margin:auto;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
</svg>
</div>
<h2 style="color:var(--danger); margin-bottom: 16px;">เข้าสู่ระบบไม่สำเร็จ</h2>
<p style="font-size:1.1rem; color:var(--text-dark); margin-bottom: 8px;">
<strong><?php echo $error_message; ?></strong> ไม่ถูกต้อง
</p>
<p class="text-muted">กรุณาตรวจสอบอีกครั้ง</p>
<div style="margin-top: 30px; font-size: 0.95rem; color: var(--text-light);">
กลับไปหน้าแรกใน <span id="COOL_REDIRECT" style="font-weight:bold; color:var(--primary);">5</span> วินาที
</div>
<a href="index.php" class="btn btn-primary" style="margin-top: 20px; width:100%;">กลับไปหน้าแรกลิงก์นี้</a>
</div>
</body>
</html>
@@ -0,0 +1,50 @@
<?php
// includes/header.php
?>
<header class="navbar" style="margin-bottom: 24px; border-radius: 16px; margin-top: 20px; margin-right: 20px;">
<div class="navbar-brand">
<span id="date_time" style="font-size: 0.95rem; font-weight: 500; color: var(--text-light);"></span>
</div>
<div class="navbar-menu">
<div class="user-info-card">
<div style="text-align: right;">
<div style="font-weight: 600; color: var(--text-dark);"><?php echo htmlspecialchars($name ?? $account ?? 'User'); ?></div>
<div style="font-size: 0.8rem; color: var(--primary);"><?php echo htmlspecialchars($position ?? 'เจ้าหน้าที่'); ?></div>
</div>
<div class="user-avatar" style="width: 48px; height: 48px; font-size: 18px;">
<?php echo mb_substr(htmlspecialchars($name ?? 'U'), 0, 1, 'UTF-8'); ?>
</div>
</div>
<a href="logout.php" class="btn btn-danger" style="margin-left: 16px; border-radius: 20px; padding: 8px 16px;">
ออกจากระบบ
</a>
</div>
</header>
<script>
function date_time(id) {
let date = new Date();
let year = date.getFullYear() + 543;
let month = date.getMonth();
let months = ['ม.ค.', 'ก.พ.', 'มี.ค.', 'เม.ย.', 'พ.ค.', 'มิ.ย.', 'ก.ค.', 'ส.ค.', 'ก.ย.', 'ต.ค.', 'พ.ย.', 'ธ.ค.'];
let d = date.getDate();
let h = date.getHours();
if(h<10) h = "0"+h;
let m = date.getMinutes();
if(m<10) m = "0"+m;
let s = date.getSeconds();
if(s<10) s = "0"+s;
let result = d + ' ' + months[month] + ' ' + year + ' เวลา ' + h + ':' + m + ':' + s + ' น.';
let el = document.getElementById(id);
if(el) {
el.innerHTML = result;
setTimeout(function(){ date_time(id); }, 1000);
}
}
document.addEventListener('DOMContentLoaded', function() {
date_time('date_time');
});
</script>
@@ -0,0 +1,64 @@
<?php
// includes/sidebar.php
$chk_itcenter = preg_match('/itcenter/', $account ?? '');
?>
<aside class="glass-panel sidebar" style="width: 280px; min-height: 100vh; margin-bottom: 0; border-radius: 0; display: flex; flex-direction: column;">
<div style="padding-bottom: 20px; border-bottom: 1px solid var(--glass-border); margin-bottom: 20px; text-align: center;">
<svg style="width:48px;height:48px;color:var(--primary);margin-bottom:10px;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"></path>
</svg>
<h2 style="font-size: 1.25rem;">HOSxP Web</h2>
</div>
<div style="flex: 1;">
<div style="font-size: 0.8rem; font-weight: 700; color: var(--text-light); text-transform: uppercase; margin-bottom: 10px; letter-spacing: 1px;">เมนูหลัก</div>
<a href="main.php" class="sidebar-link <?php echo ($page_link == 'main.php') ? 'active' : ''; ?>">
<svg style="width:20px;height:20px;" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path></svg>
หน้าหลัก
</a>
<div style="font-size: 0.8rem; font-weight: 700; color: var(--text-light); text-transform: uppercase; margin-top: 30px; margin-bottom: 10px; letter-spacing: 1px;">ค้นหาข้อมูลผู้รับบริการ</div>
<a href="search_hn.php" class="sidebar-link <?php echo ($page_link == 'search_hn.php') ? 'active' : ''; ?>">ค้นจาก HN</a>
<a href="search_cid.php" class="sidebar-link <?php echo ($page_link == 'search_cid.php') ? 'active' : ''; ?>">ค้นจากเลขบัตรประชาชน</a>
<a href="search_passport.php" class="sidebar-link <?php echo ($page_link == 'search_passport.php') ? 'active' : ''; ?>">ค้นจาก Passport</a>
<?php if ($chk_itcenter) { ?>
<a href="search_name.php" class="sidebar-link <?php echo ($page_link == 'search_name.php') ? 'active' : ''; ?>">ค้นจากชื่อ - สกุล</a>
<div style="font-size: 0.8rem; font-weight: 700; color: var(--text-light); text-transform: uppercase; margin-top: 30px; margin-bottom: 10px; letter-spacing: 1px;">ผู้ดูแลระบบ</div>
<a href="2fa_authen.php" class="sidebar-link <?php echo ($page_link == '2fa_authen.php') ? 'active' : ''; ?>">ทำ 2FA Authentication</a>
<a href="hosxp_cost.php" class="sidebar-link <?php echo ($page_link == 'hosxp_cost.php') ? 'active' : ''; ?>">แก้ไขข้อมูลค่าใช้จ่าย HOSxP</a>
<?php } ?>
</div>
<div style="margin-top: auto; padding-top: 20px; border-top: 1px solid var(--glass-border); font-size: 0.85rem; color: var(--text-light);">
<div>OS: <span style="color:var(--primary); font-weight:600;"><?php echo htmlspecialchars($user_os ?? ''); ?></span></div>
<div>IP: <span style="color:var(--primary); font-weight:600;"><?php echo htmlspecialchars($ip ?? ''); ?></span></div>
</div>
</aside>
<style>
.sidebar-link {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 16px;
color: var(--text-dark);
border-radius: 8px;
margin-bottom: 4px;
font-weight: 500;
transition: all 0.2s;
}
.sidebar-link:hover {
background: rgba(2, 132, 199, 0.1);
color: var(--primary);
}
.sidebar-link.active {
background: var(--primary);
color: white;
box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}
.sidebar-link.active svg {
color: white;
}
</style>
+20
View File
@@ -0,0 +1,20 @@
<?php
require_once("config/db.php");
require_once("check_client.php");
$ip = $show_ip ?? $_SERVER['REMOTE_ADDR'];
$stmt = $conn2->prepare("SELECT block_ip_number FROM block_ip WHERE block_ip_number = ?");
if ($stmt) {
$stmt->bind_param("s", $ip);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows >= 1) {
$stmt->close();
echo '<div style="display:flex; justify-content:center; align-items:center; height:100vh; font-family:sans-serif; color:red; font-size:1.5rem;"><b>Your IP is Blocked !!!</b></div>';
exit();
}
$stmt->close();
}
header("Location: login.php");
exit();
?>
+41
View File
@@ -0,0 +1,41 @@
document.addEventListener('DOMContentLoaded', () => {
console.log('App initialized.');
// Helper: Toggles a class on an element
const toggleClass = (selector, className) => {
const el = document.querySelector(selector);
if (el) {
el.classList.toggle(className);
}
};
// Helper: Attach event listener safely
const addEvent = (selector, event, handler) => {
const els = document.querySelectorAll(selector);
els.forEach(el => el.addEventListener(event, handler));
};
// Example: Tab switching logic (can be expanded)
addEvent('.tab-btn', 'click', (e) => {
const targetId = e.currentTarget.dataset.target;
// Remove active from all tabs
document.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('active'));
document.querySelectorAll('.tab-content').forEach(content => content.style.display = 'none');
// Add active to clicked tab
e.currentTarget.classList.add('active');
const targetContent = document.getElementById(targetId);
if (targetContent) {
targetContent.style.display = 'block';
}
});
// Auto-dismiss alerts after 5 seconds
setTimeout(() => {
document.querySelectorAll('.alert').forEach(alert => {
alert.style.opacity = '0';
setTimeout(() => alert.remove(), 300);
});
}, 5000);
});
+21
View File
@@ -0,0 +1,21 @@
<?php
$page = "ล็อกอิน";
require_once("config/db.php");
require_once("check_client.php");
$ip = $show_ip ?? $_SERVER['REMOTE_ADDR'];
$stmt = $conn2->prepare("SELECT block_ip_number FROM block_ip WHERE block_ip_number = ?");
if ($stmt) {
$stmt->bind_param("s", $ip);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows >= 1) {
$stmt->close();
echo '<div style="display:flex; justify-content:center; align-items:center; height:100vh; font-family:sans-serif; color:red; font-size:1.5rem;"><b>Your IP is Blocked !!!</b></div>';
exit();
}
$stmt->close();
}
require_once("login_form.php");
?>
@@ -0,0 +1,100 @@
<!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 | ล็อกอิน</title>
<link rel="icon" type="image/png" sizes="16x16" href="favicon1.ico">
<link rel="stylesheet" href="css/styles.css" type="text/css" />
<style>
body.login-page {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
.login-card {
width: 100%;
max-width: 400px;
padding: 40px;
text-align: center;
}
.login-logo {
margin-bottom: 24px;
color: var(--primary);
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
.btn-block {
width: 100%;
padding: 14px;
font-size: 1rem;
}
</style>
</head>
<body class="login-page">
<div class="glass-panel login-card">
<div class="login-logo">
<svg style="width:64px;height:64px;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"></path>
</svg>
</div>
<h2 style="margin-bottom: 8px;">HOSxP Web Service</h2>
<p class="text-muted" style="margin-bottom: 30px;">ลงชื่อเข้าใช้เพื่อเริ่มต้นระบบ</p>
<form id="loginform" action="authen.php" method="post" onsubmit="return validateForm()">
<div class="form-group">
<input type="text" id="username" name="username" class="form-control" placeholder="ชื่อผู้ใช้งาน (Username)" required />
</div>
<div class="form-group">
<input type="password" id="password" name="password" class="form-control" placeholder="รหัสผ่าน (Password)" required />
</div>
<div class="form-group">
<input type="number" id="2fa_auth" name="2fa_auth" class="form-control" placeholder="รหัส OTP 2FA (ถ้ามี)" required />
</div>
<input type="hidden" name="show_ip" value="<?php echo htmlspecialchars($show_ip ?? ''); ?>" />
<input type="hidden" name="user_os" value="<?php echo htmlspecialchars($user_os ?? ''); ?>" />
<input type="hidden" name="user_browser" value="<?php echo htmlspecialchars($user_browser ?? ''); ?>" />
<div class="form-group" style="margin-top: 30px;">
<button type="submit" class="btn btn-primary btn-block">เข้าสู่ระบบ</button>
</div>
</form>
</div>
<script>
function validateForm() {
const user = document.getElementById('username');
const pass = document.getElementById('password');
const auth2fa = document.getElementById('2fa_auth');
let isValid = true;
[user, pass, auth2fa].forEach(el => {
if(!el.value.trim()) {
el.style.borderColor = 'var(--danger)';
isValid = false;
} else {
el.style.borderColor = 'rgba(0,0,0,0.1)';
}
});
if(!isValid) {
user.closest('.login-card').animate([
{ transform: 'translateX(0)' },
{ transform: 'translateX(-10px)' },
{ transform: 'translateX(10px)' },
{ transform: 'translateX(-10px)' },
{ transform: 'translateX(10px)' },
{ transform: 'translateX(0)' }
], { duration: 400 });
}
return isValid;
}
</script>
</body>
</html>
+60
View File
@@ -0,0 +1,60 @@
<?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 = "main.php";
require_once("config/db.php");
require_once("check_client.php");
require_once("date_format.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 | หน้าหลัก</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;
}
</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" style="animation: slideUp 0.5s ease;">
<?php require_once("right_panel.php"); ?>
</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>
</body>
</html>
+158
View File
@@ -0,0 +1,158 @@
<?php
session_start();
if (empty($_SESSION['sess_userid']) || $_SESSION['sess_userid'] !== session_id()) {
header("Location: index.php");
exit();
}
$login_id = $_SESSION['account'];
$account = $_SESSION['account'];
$name = $_SESSION['name'];
$position = $_SESSION['position'];
$ip = $_SESSION['ip'];
$page = "รายละเอียดข้อมูลผู้รับบริการ";
$page_link = "patient.php";
require_once("config/db.php");
mysqli_report(MYSQLI_REPORT_OFF);
mysqli_query($conn1, "SET SESSION sql_mode=''");
mysqli_query($conn2, "SET SESSION sql_mode=''");
require_once("date_format.php");
require_once("check_client.php");
$hn = isset($_GET['hn']) ? base64_decode($_GET['hn']) : '';
$nn = isset($_GET['nn']) ? base64_decode($_GET['nn']) : '';
$vdate = isset($_GET['vdate']) ? base64_decode($_GET['vdate']) : '';
?>
<!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 | <?php echo $page; ?></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;
}
.patient-layout {
display: flex;
gap: 24px;
margin-top: 16px;
align-items: flex-start;
}
.visit-history {
width: 320px;
flex-shrink: 0;
padding: 0;
overflow: hidden;
}
.visit-list {
height: calc(100vh - 180px);
overflow-y: auto;
padding: 0;
margin: 0;
list-style: none;
}
.visit-list li a {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 16px;
border-bottom: 1px solid rgba(0,0,0,0.05);
color: var(--text-dark);
text-decoration: none;
font-size: 0.95rem;
transition: background 0.2s;
}
.visit-list li a:hover {
background: rgba(2, 132, 199, 0.05);
}
.visit-list li a.active {
background: rgba(2, 132, 199, 0.1);
font-weight: 600;
border-left: 4px solid var(--primary);
}
.patient-details {
flex-grow: 1;
min-width: 0;
}
</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="patient-layout">
<!-- Left Panel: Visit History -->
<div class="glass-panel visit-history">
<div style="padding: 16px; background: rgba(0,0,0,0.03); border-bottom: 1px solid var(--glass-border); font-weight: 600; color: var(--text-dark); display: flex; align-items: center; gap: 8px;">
<svg style="width:20px;height:20px;color:var(--primary);" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
ประวัติมารับบริการ
</div>
<ul class="visit-list">
<?php
if($hn) {
$sql3 = "SELECT * FROM ovst WHERE hn=? ORDER BY vstdate DESC";
$stmt3 = $conn1->prepare($sql3);
if($stmt3) {
$stmt3->bind_param("s", $hn);
$stmt3->execute();
$res3 = $stmt3->get_result();
while ($row3 = $res3->fetch_assoc()) {
$is_active = ($vdate == $row3['vstdate']) ? 'active' : '';
$nn_val = ($row3['an'] != NULL) ? $row3['an'] : $row3['vn'];
$link = "patient.php?hn=" . base64_encode($hn) . "&vdate=" . base64_encode($row3['vstdate']) . "&nn=" . base64_encode($nn_val);
echo "<li><a href='{$link}' class='{$is_active}'>";
echo "<span>" . thai_date2($row3['vstdate']) . "</span>";
echo "<div>";
if ($row3['an'] != NULL) { echo '<span class="badge badge-warning" style="margin-right:4px;">Admit</span>'; }
if ($row3['vn'] == $nn || $row3['an'] == $nn) { if ($nn != '') { echo '<span class="badge badge-info">View</span>'; } }
echo "</div>";
echo "</a></li>";
}
$stmt3->close();
}
}
?>
</ul>
</div>
<!-- Right Panel: Patient Details -->
<div class="patient-details" style="animation: slideUp 0.5s ease;">
<?php
if($hn) {
require_once("right_panel_patient.php");
} else {
echo "<div class='glass-panel flex-center' style='min-height: 400px; color: var(--text-muted); font-size: 1.1rem; flex-direction:column; gap:16px;'>
<svg style='width:64px;height:64px;color:var(--text-light);' 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>
กรุณาเลือกประวัติการมารับบริการด้านซ้ายมือ หรือกลับไปค้นหาผู้ป่วยใหม่</div>";
}
?>
</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>
</body>
</html>
@@ -0,0 +1,154 @@
<?php
// right_panel.php - Dashboard stats
$timezone = "Asia/Bangkok";
date_default_timezone_set($timezone);
$today = date("Y-m-d H:i:s");
$d_conv_search = date("Y-m-d");
// Helper function for quick count queries
function get_count($conn, $query, $date_param) {
$stmt = $conn->prepare($query);
if($stmt) {
$stmt->bind_param("s", $date_param);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
$stmt->close();
return $row['cc'] ?? 0;
}
return 0;
}
$cc_er = get_count($conn1, "SELECT count(*) as cc FROM er_regist WHERE vstdate=?", $d_conv_search);
$cc_pq = get_count($conn1, "SELECT count(*) as cc FROM pq_screen WHERE screen_date=?", $d_conv_search);
$cc_pqd = get_count($conn1, "SELECT count(*) as cc FROM pq_doctor WHERE doctor_date=?", $d_conv_search);
$cc_dt = get_count($conn1, "SELECT count(distinct hn) as cc FROM dtmain WHERE vstdate=?", $d_conv_search);
$cc_lab1 = get_count($conn1, "SELECT count(*) as cc FROM lab_head WHERE order_date=?", $d_conv_search);
$cc_lab2 = get_count($conn1, "SELECT count(*) as cc FROM lab_head WHERE order_date=? AND confirm_report='Y'", $d_conv_search);
$sub_y = substr((date("Y") + 543), 2, 2);
$d_rx = $sub_y . date("md") . "%";
$cc_rx = get_count($conn1, "SELECT count(*) as cc FROM rx_operator WHERE vn like ?", $d_rx);
$cc_rx2 = get_count($conn1, "SELECT count(*) as cc FROM rx_operator WHERE vn like ? AND pay='Y'", $d_rx);
$cc_ipt = get_count($conn1, "SELECT count(*) as cc FROM ipt WHERE regdate=?", $d_conv_search);
$cc_ipt2 = get_count($conn1, "SELECT count(*) as cc FROM ipt WHERE dchdate=?", $d_conv_search);
$cc_ovst = get_count($conn1, "SELECT count(*) as cc FROM ovst WHERE vstdate=? AND ovstost='54'", $d_conv_search);
$cc_ipt3 = get_count($conn1, "SELECT count(*) as cc FROM ipt WHERE dchdate=? AND dchtype='04'", $d_conv_search);
// News from local DB
$news_items = [];
$result_news2 = $conn2->query("SELECT * FROM news ORDER BY date_add DESC LIMIT 10");
if ($result_news2) {
while($row = $result_news2->fetch_assoc()) {
$news_items[] = $row;
}
}
?>
<div class="glass-header" style="margin-top: 10px;">
<h2>สรุปยอดให้บริการประจำวัน</h2>
<span class="text-muted">ข้อมูล ณ วันที่ <?php echo thai_date5(datetime_to_date($today)); ?> เวลา <?php echo datetime_to_time($today); ?> น.</span>
</div>
<div class="grid-2">
<!-- Stats Column -->
<div class="glass-panel" style="grid-column: span 1;">
<h3 style="margin-bottom: 20px; color: var(--primary); display: flex; align-items: center; gap: 8px;">
<svg style="width:24px;height:24px;" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"></path></svg>
ภาพรวมการให้บริการ (OPD & ER)
</h3>
<table class="modern-table">
<tbody>
<tr>
<td>ผู้ป่วยรับบริการห้องฉุกเฉิน (ER)</td>
<td style="text-align: right; font-weight: 600; color: var(--primary);"><?php echo number_format($cc_er); ?> ราย</td>
</tr>
<tr>
<td>ผ่านการซักประวัติ</td>
<td style="text-align: right; font-weight: 600; color: var(--primary);"><?php echo number_format($cc_pq); ?> ราย</td>
</tr>
<tr>
<td>ผ่านการตรวจ ณ ห้องตรวจ</td>
<td style="text-align: right; font-weight: 600; color: var(--primary);"><?php echo number_format($cc_pqd); ?> ราย</td>
</tr>
<tr>
<td>รับบริการห้องทันตกรรม</td>
<td style="text-align: right; font-weight: 600; color: var(--primary);"><?php echo number_format($cc_dt); ?> ราย</td>
</tr>
<tr>
<td>ผู้ป่วยนอกถูกส่งต่อ (Refer Out)</td>
<td style="text-align: right; font-weight: 600; color: var(--primary);"><?php echo number_format($cc_ovst); ?> ราย</td>
</tr>
</tbody>
</table>
<h3 style="margin-top: 30px; margin-bottom: 20px; color: var(--success); display: flex; align-items: center; gap: 8px;">
<svg style="width:24px;height:24px;" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg>
ผู้ป่วยใน (IPD)
</h3>
<table class="modern-table">
<tbody>
<tr>
<td>รับใหม่ (Admit)</td>
<td style="text-align: right; font-weight: 600; color: var(--success);"><?php echo number_format($cc_ipt); ?> ราย</td>
</tr>
<tr>
<td>จำหน่าย (Discharge)</td>
<td style="text-align: right; font-weight: 600; color: var(--success);"><?php echo number_format($cc_ipt2); ?> ราย</td>
</tr>
<tr>
<td>ผู้ป่วยในถูกส่งต่อ (Refer Out IPD)</td>
<td style="text-align: right; font-weight: 600; color: var(--success);"><?php echo number_format($cc_ipt3); ?> ราย</td>
</tr>
</tbody>
</table>
<h3 style="margin-top: 30px; margin-bottom: 20px; color: #8b5cf6; display: flex; align-items: center; gap: 8px;">
<svg style="width:24px;height:24px;" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"></path></svg>
บริการอื่นๆ
</h3>
<table class="modern-table">
<tbody>
<tr>
<td>ใบสั่งจ่ายยาจากห้องยา</td>
<td style="text-align: right; font-weight: 600; color: #8b5cf6;"><?php echo number_format($cc_rx); ?> ครั้ง</td>
</tr>
<tr>
<td>ใบส่งตรวจห้องแล็บ</td>
<td style="text-align: right; font-weight: 600; color: #8b5cf6;"><?php echo number_format($cc_lab1); ?> ใบ</td>
</tr>
<tr>
<td>รายงานผลแล็บแล้ว</td>
<td style="text-align: right; font-weight: 600; color: #8b5cf6;"><?php echo number_format($cc_lab2); ?> ใบ</td>
</tr>
</tbody>
</table>
</div>
<!-- News Column -->
<div class="glass-panel" style="grid-column: span 1;">
<h3 style="margin-bottom: 20px; color: var(--text-dark); display: flex; align-items: center; gap: 8px;">
<svg style="width:24px;height:24px;color:var(--warning);" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5.882V19.24a1.76 1.76 0 01-3.417.592l-2.147-6.15M18 13a3 3 0 100-6M5.436 13.683A4.001 4.001 0 017 6h1.832c4.1 0 7.625-1.234 9.168-3v14c-1.543-1.766-5.067-3-9.168-3H7a3.988 3.988 0 01-1.564-.317z"></path></svg>
รายการประกาศอัปเดต (News)
</h3>
<div style="display:flex; flex-direction:column; gap:16px;">
<?php if(count($news_items) > 0): ?>
<?php foreach($news_items as $news): ?>
<div style="padding: 16px; background: rgba(255,255,255,0.4); border-radius: 8px; border-left: 4px solid var(--primary);">
<div style="font-size: 0.8rem; color: var(--primary); margin-bottom: 8px; font-weight: 600;">
<?php echo datetime_to_date($news['date_add']); ?>
</div>
<div style="font-size: 0.95rem; color: var(--text-dark); line-height: 1.5;">
<?php echo htmlspecialchars($news['title']); ?>
</div>
</div>
<?php endforeach; ?>
<?php else: ?>
<div style="text-align: center; color: var(--text-muted); padding: 40px 0;">ไม่มีข้อมูลประกาศ</div>
<?php endif; ?>
</div>
</div>
</div>
@@ -0,0 +1,726 @@
<?php
//@session_start();
//$login_id = $_SESSION['account'];
//$pt_lab = $_SESSION['lab_pt'];
//require("connect_web.php");
//require("connect_hosxp.php");
//require("connect_web.php");
//require("date_format.php");
//$hn = base64_decode($_GET['hn']);
//$nn = base64_decode($_GET['nn']);
$timezone = "Asia/Bangkok";
if (function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
$today = date("Y-m-d H:i:s");
try {
$sql_view_hn = "INSERT INTO check_view_hn VALUES (NULL, '$login_id', '$hn','$nn', '$today');";
$result_view_hn = mysqli_query($conn2, $sql_view_hn);
} catch (Exception $e) {
// Ignore logging errors to prevent 500
}
$sql1 = "select a.*,c.name as pt from patient a left outer join ovst b on a.hn=b.hn left outer join pttype c on a.pttype=c.pttype where a.hn='$hn'";
$result1 = mysqli_query($conn1, $sql1);
$row1 = $result1 ? mysqli_fetch_array($result1) : [];
$sql2 = "SELECT p.hometel as tel, n.name as nation, r.name as religion1, img.image as img1, concat(p.addrpart,' หมู่ ',p.moopart,' ต. ',t3.name,' อ.',t2.name,' จ. ',t1.name,' ',p.po_code) as addr FROM patient p left outer join thaiaddress t1 on t1.addressid=concat(p.chwpart,'0000') left outer join thaiaddress t2 on t2.addressid=concat(p.chwpart,p.amppart,'00') left outer join thaiaddress t3 on t3.addressid=concat(p.chwpart,p.amppart,p.tmbpart) left outer join nationality n on p.nationality=n.nationality left outer join religion r on p.religion=r.religion left outer join patient_image img on p.hn=img.hn where p.hn='$hn' ";
$result2 = mysqli_query($conn1, $sql2);
$row2 = $result2 ? mysqli_fetch_array($result2) : [];
$ucid = $row1['cid'];
//SQL Check Covid19 Certificate
// $sql_covid19 = "select * from cert_request where cid='$ucid' and cert_file !='' ";
// $result_covid19 = mysqli_query($conn_covid19, $sql_covid19);
// $num_row_covid19 = mysqli_num_rows($result_covid19);
// $row_covid19 = mysqli_fetch_array($result_covid19);
// if ($num_row_covid19 != 0) {
// $cert_path = "https://www1.samuihospital.go.th/line-bot/covid19/cert/cert_view_data_doc_pc.php?cid=" . $row_covid19['cid'];
// $cert_title = '<i class="iconsweets-magnifying iconsweets-white"></i>คลิกเปิดดู';
// $cert_a_class = "badge badge-info";
// } else {
// $cert_path = "#";
// $cert_title = "ไม่พบข้อมูล";
// $cert_a_class = "";
// }
//---- Check visit OPD/IPD -------
$sql_check_visit = "select * from ovst where hn='$hn' and vstdate='$vdate'";
$result_check_visit = mysqli_query($conn1, $sql_check_visit);
$row_check_visit = $result_check_visit ? mysqli_fetch_array($result_check_visit) : false;
//----------------------------------
//---- Resolve true VN (in case $nn is an AN) -------
if ($vdate != NULL) {
$sql4 = "select a.vstdate, a.vsttime, a.vn as a_vn from ovst a where a.hn='$hn' and (a.vn='$nn' or a.an='$nn')";
$result4 = mysqli_query($conn1, $sql4);
$row4 = $result4 ? mysqli_fetch_array($result4) : [];
$vn1 = isset($row4['a_vn']) ? $row4['a_vn'] : $nn;
} else {
$vn1 = $nn;
}
//----------------------------------
//---- Check visit Report Lan Covid-19 -------
$sql_check_novel_covid19 = "select h.lab_order_number,h.report_date,h.report_time
from lab_head h left outer join lab_order lo on h.lab_order_number=lo.lab_order_number
where lo.lab_items_code in('1822','1837','1842','1856','1900','2030','2038','2044','1846','2054','2103') and (h.vn='$vn1' or h.vn='$nn') and ( lo.lab_order_result not in(' ') or lo.lab_order_result is not null ) order by lo.lab_items_code";
$result_check_novel_covid19 = mysqli_query($conn1, $sql_check_novel_covid19);
$num_row_check_novel_covid19 = $result_check_novel_covid19 ? mysqli_num_rows($result_check_novel_covid19) : 0;
$row_check_novel_covid19 = $result_check_novel_covid19 ? mysqli_fetch_array($result_check_novel_covid19) : [];
if ($num_row_check_novel_covid19 == 0) {
$novel_covid19_box = "none";
} else {
$novel_covid19_box = "table-row";
}
//----------------------------------
//---- Check Doctor Cert Covid-19 -------
$sql_check_doctor_cert_covid19 = "select * from universal_head where universal_form_id='95' and vn = '$nn'";
$result_check_doctor_cert_covid19 = mysqli_query($conn1, $sql_check_doctor_cert_covid19);
$num_row_check_doctor_cert_covid19 = $result_check_doctor_cert_covid19 ? mysqli_num_rows($result_check_doctor_cert_covid19) : 0;
$row_check_doctor_cert_covid19 = $result_check_doctor_cert_covid19 ? mysqli_fetch_array($result_check_doctor_cert_covid19) : [];
if ($num_row_check_doctor_cert_covid19 == 0) {
$doctor_cert_covid19_box = "none";
} else {
$doctor_cert_covid19_box = "table-row";
}
//----------------------------------
if ($vdate != NULL) {
// 2. Get Vitals from opdscreen
$sql_vitals = "select * from opdscreen where vn='$vn1'";
$result_vitals = mysqli_query($conn1, $sql_vitals);
$row_vitals = $result_vitals ? mysqli_fetch_array($result_vitals) : [];
$vsign = "BT : " . sprintf("%.1f", (float)@$row_vitals["temperature"]) . "&nbsp;&deg;C BP :&nbsp;" . (int)@$row_vitals["bps"] . "/" . (int)@$row_vitals["bpd"] . "&nbsp;mmHg ";
$vsign .= "PR : " . (int)@$row_vitals["pulse"] . " /min " . "RR : " . (int)@$row_vitals["rr"] . " /min" . "&nbsp;BW : " . sprintf("%.1f", (float)@$row_vitals["bw"]) . " Kg. ";
if (@$row_vitals["height"] <> 0) {
$vsign .= "Ht : " . (int)@$row_vitals["height"] . " Cm ";
}
if (@$row_vitals["fbs"] <> 0) {
$vsign .= "FBS : " . (int)@$row_vitals["fbs"] . " mg/dl";
}
if (@$row_vitals["bmi"] <> 0) {
$vsign .= "BMI : " . (int)@$row_vitals["bmi"] . " Kg/(m2)";
}
// Debug output
error_log("DEBUG SQL4: $sql4\nDEBUG vn1: $vn1\nDEBUG nn: $nn\n", 3, "debug_log.txt");
//---- Check Admit Ward-------
$sql_check_admit_ward = "SELECT ipt.an, ward.name as ward_name FROM ipt INNER JOIN ward ON ipt.ward = ward.ward WHERE ipt.vn = '$vn1' ";
$result_check_admit_ward = mysqli_query($conn1, $sql_check_admit_ward);
$num_row_check_admit_ward = $result_check_admit_ward ? mysqli_num_rows($result_check_admit_ward) : 0;
$row_check_admit_ward = $result_check_admit_ward ? mysqli_fetch_array($result_check_admit_ward) : [];
$admit_ward = $row_check_admit_ward['ward_name'];
if ($num_row_check_admit_ward == 0) {
$admit_ward_box = "none";
} else {
$admit_ward_box = "table-row";
}
//----------------------------------
$sql5 = "select agent,symptom from opd_allergy where hn='$hn'"; //แพ้ยา
$result5 = mysqli_query($conn1, $sql5);
$sql6 = "select cc_persist_disease from opd_ill_history where hn='$hn'"; //โรคประจำตัว
$result6 = mysqli_query($conn1, $sql6);
$sql7 = "select cc_operation_name from opd_ill_history where hn='$hn'"; //ประวัติผ่าตัด
$result7 = mysqli_query($conn1, $sql7);
$sql8 = "select * from ovstdiag where (vn='$vn1' or vn='$nn') order by icd10 desc,diagtype"; //diag
$result8 = mysqli_query($conn1, $sql8);
$sql9 = "select count(*) as cc from opitemrece where (vn='$vn1' or an='$nn')";
$result_sd = mysqli_query($conn1, $sql9);
$rs1 = $result_sd ? mysqli_fetch_array($result_sd) : ["cc" => 0];
$num_rows_max2 = 0;
if ($rs1["cc"] > 0) { //a
$sqlMedi = "select o.*,concat(s.name,' ',s.strength,' ',s.units) as drugname ,o.qty as sumqty, d.shortlist , i.displaycolor ,sp.* ,u.name as ustaff , ";
$sqlMedi .= "concat(sp.name1,' ',sp.name2,' ', sp.name3) as spname ";
$sqlMedi .= "from opitemrece o ";
$sqlMedi .= "left outer join s_drugitems s on s.icode=o.icode ";
$sqlMedi .= "left outer join drugusage d on d.drugusage=o.drugusage ";
$sqlMedi .= "left outer join sp_use sp on sp.sp_use = o.sp_use ";
$sqlMedi .= "left outer join opduser u on u.loginname=o.staff ";
$sqlMedi .= "left outer join drugitems i on i.icode=o.icode where (o.vn='$vn1' or o.an='$nn') ";
$sqlMedi .= "and o.sub_type in ('1','3') ";
$sqlMedi .= "order by o.order_no ";
// Force empty sql_mode right before query execution
mysqli_query($conn1, "SET SESSION sql_mode=''");
$result_sd = mysqli_query($conn1, $sqlMedi);
$num_rows_max2 = $result_sd ? mysqli_num_rows($result_sd) : 0;
}
$sql_xray = "select xr.*,xh.xray_list as list,xh.department_name as dep,u.name as xname,xt.name as xtype from xray_report xr left outer join xray_head xh on xh.vn=xr.vn left outer join opduser u on u.loginname=xr.staff left outer join xray_type xt on xt.xray_type=xr.xray_type where (xr.vn='$vn1' or xr.an='$nn') and xr.confirm='Y' ";
$result_xray = mysqli_query($conn1, $sql_xray);
$num_rows_max4 = $result_xray ? mysqli_num_rows($result_xray) : 0;
}
$birthday = $row1['birthday']; //รูปแบบการเก็บค่าข้อมูลวันเกิด
$today = date("Y-m-d"); //จุดต้องเปลี่ยน
list($byear, $bmonth, $bday) = explode("-", $birthday); //จุดต้องเปลี่ยน
list($tyear, $tmonth, $tday) = explode("-", $today); //จุดต้องเปลี่ยน
$mbirthday = mktime(0, 0, 0, $bmonth, $bday, $byear);
$mnow = mktime(0, 0, 0, $tmonth, $tday, $tyear);
$mage = ($mnow - $mbirthday);
$u_y = date("Y", $mage) - 1970;
$u_m = date("m", $mage) - 1;
$u_d = date("d", $mage) - 1;
$sql_vaccine_covid19 = "SELECT * FROM visit_immunization_samui_1 WHERE ref_hn = '$ucid' order by vaccine_plan_no asc"; //วัคซีนโควิด19
$result_vaccine_covid19 = mysqli_query($conn1, $sql_vaccine_covid19);
$num_rows_vaccine_covid19 = $result_vaccine_covid19 ? mysqli_num_rows($result_vaccine_covid19) : 0;
?>
<div class="glass-panel">
<div class="top-info">
<div class="top-info-left">
<?php if ($row2['img1'] == "") {
echo '<img src="img/non-pic.png"/>';
} else {
echo '<img src="data:image/jpeg;base64,' . base64_encode($row2['img1']) . '"/>';
} ?>
</div>
<div class="top-info-right">
<div>
<table class="modern-table">
<tr>
<th>ชื่อ - สกุล :</th>
<td><strong><?php echo $row1['pname'] . "" . $row1['fname'] . "&nbsp;&nbsp;" . $row1['lname']; ?></strong></td>
</tr>
<tr>
<th>เลขบัตรประชาชน :</th>
<td><strong><?php echo $ucid; ?></strong></td>
</tr>
<tr>
<th>เลข HN :</th>
<td><a href="patient.php?hn=<?php echo $_GET['hn']; ?>"><strong><?php echo $hn; ?></strong></a></td>
</tr>
<tr>
<th>สิทธิ์การรักษา :</th>
<td><strong><?php echo $row1['pt']; ?></strong></td>
</tr>
</table>
</div>
<div>
<table class="modern-table">
<tr>
<th>ที่อยู่ :</th>
<td><strong><?php echo $row2['addr']; ?></strong></td>
</tr>
<tr>
<th>โทรศัพท์ :</th>
<td><strong><?php echo ($row2['tel'] == "") ? "-" : $row2['tel']; ?></strong></td>
</tr>
<tr>
<th>วันเกิด :</th>
<td><strong><?php echo thai_date7($row1['birthday']); ?></strong></td>
</tr>
<tr>
<th>อายุ :</th>
<td><strong><?php echo "$u_y ปี&nbsp;&nbsp;$u_m เดือน&nbsp;&nbsp;$u_d วัน"; ?></strong></td>
</tr>
<tr>
<th>สัญชาติ :</th>
<td><strong><?php echo $row2['nation']; ?></strong></td>
</tr>
<tr>
<th>ศาสนา :</th>
<td><strong><?php echo $row2['religion1']; ?></strong></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="glass-panel" style="display:<?php if ($vdate != "") {
echo "none";
} else {
echo "block";
} ?>">
<br />
<h4 class="widgettitle">ข้อมูลการฉีดวัคซีนโควิด-19</h4>
<?php if ($num_rows_vaccine_covid19 == 0) { //row1
echo "<font color='red'>&nbsp;- <span class=detail-text2>ไม่มีข้อมูลรายการวัคซีนโควิด-19</span><br></font>";
} else {
?>
<table class="modern-table">
<thead>
<tr>
<th class="head0">
<center>
ลำดับ
</center>
</th>
<th class="head0">
<center>
ชื่อวัคซีน
</center>
</th>
<th class="head1">
<center>
วันที่ฉีด
</center>
</th>
<th class="head0">
<center>
Lot.
</center>
</th>
<th class="head1">
<center>
Serial
</center>
</th>
</tr>
</thead>
<tbody>
<?php
$i22 = 0;
while ($i22 < $num_rows_vaccine_covid19) { //while2
$rs_vaccine_covid19 = mysqli_fetch_array($result_vaccine_covid19);
?>
<tr class="gradeX">
<td><?php echo $rs_vaccine_covid19["vaccine_plan_no"]; ?></td>
<td><?php echo $rs_vaccine_covid19["vaccine_manufacturer"]; ?></td>
<td>
<center><?php echo thai_date8(datetime_to_date($rs_vaccine_covid19["immunization_datetime"])); ?></center>
</td>
<td><?php echo $rs_vaccine_covid19["lot_number"]; ?></td>
<td>
<center><?php echo $rs_vaccine_covid19["vaccine_serial_no"]; ?></center>
</td>
</tr>
<?php
$i22++;
} //while2
?>
</tbody>
</table>
<?php } ?>
<div class="glass-panel" style="display:<?php if ($vdate == "") {
echo "none";
} else {
echo "block";
} ?>">
<!-- แสดงข้อมูล ณ วันที่มารับบริการ -->
<h4 class="widgettitle">ข้อมูลการรับบริการ ณ <?php echo thai_date7($vdate); ?></h4>
<table class="modern-table">
<tr>
<td class="width15">วันที่มารับบริการ :</td>
<td class="width85"><strong><?php echo thai_date7($row4['vstdate']); ?> เวลา <?php echo $row4['vsttime']; ?></strong></td>
</tr>
<tr>
<td>เลข VN :</td>
<td><strong><?php echo $row4['vn']; ?></strong></td>
</tr>
<tr>
<td>อาการ/ประวัติ :</td>
<td><strong><?php echo $row4['hpi']; ?></strong></td>
</tr>
<tr>
<td>PE :</td>
<td><strong><?php echo $row4['pe']; ?></strong></td>
</tr>
<tr>
<td>โรคประจำตัว :</td>
<td><strong><?php echo $row4['pmh']; ?></strong><br /><strong>
<?php if($result6) while ($row6 = mysqli_fetch_array($result6)) { ?>
<strong><?php echo $row6['cc_persist_disease'] . "</br>"; ?></strong>
<?php } ?>
</strong></td>
</tr>
<tr>
<td>ประวัติการแพ้ยา :</td>
<td><?php if($result5) while ($row5 = mysqli_fetch_array($result5)) { ?>
<strong><?php echo $row5['agent'] . " - " . $row5['symptom'] . "</br>"; ?></strong>
<?php } ?>
</td>
</tr>
<tr>
<td>ประวัติการผ่าตัด :</td>
<td><strong>
<?php if($result7) while ($row7 = mysqli_fetch_array($result7)) { ?>
<strong><?php echo $row7['cc_operation_name'] . "</br>"; ?></strong>
<?php } ?>
</strong></td>
</tr>
<tr>
<td>Vital Sign :</td>
<td><strong><?php echo $vsign; ?></strong></td>
</tr>
<tr>
<td>วินิจฉัยเบื้องต้น :</td>
<td><strong>
<?php $num_rows_max1 = $result8 ? mysqli_num_rows($result8) : 0;
if ($num_rows_max1 == 0) {
echo "<font color=#0066FF>&nbsp;- ไม่มีข้อมูล Dx<br></font>";
} else { //n row
$i = 0;
while ($i < $num_rows_max1) {
$rs2 = $result8 ? mysqli_fetch_array($result8) : [];
$dx_icd = $rs2["icd10"];
$dt_name = $rs2["doctor"];
if ($dx_icd <> "") {
$sqlDxn = "select name from icd101 where code='$dx_icd' ";
$result_dx = mysqli_query($conn1, $sqlDxn);
$rs_dx = $result_dx ? mysqli_fetch_array($result_dx) : ["name" => ""];
$dx_name = $rs_dx["name"];
}
if ($dt_name <> "") {
$sqlDc_n = "select name from doctor where code='$dt_name' ";
$result_dcn = mysqli_query($conn1, $sqlDc_n);
$rs_dcn = $result_dcn ? mysqli_fetch_array($result_dcn) : ["name" => ""];
$dcn_name = $rs_dcn["name"];
}
echo "&nbsp;<font color=red>Dx." . ($i + 1) . "</font><font color=#0066FF>&nbsp;$dx_icd&nbsp;</font><font color=green>$dx_name</font>
&nbsp;[<font color=>$dcn_name</font>]<br>";
$i++;
} //while
} //e n row
//end diag
?>
</strong></td>
</tr>
<tr style="display: <?php echo $admit_ward_box;
?>;">
<td>
Admit Ward :
</td>
<td>
<font color=blue><?php echo $admit_ward; ?></font>
</td>
</tr>
<tr style="display: <?php echo $doctor_cert_covid19_box;
?>;">
<td>
<font color=blue>ใบรับรองแพทย์<br>Covid-19</font> :
</td>
<td>
<select onchange="window.open(this.value)">
<option selected disabled>--- เลือกแพทย์ ---</option>
<option value="doctor_cert_covid19.php?nn=<?php echo base64_encode($nn); ?>&doctor=<?php echo base64_encode("1329900133434"); ?>">นพ.มรรษยุว์ อิงคภาสกร</option>
<option value="doctor_cert_covid19.php?nn=<?php echo base64_encode($nn); ?>&doctor=<?php echo base64_encode("1840100404457"); ?>">นพ.ภควัต พรหมเพชร</option>
<option value="doctor_cert_covid19.php?nn=<?php echo base64_encode($nn); ?>&doctor=<?php echo base64_encode("1909900457323"); ?>">พญ.จิตติมา มุสิกพันธุ์</option>
</select>
</td>
</tr>
<!-- <tr style="display: <?php //echo $novel_covid19_box;
?>;">
<td>
<font color=orange>ใบผลตรวจ Covid-19</font> :
</td>
<td><a href="report_lab_covid19.php?nn=<?php //echo base64_encode($nn);
?>" target="_blank" style="text-decoration: none;">ใบผลตรวจ Covid-19</a></td>
</tr> -->
</table>
<div class="glass-panel">
<h4 class="widgettitle">รายการยา</h4>
<?php if ($num_rows_max2 == 0) {
echo "<font color='red'>&nbsp;- <span class=detail-text2>ไม่มีข้อมูลรายการยา</span><br></font>";
} else {
?>
<table class="modern-table">
<thead>
<tr>
<th class="head0">
<center>
ลำดับ
</center>
</th>
<th class="head0">
<center>
ชื่อเวชภัณฑ์
</center>
</th>
<th class="head1">
<center>
วิธีใช้
</center>
</th>
<th class="head0">
<center>
จำนวน
</center>
</th>
<th class="head1">
<center>
รวมราคา
</center>
</th>
<th class="head0">
<center>
ผู้สั่ง/ตรวจสอบ
</center>
</th>
</tr>
</thead>
<tbody>
<?php
$i2 = 0;
while ($i2 < $num_rows_max2) { //while2
$rs_sd = $result_sd ? mysqli_fetch_array($result_sd) : [];
?>
<tr class="gradeX">
<td>
<center>
<?php echo ($i2 + 1); ?>
</center>
</td>
<td><?php echo $rs_sd["drugname"]; ?></td>
<td><?php if ($rs_sd["spname"] <> "") {
echo $rs_sd["spname"];
} else {
echo $rs_sd["shortlist"];
} ?></td>
<td>
<center>
<?php echo $rs_sd["qty"]; ?>
</center>
</td>
<td>
<center>
<?php echo number_format($rs_sd["sum_price"]); ?>
</center>
</td>
<td>
<center>
<?php echo $rs_sd["ustaff"]; ?>
</center>
</td>
</tr>
<?php
$i2++;
} //while2
?>
</tbody>
</table>
<?php } ?>
<div class="glass-panel">
<!-- start ส่งตรวจทางห้องปฏิบัิติการ -->
<?php
$sqlLab1 = "select * from lab_head where (vn='$vn1' or vn='$nn') order by report_date desc ";
$result_lab1 = mysqli_query($conn1, $sqlLab1);
$num_rows_lab1 = $result_lab1 ? mysqli_num_rows($result_lab1) : 0;
if ($num_rows_lab1 == 0) {
echo '<h4 class="widgettitle">ผลแล็บ</h4> <font color="red">&nbsp;- <span class=detail-text2>ไม่มีข้อมูลการส่งตรวจทางห้องปฏิบัติการ</span><br></font>';
} else {
$i4 = 0;
$lab_order_list = "";
while ($i4 < $num_rows_lab1) {
$rs_lab1 = $result_lab1 ? mysqli_fetch_array($result_lab1) : [];
if ($lab_order_list == "") {
$lab_order_list = "'" . $rs_lab1["lab_order_number"] . "'";
} else {
$lab_order_list = $lab_order_list . ",'" . $rs_lab1["lab_order_number"] . "'";
}
$i4++;
}
if ($lab_order_list == "") {
$lab_order_list = "0";
}
$sqlLab2 = "select l.*,i.lab_items_name,i.lab_items_unit,i.lab_items_code,i.lab_items_normal_value,e.staff,l.lab_order_number,j.lab_items_sub_group_name,h.order_date from lab_order l left outer join lab_entry_log e on e.lab_order_number=l.lab_order_number left outer join lab_items i on i.lab_items_code=l.lab_items_code left outer join lab_order_image k on k.lab_order_number=l.lab_order_number left outer join lab_items_sub_group j on j.lab_items_sub_group_code = l.lab_items_sub_group_code LEFT OUTER JOIN lab_head h ON h.lab_order_number = l.lab_order_number where l.lab_order_number in ($lab_order_list) and l.lab_order_result <>'' and i.lab_items_code not in ('332','657','1590','1592','1594','1596','1602','1604','1606','1608') order by l.lab_items_sub_group_code, i.display_order ";
mysqli_query($conn1, "SET SESSION sql_mode=''");
$result_lab2 = mysqli_query($conn1, $sqlLab2);
$num_rows_lab2 = $result_lab2 ? mysqli_num_rows($result_lab2) : 0;
if ($num_rows_lab2 == 0) {
echo "<br>&nbsp;- <span class=detail-text2>ไม่มีรายการผลแล็บ</span>";
} else {
?>
<h4 class="widgettitle">รายงานผลแล็บ</h4>
<table class="modern-table">
<thead>
<tr bgcolor="#3399CC" background="img_mian/bgcolor2.gif" class="headtable">
<th class="head0">
<center>
ลำดับ
</center>
</th>
<th class="head0">
<center>
วันที่ส่งตรวจ
</center>
</th>
<th class="head0">
<center>
ชื่อการส่งตรวจ
</center>
</th>
<th class="head0">
<center>
ผล
</center>
</th>
<th class="head0">
<center>
ค่าปกติ
</center>
</th>
<th class="head0">
<center>
Sub Group
</center>
</th>
</tr>
<thead>
<?php
$i3 = 0;
while ($i3 < $num_rows_lab2) { //while2
$rs_lab2 = $result_lab2 ? mysqli_fetch_array($result_lab2) : [];
$ln = base64_encode($rs_lab2["lab_order_number"]);
?>
<tbody>
<tr class="gradeX">
<td width="" align="">
<center>
<?php echo ($i3 + 1); ?>
</center>
</td>
<td width="10%" align="center">&nbsp;<?php echo thai_date2($rs_lab2["order_date"]); ?></td>
<td width="" align="left">&nbsp;<?php echo $rs_lab2["lab_items_name"]; ?></td>
<td width="" align="left"><?php
if ($rs_lab2["confirm"] == "Y") {
echo $rs_lab2["lab_order_result"] . " " . $rs_lab2["lab_items_unit"] . "&nbsp;&nbsp;&nbsp;";
if (($rs_lab2["lab_order_result"] == "ดูผลใน Image หน้าที่ 1") || ($rs_lab2["lab_order_result"] == "ดูผลใน Image หน้าที่ 2") || ($rs_lab2["lab_order_result"] == "ดูผลใน Image") || ($rs_lab2["lab_order_result"] == " ดูผลใน Image") || ($rs_lab2["lab_order_result"] == "Undetectable") || ($rs_lab2["lab_order_result"] == "Detectable")) {
echo '<a href="lab_image.php?ln=' . $ln . ' " target="_blank" style="text-decoration:none;">[ อ่านผล ]</a> ';
}
} else {
echo "ยังไม่รายงาน";
}
?></td>
<td width="" align="left"><?php echo $rs_lab2["lab_items_normal_value"]; ?></td>
<td width="" align="left">
<?php
if ($rs_lab2["lab_items_sub_group_name"] != NULL) {
echo $rs_lab2["lab_items_sub_group_name"];
} else {
echo "-";
}
?>
</td>
</tr>
<?php
$i3++;
} //while2
?>
<tbody>
</table>
<?php }
} //end row1
?>
<!-- end ส่งตรวจทางห้องปฏิบัติการ -->
<div class="glass-panel">
<h4 class="widgettitle">รายการ x-ray</h4>
<?php if ($num_rows_max4 == 0) {
echo "<font color='red'>&nbsp;- <span class=detail-text2>ไม่มีข้อมูลรายการ x-ray</span><br></font>";
} else {
?>
<table class="modern-table">
<thead>
<tr>
<th class="head0">
<center>
ลำดับ
</center>
</th>
<th class="head0">
<center>
ประเภท
</center>
</th>
<th class="head0">
<center>
ท่า
</center>
</th>
<th class="head0">
<center>
วันที่รายงานผล
</center>
</th>
<th class="head0">
<center>
ส่งมาโดย
</center>
</th>
<th class="head0">
<center>
อ่านผล
</center>
</th>
</tr>
</thead>
<tbody>
<?php
$i4 = 0;
while ($i4 < $num_rows_max4) { //while2
$rs_xray = $result_xray ? mysqli_fetch_array($result_xray) : [];
?>
<tr class="gradeX">
<td>
<center>
<?php echo ($i4 + 1); ?>
</center>
</td>
<td><?php echo $rs_xray["list"]; ?></td>
<td>
<center><?php echo $rs_xray["xtype"]; ?></center>
</td>
<td>
<center>
<?php if ($rs_xray["report_date"] == "") {
echo "-";
} else {
echo "<a href='xray_result.php?xn=" . base64_encode($rs_xray["xn"]) . "' target='_blank'>" . thai_date2($rs_xray["report_date"]) . "</a>";
} ?>
</center>
</td>
<td>
<center><?php echo $rs_xray["dep"]; ?></center>
</td>
<td>
<center>
<a class="badge badge-info" href="http://49.231.191.174:9000/pkg_pacs/external_interface.aspx?TYPE=V&LID=ksh&LPW=1&PID=<?php echo $hn; ?>&AN=10742<?php echo $rs_xray["xn"]; ?>" data-target="" data-toggle="" target="_blank"><i class="iconsweets-magnifying iconsweets-white"></i>ดูฟิล์ม X-Ray</a>
</center>
</td>
</tr>
<?php
$i4++;
} //while2
?>
</tbody>
</table>
<?php } ?>
</div>
@@ -0,0 +1,89 @@
<?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_cid.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 | ค้นหาจาก เลขบัตรประชาชน</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">ค้นหาข้อมูลผู้รับบริการ จาก เลขบัตรประชาชน (CID)</div>
<form id="searchForm" style="display:flex; gap:1rem; margin-bottom: 2rem; align-items:center;">
<input type="text" id="cid" class="form-control" placeholder="ระบุเลขบัตรประชาชน 13 หลัก" 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;">กรุณากรอก เลขบัตรประชาชน และกดค้นหา</td></tr>
</tbody>
</table>
</div>
</div>
</div>
</main>
</div>
<script>
document.getElementById('searchForm').addEventListener('submit', function(e) {
e.preventDefault();
const cid = document.getElementById('cid').value;
const tbody = document.getElementById('resultTableBody');
tbody.innerHTML = '<tr><td colspan="5">กำลังค้นหา...</td></tr>';
fetch('search_cid2.php?cid=' + encodeURIComponent(cid))
.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>
@@ -0,0 +1,38 @@
<?php
require_once("config/db.php");
$cid = $_GET['cid'] ?? '';
$rows = [];
if ($cid !== "") {
$data = "%" . $cid . "%";
$sql = "SELECT hn, pname, fname, lname, cid FROM patient WHERE cid LIKE ? LIMIT 5";
$stmt = $conn1->prepare($sql);
if ($stmt) {
$stmt->bind_param("s", $data);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
$rows[] = $row;
}
$stmt->close();
}
}
if (empty($rows)) {
echo "<tr><td colspan='5'>ไม่มีข้อมูลที่ต้องการค้นหา</td></tr>";
} else {
$num = 1;
foreach ($rows as $row) {
$encoded_hn = base64_encode($row['hn']);
echo "<tr>";
echo "<td>" . $num . "</td>";
echo "<td>" . htmlspecialchars($row['hn']) . "</td>";
echo "<td>" . htmlspecialchars($row['pname'] . $row['fname'] . " " . $row['lname']) . "</td>";
echo "<td>" . htmlspecialchars($row['cid']) . "</td>";
echo "<td><a href='patient.php?hn=" . $encoded_hn . "' class='btn' style='background:rgba(37,99,235,0.1); color:var(--primary); padding:0.25rem 0.5rem;'>ดูข้อมูล</a></td>";
echo "</tr>";
$num++;
}
}
?>
+109
View File
@@ -0,0 +1,109 @@
<?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>
@@ -0,0 +1,38 @@
<?php
require_once("config/db.php");
$hn = $_POST['hn'] ?? '';
$rows = [];
if ($hn !== "") {
$data = "%" . $hn . "%";
$sql = "SELECT hn, pname, fname, lname, cid FROM patient WHERE hn LIKE ? LIMIT 5";
$stmt = $conn1->prepare($sql);
if ($stmt) {
$stmt->bind_param("s", $data);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
$rows[] = $row;
}
$stmt->close();
}
}
if (empty($rows)) {
echo "<tr><td colspan='5'>ไม่มีข้อมูลที่ต้องการค้นหา</td></tr>";
} else {
$num = 1;
foreach ($rows as $row) {
$encoded_hn = base64_encode($row['hn']);
echo "<tr>";
echo "<td>" . $num . "</td>";
echo "<td>" . htmlspecialchars($row['hn']) . "</td>";
echo "<td>" . htmlspecialchars($row['pname'] . $row['fname'] . " " . $row['lname']) . "</td>";
echo "<td>" . htmlspecialchars($row['cid']) . "</td>";
echo "<td><a href='patient.php?hn=" . $encoded_hn . "' class='btn' style='background:rgba(37,99,235,0.1); color:var(--primary); padding:0.25rem 0.5rem;'>ดูข้อมูล</a></td>";
echo "</tr>";
$num++;
}
}
?>
@@ -0,0 +1,98 @@
<?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_name.php";
// Only itcenter can access
$chk1 = preg_match('/itcenter/', $account);
if (!$chk1) {
echo "<center><font color='red'>ไม่มีสิทธิ์เข้าถึงหน้านี้</font></center>";
exit();
}
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 | ค้นหาจาก ชื่อ-สกุล</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">ค้นหาข้อมูลผู้รับบริการ จาก ชื่อ หรือ นามสกุล</div>
<form id="searchForm" style="display:flex; gap:1rem; margin-bottom: 2rem; align-items:center;">
<input type="text" id="fname" class="form-control" placeholder="ชื่อ" style="max-width: 200px;">
<input type="text" id="lname" class="form-control" placeholder="นามสกุล" style="max-width: 200px;">
<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;">กรุณากรอก ชื่อ หรือ นามสกุล และกดค้นหา</td></tr>
</tbody>
</table>
</div>
</div>
</div>
</main>
</div>
<script>
document.getElementById('searchForm').addEventListener('submit', function(e) {
e.preventDefault();
const fname = document.getElementById('fname').value;
const lname = document.getElementById('lname').value;
const tbody = document.getElementById('resultTableBody');
tbody.innerHTML = '<tr><td colspan="5">กำลังค้นหา...</td></tr>';
fetch('search_name2.php?fname=' + encodeURIComponent(fname) + '&lname=' + encodeURIComponent(lname))
.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>
@@ -0,0 +1,58 @@
<?php
require_once("config/db.php");
$fname = $_GET['fname'] ?? '';
$lname = $_GET['lname'] ?? '';
$rows = [];
if ($fname !== "" || $lname !== "") {
$sql = "SELECT hn, pname, fname, lname, cid FROM patient WHERE ";
$params = [];
$types = "";
if ($fname !== "") {
$sql .= "fname LIKE ? ";
$params[] = "%" . $fname . "%";
$types .= "s";
}
if ($lname !== "") {
if ($fname !== "") {
$sql .= "AND ";
}
$sql .= "lname LIKE ? ";
$params[] = "%" . $lname . "%";
$types .= "s";
}
$sql .= " LIMIT 5";
$stmt = $conn1->prepare($sql);
if ($stmt) {
if (!empty($params)) {
$stmt->bind_param($types, ...$params);
}
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
$rows[] = $row;
}
$stmt->close();
}
}
if (empty($rows)) {
echo "<tr><td colspan='5'>ไม่มีข้อมูลที่ต้องการค้นหา</td></tr>";
} else {
$num = 1;
foreach ($rows as $row) {
$encoded_hn = base64_encode($row['hn']);
echo "<tr>";
echo "<td>" . $num . "</td>";
echo "<td>" . htmlspecialchars($row['hn']) . "</td>";
echo "<td>" . htmlspecialchars($row['pname'] . $row['fname'] . " " . $row['lname']) . "</td>";
echo "<td>" . htmlspecialchars($row['cid']) . "</td>";
echo "<td><a href='patient.php?hn=" . $encoded_hn . "' class='btn' style='background:rgba(37,99,235,0.1); color:var(--primary); padding:0.25rem 0.5rem;'>ดูข้อมูล</a></td>";
echo "</tr>";
$num++;
}
}
?>
@@ -0,0 +1,89 @@
<?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_passport.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 | ค้นหาจาก Passport</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">ค้นหาข้อมูลผู้รับบริการ จาก Passport</div>
<form id="searchForm" style="display:flex; gap:1rem; margin-bottom: 2rem; align-items:center;">
<input type="text" id="passport_no" class="form-control" placeholder="ระบุเลข Passport" 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>Passport No.</th>
<th>ดูข้อมูล</th>
</tr>
</thead>
<tbody id="resultTableBody">
<tr><td colspan="5" style="color:var(--text-muted); padding:2rem;">กรุณากรอก Passport No. และกดค้นหา</td></tr>
</tbody>
</table>
</div>
</div>
</div>
</main>
</div>
<script>
document.getElementById('searchForm').addEventListener('submit', function(e) {
e.preventDefault();
const passport_no = document.getElementById('passport_no').value;
const tbody = document.getElementById('resultTableBody');
tbody.innerHTML = '<tr><td colspan="5">กำลังค้นหา...</td></tr>';
fetch('search_passport2.php?passport_no=' + encodeURIComponent(passport_no))
.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>
@@ -0,0 +1,38 @@
<?php
require_once("config/db.php");
$passport_no = $_GET['passport_no'] ?? '';
$rows = [];
if ($passport_no !== "") {
$data = "%" . $passport_no . "%";
$sql = "SELECT hn, pname, fname, lname, passport_no FROM patient WHERE passport_no LIKE ? LIMIT 5";
$stmt = $conn1->prepare($sql);
if ($stmt) {
$stmt->bind_param("s", $data);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
$rows[] = $row;
}
$stmt->close();
}
}
if (empty($rows)) {
echo "<tr><td colspan='5'>ไม่มีข้อมูลที่ต้องการค้นหา</td></tr>";
} else {
$num = 1;
foreach ($rows as $row) {
$encoded_hn = base64_encode($row['hn']);
echo "<tr>";
echo "<td>" . $num . "</td>";
echo "<td>" . htmlspecialchars($row['hn']) . "</td>";
echo "<td>" . htmlspecialchars($row['pname'] . $row['fname'] . " " . $row['lname']) . "</td>";
echo "<td>" . htmlspecialchars($row['passport_no']) . "</td>";
echo "<td><a href='patient.php?hn=" . $encoded_hn . "' class='btn' style='background:rgba(37,99,235,0.1); color:var(--primary); padding:0.25rem 0.5rem;'>ดูข้อมูล</a></td>";
echo "</tr>";
$num++;
}
}
?>
+41
View File
@@ -0,0 +1,41 @@
<?php
require_once("config/db.php");
mysqli_report(MYSQLI_REPORT_OFF);
$hn = "0005969";
$nn = "690619000132"; // 690619000132
$vn1 = $nn; // Assuming vn1 is nn for testing
echo "TESTING VN: $vn1\n";
// Test opitemrece
$sql = "select count(*) as cc from opitemrece where vn='$vn1'";
$res = mysqli_query($conn1, $sql);
$row = mysqli_fetch_assoc($res);
echo "opitemrece (vn='$vn1'): " . $row['cc'] . " rows\n";
// Test opitemrece with AN
$sql = "select count(*) as cc from opitemrece where an='$vn1'";
$res = mysqli_query($conn1, $sql);
$row = mysqli_fetch_assoc($res);
echo "opitemrece (an='$vn1'): " . $row['cc'] . " rows\n";
// Test lab_head
$sql = "select count(*) as cc from lab_head where vn='$vn1'";
$res = mysqli_query($conn1, $sql);
$row = mysqli_fetch_assoc($res);
echo "lab_head (vn='$vn1'): " . $row['cc'] . " rows\n";
// Test xray_report
$sql = "select count(*) as cc from xray_report where vn='$vn1' or an='$vn1'";
$res = mysqli_query($conn1, $sql);
$row = mysqli_fetch_assoc($res);
echo "xray_report: " . $row['cc'] . " rows\n";
// Test ovst
$sql = "select an, vn from ovst where vn='$vn1' or an='$vn1'";
$res = mysqli_query($conn1, $sql);
while($row = mysqli_fetch_assoc($res)){
echo "ovst match: vn=" . $row['vn'] . ", an=" . $row['an'] . "\n";
}
?>