<?php $this->layout('main', ['title' => 'Administration', 'manual' => true]); ?>

<div class="block-header">
    <h2><?=__('Administration') ?></h2>
</div>

<div class="row">
    <?php foreach($admin_panels as $category_name => $category_info): ?>
    <div class="col-sm-4">
        <section class="card" role="region">
            <div class="card-header ch-alt">
                <h2><i class="<?=$category_info['icon'] ?>"></i> <?=$category_name ?></h2>
            </div>
            <div class="card-body card-padding-sm">
                <ul class="nav nav-list" <?php if (count($category_info['items']) >= 15): ?>style="height: 300px; overflow-y: scroll;"<?php endif; ?>>
                    <?php foreach($category_info['items'] as $item_name => $item_params): ?>
                        <li>
                            <a href="<?=(is_array($item_params['url']) ? $router->route($item_params['url']) : $router->named($item_params['url'])) ?>" title="<?=$item_params['title'] ?>">
                                <i class="<?=$item_params['icon'] ?>"></i> <?=$item_name ?>
                            </a>
                        </li>
                    <?php endforeach; ?>
                </ul>
            </div>
        </section>
    </div>
    <?php endforeach; ?>
</div>

<div class="block-header">
    <h2>Synchronization Tasks</h2>
</div>

<div class="row">
    <?php foreach($sync_times as $sync_key => $sync_info): ?>
    <div class="col-sm-3">
        <section class="card" role="region">
            <div class="card-header bgm-bluegray">
                <h2>
                    <?=$sync_info['name'] ?>
                    <small><?=implode(', ', $sync_info['contents']) ?></small>
                </h2>
                <a class="btn bgm-blue btn-float" role="button" href="<?=$router->named('admin:index:sync', ['type' => $sync_key]) ?>" title="Run Manually"><i class="zmdi zmdi-mail-send"></i></a>
            </div>
            <div class="card-body card-padding">
                <p><?=$customization->formatDateTime($sync_info['latest']) ?><br><small><?=sprintf(__('%s ago'), $sync_info['diff_text']) ?></small></p>
            </div>
        </section>
    </div>
    <?php endforeach; ?>
</div>
