<?php include __DIR__ . '/../header.php'; ?>

<div class="container-fluid py-4">

    <div class="d-flex justify-content-between align-items-center mb-3">
        <h3><?= __('products.title', 'Products') ?></h3>
        <a href="/admin/products/create" class="btn btn-primary">
            <?= __('products.add', 'Add Product') ?>
        </a>
    </div>

    <table class="table table-bordered table-striped">
        <thead>
        <tr>
            <th><?= __('products.id', 'ID') ?></th>
            <th><?= __('products.title', 'Title') ?></th>
            <th><?= __('products.price', 'Price') ?></th>
            <th><?= __('products.stock', 'Stock') ?></th>
            <th><?= __('products.status', 'Status') ?></th>
            <th><?= __('products.actions', 'Actions') ?></th>
        </tr>
        </thead>
        <tbody>

        <?php foreach ($items as $p): ?>
            <tr>
                <td><?= $p['id'] ?></td>
                <td><?= $p['title'] ?></td>
                <td><?= $p['price'] ?> <?= $p['currency'] ?></td>
                <td><?= $p['stock_quantity'] ?></td>
                <td><?= $p['status'] ?></td>
                <td>
                    <a href="/admin/products/edit/<?= $p['id'] ?>" class="btn btn-warning btn-sm"><?= __('actions.edit', 'Edit') ?></a>
                    <a href="/admin/products/delete/<?= $p['id'] ?>"
                       class="btn btn-danger btn-sm"
                       onclick="return confirm('<?= __('actions.confirm_delete', 'Are you sure?') ?>')">
                       <?= __('actions.delete', 'Delete') ?>
                    </a>
                </td>
            </tr>
        <?php endforeach; ?>

        </tbody>
    </table>

</div>

<?php include __DIR__ . '/../footer.php'; ?>
