File manager - Edit - /var/www/order.cmtc.ac.th/admin/orders_free_print.php
Back
<?php session_start(); if(!isset($_SESSION['admin'])) { header('Location: index.php'); exit; } include('../config/db.php'); date_default_timezone_set('Asia/Bangkok'); $date_from = $_GET['date_from'] ?? date('Y-m-d', strtotime('-6 days')); $date_to = $_GET['date_to'] ?? date('Y-m-d'); $filter_receive = $_GET['receive'] ?? 'all'; $search = trim($_GET['search'] ?? ''); // เงื่อนไขเฉพาะ Free Order $where = "WHERE o.order_type='Free Order' AND DATE(o.created_at) BETWEEN ? AND ?"; $params = [$date_from, $date_to]; $types = 'ss'; if($filter_receive != 'all'){ $where .= " AND o.receive_method=?"; $params[] = ($filter_receive=='self' ? 'รับสินค้าด้วยตนเอง' : 'จัดส่งทางไปรษณีย์'); $types .= 's'; } if($search != ''){ $where .= " AND (o.booking_no LIKE ? OR o.fullname LIKE ? OR o.phone LIKE ?)"; $s = "%".$search."%"; $params[] = $s; $params[] = $s; $params[] = $s; $types .= 'sss'; } $sql = " SELECT o.*, GROUP_CONCAT(CONCAT(p.name,' x',i.qty) SEPARATOR ', ') AS items FROM orders o JOIN order_items i ON o.id=i.order_id JOIN products p ON i.product_id=p.id $where GROUP BY o.id ORDER BY o.id DESC "; $stmt = $conn->prepare($sql); $stmt->bind_param($types, ...$params); $stmt->execute(); $res = $stmt->get_result(); ?> <!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <title>รายงาน Free Order</title> <link href="https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;600&display=swap" rel="stylesheet"> <style> body{font-family:'Kanit',sans-serif;margin:20px;} table{width:100%;border-collapse:collapse;margin-top:20px;font-size:14px;} th,td{border:1px solid #999;padding:6px 8px;} th{background:#fff2cc;} .text-center{text-align:center;} tfoot td{font-weight:bold;background:#f9f9f9;} @media print{.noprint{display:none;}} </style> </head> <body> <h2 style="text-align:center;">🟡 รายงานการจอง Free Order</h2> <h4 style="text-align:center;">วันที่ <?=htmlspecialchars($date_from)?> ถึง <?=htmlspecialchars($date_to)?></h4> <?php if($filter_receive!='all'): ?> <p style="text-align:center;">วิธีรับสินค้า: <?=($filter_receive=='self'?'รับสินค้าด้วยตนเอง':'จัดส่งทางไปรษณีย์');?></p> <?php endif; ?> <?php if($search!=''): ?> <p style="text-align:center;">คำค้น: "<?=htmlspecialchars($search)?>"</p> <?php endif; ?> <table> <thead> <tr> <th>ลำดับ</th> <th>เลขที่ใบจอง</th> <th>ชื่อผู้จอง</th> <th>เบอร์โทร</th> <th>รายการเหรียญ</th> <th>ยอดรวม</th> <th>สถานะ</th> <th>วิธีรับสินค้า</th> <th>วันที่จอง</th> </tr> </thead> <tbody> <?php $n=1;$sum_total=0; if($res->num_rows>0): while($row=$res->fetch_assoc()): $sum_total+=$row['total']; ?> <tr> <td class="text-center"><?=$n++?></td> <td><?=$row['booking_no']?></td> <td><?=$row['fullname']?></td> <td><?=$row['phone']?></td> <td><?=$row['items']?></td> <td class="text-center"><?=number_format($row['total'],2)?></td> <td><?=$row['status']?></td> <td><?=$row['receive_method']?></td> <td><?=$row['created_at']?></td> </tr> <?php endwhile; else: ?> <tr><td colspan="9" class="text-center">ไม่พบข้อมูล</td></tr> <?php endif; ?> </tbody> <tfoot> <tr> <td colspan="5" align="right">รวมทั้งหมด</td> <td class="text-center"><?=number_format($sum_total,2)?></td> <td colspan="3"></td> </tr> </tfoot> </table> <div class="noprint" style="text-align:center;margin-top:20px;"> <button onclick="window.print()">🖨 พิมพ์</button> <button onclick="window.close()">❌ ปิด</button> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.42 |
proxy
|
phpinfo
|
Settings