File manager - Edit - /var/www/order.cmtc.ac.th/user/includes/timer_bar.php
Back
<meta charset="UTF-8"> <?php if (session_status() === PHP_SESSION_NONE) session_start(); $remaining_seconds = 0; if (isset($_SESSION['checkout_expire'])) { $remaining_seconds = max(0, $_SESSION['checkout_expire'] - time()); } ?> <?php if ($remaining_seconds > 0): ?> <!-- ✅ Floating Sidebar Countdown --> <div id="timerSidebar" style=" position: fixed; bottom: 20px; right: 20px; width: 280px; background: #f8f9fa; border: 2px solid #dee2e6; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); padding: 16px; font-family: 'Kanit', sans-serif; font-size: 16px; z-index: 2000; transition: all 0.3s ease; "> <div id="timerHeader" style="text-align:center; font-weight:600; color:#dc3545;"> ⏳ เวลาที่เหลือในการชำระเงิน </div> <div id="globalTimer" style=" font-size: 24px; text-align: center; font-weight: bold; color: #dc3545; margin: 8px 0; ">--:--</div> <div style="text-align:center;"> <a href="checkout.php" class="btn btn-success w-100 fw-bold shadow-sm"> 💳 ไปหน้าชำระเงิน </a> </div> </div> <script> let remaining = <?=$remaining_seconds?>; const timerDisplay = document.getElementById('globalTimer'); const sidebar = document.getElementById('timerSidebar'); const header = document.getElementById('timerHeader'); function formatTime(sec){ const m = Math.floor(sec / 60); const s = sec % 60; return m.toString().padStart(2,'0') + ':' + s.toString().padStart(2,'0'); } function updateSidebarColor(sec){ const percent = (sec / (30 * 60)) * 100; if(percent > 50){ sidebar.style.borderColor = "#28a745"; // เขียว header.style.color = "#28a745"; timerDisplay.style.color = "#28a745"; } else if(percent > 20){ sidebar.style.borderColor = "#ffc107"; // เหลือง header.style.color = "#ffc107"; timerDisplay.style.color = "#ffc107"; } else { sidebar.style.borderColor = "#dc3545"; // แดง header.style.color = "#dc3545"; timerDisplay.style.color = "#dc3545"; } } const countdown = setInterval(()=>{ if(remaining <= 0){ clearInterval(countdown); timerDisplay.textContent = "หมดเวลา"; sidebar.style.borderColor = "#dc3545"; setTimeout(()=> window.location.href="includes/expired.php", 1500); } else { timerDisplay.textContent = formatTime(remaining); updateSidebarColor(remaining); remaining--; } }, 1000); </script> <?php else: ?> <!-- 🟢 ไม่มีรายการรอชำระ --> <div id="timerSidebar" style=" position: fixed; bottom: 20px; right: 20px; width: 260px; background: #f1f3f5; border: 1px solid #ced4da; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); padding: 16px; font-family: 'Kanit', sans-serif; font-size: 15px; z-index: 2000; text-align: center; "> <div style="color:#6c757d; font-weight:600;">💰 ไม่มีรายการรอชำระเงิน</div> <a href="index.php" class="btn btn-outline-primary w-100 fw-bold mt-2"> 🛒 ดูตะกร้า </a> </div> <?php endif; ?>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.41 |
proxy
|
phpinfo
|
Settings