<?php /** @var array $orders */ /** @var string $seg */ ?>
<div class="page-head"><div><h1>订单管理</h1><div class="desc">查看客户下单与付款状态（超级管理员 / 管理员可见）</div></div></div>
<div class="admin-card">
 <table class="admin-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 foreach ($orders as $o): ?>
     <tr>
       <td><?php echo e($o['order_no']); ?></td>
       <td><?php echo e($o['product_name']); ?></td>
       <td><?php echo e($o['customer_name']); ?><br><span class="muted"><?php echo e($o['phone']); ?></span></td>
       <td><?php echo e($o['qty']); ?></td>
       <td>¥<?php echo e($o['amount']); ?></td>
       <td><?php echo $o['channel'] === 'wechat' ? '微信' : ($o['channel'] === 'alipay' ? '支付宝' : '—'); ?></td>
       <td><?php echo $o['status'] === 'paid'
            ? '<span class="tag-mini" style="background:#dcfce7;color:#15803d">已支付</span>'
            : '<span class="tag-mini" style="background:#fef3c7;color:#b45309">待支付</span>'; ?></td>
       <td class="muted"><?php echo e($o['created_at']); ?></td>
       <td>
         <div class="row-actions">
           <a class="btn-soft btn-sm" href="<?php echo site_url('admin/orders/show/' . $o['id']); ?>">详情</a>
           <?php if ($o['status'] !== 'paid'): ?>
           <form method="post" action="<?php echo site_url('admin/orders/markPaid/' . $o['id']); ?>" style="display:inline">
             <?php echo csrf_field(); ?><button class="btn-primary btn-sm" type="submit" data-confirm="标记为已支付？">标记支付</button>
           </form>
           <?php endif; ?>
           <form method="post" action="<?php echo site_url('admin/orders/delete/' . $o['id']); ?>" style="display:inline">
             <?php echo csrf_field(); ?><button class="btn-danger btn-sm" type="submit" data-confirm="确认删除该订单？">删除</button>
           </form>
         </div>
       </td>
     </tr>
   <?php endforeach; ?>
   </tbody>
 </table>
 <?php if (empty($orders)): ?><p class="muted" style="padding:20px">暂无订单</p><?php endif; ?>
</div>
