66 lines
3.4 KiB
PHP
66 lines
3.4 KiB
PHP
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h1 class="h3 mb-0 text-gray-800">ตั้งค่า LINE Notify</h1>
|
|
<a href="<?= BASE_URL ?>/settings" class="btn btn-secondary"><i class="fa-solid fa-arrow-left me-1"></i> กลับ</a>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-lg-6">
|
|
<div class="card shadow border-0 mb-4">
|
|
<div class="card-header bg-white py-3">
|
|
<h6 class="m-0 font-weight-bold text-success"><i class="fa-brands fa-line me-2"></i>การเชื่อมต่อ LINE Notify</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="text-muted">ระบบจะส่งการแจ้งเตือนไปยังผู้มีอำนาจพิจารณาเมื่อมีคำขอใหม่ และแจ้งเตือนผู้ขอเมื่อมีการอนุมัติ/ปฏิเสธ</p>
|
|
|
|
<form action="<?= BASE_URL ?>/settings/line-notify/save" method="POST">
|
|
<input type="hidden" name="csrf_token" value="<?= $csrf_token ?>">
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">LINE Notify Token <span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="line_token" value="<?= htmlspecialchars($line_token ?? '') ?>" placeholder="กรอก Token ที่ได้จาก LINE Notify">
|
|
<div class="form-text">คุณสามารถรับ Token ได้จาก <a href="https://notify-bot.line.me/" target="_blank">LINE Notify</a></div>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-success"><i class="fa-solid fa-save me-1"></i> บันทึกตั้งค่า</button>
|
|
<button type="button" class="btn btn-outline-primary ms-2" id="testLineBtn"><i class="fa-solid fa-paper-plane me-1"></i> ทดสอบส่งข้อความ</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
$extraScripts = '
|
|
<script>
|
|
document.getElementById("testLineBtn").addEventListener("click", function() {
|
|
const btn = this;
|
|
btn.disabled = true;
|
|
btn.innerHTML = \'<i class="fa-solid fa-spinner fa-spin me-1"></i> กำลังทดสอบ...\';
|
|
|
|
fetch("' . BASE_URL . '/settings/line-notify/test", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
},
|
|
body: "csrf_token=' . $csrf_token . '"
|
|
})
|
|
.then(res => res.json())
|
|
.then(data => {
|
|
btn.disabled = false;
|
|
btn.innerHTML = \'<i class="fa-solid fa-paper-plane me-1"></i> ทดสอบส่งข้อความ\';
|
|
if (data.status === "success") {
|
|
alert(data.message);
|
|
} else {
|
|
alert("เกิดข้อผิดพลาด: " + data.message);
|
|
}
|
|
})
|
|
.catch(err => {
|
|
btn.disabled = false;
|
|
btn.innerHTML = \'<i class="fa-solid fa-paper-plane me-1"></i> ทดสอบส่งข้อความ\';
|
|
alert("Error: " + err.message);
|
|
});
|
|
});
|
|
</script>
|
|
';
|
|
?>
|