<div class="report-widget">
    <h3><?= e($this->property('title')) ?></h3>

    <?php if (!isset($error)): ?>
        <div class="table-container">
            <table class="table data" data-control="rowlink">
                <thead>
                    <tr>
                        <th><span>Page URL</span></th>
                        <th><span>Pageviews</span></th>
                        <th><span>% Pageviews</span></th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($rows as $row): 
                        $percentage = $total > 0 ? round($row[1]/$total*100, 2) : 0;
                        $url = $row[0];
                    ?>
                        <tr>
                            <td><a href="<?= $url ?>" target="_blank"><?= e($row[0]) ?></a></td>
                            <td><a href="<?= $url ?>" target="_blank"><?= e($row[1]) ?></a></td>
                            <td>
                                <div class="progress">
                                    <div class="bar" style="width: <?= $percentage.'%' ?>"></div>
                                    <a href="<?= $url ?>" target="_blank"><?= $percentage.'%' ?></a>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach ?>
                    <?php if (!count($rows)): ?>
                        <tr>
                            <td colspan="3">There were no pageviews in the selected interval.</td>
                        </tr>
                    <?php endif ?>
                </tbody>
            </table>
        </div>
    <?php else: ?>
        <p class="flash-message static warning"><?= e($error) ?></p>
    <?php endif ?>
</div>
