<?php $lastComm = $di->affCommissionTable->selectLast($num); ?>
<?php if ($lastComm) : ?>
<div class="admin-last admin-aff-lastcomm">
    <h2><?php __e('Last %s Affiliate Commission', $num); ?></h2>
    <div class="am-grid-container">
        <table class="am-grid grid-no-highlight">
            <tr>
                <th class="helper-corner-left"><?php __e('Affiliate') ?></th>
                <th class=""><?php __e('Time') ?></th>
                <th class=""><?php __e('Commission') ?></th>
                <th class=""><?php __e('Invoice') ?></th>
            </tr>
            <?php foreach ($lastComm as $c): ?>
            <tr class="am-grid-row <?php echo (@$rownum++%2) ? 'odd' : 'even' ?>">
                <td><?php $c->name = $c->name_f . ' ' . $c->name_l;
                        if (trim($c->name)): ?>
                        <strong><?php p($c->name) ?></strong>
                        (<a class="link" href="<?php echo $this->userUrl($c->aff_id) ?>" data-tooltip-url="<?php echo $this->url('admin-users/card', "id={$c->aff_id}") ?>"><?php p($c->login) ?></a>)
                    <?php else: ?>
                        <a class="link" href="<?php echo $this->userUrl($c->aff_id) ?>" data-tooltip-url="<?php echo $this->url('admin-users/card', "id={$c->aff_id}") ?>"><?php p($c->login) ?></a>
                    <?php endif; ?>
                    <br />
                    <?php p($c->email); ?></td>
                <td class=""><time datetime="<?php p(date('c', amstrtotime($c->dattm))) ?>" title="<?php p($this->getElapsedTime($c->dattm)) ?>">
                    <?php if (sqlDate($c->dattm) == sqlDate('today')) : ?>
                        <?php p(amTime($c->dattm)) ?>
                    <?php else: ?>
                        <?php p(amDate($c->dattm)) ?><br /><small style="color:#aaa"><?php p(amTime($c->dattm)) ?></small>
                    <?php endif; ?>
                    </time></td>
                <td class="">
                    <?php $cc = new Am_Currency; echo $cc->render($c->amount); ?>
                </td>
                <td class="">
                    <?php $i = $c; ?>
                    <a class="link" href="<?php echo $this->url('admin-user-payments/index/user_id/'.$i->user_id.'#invoice-'.$i->invoice_id) ?>"><?php p($i->invoice_id).p('/').p($i->public_id) ?></a>
                </td>
            </tr>
            <tr class="am-grid-row <?php echo (@$arownum++%2) ? 'odd' : 'even' ?>">
                <td colspan="4" class="container-width-narrow-show">
                    <div class="admin-last_time">
                        &#x1f550; <time datetime="<?php p(date('c', amstrtotime($u->added))) ?>" title="<?php p($this->getElapsedTime($u->added)) ?>"><?php p(amDatetime($u->added)) ?></time>
                    </div>
                </td>
            </tr>
            <?php endforeach ?>
        </table>
    </div>
</div>
<?php else: ?>
<div class="widget-nodata">
    <h2><?php __e('Last %s Affiliate Commissions', $num); ?></h2>
    <p><?php __e("There are no commisions logged") ?></p>
</div>
<?php endif; ?>