File manager - Edit - /var/www/order.cmtc.ac.th/admin/print_invoice.php
Back
<?php session_start(); if(!isset($_SESSION['admin'])) { header('Location: index.php'); exit; } include('../config/db.php'); $id = intval($_GET['id']); $o = $conn->query("SELECT * FROM orders WHERE id=$id")->fetch_assoc(); $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>ใบเสร็จรับเงิน - <?=$o['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; } table { width:100%; border-collapse: collapse; } th,td { border:1px solid #999; padding:8px; } th { background:#eee; } .text-right { text-align:right; } .text-center { text-align:center; } .info-box { border:1px solid #ccc; padding:15px; margin-bottom:15px; border-radius:6px; background:#fafafa; } .badge { display:inline-block; padding:3px 10px; border-radius:12px; font-size:13px; font-weight:600; } .badge-normal { background:#28a745; color:#fff; } .badge-free { background:#ffc107; color:#000; } .logo { width:100px; display:block; margin:0 auto 10px; } .shipping-label { margin-top: 40px; border-top: 2px dashed #000; padding-top: 25px; } .label-box { border:1px solid #000; padding:15px; border-radius:8px; width: 60%; min-height: 150px; display:inline-block; vertical-align:top; font-size:16px; } .label-box b { display:block; margin-bottom:4px; } .label-header { font-weight:bold; text-decoration:underline; margin-bottom:10px; font-size:17px; } .address-left { float:left; width:60%; } .address-right { float:right; width:35%; } .clearfix::after { content:""; clear:both; display:table; } </style> </head> <body> <h2 class="text-center">ใบเสร็จรับเงิน / ใบจัดส่งสินค้า</h2> <hr> <div class="info-box"> <b>เลขที่ใบจอง:</b> <?=$o['booking_no']?><br> <b>ประเภทคำสั่งซื้อ:</b> <?php if($o['order_type']=='Pre Order'): ?> <span class="badge badge-free">Pre Order</span> <?php else: ?> <span class="badge badge-normal">ปกติ</span> <?php endif; ?><br> <b>ชื่อผู้จอง:</b> <?=$o['fullname']?><br> <b>เบอร์โทร:</b> <?=$o['phone']?><br> <b>ที่อยู่:</b> <?=$o['address']?><br> <b>รหัสไปรษณีย์:</b> <?=$o['zipcode']?><br> <b>วิธีรับสินค้า:</b> <?=$o['receive_method']?><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><?=$r['name']?> </td> <td class="text-center"><?=$r['qty']?></td> <td class="text-right"><?=number_format($r['price'],2)?></td> <td class="text-right"><?=number_format($sum,2)?></td> </tr> <?php endwhile; ?> <tr> <th colspan="3" class="text-right">ยอดรวมสุทธิ</th> <th class="text-right"><?=number_format($total,2)?></th> </tr> </tbody> </table> <p style="margin-top:30px;text-align:right;">ลงชื่อ .......................................... ผู้รับเงิน</p> <!-- ✅ ส่วนจัดส่งหรือรับด้วยตนเอง --> <div class="shipping-label clearfix"> <?php if($o['receive_method']=='จัดส่งทางไปรษณีย์'): ?> <div class="label-box address-left"> <div class="label-header">ผู้รับ</div> <b> <?=htmlspecialchars($o['fullname'])?> </b> <?=nl2br(htmlspecialchars($o['address']))?> <br> รหัสไปรษณีย์: <?=htmlspecialchars($o['zipcode'])?> <br> โทร: <?=htmlspecialchars($o['phone'])?> </div> <div><br><br><br><br><br><br><br><br><br><br></div> <div class="label-box address-right"> <div class="label-header">ผู้ส่ง</div> <b>วิทยาลัยเทคนิคเชียงใหม่</b> เลขที่ 9 ถ.เวียงแก้ว ต.ศรีภูมิ อ.เมืองเชียงใหม่ จ.เชียงใหม่ 50200<br> โทร. 053-217-708 </div> <?php elseif($o['receive_method']=='รับเหรียญด้วยตนเอง'): ?> <div class="label-box"> <div class="label-header">ข้อมูลผู้รับเรียญ (รับด้วยตนเอง)</div> <b>เลขที่ใบจอง:</b> <?=htmlspecialchars($o['booking_no'])?><br> <b>ชื่อผู้รับ:</b> <?=htmlspecialchars($o['fullname'])?><br> <b>เบอร์โทรศัพท์:</b> <?=htmlspecialchars($o['phone'])?><br> <br> </div> <?php endif; ?> </div> <script>window.print();</script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.4 |
proxy
|
phpinfo
|
Settings