File manager - Edit - /var/www/order.cmtc.ac.th/user/index_org.php
Back
<?php include('../config/db.php'); ?> <?php // ✅ ตรวจสอบสถานะระบบจอง $booking_row = $conn->query("SELECT setting_value FROM settings WHERE setting_key='booking_status'")->fetch_assoc(); $booking_status = $booking_row['setting_value'] ?? 'on'; // ✅ ตรวจสอบค่าสถานะ Free Order $setting = $conn->query("SELECT setting_value FROM settings WHERE setting_key='free_order'")->fetch_assoc(); $free_order_status = $setting['setting_value'] ?? 'off'; // ✅ ดึงข้อมูลสินค้า $res = $conn->query("SELECT * FROM products"); ?> <?php include('template_user_header.php'); ?> <meta charset="UTF-8"> <h3 class="mb-3 text-center">🪙 เลือกรายการเหรียญที่ต้องการจอง</h3> <?php if($booking_status == 'off'): ?> <div class="alert alert-danger text-center fs-5 fw-bold"> ❌ ขณะนี้ระบบปิดการจองเหรียญชั่วคราว<br>กรุณาติดต่อเจ้าหน้าที่หรือตรวจสอบภายหลัง </div> <?php else: ?> <form action="checkout.php" method="post" id="bookingForm"> <div id="step1" class="step-box active"> <h5>1️⃣ เลือกรายการเหรียญ</h5> <table class="table table-bordered bg-white"> <thead class="table-secondary text-center"> <tr><th>เลือก</th><th>รูปภาพ</th><th>ชื่อเหรียญ</th><th>ราคา</th><th>คงเหลือ</th><th>จำนวน</th></tr> </thead> <tbody> <?php while($r=$res->fetch_assoc()): ?> <?php $img1 = !empty($r['img1']) ? "../uploads/products/{$r['img1']}" : ""; $img2 = !empty($r['img2']) ? "../uploads/products/{$r['img2']}" : ""; ?> <tr> <td class="text-center"> <?php if($r['stock'] > 0 || $free_order_status == 'on'): ?> <input type="checkbox" name="product_id[]" value="<?=$r['id']?>"> <?php else: ?> <input type="checkbox" disabled> <?php endif; ?> </td> <td class="text-center"> <?php if($img1 || $img2): ?> <div class="dual-img d-flex justify-content-center gap-2"> <?php if($img1): ?><div><img src="<?=$img1?>" width="80"><div class="small text-muted">หน้า</div></div><?php endif; ?> <?php if($img2): ?><div><img src="<?=$img2?>" width="80"><div class="small text-muted">หลัง</div></div><?php endif; ?> </div> <?php endif; ?> </td> <td><?=$r['name']?></td> <td><?=number_format($r['price'],2)?></td> <td> <?php if($r['stock'] > 0): ?> <?=$r['stock']?> <?php else: ?> <?php if($free_order_status == 'on'): ?> <span class="text-warning fw-bold">หมด (Free Order เปิด)</span> <?php else: ?> <span class="text-danger fw-bold">หมด (ไม่เปิด Free Order)</span> <?php endif; ?> <?php endif; ?> </td> <td> <?php if($r['stock'] > 0 || $free_order_status == 'on'): ?> <input type="number" name="qty[<?=$r['id']?>]" value="1" min="1" class="form-control form-control-sm" style="width:90px;"> <?php else: ?> <input type="number" class="form-control form-control-sm" style="width:90px;" disabled> <?php endif; ?> </td> </tr> <?php endwhile; ?> </tbody> </table> <div class="text-end"><button type="button" id="nextStep" class="btn btn-primary">ถัดไป ➜</button></div> </div> <div id="step2" class="step-box"> <h5>2️⃣ เลือกวิธีรับสินค้า</h5> <div class="mb-3"> <select name="receive_method" id="receiveMethod" class="form-control" required> <option value="">-- เลือกวิธีรับสินค้า --</option> <option value="รับสินค้าด้วยตนเอง">รับสินค้าด้วยตนเอง</option> <option value="จัดส่งทางไปรษณีย์">จัดส่งทางไปรษณีย์</option> </select> </div> <div id="customerInfo" class="border rounded p-3 bg-white" style="display:none;"> <h6 class="text-secondary mb-2">ข้อมูลผู้จอง / ผู้รับสินค้า</h6> <div class="row"> <div class="col-md-6 mb-3"><label>ชื่อ-นามสกุล</label><input type="text" name="fullname" id="fullname" class="form-control"></div> <div class="col-md-6 mb-3"><label>เบอร์โทรศัพท์</label><input type="text" name="phone" id="phone" class="form-control"></div> </div> <div class="mb-3"><label>ที่อยู่จัดส่ง</label><textarea name="address" id="address" class="form-control" rows="2"></textarea></div> <div class="col-md-4 mb-3"><label>รหัสไปรษณีย์</label><input type="text" name="zipcode" id="zipcode" class="form-control"></div> </div> <div class="d-flex justify-content-between mt-3"> <button type="button" class="btn btn-secondary" id="prevStep">⬅ ย้อนกลับ</button> <button type="submit" class="btn btn-success">ดำเนินการต่อ ➜</button> </div> </div> </form> <?php endif; ?> <script> // ✅ เมื่อคลิก "ถัดไป" document.getElementById('nextStep')?.addEventListener('click', function() { const chk = document.querySelectorAll('input[name="product_id[]"]:checked'); if (chk.length === 0) { alert('กรุณาเลือกเหรียญอย่างน้อย 1 รายการ'); return; } document.getElementById('step1').classList.remove('active'); document.getElementById('step2').classList.add('active'); }); // ✅ ปุ่มย้อนกลับ document.getElementById('prevStep')?.addEventListener('click', function() { document.getElementById('step2').classList.remove('active'); document.getElementById('step1').classList.add('active'); }); // ✅ แสดงฟอร์มข้อมูลผู้จองเมื่อเลือกวิธีรับสินค้า document.getElementById('receiveMethod')?.addEventListener('change', function() { document.getElementById('customerInfo').style.display = (this.value !== '') ? 'block' : 'none'; }); </script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.42 |
proxy
|
phpinfo
|
Settings