<?= $this->layout('_layout', ['title' => $title]); ?>

<?= $this->layout('_layout', ['title' => $title]); ?>

<main class="main">
    <?= $this->insert('includes/aside_info') ?>
    <div class="content">
        <div class="h2-title h2-title-content flex-s-c">
            <span>Rankings &raquo; <?= $gerate['title'] ?></span>
        </div>
        <?= $this->insert('partials/rankings/_links') ?>

        <?php if (web()->ranking_geral_type == 'box') : ?>
            <div class="ranking-view flex justify-center items-center gap-8 flex-wrap mt-4">
                <?php foreach ($gerate['ranking'] as $rank) :
                    if ($gerate['type'] == 'char') : ?>
                        <a href="#" class="preview" data-type="char" data-name="<?= $rank['name'] ?>">
                            <div class="text-center p-3 bg-neutral-200/60 border-2 border-neutral-200 rounded-xs text-xs w-36">
                                <p class="p-1 bg-neutral-600 rounded-full "><?= $rank['name'] ?></p>
                                <div class="my-4"><img src="<?= __avatar($rank['image']) ?>" class="w-24 h-24 object-contain mx-auto"></div>
                                <p class="p-1 bg-neutral-600 rounded-full py-1">Level: <span><?= $rank['level'] ?></span></p>
                                <p class="p-1 bg-neutral-600 rounded-full my-2">Guild: <span><?= $rank['guild'] ?></span></p>
                                <p class="p-1 bg-neutral-600 rounded-full"><?= $rank['score'] ?> <small>(<?= ucfirst($gerate['tag_name']) ?>)</small></p>
                            </div>
                        </a>
                    <?php else : ?>
                        <a href="#" class="preview" data-type="guild" data-name="<?= $rank['gname'] ?>">
                            <div class="text-center p-3 bg-neutral-200/60 border-2 border-neutral-200 rounded-xs text-xs w-36">
                                <p class="p-1 bg-neutral-600 rounded-full"><?= $rank['gname'] ?></p>
                                <div class="my-4 mx-auto"><img src="<?= __guildmark($rank['mark']) ?>" class="w-24 h-24 object-contain mx-auto"></div>
                                <p class="p-1 bg-neutral-600 rounded-full py-1">GM: <span><?= $rank['master'] ?></span></p>
                                <p class="p-1 bg-neutral-600 rounded-full my-2">Membros: <span><?= $rank['members'] ?></span></p>
                                <p class="p-1 bg-neutral-600 rounded-full"><?= $rank['score'] ?> <small>(<?= ucfirst($gerate['tag_name']) ?>)</small></p>
                            </div>
                        </a>
                <?php endif;
                endforeach; ?>
            </div>
        <?php else : ?>
            <div class="table-row table-scroll">
                <table class="rankingTable">
                    <thead>
                        <tr>
                            <td>#</td>
                            <td></td>
                            <td><?= $gerate['type'] == 'char' ? 'Level' : 'Master' ?></td>
                            <td><?= $gerate['type'] == 'char' ? 'Character' : 'Guild' ?></td>
                            <td><?= $gerate['type'] == 'char' ? 'Guild' : 'Members' ?></td>
                            <td><?= ucfirst($gerate['tag_name']) ?></td>
                        </tr>
                    <tbody>
                        <?php $cont = 0;
                        foreach ($gerate['ranking'] as $rank) :
                            $cont++;
                            if ($gerate['type'] == 'char') : ?>
                                <tr>
                                    <td><?= $cont ?></td>
                                    <td><?= $rank['status'] == 'offline' ? '' : '[Online]' ?></td>
                                    <td><?= $rank['level'] ?></td>
                                    <td><img src="<?= __files('images/classes/' . characters['classes'][$rank['class']]['short_name'] . '.png') ?>" width="25" height="25"> <a href="<?= __redirect("preview/char/{$rank['name']}") ?>"><?= $rank['name'] ?></a></td>
                                    <td><a href="<?= $rank['guild'] != '-' ? __redirect("preview/guild/{$rank['guild']}") : "javascriont::" ?>"><?= $rank['guild'] ?></a></td>
                                    <td><?= $rank['score'] ?></td>
                                </tr>
                            <?php else : ?>
                                <tr>
                                    <td><?= $cont ?></td>
                                    <td></td>
                                    <td><a href="<?= __redirect("preview/char/{$rank['master']}") ?>"><?= $rank['master'] ?></a></td>
                                    <td><img src="<?= __guildmark($rank['mark']) ?>" width="25" height="25"> <a href="<?= __redirect("preview/guild/{$rank['gname']}") ?>"><?= $rank['gname'] ?></a></td>
                                    <td><?= $rank['members'] ?></td>
                                    <td><?= $rank['score'] ?></td>
                                </tr>
                        <?php endif;
                        endforeach; ?>
                    </tbody>
                </table>
            </div>
        <?php endif; ?>
    </div>
</main>
