<?php

use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Module\FamilyListModule;
use Fisharebest\Webtrees\Module\IndividualListModule;
use Fisharebest\Webtrees\Module\MediaListModule;
use Fisharebest\Webtrees\Module\NoteListModule;
use Fisharebest\Webtrees\Module\RepositoryListModule;
use Fisharebest\Webtrees\Module\SourceListModule;

?>

<?php foreach ($all_trees as $tree) : ?>
    <tr class="<?= $changes[$tree->id()] ? 'danger' : '' ?>">
        <th scope="row">
            <a href="<?= e(route('tree-page', ['ged' => $tree->name()])) ?>">
                <?= e($tree->name()) ?>
                -
                <?= e($tree->title()) ?>
            </a>
        </th>
        <td>
            <a href="<?= e(route('admin-trees', ['ged' => $tree->name()])) ?>" title="<?= I18N::translate('Preferences') ?>">
                <?= view('icons/preferences') ?>
            </a>
        </td>
        <td class="text-right">
            <?php if ($changes[$tree->id()]) : ?>
                <a href="<?= e(route('show-pending', ['ged' => $tree->name(), 'url' => route('admin-control-panel')])) ?>">
                    <?= I18N::number($changes[$tree->id()]) ?>
                    <span class="sr-only"><?= I18N::translate('Pending changes') ?> <?= e($tree->title()) ?></span>
                </a>
            <?php else : ?>
                -
            <?php endif ?>
        </td>
        <td class="d-none d-sm-table-cell text-right">
            <?php if ($individuals[$tree->id()] > 0) : ?>
                <?php if ($individual_list_module instanceof IndividualListModule) : ?>
                    <a href="<?= e($individual_list_module->listUrl($tree)) ?>"><?= I18N::number($individuals[$tree->id()]) ?></a>
                <?php else : ?>
                    <?= I18N::number($individuals[$tree->id()]) ?>
                <?php endif ?>
            <?php else : ?>
                -
            <?php endif ?>
        </td>
        <td class="d-none d-lg-table-cell text-right">
            <?php if ($families[$tree->id()] > 0) : ?>
                <?php if ($family_list_module instanceof FamilyListModule) : ?>
                    <a href="<?= e($family_list_module->listUrl($tree)) ?>"><?= I18N::number($families[$tree->id()]) ?></a>
                <?php else : ?>
                    <?= I18N::number($families[$tree->id()]) ?>
                <?php endif ?>
            <?php else : ?>
                -
            <?php endif ?>
        </td>
        <td class="d-none d-sm-table-cell text-right">
            <?php if ($sources[$tree->id()] > 0) : ?>
                <?php if ($source_list_module instanceof SourceListModule) : ?>
                    <a href="<?= e($source_list_module->listUrl($tree)) ?>"><?= I18N::number($sources[$tree->id()]) ?></a>
                <?php else : ?>
                    <?= I18N::number($sources[$tree->id()]) ?>
                <?php endif ?>
            <?php else : ?>
                -
            <?php endif ?>
        </td>
        <td class="d-none d-lg-table-cell text-right">
            <?php if ($repositories[$tree->id()] > 0) : ?>
                <?php if ($repository_list_module instanceof RepositoryListModule) : ?>
                    <a href="<?= e($repository_list_module->listUrl($tree)) ?>"><?= I18N::number($repositories[$tree->id()]) ?></a>
                <?php else : ?>
                    <?= I18N::number($repositories[$tree->id()]) ?>
                <?php endif ?>
            <?php else : ?>
                -
            <?php endif ?>
        </td>
        <td class="d-none d-sm-table-cell text-right">
            <?php if ($media[$tree->id()] > 0) : ?>
                <?php if ($media_list_module instanceof MediaListModule) : ?>
                    <a href="<?= e($media_list_module->listUrl($tree)) ?>"><?= I18N::number($media[$tree->id()]) ?></a>
                <?php else : ?>
                    <?= I18N::number($media[$tree->id()]) ?>
                <?php endif ?>
            <?php else : ?>
                -
            <?php endif ?>
        </td>
        <td class="d-none d-lg-table-cell text-right">
            <?php if ($notes[$tree->id()] > 0) : ?>
                <?php if ($note_list_module instanceof NoteListModule) : ?>
                    <a href="<?= e($note_list_module->listUrl($tree)) ?>"><?= I18N::number($notes[$tree->id()]) ?></a>
                <?php else : ?>
                    <?= I18N::number($notes[$tree->id()]) ?>
                <?php endif ?>
            <?php else : ?>
                -
            <?php endif ?>
        </td>
    </tr>
<?php endforeach ?>
