<?php if (isset($access_denied) && $access_denied): ?>
    <div class="container mt-4">
        <div class="alert alert-danger">Access Denied. Administrator only.</div>
    </div>
    <?php return; ?>
<?php endif; ?>

<div class="container mt-4">
    <h2>Copy/Sync Outlet Data</h2>
    <?= $message ?? '' ?>
    
    <div class="card">
        <div class="card-body">
            <form method="POST">
                <div class="row mb-3">
                    <div class="col-md-6">
                        <label class="form-label">Source Outlet</label>
                        <select name="source_id" class="form-select" required>
                            <?php foreach($outlets as $o): ?>
                                <option value="<?= $o['id'] ?>"><?= htmlspecialchars($o['name']) ?></option>
                            <?php endforeach; ?>
                        </select>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Target Outlet</label>
                        <select name="target_id" class="form-select" required>
                            <?php foreach($outlets as $o): ?>
                                <option value="<?= $o['id'] ?>"><?= htmlspecialchars($o['name']) ?></option>
                            <?php endforeach; ?>
                        </select>
                    </div>
                </div>
                
                <div class="mb-3">
                    <label class="form-label">Data to Copy/Sync</label>
                    <div class="form-check">
                        <input class="form-check-input" type="checkbox" name="copy_items" id="copy_items" checked>
                        <label class="form-check-label" for="copy_items">Items (will also sync Categories, Units, Suppliers)</label>
                        <div class="form-text text-muted">
                            Existing items will be updated (prices, names, etc) but <strong>stock quantity will be preserved</strong>. New items will be created with 0 stock.
                        </div>
                    </div>
                    <div class="form-check">
                        <input class="form-check-input" type="checkbox" name="copy_categories" id="copy_categories" checked>
                        <label class="form-check-label" for="copy_categories">Categories</label>
                    </div>
                    <div class="form-check">
                        <input class="form-check-input" type="checkbox" name="copy_units" id="copy_units" checked>
                        <label class="form-check-label" for="copy_units">Units</label>
                    </div>
                    <div class="form-check">
                        <input class="form-check-input" type="checkbox" name="copy_suppliers" id="copy_suppliers" checked>
                        <label class="form-check-label" for="copy_suppliers">Suppliers</label>
                    </div>
                </div>
                
                <button type="submit" class="btn btn-primary">Start Copy/Sync</button>
                <a href="index.php?page=settings" class="btn btn-secondary">Back</a>
            </form>
        </div>
    </div>
</div>