File manager - Edit - /var/www/order.cmtc.ac.th/user/print_invoice_user.php
Back
<?php include('../config/db.php'); $id = intval($_GET['id'] ?? 0); if(!$id){ die("ไม่พบข้อมูลใบจอง"); } $order = $conn->query("SELECT * FROM orders WHERE id=$id")->fetch_assoc(); if(!$order){ die("ไม่พบข้อมูลใบจองนี้"); } $items = $conn->query(" SELECT p.name, i.qty, i.price FROM order_items i JOIN products p ON i.product_id=p.id WHERE i.order_id=$id "); ?> <!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <title>ใบจองเลขที่ <?php echo htmlspecialchars($order['booking_no']); ?></title> <link href="https://fonts.googleapis.com/css2?family=Kanit:wght@400;600&display=swap" rel="stylesheet"> <style> body { font-family: 'Kanit', sans-serif; margin: 40px; background: #fff; color: #000; position: relative; } /* ✅ ลายน้ำกลางกระดาษ */ body::before { content: "วิทยาลัยเทคนิคเชียงใหม่ การศึกษาเพื่ออาชีพและพัฒนาสังคม"; position: fixed; top: 45%; left: 50%; transform: translate(-50%, -50%) rotate(-25deg); font-size: 32px; color: rgba(0,0,0,0.08); white-space: nowrap; z-index: 0; pointer-events: none; } .header { text-align: center; margin-bottom: 20px; position: relative; z-index: 1; } .header img { width: 100px; height: auto; margin-bottom: 10px; } h2 { margin: 5px 0; } h3 { margin: 0; font-weight: 500; } table { width: 100%; border-collapse: collapse; margin-top: 10px; position: relative; z-index: 1; } th, td { border: 1px solid #999; padding: 8px; } th { background: #f0f0f0; } .text-right { text-align: right; } .text-center { text-align: center; } .info-box { border: 1px solid #ccc; padding: 10px; border-radius: 6px; margin-bottom: 15px; position: relative; z-index: 1; } .footer-note { text-align: center; margin-top: 40px; font-size: 16px; color: #444; position: relative; z-index: 1; } @media print { @page { size: A4; margin: 20mm; } body { margin: 0; } } </style> </head> <body onload="window.print()"> <div class="header"> <!-- <img src="../assets/img/logo_cmtc.png" alt="CMTC Logo"> --> <h2>วิทยาลัยเทคนิคเชียงใหม่</h2> <h3>ใบจอง<?=$$coin_name?></h3> <p><b>เลขที่ใบจอง:</b> <?php echo htmlspecialchars($order['booking_no']); ?></p> </div> <div class="info-box"> <b>ชื่อผู้จอง:</b> <?php echo htmlspecialchars($order['fullname']); ?><br> <b>เบอร์โทร:</b> <?php echo htmlspecialchars($order['phone']); ?><br> <b>ที่อยู่:</b> <?php echo htmlspecialchars($order['address']); ?><br> <b>รหัสไปรษณีย์:</b> <?php echo htmlspecialchars($order['zipcode']); ?><br> <b>วิธีรับสินค้า:</b> <?php echo htmlspecialchars($order['receive_method']); ?><br> <b>สถานะ:</b> <span style="color:green;"><?php echo htmlspecialchars($order['status']); ?></span><br> </div> <table> <thead> <tr> <th>รายการพระ</th> <th>จำนวน</th> <th>ราคา/หน่วย</th> <th>รวม</th> </tr> </thead> <tbody> <?php $total = 0; while($r = $items->fetch_assoc()): $sum = $r['qty'] * $r['price']; $total += $sum; ?> <tr> <td><?php echo htmlspecialchars($r['name']); ?></td> <td class="text-center"><?php echo $r['qty']; ?></td> <td class="text-right"><?php echo number_format($r['price'],2); ?></td> <td class="text-right"><?php echo number_format($sum,2); ?></td> </tr> <?php endwhile; ?> <tr> <th colspan="3" class="text-right">ยอดรวมสุทธิ</th> <th class="text-right"><?php echo number_format($total,2); ?></th> </tr> </tbody> </table> <p style="margin-top:40px;text-align:right;">ลงชื่อ .......................................... ผู้จอง</p> <p style="text-align:right;">วันที่พิมพ์: <?php echo date("d/m/Y H:i"); ?> น.</p> <div class="footer-note"> 💬 <b>ขออนุโมทนาบุญ</b> ในความตั้งใจทำความดีของท่าน<br> ขอให้บุญนี้เป็นเหตุแห่งความสุข ความเจริญ และความสำเร็จในชีวิต </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.41 |
proxy
|
phpinfo
|
Settings