<?php
/**
 * @version 7.10 [rev.7.10.01]
 */
/** @var \Ppb\Db\Table\Row\User $user */
/** @var string $filter */
?>
<div>
    <div class="col-sm-4 user-box">
        <dl>
            <dd>
                <div class="lead">
                    <?php echo $this->userDetails()->setUser($user)->display(); ?>
                </div>
            </dd>

            <dd>
                <a class="btn btn-default"
                   href="<?php echo $this->url(array('module' => 'members', 'controller' => 'messaging', 'action' => 'create', 'username' => $user['username'], 'topic_type' => \Ppb\Service\Messaging::ABUSE_REPORT_USER)); ?>"
                   title="<?php echo $this->_('Report Abuse'); ?>"><?php echo $this->_('Report User'); ?></a>
            </dd>
            <dd>
                <i class="fa fa-globe"></i>
                <?php echo $this->userDetails()->location(); ?>
            </dd>

            <dt><?php echo $this->_('Feedback'); ?></dt>
            <?php /*
            <dd>
                <?php echo $this->_('Score'); ?>:
                <?php echo $user->getReputationScore(); ?>
                -
                <?php echo $this->_('Percentage'); ?>:
                <?php echo $user->getReputationPercentage(); ?>
            </dd>
            */ ?>
            <dd>
                <?php echo $user->getReputationPercentage(); ?>
            </dd>

            <dt><?php echo $this->_('Member Since'); ?></dt>
            <dd><?php echo $this->date($user->getData('created_at'), true); ?></dd>

            <dt>&nbsp;</dt>
            <dd>
                <a href="<?php echo $this->url($user->otherItemsLink()); ?>">
                    <?php echo $this->_('View items for sale'); ?>
                </a>
            </dd>
            <?php if ($user->getData('store_active')) { ?>
                <dd>
                    <a href="<?php echo $this->url($user->storeLink()); ?>">
                        <?php echo $this->_('View seller\'s store'); ?>
                    </a>
                </dd>
            <?php } ?>
        </dl>
    </div>
    <div class="col-sm-6 col-sm-offset-2">
        <table class="table table-bordered table-condensed">
            <thead>
            <tr>
                <th><?php echo $this->_('Feedback'); ?></th>
                <th class="size-small">
                    <i class="fa fa-plus-circle text-success"></i>
                </th>
                <th class="size-small">
                    <i class="fa fa-circle muted"></i>
                </th>
                <th class="size-small">
                    <i class="fa fa-minus-circle text-danger"></i>
                </th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td><?php echo $this->_('Last Month'); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '>', null,
                        \Ppb\Service\Reputation::INTERVAL_ONE_MONTH); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '=', null,
                        \Ppb\Service\Reputation::INTERVAL_ONE_MONTH); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '<', null,
                        \Ppb\Service\Reputation::INTERVAL_ONE_MONTH); ?></td>
            </tr>
            <tr>
                <td><?php echo $this->_('Last 6 Months'); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '>', null,
                        \Ppb\Service\Reputation::INTERVAL_SIX_MONTHS); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '=', null,
                        \Ppb\Service\Reputation::INTERVAL_SIX_MONTHS); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '<', null,
                        \Ppb\Service\Reputation::INTERVAL_SIX_MONTHS); ?></td>
            </tr>
            <tr>
                <td><?php echo $this->_('Last 12 Months'); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '>', null,
                        \Ppb\Service\Reputation::INTERVAL_TWELVE_MONTHS); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '=', null,
                        \Ppb\Service\Reputation::INTERVAL_TWELVE_MONTHS); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '<', null,
                        \Ppb\Service\Reputation::INTERVAL_TWELVE_MONTHS); ?></td>
            </tr>
            <tr>
                <td><?php echo $this->_('As Seller'); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '>',
                        \Ppb\Service\Reputation::SALE); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '=',
                        \Ppb\Service\Reputation::SALE); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '<',
                        \Ppb\Service\Reputation::SALE); ?></td>
            </tr>
            <tr>
                <td><?php echo $this->_('As Buyer'); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '>',
                        \Ppb\Service\Reputation::PURCHASE); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '=',
                        \Ppb\Service\Reputation::PURCHASE); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD, '<',
                        \Ppb\Service\Reputation::PURCHASE); ?></td>
            </tr>
            <tr>
                <td><?php echo $this->_('Total'); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD,
                        '>'); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD,
                        '='); ?></td>
                <td><?php echo $user->calculateReputationScore(\Ppb\Service\Reputation::POSITIVE_THRESHOLD,
                        '<'); ?></td>
            </tr>
            </tbody>
        </table>
    </div>
</div>

<div class="clearfix"></div>

<ul class="nav nav-tabs">
    <?php foreach ($tabs as $key => $value) { ?>
        <li <?php echo ($filter == $key) ? 'class="active"' : ''; ?>>
            <a href="<?php echo $this->url(array_merge($user->reputationLink(), array('filter' => $key))); ?>"><?php echo $value; ?></a>
        </li>
    <?php } ?>
</ul>

<?php echo $this->action('browse', 'reputation', null, array('filter' => $filter, 'userId' => $user['id'])); ?>

        