<?php
/** PSI 出库单打印正文 */
/** @var array $o @var array $items */
$amt = array_sum(array_map(fn($i) => (float)($i['amount'] ?? 0), $items));
?>
<h2>出库单</h2>
<div class="sub"><?php echo e($o['order_no']); ?></div>
<div class="meta">
    <span><b>关联销售订单：</b><?php echo $o['so_no'] ? e($o['so_no']) : '—'; ?></span>
    <span><b>客户：</b><?php echo e($o['customer']); ?></span>
    <span><b>业务员：</b><?php echo e($o['salesman']); ?></span>
    <span><b>仓库：</b><?php echo e($o['warehouse']); ?></span>
    <span><b>出库日期：</b><?php echo e($o['delivery_date'] ?? '—'); ?></span>
</div>
<table>
    <thead><tr><th>商品</th><th>规格</th><th>单位</th><th>数量</th><th>单价</th><th>金额</th></tr></thead>
    <tbody>
    <?php foreach ($items as $it): ?>
        <tr>
            <td><?php echo e($it['name']); ?></td>
            <td><?php echo e($it['spec']); ?></td>
            <td><?php echo e($it['unit']); ?></td>
            <td><?php echo e($it['qty']); ?></td>
            <td>¥<?php echo e(number_format((float)($it['price'] ?? 0), 2)); ?></td>
            <td>¥<?php echo e(number_format((float)($it['amount'] ?? 0), 2)); ?></td>
        </tr>
    <?php endforeach; ?>
    </tbody>
    <tfoot><tr><th colspan="5" style="text-align:right">合计</th><th>¥<?php echo e(number_format($amt, 2)); ?></th></tr></tfoot>
</table>
<?php if ($o['remark']): ?><p style="font-size:13px;color:#374151;margin-top:10px"><b>备注：</b><?php echo e($o['remark']); ?></p><?php endif; ?>
<div class="sign"><span>发货：<?php echo e($o['salesman']); ?></span><span>收货签字：____________</span></div>
