<section class="content-header">
    <h1><?= __('Templates available') ?></h1>

    <div class="actions">
        <a data-ajax class="btn btn-warning btn-sm" href="<?= admin_url_to('/market/templates') ?>"><?= __('Market') ?></a>
        <a data-load-with-modal data-modal="modal-install" class="btn btn-default btn-sm" href="<?= admin_url_to('/configs/template/install') ?>"><?= __('Install') ?></a>
    </div>
</section>

<div class="modal" id="modal-install"></div>

<section class="content">
    <div class="templates">
        <div class="row">
            <?php foreach ($templates as $index => $template): ?>
                <div class="col-xs-6 col-md-3">
                    <div class="box box-<?= $template['name'] === config('template') ? 'success' : 'default' ?>">
                        <div class="box-body">
                            <div class="template">
                                <?php $path = config('base_path') ?>
                                <div class="image">
                                    <img src="<?= !empty($path) ? '/' . $path : '' ?>/templates/<?= $template['name'] ?>/screenshot.png" style="max-height:150px" />
                                </div>

                                <div class="caption">
                                    <h3><?= $template['title'] ?></h3>
                                    <p class="author">
                                        <?= __('by') ?>
                                        <?php if (isset($template['website'])): ?>
                                            <a href="<?= $template['website'] ?>" target="_blank"><?= $template['author'] ?></a>
                                        <?php else: ?>
                                            <?= $template['author'] ?>
                                        <?php endif ?>
                                    </p>

                                    <div class="buttons">
                                        <?php if (!$template['active']): ?>
                                            <a data-ajax-action class="btn btn-xs btn-success" href="<?= admin_url_to('/configs/template/active/' . $template['name']) ?>"><?= __('Activate') ?></a>
                                        <?php endif ?>

                                        <?php if (!config('fix_template', true)): ?>
<!--                                            <a target="_blank" class="btn btn-default btn-xs" href="--><?//= url_to('/?template=' . $template['name']) ?><!--">--><?//= __('preview') ?><!--</a>-->
                                        <?php endif ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            <?php endforeach ?>
        </div>
    </div>
</section>