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
@@ -0,0 +1,29 @@
<?php
// liff/api_login.php
session_start();
require_once '../includes/db.php';
header('Content-Type: application/json');
$input = json_decode(file_get_contents('php://input'), true);
$line_uid = $input['line_uid'] ?? '';
if (empty($line_uid)) {
echo json_encode(['status' => 'error', 'message' => 'No Line UID provided']);
exit;
}
// Check if this Line UID is already in the system and active
$stmt = $pdo_bot->prepare("SELECT * FROM line_staff_register WHERE user_id = ? AND ksh_user = 'Y'");
$stmt->execute([$line_uid]);
$staff = $stmt->fetch();
if ($staff) {
// User exists, set session
$_SESSION['cid'] = $staff['cid'];
echo json_encode(['status' => 'success', 'redirect' => 'index.php']);
} else {
// User not found, needs registration
echo json_encode(['status' => 'not_found']);
}
?>
@@ -0,0 +1,38 @@
<?php
session_start();
require_once '../includes/db.php';
if (!isset($_SESSION['cid'])) { header("Location: register.php"); exit; }
$stmt = $pdo->prepare("SELECT * FROM attendances WHERE cid = ? ORDER BY work_date DESC LIMIT 30");
$stmt->execute([$_SESSION['cid']]);
$attendances = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ข้อมูลเวลาเข้า-ออกงาน</title>
<link href="https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../assets/css/style.css">
</head>
<body>
<div class="header">
<h2>เวลาเข้า-ออกงาน (30 วันล่าสุด)</h2>
</div>
<div class="card" style="margin: 20px;">
<?php if (count($attendances) > 0): ?>
<?php foreach ($attendances as $att): ?>
<div style="border-bottom: 1px solid #eee; padding: 10px 0; display:flex; justify-content: space-between;">
<div><strong>วันที่:</strong> <?= $att['work_date'] ?></div>
<div><strong>เข้า:</strong> <?= $att['time_in'] ?: '-' ?> <strong>ออก:</strong> <?= $att['time_out'] ?: '-' ?></div>
</div>
<?php endforeach; ?>
<?php else: ?>
<p style="text-align:center;">ไม่มีข้อมูลการลงเวลา</p>
<?php endif; ?>
<br>
<a href="index.php" class="btn-magic" style="background: #ccc; color: #333;">กลับสู่เมนูหลัก</a>
</div>
</body>
</html>
@@ -0,0 +1,120 @@
<?php
session_start();
require_once '../includes/db.php';
if (!isset($_SESSION['cid'])) {
// If not logged in, go to register which handles LIFF auto-login
header("Location: register.php");
exit;
}
$cid = $_SESSION['cid'];
// Fetch Staff Data
$stmt = $pdo_bot->prepare("SELECT * FROM line_staff_register WHERE cid = ?");
$stmt->execute([$cid]);
$staff = $stmt->fetch();
if (!$staff) {
// If not found, redirect to register
header("Location: register.php");
exit;
}
// Check Assessment Requirement
$require_assessment = getSetting($pdo, 'require_assessment');
$assessment_status = $staff['assessment_status'];
$can_access_menus = true;
if ($require_assessment == '1' && $assessment_status == '0') {
$can_access_menus = false;
}
?>
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>KSH-STAFF Menu</title>
<link href="https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../assets/css/style.css">
<!-- SweetAlert2 -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- FontAwesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
</head>
<body>
<div class="header">
<div class="shiny-logo" style="width: 100px; height: 100px; border-radius: 50%; margin: 0 auto; display: flex; align-items: center; justify-content: center; background: #fff;">
<img src="../assets/images/logo.png" alt="Logo" style="width: 100%; height: 100%; object-fit: contain;">
</div>
<h1>KSH-STAFF</h1>
<p>ยินดีต้อนรับ, คุณ <?= htmlspecialchars($staff['fname'] . ' ' . $staff['lname']) ?></p>
</div>
<div class="card" style="margin: 20px;">
<?php if (!$can_access_menus): ?>
<div style="background: #fff3cd; color: #856404; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #ffeeba;">
<i class="fas fa-exclamation-triangle"></i> <strong>แจ้งเตือน!</strong> คุณยังไม่ได้ทำแบบประเมินหน่วยงาน โปรดทำแบบประเมินเพื่อเข้าใช้งานเมนูต่างๆ
<br><br>
<button class="btn-magic" onclick="doAssessment()">ทำแบบประเมินตอนนี้</button>
</div>
<?php endif; ?>
<div class="menu-grid">
<a href="profile.php" class="menu-item" onclick="return checkAccess()">
<div class="menu-icon"><i class="fas fa-user"></i></div>
1. ข้อมูลส่วนตัว
</a>
<a href="leave.php" class="menu-item" onclick="return checkAccess()">
<div class="menu-icon"><i class="fas fa-calendar-alt"></i></div>
2. ข้อมูลวันลา
</a>
<a href="attendance.php" class="menu-item" onclick="return checkAccess()">
<div class="menu-icon"><i class="fas fa-clock"></i></div>
3. เวลาเข้า-ออก
</a>
<a href="salary.php" class="menu-item" onclick="return checkAccess()">
<div class="menu-icon"><i class="fas fa-file-invoice-dollar"></i></div>
4. ข้อมูลเงินเดือน
</a>
<a href="links.php" class="menu-item" onclick="return checkAccess()">
<div class="menu-icon"><i class="fas fa-link"></i></div>
5. ระบบอื่นๆ
</a>
</div>
</div>
<script>
const canAccess = <?= $can_access_menus ? 'true' : 'false' ?>;
function checkAccess() {
if (!canAccess) {
Swal.fire({
icon: 'warning',
title: 'ไม่สามารถเข้าใช้งานได้',
text: 'กรุณาทำแบบประเมินหน่วยงานก่อนเข้าใช้งานเมนูนี้',
confirmButtonText: 'รับทราบ',
confirmButtonColor: '#0072ff'
});
return false;
}
return true;
}
function doAssessment() {
Swal.fire({
title: 'จำลองการทำแบบประเมิน',
text: 'กำลังพาไปยังระบบประเมิน...',
icon: 'info'
}).then(() => {
// Mock redirect to assessment or API call
window.location.href = 'mock_assessment.php';
});
}
</script>
</body>
</html>
@@ -0,0 +1,39 @@
<?php
session_start();
require_once '../includes/db.php';
if (!isset($_SESSION['cid'])) { header("Location: register.php"); exit; }
$stmt = $pdo->prepare("SELECT * FROM leaves WHERE cid = ? ORDER BY start_date DESC");
$stmt->execute([$_SESSION['cid']]);
$leaves = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ข้อมูลวันลา</title>
<link href="https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../assets/css/style.css">
</head>
<body>
<div class="header">
<h2>ข้อมูลวันลา</h2>
</div>
<div class="card" style="margin: 20px;">
<?php if (count($leaves) > 0): ?>
<?php foreach ($leaves as $leave): ?>
<div style="border-bottom: 1px solid #eee; padding: 10px 0;">
<strong>ประเภท:</strong> <?= htmlspecialchars($leave['leave_type']) ?><br>
<strong>วันที่:</strong> <?= $leave['start_date'] ?> ถึง <?= $leave['end_date'] ?><br>
<strong>สถานะ:</strong> <?= htmlspecialchars($leave['status']) ?>
</div>
<?php endforeach; ?>
<?php else: ?>
<p style="text-align:center;">ไม่มีข้อมูลวันลา</p>
<?php endif; ?>
<br>
<a href="index.php" class="btn-magic" style="background: #ccc; color: #333;">กลับสู่เมนูหลัก</a>
</div>
</body>
</html>
@@ -0,0 +1,30 @@
<?php
session_start();
if (!isset($_SESSION['cid'])) { header("Location: register.php"); exit; }
$cid = $_SESSION['cid'];
?>
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ระบบอื่นๆ</title>
<link href="https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../assets/css/style.css">
</head>
<body>
<div class="header">
<h2>ระบบอื่นๆ</h2>
</div>
<div class="card" style="margin: 20px;">
<p>คลิกเพื่อไปยังระบบต่างๆ (ส่งค่ารหัสประจำตัวไปด้วย)</p>
<div style="display: flex; flex-direction: column; gap: 10px;">
<a href="https://example.com/system1?cid=<?= htmlspecialchars($cid) ?>" target="_blank" class="btn-magic" style="background: #28a745;">ระบบสารบรรณ</a>
<a href="https://example.com/system2?cid=<?= htmlspecialchars($cid) ?>" target="_blank" class="btn-magic" style="background: #17a2b8;">ระบบแจ้งซ่อม</a>
<a href="https://example.com/system3?cid=<?= htmlspecialchars($cid) ?>" target="_blank" class="btn-magic" style="background: #6c757d;">ระบบเบิกวัสดุ</a>
</div>
<br><br>
<a href="index.php" class="btn-magic" style="background: #ccc; color: #333;">กลับสู่เมนูหลัก</a>
</div>
</body>
</html>
@@ -0,0 +1,39 @@
<?php
session_start();
require_once '../includes/db.php';
if (!isset($_SESSION['cid'])) {
header("Location: register.php");
exit;
}
$stmt = $pdo_bot->prepare("SELECT * FROM line_staff_register WHERE cid = ?");
$stmt->execute([$_SESSION['cid']]);
$staff = $stmt->fetch();
?>
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ข้อมูลส่วนตัว</title>
<link href="https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../assets/css/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
</head>
<body>
<div class="header">
<h2><i class="fas fa-user"></i> ข้อมูลส่วนตัว</h2>
</div>
<div class="card" style="margin: 20px;">
<p><strong>CID:</strong> <?= htmlspecialchars($staff['cid']) ?></p>
<p><strong>HN:</strong> <?= htmlspecialchars($staff['hn']) ?></p>
<p><strong>ชื่อ-นามสกุล:</strong> <?= htmlspecialchars($staff['fname'] . ' ' . $staff['lname']) ?></p>
<p><strong>เบอร์โทรศัพท์:</strong> <?= htmlspecialchars($staff['phone']) ?></p>
<p><strong>สถานะประเมิน:</strong> <?= $staff['assessment_status'] == '1' ? '<span style="color:green;">ทำแล้ว</span>' : '<span style="color:red;">ยังไม่ทำ</span>' ?></p>
<br>
<a href="index.php" class="btn-magic" style="background: #ccc; color: #333;">กลับสู่เมนูหลัก</a>
</div>
</body>
</html>
@@ -0,0 +1,281 @@
<?php
session_start();
require_once '../includes/db.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$cid = trim($_POST['cid'] ?? '');
$phone = trim($_POST['phone'] ?? '');
$line_uid = trim($_POST['line_uid'] ?? '');
$consent = $_POST['consent'] ?? '';
if (empty($line_uid)) {
$error = "เกิดข้อผิดพลาด: ไม่พบข้อมูล Line UID กรุณาเปิดผ่านแอปพลิเคชัน Line";
} elseif (empty($consent)) {
$error = "กรุณากดยอมรับข้อตกลงการใช้งาน";
} else {
// Find HN from HIS patient table using $conn_hosxp
if ($conn_hosxp) {
$cid_safe = mysqli_real_escape_string($conn_hosxp, $cid);
$getHN = "SELECT * FROM patient WHERE cid='$cid_safe'";
$result_hn = mysqli_query($conn_hosxp, $getHN);
$patient = mysqli_fetch_assoc($result_hn);
} else {
// Fallback for local testing if hosxp connection fails
// (Using the mock table in $pdo)
$stmt_hn = $pdo->prepare("SELECT hn, fname, lname FROM patient WHERE cid = ?");
$stmt_hn->execute([$cid]);
$patient = $stmt_hn->fetch();
}
if ($patient) {
$hn = $patient['hn'];
$fname = $patient['fname'];
$lname = $patient['lname'];
// Check if CID already registered in line_staff_register
$stmt_check = $pdo_bot->prepare("SELECT * FROM line_staff_register WHERE cid = ?");
$stmt_check->execute([$cid]);
$existing = $stmt_check->fetch();
if ($existing) {
if (!empty($existing['user_id']) && $existing['user_id'] !== $line_uid) {
$error = "เลขบัตรประชาชนนี้ถูกผูกกับบัญชี Line อื่นไปแล้ว";
} else {
// Update existing
$update = $pdo_bot->prepare("UPDATE line_staff_register SET user_id = ?, phone = ?, hn = ?, fname = ?, lname = ?, date = NOW(), ksh_user = 'Y' WHERE cid = ?");
$update->execute([$line_uid, $phone, $hn, $fname, $lname, $cid]);
$_SESSION['cid'] = $cid;
echo "<script>alert('อัปเดตข้อมูลและผูกบัญชี Line สำเร็จ'); window.location.href='index.php';</script>";
exit;
}
} else {
// Insert new
$insert = $pdo_bot->prepare("INSERT INTO line_staff_register (user_id, fname, lname, cid, phone, date, hn, ksh_user, assessment_status) VALUES (?, ?, ?, ?, ?, NOW(), ?, 'Y', 0)");
$insert->execute([$line_uid, $fname, $lname, $cid, $phone, $hn]);
$_SESSION['cid'] = $cid;
echo "<script>alert('ลงทะเบียนสำเร็จ'); window.location.href='index.php';</script>";
exit;
}
} else {
$error = "ไม่พบหมายเลขบัตรประชาชนในระบบข้อมูลผู้ป่วย (HIS) กรุณาติดต่อหน่วยงานที่ดูแล";
}
}
}
?>
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>ลงทะเบียนเข้าใช้งาน</title>
<link rel="icon" type="image/png" href="../assets/img/logo.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<script src="https://static.line-scdn.net/liff/edge/2/sdk.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
sans: ['Sarabun', 'sans-serif'],
},
animation: {
shine: 'shine 3s ease-in-out infinite'
},
keyframes: {
shine: {
'0%': { left: '-150%' },
'20%': { left: '150%' },
'100%': { left: '150%' }
}
}
}
}
}
</script>
</head>
<body class="bg-gray-50 font-sans antialiased text-gray-800 min-h-screen flex flex-col items-center justify-center p-4">
<div class="w-full max-w-md">
<!-- Header -->
<div class="text-center mb-8">
<div class="relative inline-block overflow-hidden rounded-full w-24 h-24 mx-auto mb-4 shadow-md bg-white p-1">
<img src="../assets/img/logo.png" alt="Logo" class="w-full h-full object-cover rounded-full relative z-10">
<div class="absolute inset-0 z-20 w-1/2 h-full bg-gradient-to-r from-transparent via-white/60 to-transparent -skew-x-12 animate-shine mix-blend-overlay"></div>
</div>
<h2 class="text-2xl font-bold text-gray-800">ลงทะเบียน KSH-STAFF</h2>
</div>
<!-- Loading State -->
<div id="loading" class="text-center bg-white rounded-2xl shadow-sm border border-gray-100 p-8">
<i class="fas fa-circle-notch fa-spin text-blue-500 text-4xl mb-4"></i>
<p class="text-gray-600 font-medium">กำลังตรวจสอบข้อมูล Line ของคุณ...</p>
</div>
<!-- Register Form -->
<div id="register-form" class="hidden bg-white rounded-2xl shadow-sm border border-gray-100 p-6 md:p-8">
<?php if (!empty($error)): ?>
<div class="bg-red-50 text-red-500 text-sm font-medium py-3 px-4 rounded-lg text-center mb-6 border border-red-100">
<?= htmlspecialchars($error) ?>
</div>
<?php endif; ?>
<form method="post" id="form-content">
<input type="hidden" name="line_uid" id="line_uid" value="">
<div class="mb-5">
<label class="block text-sm font-semibold text-gray-700 mb-2">เลขบัตรประชาชน (13 หลัก)</label>
<input type="text" name="cid" class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-blue-500 focus:ring-2 focus:ring-blue-200 outline-none transition duration-200" placeholder="ระบุเลข 13 หลัก" required pattern="\d{13}" oninvalid="this.setCustomValidity('รูปแบบเลขบัตรไม่ถูกต้อง')" oninput="this.setCustomValidity('')">
</div>
<div class="mb-6">
<label class="block text-sm font-semibold text-gray-700 mb-2">หมายเลขโทรศัพท์</label>
<input type="text" name="phone" class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-blue-500 focus:ring-2 focus:ring-blue-200 outline-none transition duration-200" placeholder="08xxxxxxxx" required pattern="\d{9,10}" oninvalid="this.setCustomValidity('รูปแบบเบอร์โทรศัพท์ไม่ถูกต้อง')" oninput="this.setCustomValidity('')">
</div>
<div class="mb-8 flex items-start gap-3 bg-gray-50 p-4 rounded-xl border border-gray-100">
<div class="flex items-center h-5 mt-0.5">
<input type="checkbox" name="consent" id="consent" value="1" required class="w-5 h-5 text-blue-600 bg-white border-gray-300 rounded focus:ring-blue-500">
</div>
<label for="consent" class="text-sm text-gray-600 cursor-pointer select-none">
ข้าพเจ้ายอมรับ <button type="button" onclick="document.getElementById('pdpaModal').classList.remove('hidden')" class="text-blue-600 font-semibold hover:underline">ข้อตกลงการใช้งาน</button>
</label>
</div>
<button type="submit" class="w-full bg-gradient-to-r from-blue-500 to-blue-600 hover:from-blue-600 hover:to-blue-700 text-white font-bold py-3.5 px-4 rounded-xl shadow-md transform hover:-translate-y-0.5 transition duration-200">
ยืนยันการลงทะเบียน
</button>
</form>
</div>
</div>
<!-- PDPA Modal -->
<div id="pdpaModal" class="hidden fixed inset-0 z-50 overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true">
<div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
<!-- Background overlay -->
<div class="fixed inset-0 bg-gray-900 bg-opacity-50 transition-opacity" aria-hidden="true" onclick="document.getElementById('pdpaModal').classList.add('hidden')"></div>
<span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span>
<div class="inline-block align-bottom bg-white rounded-2xl text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg w-full">
<div class="bg-blue-600 px-6 py-4 flex justify-between items-center">
<h3 class="text-lg leading-6 font-bold text-white" id="modal-title">ข้อตกลงการใช้งาน</h3>
<button type="button" class="text-white hover:text-gray-200 focus:outline-none" onclick="document.getElementById('pdpaModal').classList.add('hidden')">
<i class="fas fa-times text-xl"></i>
</button>
</div>
<div class="bg-white px-6 py-6 h-96 overflow-y-auto text-sm text-gray-600 leading-relaxed">
<p class="mb-4 indent-4">โปรดอ่านข้อความด้านล่างนี้เพื่อทำความเข้าใจวัตถุประสงค์ในการเก็บรวบรวม ใช้ และเปิดเผยข้อมูลของท่าน โรงพยาบาลเกาะสมุยให้บริการ LINE Official Account KSH STAFF เพื่ออำนวยความสะดวกในการสื่อสารและให้บริการแก่ท่าน การที่ท่านกดเพิ่มเพื่อนใน LINE Official Account ของโรงพยาบาล หรือให้ข้อมูลส่วนบุคคลแก่เราผ่านช่องทาง LINE นี้ ถือว่าท่านได้อ่านและทำความเข้าใจ รวมถึงให้ความยินยอมตามวัตถุประสงค์ดังต่อไปนี้ :</p>
<ul class="space-y-4">
<li><b class="text-gray-800">1. วัตถุประสงค์ในการเก็บรวบรวม ใช้ และเปิดเผยข้อมูล:</b>
<ul class="list-disc pl-5 mt-2 space-y-1">
<li>เพื่อใช้เป็นช่องทางในการติดต่อสื่อสารระหว่างท่านกับโรงพยาบาล เช่น ข้อมูลส่วนตัว, ข้อมูลเงินเดือน, ข้อมูลการลา, ข้อมูลการเข้า-ออกงาน</li>
<li>เพื่อประชาสัมพันธ์ข้อมูลข่าวสาร, กิจกรรมที่เกี่ยวข้องกับบริการของโรงพยาบาล</li>
<li>เพื่อตอบคำถาม หรือให้ความช่วยเหลือตามที่ท่านสอบถามผ่านช่องทาง LINE</li>
<li>เพื่อปรับปรุงและพัฒนาบริการของโรงพยาบาลให้ดียิ่งขึ้น</li>
</ul>
</li>
<li><b class="text-gray-800">2. ข้อมูลส่วนบุคคลที่อาจมีการเก็บรวบรวม:</b>
<ul class="list-disc pl-5 mt-2 space-y-1">
<li><b>ข้อมูลบัญชี LINE ของท่าน:</b> ชื่อโปรไฟล์, รูปโปรไฟล์</li>
<li><b>ข้อความสนทนา:</b> ข้อความที่ท่านส่งมายัง LINE Official Account ของโรงพยาบาล</li>
<li><b>ข้อมูลที่ท่านให้เพิ่มเติม:</b> เช่น ชื่อ-นามสกุล,เลขบัตรประจำตัวประชาชน, เบอร์โทรศัพท์, วันเกิด,หมายเลขPassport หรือข้อมูลสุขภาพเบื้องต้น</li>
</ul>
</li>
<li><b class="text-gray-800">3. การคุ้มครองข้อมูลส่วนบุคคล:</b>
<ul class="list-disc pl-5 mt-2 space-y-1">
<li>โรงพยาบาลจะเก็บรักษาข้อมูลส่วนบุคคลของท่านที่ได้รับผ่าน LINE Official Account ไว้เป็นความลับตามมาตรฐานการรักษาความปลอดภัยของโรงพยาบาลและกฎหมายคุ้มครองข้อมูลส่วนบุคคล (PDPA)</li>
<li>ข้อมูลของท่านจะถูกใช้งานตามวัตถุประสงค์ที่แจ้งไว้เท่านั้น และจะไม่ถูกเปิดเผยแก่บุคคลที่สามโดยไม่ได้รับความยินยอมจากท่าน เว้นแต่เป็นกรณีที่กฎหมายกำหนด</li>
</ul>
</li>
<li><b class="text-gray-800">4. สิทธิของท่าน:</b>
<ul class="list-disc pl-5 mt-2 space-y-1">
<li>ท่านมีสิทธิที่จะยกเลิกการเป็นเพื่อนกับ LINE Official Account ของโรงพยาบาลได้ตลอดเวลา</li>
<li>ท่านสามารถขอเข้าถึง ขอแก้ไข หรือขอให้ลบข้อมูลส่วนบุคคลของท่านที่เกี่ยวข้องกับการใช้ LINE Official Account นี้ได้ โดยติดต่อ งานสุขภาพดิจิทัล โรงพยาบาลเกาะสมุย โทร 077913200 ต่อ 3013</li>
</ul>
</li>
</ul>
<div class="mt-6 p-4 bg-blue-50 rounded-lg text-blue-800 border border-blue-100">
<p class="font-semibold mb-2">โดยการกด "เพิ่มเพื่อน" หรือดำเนินการใช้งาน LINE Official Account KSH STAFF ต่อไป ถือว่าท่านได้อ่านและตกลงให้ความยินยอมตามข้อกำหนดข้างต้นทุกประการ</p>
<p class="text-xs">หากมีข้อสงสัยหรือต้องการสอบถามเพิ่มเติม โปรดติดต่อ งานสุขภาพดิจิทัล โรงพยาบาลเกาะสมุย โทร 077913200 ต่อ 3013 หรือ contact@samuihospital.go.th</p>
</div>
</div>
<div class="bg-gray-50 px-6 py-4 flex justify-end border-t border-gray-200">
<button type="button" class="bg-gray-200 hover:bg-gray-300 text-gray-800 font-semibold py-2 px-6 rounded-lg transition duration-200" onclick="document.getElementById('pdpaModal').classList.add('hidden')">ปิดหน้าต่าง</button>
</div>
</div>
</div>
</div>
<script>
// ใส่ LIFF ID ของคุณที่นี่
const LIFF_ID = "YOUR_LIFF_ID_HERE";
async function initializeLiff() {
try {
if (LIFF_ID === "YOUR_LIFF_ID_HERE") {
console.warn("Please configure your LIFF_ID. Bypassing LIFF for testing.");
showRegisterForm("U_TEST_DUMMY_ID", "Tester");
return;
}
await liff.init({ liffId: LIFF_ID });
if (!liff.isLoggedIn()) {
liff.login();
return;
}
const profile = await liff.getProfile();
const userId = profile.userId;
const displayName = profile.displayName;
// ตรวจสอบว่าเคยลงทะเบียนหรือยัง
const response = await fetch('api_login.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ line_uid: userId })
});
const data = await response.json();
if (data.status === 'success') {
// ล็อกอินอัตโนมัติสำเร็จ
window.location.href = data.redirect;
} else {
// ยังไม่เคยลงทะเบียน ให้แสดงฟอร์ม
showRegisterForm(userId, displayName);
}
} catch (err) {
console.error('LIFF Error:', err);
Swal.fire('ข้อผิดพลาด', 'ไม่สามารถเชื่อมต่อระบบ Line ได้: ' + err.message, 'error');
document.getElementById('loading').innerHTML = "<div class='text-red-500 font-semibold'>ไม่สามารถใช้งาน LIFF ได้</div>";
}
}
function showRegisterForm(userId, displayName) {
document.getElementById('loading').classList.add('hidden');
document.getElementById('register-form').classList.remove('hidden');
document.getElementById('line_uid').value = userId;
document.getElementById('line_display_name').innerText = displayName;
}
window.onload = function() {
initializeLiff();
<?php if (!empty($error)): ?>
document.getElementById('loading').classList.add('hidden');
document.getElementById('register-form').classList.remove('hidden');
<?php endif; ?>
};
</script>
</body>
</html>
@@ -0,0 +1,38 @@
<?php
session_start();
require_once '../includes/db.php';
if (!isset($_SESSION['cid'])) { header("Location: register.php"); exit; }
$stmt = $pdo->prepare("SELECT * FROM salaries WHERE cid = ? ORDER BY year DESC, month DESC LIMIT 12");
$stmt->execute([$_SESSION['cid']]);
$salaries = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ข้อมูลเงินเดือน</title>
<link href="https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../assets/css/style.css">
</head>
<body>
<div class="header">
<h2>สลิปเงินเดือน</h2>
</div>
<div class="card" style="margin: 20px;">
<?php if (count($salaries) > 0): ?>
<?php foreach ($salaries as $sal): ?>
<div style="border-bottom: 1px solid #eee; padding: 10px 0; display:flex; justify-content: space-between; align-items:center;">
<div><strong>เดือน/ปี:</strong> <?= str_pad($sal['month'], 2, '0', STR_PAD_LEFT) ?>/<?= $sal['year'] ?></div>
<div><strong style="color: #0072ff;"><?= number_format($sal['net_salary'], 2) ?> ฿</strong></div>
</div>
<?php endforeach; ?>
<?php else: ?>
<p style="text-align:center;">ไม่มีข้อมูลเงินเดือน</p>
<?php endif; ?>
<br>
<a href="index.php" class="btn-magic" style="background: #ccc; color: #333;">กลับสู่เมนูหลัก</a>
</div>
</body>
</html>