File manager - Edit - /home/webapp69.cm.in.th/u69319090039/Shop39/public/assets/app/Views/seller/orders/detail.php
Back
<?php /** * Seller Order Detail View * - Status timeline, status update modal, QR code, items, print button */ $statusColors = [ 'pending' => 'warning', 'waiting_payment' => 'secondary', 'paid' => 'info', 'preparing' => 'primary', 'shipping' => 'info', 'delivered' => 'success', 'completed' => 'success', 'cancelled' => 'danger', 'refunded' => 'dark', ]; $currentColor = $statusColors[$order['status']] ?? 'secondary'; ?> <style> .timeline { position: relative; padding-left: 1.5rem; } .timeline::before { content:''; position:absolute; left:.35rem; top:0; bottom:0; width:2px; background:#dee2e6; } .timeline-item { position: relative; padding-bottom: 1.25rem; } .timeline-item:last-child { padding-bottom: 0; } .timeline-dot { width:14px; height:14px; border-radius:50%; background:#0d6efd; border:2px solid #fff; box-shadow:0 0 0 2px #0d6efd; position:absolute; left:-1.3rem; top:.25rem; } .timeline-dot.done { background:#198754; box-shadow:0 0 0 2px #198754; } .timeline-dot.cancel { background:#dc3545; box-shadow:0 0 0 2px #dc3545; } .info-row { display:flex; gap:.5rem; margin-bottom:.5rem; font-size:.9rem; } .info-row .label { color:#6c757d; min-width:130px; font-weight:600; } </style> <!-- Back button + title --> <div class="d-flex align-items-center gap-3 mb-4"> <a href="<?= APP_URL ?>/seller/orders" class="btn btn-outline-secondary rounded-pill btn-sm px-3"> <i class="bi bi-arrow-left me-1"></i>กลับ </a> <div> <h5 class="fw-bold mb-0">ออเดอร์ #<?= Security::e($order['order_number']) ?></h5> <small class="text-muted"><?= date('d/m/Y H:i', strtotime($order['created_at'])) ?></small> </div> <span class="badge bg-<?= $currentColor ?> rounded-pill fs-6 ms-auto"> <?= Security::e($statusLabels[$order['status']] ?? $order['status']) ?> </span> </div> <div class="row g-4"> <!-- LEFT: Order Info + Items --> <div class="col-lg-8"> <!-- Customer Info --> <div class="card border-0 shadow-sm rounded-3 mb-4"> <div class="card-header bg-white border-bottom py-3 fw-bold"><i class="bi bi-person me-2 text-primary"></i>ข้อมูลลูกค้า</div> <div class="card-body"> <div class="info-row"><span class="label">ชื่อลูกค้า</span><span><?= Security::e($order['customer_name']) ?></span></div> <div class="info-row"><span class="label">อีเมล</span><span><?= Security::e($order['customer_email'] ?? '-') ?></span></div> <div class="info-row"><span class="label">โทรศัพท์</span><span><?= Security::e($order['customer_phone'] ?? '-') ?></span></div> <div class="info-row"><span class="label">ที่อยู่จัดส่ง</span><span style="white-space:pre-line"><?= Security::e($order['shipping_address']) ?></span></div> </div> </div> <!-- Order Items --> <div class="card border-0 shadow-sm rounded-3 mb-4"> <div class="card-header bg-white border-bottom py-3 fw-bold"><i class="bi bi-bag me-2 text-primary"></i>รายการสินค้า</div> <div class="table-responsive"> <table class="table mb-0"> <thead class="table-light"> <tr> <th class="ps-3">สินค้า</th> <th>SKU</th> <th class="text-center">จำนวน</th> <th class="text-end">ราคา/ชิ้น</th> <th class="text-end pe-3">รวม</th> </tr> </thead> <tbody> <?php foreach ($items as $item): ?> <tr> <td class="ps-3 fw-semibold"><?= Security::e($item['title']) ?></td> <td><small class="text-muted"><?= Security::e($item['sku'] ?? '-') ?></small></td> <td class="text-center"><?= (int)$item['quantity'] ?></td> <td class="text-end">฿<?= number_format($item['price'], 2) ?></td> <td class="text-end pe-3 fw-bold">฿<?= number_format($item['subtotal'] ?? ($item['price'] * $item['quantity']), 2) ?></td> </tr> <?php endforeach; ?> </tbody> <tfoot class="table-light"> <?php if (!empty($order['discount_amount']) && $order['discount_amount'] > 0): ?> <tr> <td colspan="4" class="text-end text-muted pe-3">ส่วนลด</td> <td class="text-end text-danger pe-3">-฿<?= number_format($order['discount_amount'], 2) ?></td> </tr> <?php endif; ?> <tr> <td colspan="4" class="text-end fw-bold pe-3">ยอดรวมทั้งสิ้น</td> <td class="text-end fw-bold text-primary fs-5 pe-3">฿<?= number_format($order['total_amount'], 2) ?></td> </tr> </tfoot> </table> </div> </div> <!-- Status Timeline --> <div class="card border-0 shadow-sm rounded-3"> <div class="card-header bg-white border-bottom py-3 fw-bold"><i class="bi bi-clock-history me-2 text-primary"></i>ประวัติสถานะ</div> <div class="card-body"> <?php if (empty($history)): ?> <p class="text-muted mb-0 small">ยังไม่มีประวัติสถานะ</p> <?php else: ?> <div class="timeline"> <?php foreach ($history as $h): $dotClass = ($h['status_key'] === 'cancelled') ? 'cancel' : 'done'; ?> <div class="timeline-item"> <span class="timeline-dot <?= $dotClass ?>"></span> <div class="ms-1"> <strong><?= Security::e($h['status_name']) ?></strong> <span class="text-muted small ms-2"><?= date('d/m/Y H:i', strtotime($h['event_time'])) ?></span> <?php if (!empty($h['description'])): ?> <p class="mb-0 small text-muted"><?= Security::e($h['description']) ?></p> <?php endif; ?> </div> </div> <?php endforeach; ?> </div> <?php endif; ?> </div> </div> </div><!-- /col-lg-8 --> <!-- RIGHT: Actions + Tracking + QR --> <div class="col-lg-4"> <!-- Tracking Info --> <div class="card border-0 shadow-sm rounded-3 mb-4"> <div class="card-header bg-white border-bottom py-3 fw-bold"><i class="bi bi-qr-code me-2 text-primary"></i>ข้อมูลการจัดส่ง</div> <div class="card-body text-center"> <?php if (!empty($order['tracking_number'])): ?> <p class="mb-1 small text-muted">Tracking Number</p> <h5 class="fw-bold text-primary mb-3"><?= Security::e($order['tracking_number']) ?></h5> <?php if ($qrCodeUrl): ?> <img src="<?= $qrCodeUrl ?>" alt="QR Code" class="img-fluid mb-2 rounded" style="max-width:160px"> <p class="small text-muted mb-1">สแกนเพื่อติดตามพัสดุ</p> <a href="<?= Security::e($trackingUrl) ?>" target="_blank" class="btn btn-outline-primary btn-sm rounded-pill px-3"> <i class="bi bi-box-arrow-up-right me-1"></i>เปิดหน้าติดตาม </a> <?php endif; ?> <?php else: ?> <div class="text-muted py-3"> <i class="bi bi-clock fs-3 d-block mb-2"></i> <small>Tracking ID จะถูกสร้างเมื่อยืนยันออเดอร์</small> </div> <?php endif; ?> </div> </div> <!-- Actions --> <div class="card border-0 shadow-sm rounded-3 mb-4"> <div class="card-header bg-white border-bottom py-3 fw-bold"><i class="bi bi-gear me-2 text-primary"></i>การดำเนินการ</div> <div class="card-body d-grid gap-2"> <?php if (!empty($allowedNext)): ?> <?php foreach ($allowedNext as $nextStatus): $btnColor = ($nextStatus === 'cancelled') ? 'outline-danger' : 'primary'; $btnIcon = ($nextStatus === 'cancelled') ? 'x-circle' : 'check-circle'; $btnLabel = $statusLabels[$nextStatus] ?? $nextStatus; ?> <?php if ($nextStatus === 'cancelled'): ?> <button type="button" class="btn btn-outline-danger rounded-pill" data-bs-toggle="modal" data-bs-target="#cancelModal"> <i class="bi bi-x-circle me-1"></i>ยกเลิกออเดอร์ </button> <?php else: ?> <form method="POST" action="<?= APP_URL ?>/seller/orders/update/<?= $order['id'] ?>"> <input type="hidden" name="csrf_token" value="<?= Session::getCsrfToken() ?>"> <input type="hidden" name="status" value="<?= $nextStatus ?>"> <button type="submit" class="btn btn-<?= $btnColor ?> rounded-pill w-100"> <i class="bi bi-<?= $btnIcon ?> me-1"></i> <?php if ($nextStatus === 'preparing'): ?>ยืนยันออเดอร์<?php else: echo $btnLabel; ?><?php endif; ?> </button> </form> <?php endif; ?> <?php endforeach; ?> <?php endif; ?> <!-- Print Button --> <?php if (!empty($order['tracking_number'])): ?> <a href="<?= APP_URL ?>/seller/orders/print/<?= $order['id'] ?>" target="_blank" class="btn btn-outline-secondary rounded-pill"> <i class="bi bi-printer me-1"></i>พิมพ์ใบจัดส่ง </a> <?php else: ?> <button class="btn btn-outline-secondary rounded-pill" disabled> <i class="bi bi-printer me-1"></i>พิมพ์ใบจัดส่ง (ยืนยันออเดอร์ก่อน) </button> <?php endif; ?> </div> </div> <!-- Order Meta --> <div class="card border-0 shadow-sm rounded-3"> <div class="card-body"> <div class="info-row"><span class="label">วันที่สั่งซื้อ</span><span><?= date('d/m/Y H:i', strtotime($order['created_at'])) ?></span></div> <div class="info-row"><span class="label">สถานะ</span><span class="badge bg-<?= $currentColor ?>"><?= Security::e($statusLabels[$order['status']] ?? $order['status']) ?></span></div> <?php if ($order['status'] === 'cancelled' && !empty($order['cancel_reason'])): ?> <div class="info-row"><span class="label">เหตุผลยกเลิก</span><span class="text-danger"><?= Security::e($order['cancel_reason']) ?></span></div> <?php endif; ?> </div> </div> </div><!-- /col-lg-4 --> </div> <!-- Cancel Modal --> <div class="modal fade" id="cancelModal" tabindex="-1"> <div class="modal-dialog modal-dialog-centered"> <div class="modal-content rounded-3 border-0 shadow"> <div class="modal-header border-0"> <h5 class="modal-title fw-bold text-danger"><i class="bi bi-x-circle me-2"></i>ยืนยันการยกเลิก</h5> <button type="button" class="btn-close" data-bs-dismiss="modal"></button> </div> <form method="POST" action="<?= APP_URL ?>/seller/orders/update/<?= $order['id'] ?>"> <div class="modal-body"> <input type="hidden" name="csrf_token" value="<?= Session::getCsrfToken() ?>"> <input type="hidden" name="status" value="cancelled"> <div class="mb-3"> <label class="form-label fw-semibold">เหตุผลการยกเลิก</label> <textarea name="cancel_reason" class="form-control rounded-3" rows="3" placeholder="ระบุเหตุผลการยกเลิก..." required></textarea> </div> </div> <div class="modal-footer border-0"> <button type="button" class="btn btn-secondary rounded-pill" data-bs-dismiss="modal">ปิด</button> <button type="submit" class="btn btn-danger rounded-pill">ยืนยันการยกเลิก</button> </div> </form> </div> </div> </div> <!-- Bootstrap JS for modal --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.23 |
proxy
|
phpinfo
|
Settings