<?php

/**
 * @var Mobicms\Render\Template\Template $this
 * @var array<int, array<string, mixed>> $users
 * @var array<int, array{name: string, url: string, active: bool}> $sort_links
 * @var int $total
 * @var int $per_page
 * @var string $pagination
 */

$this->layout('system::layout/default');
?>
<!-- List of Users -->
<?php if ($total): ?>
    <div class="btn-group btn-group-sm input-group-sm mb-3" role="group">
        <div class="input-group-prepend">
            <div class="input-group-text"><?= __('Sort') ?></div>
        </div>
        <?php foreach ($sort_links as $link): ?>
            <a href="<?= $this->e($link['url']) ?>" class="btn btn-outline-secondary ps-3 pe-3<?= $link['active'] ? ' active' : '' ?>"><?= $this->e($link['name']) ?></a>
        <?php endforeach ?>
    </div>
    <?php foreach ($users as $usr): ?>
        <?= $this->fetch('admin::user_row', ['item' => $usr]) ?>
    <?php endforeach ?>
<?php else: ?>
    <div class="row">
        <div class="col-md-6">
            <div class="alert alert-info"><?= __('List is empty') ?></div>
        </div>
    </div>
<?php endif ?>
<?php if ($total): ?>
    <div>
        <div><?= __('Total') ?>: <?= $total ?></div>
        <!-- Page switching -->
        <?php if ($total > $per_page): ?>
            <div class="mt-1"><?= $pagination ?></div>
        <?php endif ?>
    </div>
<?php endif ?>
