<?php include 'header.php'; ?>
<html>
<body>
<?php if (!empty($orderItems)): ?>
    <h2>我的商品</h2>
    <table id="orders-table" data-has-unconfirmed-clearance="<?php echo $hasUnconfirmedClearance ? 'true' : 'false'; ?>">
        <thead>
            <tr>
                <td>商品</td>
                <td>单价</td>
                <td>总量</td>
                <td>库存</td>
                <td>销售</td>
                <td>退回</td>
                <td>销售</td>
                <td>退回</td>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($orderItems as $order): ?>
            <tr data-item-id="<?php echo $order['item_id']; ?>">
                <td><?php echo htmlspecialchars($order['item_name']); ?></td>
                <td><?php echo $order['unit_price']; ?></td>
                <td><?php echo $order['quantity']; ?></td>
                <td class="stock"><?php echo $order['stock']; ?></td>
                <td class="sold"><?php echo $order['sold']; ?></td>
                <td class="returned"><?php echo $order['returned']; ?></td>
                <td>
                    <input type="number" min="0" class="sell-quantity-input" data-item-id="<?php echo $order['item_id']; ?>" placeholder="已售" style="width: 9ch;">
                    <button class="sell-item-btn" data-item-id="<?php echo $order['item_id']; ?>" ... >销售</button>
                </td>
                <td>
                    <input type="number" min="0" class="return-quantity-input" data-item-id="<?php echo $order['item_id']; ?>" placeholder="退返" style="width: 9ch;">
                    <button class="return-item-btn" data-item-id="<?php echo $order['item_id']; ?>" ... >退回</button>
                </td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
<button id="finalize-deal-btn" style="background-color:red">申请结算</button>
<button id="reset-orders-btn" <?php echo $hasUnconfirmedClearance ? 'style="display:none;"' : ''; ?>>重置</button>
<?php else: ?>
    <p>没有商品.</p>
<?php endif; ?>
</body>
</html>
<?php include 'footer.php'; ?>