<?php
/**
 * @version 7.10 [rev.7.10.01]
 */

/** @var bool $inAdmin */
?>
<nav class="navbar navbar-filter">
    <div class="navbar-left">

        <a class="btn btn-default pull-left spacing-right"
           href="<?php echo $this->url(array('action' => 'add-blocked-user')); ?>">
            <?php echo $this->_('Add Blocked User'); ?>
        </a>
    </div>
</nav>

<div class="table-responsive">
    <table class="table table-striped table-hover">
        <caption>
            <strong><?php echo $this->paginator->getPages()->totalItemCount; ?></strong> <?php echo $this->_('blocked users found.'); ?>

            <?php if ($this->paginator->getPages()->totalItemCount) { ?>
                <?php echo $this->_('Showing results'); ?>
                <strong><?php echo $this->paginator->getPages()->firstItemNumber; ?></strong>
                <?php echo $this->_('to'); ?>
                <strong><?php echo $this->paginator->getPages()->lastItemNumber; ?></strong>
            <?php } ?>
        </caption>
        <?php if ($this->paginator->getPages()->totalItemCount) { ?>
            <thead>
            <tr>
                <th class="size-small"><?php echo $this->_('Details'); ?></th>
                <?php if ($inAdmin) { ?>
                    <th class="size-mini"><?php echo $this->_('Blocked By'); ?></th>
                <?php } ?>
                <th class="size-small"><?php echo $this->_('Blocked Actions'); ?></th>
                <th><?php echo $this->_('Block Reason'); ?></th>
                <th class="size-mini"><?php echo $this->_('Block Date'); ?></th>
                <th class="size-mini"><?php echo $this->_('Options'); ?></th>
            </tr>
            </thead>
        <?php } ?>
        <tbody>
        <?php
        /** @var \Ppb\Db\Table\Row\BlockedUser $blockedUser */
        foreach ($this->paginator as $blockedUser) {
            ?>
            <tr>
                <td>
                    <div>
                            <span class="label label-info">
                                <?php echo $this->blockStatus($blockedUser)->blockType(); ?>
                            </span>
                    </div>
                    <div>
                        <?php echo $blockedUser['value']; ?>
                    </div>
                </td>
                <?php if ($inAdmin) {
                    /** @var \Ppb\Db\Table\Row\User $user */
                    $user = $blockedUser->findParentRow('\Ppb\Db\Table\Users');
                    ?>
                    <td>
                        <?php echo (!empty($user['username'])) ?
                            $user['username'] : '<span class="label label-primary">' . $this->_('Admin') . '</span>';
                        ?>
                    </td>
                <?php } ?>
                <td>
                    <?php echo $this->blockStatus()->blockedActions(); ?>
                </td>
                <td>
                    <div>
                        <?php echo ($blockedUser['show_reason']) ?
                            '<span class="label label-success">' . $this->_('Displayed') . '</span>' :
                            '<span class="label label-warning">' . $this->_('Hidden') . '</span>'; ?>
                    </div>
                    <div>
                        <small><?php echo $this->fieldDisplay($blockedUser['block_reason']); ?></small>
                    </div>
                </td>
                <td>
                    <?php echo $this->date($blockedUser['created_at'], true); ?>
                </td>
                <td>
                    <div class="btn-group">
                        <a class="btn btn-default btn-sm"
                           href="<?php echo $this->url(array('action' => 'edit-blocked-user', 'id' => $blockedUser['id']), null, true); ?>"
                           title="<?php echo $this->_('Edit Blocked User'); ?>">
                            <i class="fa fa-folder-open"></i>
                        </a>
                        <a class="btn btn-danger btn-sm confirm-box"
                           href="<?php echo $this->url(array('action' => 'delete-blocked-user', 'id' => $blockedUser['id']),
                               null, true); ?>"
                           title="<?php echo $this->_('Delete Blocked User'); ?>"
                           data-message="<?php echo $this->_('Are you sure you want to delete this blocked user?'); ?>">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </td>
            </tr>
        <?php } ?>
        </tbody>
    </table>
</div>

<?php echo $this->pagination($this->paginator, 'sliding', 'partials/pagination.phtml'); ?>

