<?php
/**
 * @version 7.7
 */
if ($listing->countDependentRowset('\Ppb\Db\Table\Offers') > 0) {
    $offers = $listing->getOffers();
    ?>
    <table class="table table-striped">
        <thead>
        <tr>
            <th><?php echo $this->_('User'); ?></th>
            <th><?php echo $this->_('Amount'); ?></th>
            <th><?php echo $this->_('Status'); ?></th>
            <th><?php echo $this->_('Quantity'); ?></th>
            <th><?php echo $this->_('Date'); ?></th>
        </tr>
        </thead>
        <tbody>
        <?php foreach ($offers as $offer) {

            $class = null;
            $class = ($offer['status'] == 'accepted') ? 'success' : $class;
            $class = ($offer['status'] == 'declined') ? 'error' : $class;
            ?>
            <tr<?php echo ($class !== null) ? ' class="' . $class . '"' : ''; ?>>
                <td><?php echo $this->userDetails()->setUser($offer->findParentRow('\Ppb\Db\Table\Users'))->display($listing['private_auction']); ?></td>
                <td><?php echo $this->amount($offer['amount'], $listing['currency']); ?></td>
                <td><?php echo $this->offerStatus($offer); ?></td>
                <td><?php echo $offer['quantity']; ?></td>
                <td><?php echo $this->date($offer['created_at']); ?></td>
            </tr>
        <?php } ?>
        </tbody>
    </table>
<?php }
else { ?>
    <div>
        <?php echo $this->_('There are no offers posted on this listing.'); ?>
    </div>
<?php } ?>
