<?php include 'header.php'; ?>
<div class="cart-items">
    <h2>商品采购</h2>
    <?php if (empty($cartItems)): ?>
        <p>请先添加商品</p>
    <?php else: ?>
        <table id="cartItems-table">
            <thead>
                <tr>
                    <th>商品</th>
                    <th>数量</th>
                    <th>单价</th>
                    <th>总价</th>
                    <th>删除</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($cartItems as $cartItem): ?>
                <tr data-item-id="<?php echo htmlspecialchars($cartItem['item_id']); ?>">
                    <td><?php echo htmlspecialchars($cartItem['item_name']); ?></td>
                    <td>
                        <button class="quantity-minus">-</button>
                        <span class="total_quantity">
                            <?php echo htmlspecialchars($cartItem['total_quantity']); ?>
                        </span>
                        <button class="quantity-plus">+</button>
                    </td>
                    <td class="unit-price">
                        <?php echo htmlspecialchars($cartItem['unit_price']); ?>
                    </td>
                    <td class="total-price">
                        <?php echo htmlspecialchars($cartItem['total_price']); ?>
                    </td>
                    <td>
                        <button class="delete-item">x</button>
                    </td>
                </tr>
                <?php endforeach; ?>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="5" style="text-align: center;">
                        <button id="confirm-order-btn">确认采购</button>
                    </td>
                </tr>
            </tfoot>
        </table>
    <?php endif; ?>
</div>
<?php include 'footer.php'; ?>