<h1 class="title"><?= __('Top Players') ?></h1>

<ul class="tabs">
    <?php foreach ($rankings as $index => $ranking): ?>
        <li><a class="tab-link<?= $index === 0 ? ' active' : '' ?>" href="#tab-<?= strtolower($ranking['id']) ?>"><?= $ranking['name'] ?></a></li>
    <?php endforeach ?>
</ul>

<div class="tabs-content">
    <?php foreach ($rankings as $index => $ranking): ?>
        <div class="tab-content<?= $index === 0 ? ' active' : '' ?>" id="tab-<?= strtolower($ranking['id']) ?>">
            <div class="top-players-group">
                <?php foreach ($ranking['data'] as $type => $data): ?>
                    <div class="top-player-group">
                        <div class="type"><?= __(ucfirst($type)) ?></div>
                        <table class="list" style="margin-bottom:10px">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th><?= __('Name') ?></th>
                                    <th style="text-align:right;"><?= __('Score') ?></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($data as $rank => $record): ?>
                                    <tr>
                                        <td style="text-align:left;"><?= $rank + 1 ?></td>
                                        <td style="text-align:left;">
                                            <div class="data-name">
                                                <?php if ($ranking['is_guild']): ?>
                                                    <?= util('Guild')->logo($record['mark'], 20) ?>
                                                <?php else: ?>
                                                    <img src="<?= util('Character')->avatar($record['avatar']) ?>" width="20" />
                                                <?php endif ?>

                                                <?php if (plugin_active('Profile')): ?>
                                                    <a data-ajax href="<?= url_to('/profile/' . ($ranking['is_guild'] ? 'guild' : 'character') . '/' . $record['name']) ?>"><?= $record['name'] ?></a>
                                                <?php else: ?>
                                                    <?= $record['name'] ?>
                                                <?php endif ?>
                                            </div>
                                        </td>
                                        <td style="text-align:right;"><?= $record['score'] ?></td>
                                    </tr>
                                <?php endforeach ?>
                            </tbody>
                        </table>
                    </div>
                <?php endforeach ?>
            </div>
        </div>
    <?php endforeach ?>
</div>