<?php
/**
 * @version 7.5
 */
?>

<?php
/** @var \Ppb\Db\Table\Row\User $seller */
$seller = $listing->findParentRow('\Ppb\Db\Table\Users');
$this->userDetails($seller);
$this->listingDetails($listing);
?>

<div class="pull-right">
    <a href="<?php echo $this->url($listing->link()); ?>" class="btn btn-default">
        <?php echo $this->_('Return to Listing'); ?>
    </a>
</div>

<form action="<?php echo $this->form->getAction(); ?>" method="<?php echo $this->form->getMethod(); ?>"
      class="form-horizontal">
    <?php echo $this->form->hiddenElements; ?>

    <dl class="dl-horizontal">
        <dt><?php echo $this->_('Name'); ?></dt>
        <dd><?php echo $listing['name']; ?></dd>

        <?php $media = $listing->getMedia(array('image', 'video')); ?>
        <?php if (count($media) > 0) {
            $mainImage = $listing->getMainImage();
            ?>
            <dd>
                <?php echo $this->thumbnail($mainImage, 76, true,
                    array('alt' => $listing['name'])); ?>
            </dd>
        <?php } ?>

        <?php if ($listing['listing_type'] == 'auction') { ?>
            <dt><?php echo $this->_('Current Bid'); ?></dt>
            <dd><?php echo $this->amount($listing->currentBid(true), $listing['currency']); ?></dd>

            <dt><?php echo $this->_('Bids'); ?></dt>
            <dd><?php echo count($listing->getBids()); ?></dd>

            <dt><?php echo $this->_('Minimum Bid'); ?></dt>
            <dd><?php echo $this->amount($listing->minimumBid(), $listing['currency']); ?></dd>
        <?php } ?>

        <?php if ($listing->isBuyOut()) { ?>
            <dt><?php echo $this->_('Price'); ?></dt>
            <dd><?php echo $this->amount($listing['buyout_price'], $listing['currency']); ?></dd>
        <?php } ?>

        <dt><?php echo $this->_('Payment Methods'); ?></dt>
        <dd><?php echo $this->fieldDisplay(array_map(function ($array) {
                return $array['name'];
            }, $listing->getPaymentMethods()), null, 'N/A'); ?></dd>
    </dl>


    <?php foreach ($this->form->getElements() as $element) { ?>
        <?php echo $this->partial('partials/form-element.phtml', array('element' => $element)); ?>
    <?php } ?>
</form>

