| Server IP : 182.53.201.61 / Your IP : 216.73.217.175 Web Server : Apache/2.2.15 (Fedora) System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 User : apache ( 48) PHP Version : 5.3.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/KPI monitor/ |
Upload File : |
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
$ebits = ini_get('error_reporting');
error_reporting($ebits ^ E_NOTICE);
include("function.php");
/*$funcContent = file_get_contents(__DIR__ . '/function.php');
echo "<pre style='background:#ffcccc; padding:10px;'>";
echo "function.php size: " . strlen($funcContent) . " bytes\n";
echo "InDept ในไฟล์: " . (strpos($funcContent, 'function InDept') !== false ? 'พบ' : 'ไม่พบ') . "\n";
echo "DeptName ในไฟล์: " . (strpos($funcContent, 'function DeptName') !== false ? 'พบ' : 'ไม่พบ') . "\n";
echo "</pre>";*/
// ===== [1] รับค่า GET และกำหนด isNew ก่อนเลย =====
$id_no = isset($_GET['id_no']) ? intval($_GET['id_no']) : 0;
$isNew = ($id_no == 0);
// ===== [2] debug (ลบออกเมื่อทดสอบเสร็จ) =====
/*echo "<pre style='background:#fff3cd; padding:10px;'>";
echo "id_no: " . $id_no . "\n";
echo "isNew: " . var_export($isNew, true) . "\n";
echo "uDept: " . $_SESSION["uDept"] . "\n";
echo "userStatus: ". (isset($_SESSION["userStatus"]) ? $_SESSION["userStatus"] : 'ไม่มีค่า') . "\n";
echo "cUserID: " . $_SESSION["cUserID"] . "\n";
echo "</pre>";
*/
// ===== [3] เช็คสิทธิ์ =====
if ($isNew) {
if (trim($_SESSION["uDept"], ', ') != 'All' && $_SESSION["userStatus"] != 1) {
echo '<script>alert("ไม่มีสิทธิ์เพิ่มตัวชี้วัด"); history.back();</script>';
exit;
}
} else {
mysql_select_db("KPI");
mysql_query("SET NAMES 'tis620';");
$sqlChk = "select dept, name from indicators where id_no=" . $id_no . " limit 1";
$resChk = mysql_query($sqlChk);
$canOpen = false;
while ($rec = mysql_fetch_object($resChk)) {
if (trim($_SESSION["uDept"], ', ') == 'All') {
$canOpen = true;
} elseif ($_SESSION["userStatus"] == 1) {
$canOpen = InDept($rec->dept, $_SESSION["uDept"]);
} elseif ($_SESSION["userStatus"] == 0) {
$canOpen = (strpos($rec->name, $_SESSION["cUserID"]) !== false);
}
}
if (!$canOpen) {
echo '<script>alert("ไม่มีสิทธิ์แก้ไขตัวชี้วัดนี้"); history.back();</script>';
exit;
}
}
// ===== [4] ผ่านสิทธิ์แล้ว ตั้งค่า Done และรับค่า GET อื่นๆ =====
$_SESSION["Done"] = 'N';
// รับค่า GET (ไม่ประกาศ $id_no ซ้ำ ใช้ค่าจาก [1] ต่อเลย)
$username = isset($_GET['username']) ? $_GET['username'] : '';
$compair = isset($_GET['compair']) ? $_GET['compair'] : '';
$eva = isset($_GET['eva']) ? $_GET['eva'] : '';
$goal = isset($_GET['goal']) ? $_GET['goal'] : '';
if (isset($_GET['bdate']) && $_GET['bdate'] !== "") {
$reportDate = trim($_GET['bdate']);
$curDate = (substr($reportDate,6)-543).'-'.substr($reportDate,3,2).'-'.substr($reportDate,0,2);
} else {
$reportDate = trim(date("d/m/").(date("Y")+543));
$curDate = date('Y-m-d');
}
$UfromDate = substr($reportDate,0,2).'/'.substr($reportDate,3,2).'/'.(substr($reportDate,6)-543);
// ===== [5] ค่า default =====
$indicators = '';
$xgoal = 'x';
$HA = $PA = $GA = $KFA = $HPT = $T_NO = $res = $def = $graph = $name = $name1 = $name2 = '';
$deptList = '';
$sd = $H = $st = $sr = 'N';
$total = $amount = 0;
// ===== [6] ดึงข้อมูล indicators (ครั้งเดียว) =====
if (!$isNew) {
mysql_select_db("KPI");
mysql_query("SET NAMES 'tis620';");
$sql = 'select * from indicators where id_no=' . $id_no . ' limit 1';
$result = mysql_query($sql);
if ($result) {
while ($object = mysql_fetch_object($result)) {
$xgoal = $object->goal;
$indicators = $object->indicators;
$deptList = $object->dept;
$name1 = $object->name1;
$name2 = $object->name2;
$HA = $object->HA;
$PA = $object->PA;
$GA = $object->GA;
$KFA = $object->KFA;
$HPT = $object->HPT;
$T_NO = $object->T_NO;
$name = $object->name;
$def = $object->def;
$graph = $object->graph;
$sd = $object->sd;
$H = $object->H;
$st = $object->st;
$sr = $object->sr;
$eva = $object->eva;
$compair = $object->compair;
$goal = $object->goal;
}
}
// ดึงผลงานของวันที่เลือก
$sql = "select * from result where id_no=" . $id_no . " and date='" . $curDate . "' limit 1";
$result = mysql_query($sql);
while ($object = mysql_fetch_object($result)) {
$total = $object->total;
$amount = $object->amount;
}
}
// หมายเหตุ: ลบ mysql_close() ออก เพราะยังต้องใช้ connection ในส่วน HTML ด้านล่าง
?>
<!DOCTYPE html>
<html lang="th">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>บันทึกข้อมูล KPI</title>
<!-- Bootstrap 5 -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/css/bootstrap-multiselect.css" rel="stylesheet">
<!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/css/bootstrap-multiselect.css" />-->
<script src="java/date/jquery.min.js"></script>
<script src="java/date/bootstrap.min.js"> </script>
<script src="java/date/bootstrap-multiselect.js"></script>
<!-- Carendar-->
<!--<link href="Jcode/jquery-ui.css" rel="stylesheet" type="text/css">-->
<!--<script src="java/date/bootstrap3-typeahead.min.js"></script> -->
<!--<script src="Jcode/jquery-ui.js"></script>-->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css" rel="stylesheet">
<link href="dist/css/bootstrap-datepicker.css" rel="stylesheet" />
<script src="dist/js/bootstrap-datepicker-custom.js"></script>
<script src="dist/locales/bootstrap-datepicker.th.min.js" charset="UTF-8"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/choices.js/public/assets/styles/choices.min.css" />
<script src="https://cdn.jsdelivr.net/npm/choices.js/public/assets/scripts/choices.min.js"></script>
<style>
body {
background-color: #f2f8ff;
font-family: "Prompt", sans-serif;
}
.container {
max-width: 1100px;
}
.card {
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
border-radius: 12px;
margin-top: 2rem;
}
h1 {
font-size: 1.8rem;
color: #FFFFFF;
font-weight: 500;
}
textarea {
resize: none;
}
label {
font-weight: 550;
font-size: 0.9rem;
}
.table-info {
border-radius: 12px;
}
.form-check-label {
font-size: 0.7rem;
}
.footer-img img {
margin: 0 10px;
}.helpBtn {
position: absolute;
top: 10px;
right: 10px;
}
</style>
</head>
<body>
<div class="container">
<div class="text-center my-3">
<img src="image/templatemo_logo.png" width="200">
<p class="text-muted mt-2">ตอบสนองวิสัยทัศน์ : บริการปลอดภัย ร่วมใจทุกภาคี เจ้าหน้าที่มีความสุข</p>
</div>
<div class="card">
<div class="card-header bg-primary text-white text-center" style="background: linear-gradient(135deg, #1a3a5c, #2d6a9f);">
<h1>บันทึกข้อมูล KPI</h1>
</div>
<div class="card-body">
<form id="form1" name="form1" method="post" enctype="multipart/form-data" action="Report.php">
<input type="hidden" name="bdate" value="<?php echo isset($_GET['bdate']) ? $_GET['bdate'] : $UfromDate; ?>">
<div class="d-flex justify-content-end align-items-center">
<h5>คำแนะนำ </h5>
<button type="button" id="helpBtn"
class="btn btn-outline-primary btn-sm background-color: #FCB53B"
data-bs-toggle="popover"
data-bs-placement="right"
title="คำแนะนำการใช้งาน"
data-bs-html="true"
data-bs-content="<p>การเปรียบเทียบ เช่น ระบุเป็นตัวเลขเป้าหมาย<br>1. หน่วยเปอร์เซ็น เติม % <br>2. หน่วยต่อพัน เติม T<br>3. หน่วยต่อแสน เติม H <br>4. < น้อยกว่า, <= น้อยกว่าเท่ากับ<br>5. > มากกว่า , >= มากกว่าเท่ากับ <br>6. = เท่ากับ (อื่นๆกรุณาแจ้ง IT)</p>
<button type='button' class='btn btn-success btn-sm' id='btnMoreHelp'>ดูเพิ่มเติม</button>
">
<i class="bi bi-question-square-fill fs-5"></i>
</button>
</div>
<div class="row mb-3">
<div class="col-md-6">
<label>ID No</label>
<input type="text" readonly class="form-control" value="<?php echo $id_no; ?>">
<input type="hidden" name="id_no" value="<?php echo $id_no; ?>">
</div>
<div class="col-md-6">
<label>วัน/เดือน/ปี</label>
<input name="DateRegis" id="DateRegis" class="form-control thdatepicker" onKeyPress="event.returnValue = false;" data-date-format="mm/dd/yyyy" value = "<?php echo $UfromDate ; ?>" />
</div>
</div>
<div class="mb-3">
<label>ตัวชี้วัด</label>
<input type="text" class="form-control" name="indicators" id="label" value="<?php echo $indicators;?>" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}">
</div>
<div class="row mb-3">
<div class="col-md-8">
<label>จำนวนผลงาน (เศษ)</label>
<input type="text" name="name2" id="name2" class="form-control" value="<?php echo $name2;?>" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}" placeholder="**ใส่ชื่อของตัวเศษ เช่น จำนวนผู้ป่วยที่ไม่เป็นไข้หวัดใหญ่**">
<small class="text-danger">** ชื่อ หรือ คำจำกัดความ แสดงความหมายของข้อมูลที่เป็นผลงานตามตัวชี้วัด เช่น ผู้ป่วยที่เป็นเพศชาย</small>
</div>
<div class="col-md-4">
<label>จำนวนผลงาน</label>
<input type="text" name="amount" id="amount" class="form-control" value="<?php echo isset($amount) ? $amount : ''; ?>" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}" placeholder="**ใส่เลขตัวเศษที่จะนำมาหารด้วยตัวส่วน**">
<div class="form-check mt-1">
<input class="form-check-input" type="checkbox" name="sr" value="Y" <?php if ($sr=="Y") echo 'checked'; ?>>
<label class="form-check-label">ใช้ค่าล่าสุด</label>
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-md-8">
<label>จำนวนข้อมูล (ส่วน)</label>
<input type="text" name="name1" id="name1" class="form-control" value="<?php echo $name1;?>" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}" placeholder="**ใส่ชื่อของตัวส่วน เช่น จำนวนผู้ป่วยทั้งหมด**">
<small class="text-danger">** ชื่อ หรือ คำจำกัดความ เพื่ออธิบายความหมายหรือที่มาของข้อมูล ที่เป็นเป้าหมายการดำเนินงาน เช่น จำนวนผู้ป่วยทั้งหมด</small>
</div>
<div class="col-md-4">
<label>จำนวนข้อมูล</label>
<input type="text" name="total" id="total" class="form-control" value="<?php echo isset($total) ? $total : ''; ?>" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}" placeholder="**ใส่เลขตัวส่วนที่จะนำเป็นตัวตั้งหาร**">
<div class="form-check mt-1">
<input class="form-check-input" type="checkbox" name="st" value="Y" <?php if ($st=="Y") echo 'checked'; ?>>
<label class="form-check-label">ไม่สะสมเป้าหมาย</label>
</div>
</div>
</div>
<label>เป้าหมาย ผลลัพธ์</label>
<div class="row mb-3 g-3">
<div class="col-md-2">
<label>หน่วย</label>
<input type="text" name="goal3" id="goal3" class="form-control" value="<?php echo $eva;?>" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}">
</div>
<div class="col-md-2">
<label>การเปรียบเทียบ</label>
<input type="text" name="goal1" id="goal1" class="form-control" value="<?php echo $compair;?>" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}">
</div>
<div class="col-md-2">
<label>ค่าประเมิน</label>
<input type="text" name="goal2" id="goal2" class="form-control"value="<?php echo $goal;?>" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}">
</div>
<div class="col-md-2 align-self-center">
<div class="form-check ">
<input class="form-check-input" type="checkbox" name="sd" value="Y" <?php if ($sd=="Y") echo 'checked'; ?>>
<label class="form-check-label">แสดง S.D</label>
</div>
</div>
</div>
<label>ผลงานเพื่อตอบสนองภารกิจ(ลำดับภารกิจ)</label>
<small class="text-danger">** กำหนดลำดับการแสดงผลสำหรับแต่ละภารกิจ</small>
<div class="row mb-3 g-3">
<div class="col-md-2">
<label>ระดับองค์กร</label>
<input type="text" name="response2" id="response2" class="form-control" value="<?php echo $HA;?>" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}">
</div>
<div class="col-md-2">
<label>PA</label>
<input type="text" name="response3" id="response3" class="form-control" value="<?php echo $PA;?>" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}">
</div>
<div class="col-md-2">
<label>ตัวชี้วัด สสจ.</label>
<input type="text" name="response5" id="response5" class="form-control" value="<?php echo $HPT;?>" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}">
</div>
<div class="col-md-2">
<label>ระดับทีม</label>
<input type="text" name="response6" id="response6" class="form-control" value="<?php echo $T_NO;?>" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}">
</div>
<div class="col-md-2">
<label>ระดับหน่วยงาน</label>
<input type="text" name="response4" id="response4" class="form-control" value="<?php echo $GA;?>" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}">
</div>
<div class="col-md-2">
<label>เข็มมุ่ง</label>
<input type="text" name="response7" id="response7" class="form-control" value="<?php echo $KFA;?>" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}">
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
<label>คำจำกัดความ (ตัวชี้วัด)</label>
<textarea id="def" name="def" rows="4" class="form-control" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}"><?php echo $def;?></textarea>
</div>
<div class="col-md-6">
<label>คำอธิบายกราฟ</label>
<textarea id="graph" name="graph" rows="4" class="form-control" onKeyPress=" if (event.keyCode ==13){event.returnValue = false;}" maxlength="1000"><?php echo $graph;?></textarea>
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
<label>หน่วยงานที่รับผิดชอบ</label>
<select id="framework" name="framework[]" multiple class="form-control">
<?php
mysql_select_db("KPI");
mysql_query("SET NAMES 'tis620'; ");
$sql="select * from dept";
$result=mysql_query($sql);
while ($rowResp = mysql_fetch_object($result)) {
$sel = (strpos($deptList, trim($rowResp->dept_id).',') !== false) ? 'selected' : '';
echo '<option value="'.$rowResp->dept_id.'" '.$sel.'>'.trim($rowResp->dept).'</option>';
}
?>
</select>
</div>
<div class="col-md-6">
<label>รหัสผู้รับผิดชอบ</label>
<input type="text" name="name" class="form-control" value="<?php echo $name; ?>">
</div>
</div>
<div class="text-end">
<p><?php echo $isNew ? 'สถานะ : เพิ่มตัวชี้วัดใหม่' : 'สถานะ : แก้ไขตัวชี้วัด'; ?></p>
<!-- ปุ่ม submit -->
<?php if ($isNew): ?>
<input type="submit" name="append" value="เพิ่มตัวชี้วัด"
style="background-color:#28a745; color:white; border:none;
padding:8px 16px; border-radius:4px; cursor:pointer;">
<?php else: ?>
<button type="submit" name="insert" id="label4" value="บันทึกข้อมูล" class="btn btn-success me-2"
style="background-color:#28a745; color:white; border:none;
padding:8px 16px; border-radius:4px; cursor:pointer;">บันทึกข้อมูล</button>
<?php endif; ?>
<!-- <button type="submit" name="insert" id="label4" value="บันทึกข้อมูล" class="btn btn-success me-2">บันทึกข้อมูล</button>
<button type="submit" name="append" value="เพิ่มตัวชี้วัด" id="label5" class="btn btn-primary me-2">เพิ่มตัวชี้วัด</button> -->
<button type="submit" name="cancel" style="background-color:#2C3947; color:white; border:none;
padding:8px 16px; border-radius:4px; cursor:pointer;" value="ยกเลิก" id="cancel" >ย้อนกลับ</button>
</div>
</form>
</div>
</div>
</div>
<!-- Popup Overlay -->
<div id="popup-overlay" style="
display:none;
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
background: rgba(0,0,0,0.5);
justify-content: center;
align-items: center;
z-index: 1050;
">
<!-- Popup กล่อง -->
<!-- <div id="popup-error" class="popup bg-white p-4 rounded shadow" style="width: 400px; text-align: center;">
<h5>ยืนยันการลบ</h5>
<p>คุณต้องการลบตัวชี้วัดนี้หรือไม่? ถ้ากดลบข้อมูลจะหายหมดเลยจริงๆนะ</p>
<div class="mt-3">
<button id="confirmDelete" class="btn btn-danger">ลบ</button>
<button onClick="closePopup()" class="btn btn-secondary">ยกเลิก</button>
</div>
</div>-->
</div>
<script>
$(document).ready(function () {
// Choices.js
const frameworkSelect = document.getElementById('framework');
const choices = new Choices(frameworkSelect, {
removeItemButton: true,
placeholder: true,
placeholderValue: 'เลือกหน่วยงาน',
searchPlaceholderValue: 'ค้นหา...',
shouldSort: false,
itemSelectText: 'เลือก',
noResultsText: 'ไม่พบผลลัพธ์',
noChoicesText: 'ไม่มีตัวเลือกให้เลือก',
});
// submit
// script
$('#form1').on('submit', function (event) {
// hidden fields
$('input[name="framework[]"]').remove();
// hidden fields
const selectedValues = choices.getValue(true);
// ลบ attribute name ออกจาก <select> เดิม เพื่อไม่ให้ส่งซ้ำ
$('#framework').removeAttr('name');
// hidden field
selectedValues.forEach(value => {
$('#form1').append('<input type="hidden" name="framework[]" value="' + value + '">');
});
//
});
});
</script>
<script>
function openPopup() {
document.getElementById("popup-overlay").style.display = "flex";
document.querySelector(".popup").style.display = "block";
document.getElementById("popup-error").style.display = "none";
const main = document.getElementById("main-content");
if (main) main.classList.add("blur");
}
function openErrorPopup(msg) {
document.getElementById("popup-overlay").style.display = "flex";
document.querySelector(".popup").style.display = "none";
const popupError = document.getElementById("popup-error");
popupError.style.display = "block";
popupError.querySelector("p").textContent = msg;
const main = document.getElementById("main-content");
if (main) main.classList.add("blur");
}
function closePopup() {
document.getElementById("popup-overlay").style.display = "none";
const main = document.getElementById("main-content");
if (main) main.classList.remove("blur");
location.reload();
}
function closeErrorPopup() {
document.getElementById("popup-overlay").style.display = "none";
const main = document.getElementById("main-content");
if (main) main.classList.remove("blur");
}
document.addEventListener("DOMContentLoaded", function () {
/*const deleteBtn = document.getElementById("label6"); // ปุ่มลบ*/
const form = document.getElementById("form1");
/* deleteBtn.addEventListener("click", function (e) {
e.preventDefault();
// แสดง popup ยืนยัน
openErrorPopup("คุณต้องการลบตัวชี้วัดนี้หรือไม่? ,ถ้ากดลบข้อมูลจะหายหมดเลยจริงๆนะ แน่ใจแล้วใช่มั้ย!!!");
});*/
// เมื่อยืนยันการลบใน popup
/* const confirmBtn = document.getElementById("confirmDelete");
confirmBtn.addEventListener("click", function (e) {
e.preventDefault();
closeErrorPopup();
// เพิ่ม hidden input สำหรับ POST ไปยัง Report.php
const hiddenDelete = document.createElement("input");
hiddenDelete.type = "hidden";
hiddenDelete.name = "delete";
hiddenDelete.value = "ลบตัวชี้วัด"; // ต้องตรงกับ if ใน PHP
form.appendChild(hiddenDelete);
form.submit(); // ส่งฟอร์ม
});*/
// ถ้ากดยกเลิก
/* const cancelBtn = document.getElementById("cancelDelete");
cancelBtn.addEventListener("click", function (e) {
e.preventDefault();
closeErrorPopup();
});*/
});
document.addEventListener('DOMContentLoaded', function () {
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl)
})
});
</script>
<script type="text/javascript">
/* $( function() {
$( "#DateRegis" ).datepicker();
} );
*/
function getValue(vname)
{
var n = document.getElementById('vname').value
return n;
}
var isRedirecting = false;
var ignoreDateChange = false;
function changeFunc() {
// ถ้ากำลัง redirect อยู่ หรือต้อง ignore การเปลี่ยนแปลง
if (isRedirecting || ignoreDateChange) {
return;
}
var dateVal = document.getElementById('DateRegis').value;
if (!dateVal || dateVal.trim() === "") {
return;
}
// ตรวจสอบว่าวันที่เปลี่ยนแปลงจริงหรือไม่
var currentUrl = new URL(window.location.href);
var currentBdate = currentUrl.searchParams.get('bdate');
// ถ้าวันที่เหมือนเดิม ไม่ต้องทำอะไร
if (currentBdate === dateVal) {
return;
}
isRedirecting = true;
var URL = "<?php echo $_SERVER['PHP_SELF'] ?>";
URL += "?bdate=" + encodeURIComponent(dateVal);
URL += "&id_no=" + encodeURIComponent("<?php echo $id_no; ?>");
// เพิ่มเฉพาะพารามิเตอร์ที่มีค่าจริงๆ
<?php if (isset($goal3) && !empty($goal3)): ?>
URL += "&eva=" + encodeURIComponent("<?php echo $goal3; ?>");
<?php endif; ?>
<?php if (isset($goal) && !empty($goal)): ?>
URL += "&goal=" + encodeURIComponent("<?php echo $goal; ?>");
<?php endif; ?>
<?php if (isset($compair) && !empty($compair)): ?>
URL += "&compair=" + encodeURIComponent("<?php echo $compair; ?>");
<?php endif; ?>
console.log("Redirecting:", URL);
window.location.href = URL;
}
$(document).ready(function () {
// ... code อื่นๆ ...
$('#form1').on('submit', function () {
var dateVal = $('.thdatepicker').val();
$('#DateRegisField').val(dateVal);
// บันทึกค่าหน่วยงานที่เลือกจาก Choices.js
const selectedValues = choices.getValue(true);
selectedValues.forEach(value => {
$(this).append('<input type="hidden" name="framework[]" value="' + value + '">');
});
});
$('.thdatepicker').datepicker({
format: 'dd/mm/yyyy',
todayBtn: true,
language: 'th',
thaiyear: true,
autoclose: true
}).on('changeDate', function(e) {
// หน่วงเวลาเพื่อให้แน่ใจว่าเป็นการเลือกวันที่เสร็จสมบูรณ์
setTimeout(function() {
var dateVal = $('#DateRegis').val();
if (dateVal) {
window.location.href = "<?php echo $_SERVER['PHP_SELF'] ?>?bdate=" +
encodeURIComponent(dateVal) + "&id_no=<?php echo $id_no; ?>";
}
}, 200);
});
});
</script>
</body>
</html>