if (typeof Swal === 'undefined') { console.warn('SweetAlert2 is not loaded. Please include SweetAlert2 before notifications.js'); } function showToast(icon, title, text = '', timer = 1500) { return Swal.fire({ toast: true, position: 'top-end', icon: icon, title: title, text: text, showConfirmButton: false, timer: timer, timerProgressBar: true }); } function showAlert(icon, title, text = '', redirectUrl = null, confirmButtonText = 'ตกลง') { return Swal.fire({ icon: icon, title: title, text: text, confirmButtonText: confirmButtonText }).then((result) => { if (redirectUrl && result.isConfirmed) { window.location.href = redirectUrl; } }); } function showHtmlAlert(icon, title, html = '', width = '600px', redirectUrl = null, confirmButtonText = 'ตกลง') { return Swal.fire({ icon: icon, title: title, html: html, width: width, confirmButtonText: confirmButtonText }).then((result) => { if (redirectUrl && result.isConfirmed) { window.location.href = redirectUrl; } }); } function showConfirm(title, text = '', icon = 'question', confirmButtonText = 'ยืนยัน', cancelButtonText = 'ยกเลิก') { return Swal.fire({ title: title, text: text, icon: icon, showCancelButton: true, confirmButtonText: confirmButtonText, cancelButtonText: cancelButtonText }); }