<?php
/** PSI 销售出库详情 */
/** @var array $s @var array $item */
$chn = ($s['channel'] ?? '') === 'export' ? '外贸出口' : '内销';
$amt = (float)($s['qty'] ?? 0) * (float)($s['price'] ?? 0);
?>
<div class="page-head">
    <div><h1>销售出库详情</h1><div class="desc">单号 <?php echo e($s['order_no']); ?></div></div>
    <div style="display:flex;gap:10px">
        <a class="btn-ghost" href="<?php echo site_url('PSI/sales/print/' . $s['id']); ?>" target="_blank"><?php echo admin_icon('printer', 16); ?> 打印</a>
        <a class="btn-ghost" href="<?php echo site_url('PSI/sales'); ?>">← 返回</a>
    </div>
</div>

<div class="panel two-col">
    <table class="tbl">
        <tr><th>客户</th><td><?php echo e($s['customer'] ?? '—'); ?></td></tr>
        <tr><th>渠道</th><td><?php echo $chn; ?></td></tr>
        <tr><th>区域</th><td><?php echo e($s['region'] ?: '—'); ?></td></tr>
        <tr><th>批次/缸号</th><td><?php echo e($s['batch_no'] ?: '—'); ?></td></tr>
        <tr><th>出库日期</th><td><?php echo e($s['created_at'] ?? '—'); ?></td></tr>
        <tr><th>备注</th><td class="muted"><?php echo e($s['remark'] ?: '—'); ?></td></tr>
    </table>
</div>

<div class="panel">
    <div class="panel-bar"><h3>出库明细</h3><span class="muted">合计 ¥<?php echo e(number_format($amt, 2)); ?></span></div>
    <div class="table-wrap">
        <table class="tbl">
            <thead><tr><th>物品</th><th>规格</th><th>单位</th><th>数量</th><th>单价</th><th>金额</th></tr></thead>
            <tbody>
                <tr>
                    <td><?php echo e($item['name'] ?? '—'); ?></td>
                    <td class="muted"><?php echo e($item['spec'] ?? ''); ?></td>
                    <td class="muted"><?php echo e($item['unit'] ?? ''); ?></td>
                    <td><?php echo e($s['qty'] ?? 0); ?></td>
                    <td>¥<?php echo e(number_format((float)($s['price'] ?? 0), 2)); ?></td>
                    <td>¥<?php echo e(number_format($amt, 2)); ?></td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
