File manager - Edit - /var/www/order.cmtc.ac.th/user/check_status.php
Back
<?php session_start(); include('../config/db.php'); include('../includes/check_timer.php'); // ✅ ตรวจสอบว่ามี session การชำระเงินค้างอยู่หรือไม่ $checkout_locked = false; if (isset($_SESSION['checkout_expire']) && time() < $_SESSION['checkout_expire']) { $checkout_locked = true; // ยังอยู่ในระยะเวลาชำระเงิน } // ✅ ตรวจสอบว่ามีเวลานับถอยหลังจาก checkout.php หรือไม่ $checkout_active = false; if (isset($_SESSION['checkout_expire'])) { if (time() < $_SESSION['checkout_expire']) { $checkout_active = true; } else { // ถ้าหมดเวลาแล้วให้ล้างค่า unset($_SESSION['checkout_expire']); } } $phone = isset($_GET['phone']) ? trim($_GET['phone']) : ''; $result = null; if ($phone !== '') { // ป้องกัน SQL Injection ขั้นพื้นฐาน $phone_esc = $conn->real_escape_string($phone); // ดึงออร์เดอร์ของเบอร์นี้ พร้อมรวมชื่อสินค้า x จำนวน ในคอลัมน์ items $sql = " SELECT o.id, o.booking_no, o.total, o.status, o.order_status, o.created_at, GROUP_CONCAT(CONCAT(p.name, ' x', i.qty) ORDER BY i.id SEPARATOR ', ') AS items FROM orders o LEFT JOIN order_items i ON o.id = i.order_id LEFT JOIN products p ON i.product_id = p.id WHERE o.phone = '$phone_esc' GROUP BY o.id ORDER BY o.id DESC "; $result = $conn->query($sql); } ?> <?php include('template_user_header.php'); ?> <?php include('includes/timer_bar.php'); ?> <!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <title>ตรวจสอบสถานะการจอง</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <link href="../assets/css/style.css" rel="stylesheet"> </head> <body class="bg-light"> <div class="container py-5"> <h3 class="text-center mb-4">ตรวจสอบสถานะการจอง</h3> <p><center>รอเจ้าหน้าที่ตรวจสอบสถานะการชำระเงินระยะเวลา 1 วันทำการ</center></p> <form method="get" class="row g-2 justify-content-center mb-4"> <div class="col-auto"> <input type="text" name="phone" class="form-control" style="width:260px" placeholder="กรอกเบอร์โทรศัพท์ผู้จอง" value="<?php echo htmlspecialchars($phone); ?>"> </div> <div class="col-auto"> <button class="btn btn-primary">ตรวจสอบ</button> </div> </form> <?php if ($phone !== ''): ?> <?php if ($result && $result->num_rows > 0): ?> <div class="table-responsive"> <table class="table table-bordered bg-white shadow-sm align-middle"> <thead class="table-dark"> <tr> <th>เลขที่ใบจอง</th> <th>รายการสินค้า</th> <th class="text-end">ยอดรวม (บาท)</th> <th>สถานะการชำระเงิน</th> <th>สถานะการจัดส่ง</th> <th>พิมพ์ใบจอง</th> </tr> </thead> <tbody> <?php while ($row = $result->fetch_assoc()): ?> <tr> <!-- <td><?php echo htmlspecialchars($row['booking_no'] ?: '-'); ?></td> --> <td> <?php if(strpos($row['status'], 'Free Order') !== false): ?> <span class="text-warning fw-bold">Free Order</span> <?php else: ?> <?=htmlspecialchars($row['booking_no'])?> <?php endif; ?> </td> <td><?php echo htmlspecialchars($row['items'] ?: '-'); ?></td> <td class="text-end"><?php echo number_format((float)$row['total'], 2); ?></td> <td> <?php $status = (string)$row['status']; $cls = 'text-primary fw-bold'; if ($status === 'ชำระเงินแล้ว') $cls = 'text-success fw-bold'; if ($status === 'ยกเลิกแล้ว') $cls = 'text-danger fw-bold'; ?> <span class="<?php echo $cls; ?>"><?php echo htmlspecialchars($status); ?></span> </td> <td> <span class="text-success fw-bold"><?php echo $row['order_status'];?></span> </td> <td class="text-center"> <?php if(!empty($row['booking_no'])): ?> <a class="btn btn-sm btn-outline-primary" href="print_invoice_user.php?id=<?php echo (int)$row['id']; ?>" target="_blank">🖨 พิมพ์ใบจอง</a> <?php else: ?> <span class="text-muted">-</span> <?php endif; ?> </td> </tr> <?php endwhile; ?> </tbody> </table> </div> <?php else: ?> <div class="alert alert-warning text-center">ไม่พบข้อมูลการจองของเบอร์นี้</div> <?php endif; ?> <?php endif; ?> </div> </div> <!-- ✅ สคริปต์ตรวจสอบเบอร์โทร --> <script> const phoneInput = document.querySelector('input[name="phone"]'); phoneInput.addEventListener('input', function() { this.value = this.value.replace(/[^0-9]/g, ''); // ตัวเลขเท่านั้น if (this.value.length > 10) this.value = this.value.slice(0, 10); }); const form = document.querySelector('form'); form.addEventListener('submit', function(e) { const phone = phoneInput.value.trim(); if (!/^[0-9]{10}$/.test(phone)) { alert('กรุณากรอกเบอร์โทรศัพท์ให้ถูกต้อง (ตัวเลข 10 หลัก)'); e.preventDefault(); } }); </script> <?php include("../footer.php"); ?> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.42 |
proxy
|
phpinfo
|
Settings