<?php
/**
 * @version 7.9 [rev.7.9.01]
 */
/** @var \Ppb\Db\Table\Row\Listing $listingModel */
/** @var string $currentStep */
/** @var array $listingFees */
/** @var \Ppb\Service\Fees\ListingSetup $listingSetupService */
?>
<?php
$listingModel['user_id'] = $this->loggedInUser['id'];
$listingModel['id'] = 0;
?>

<?php if ($currentStep == 'preview') { ?>
    <h4 class="headline">
        <i class="fa fa-angle-right"></i>
        <span><?php echo $this->_('Listing Preview'); ?></span>
    </h4>

    <?php
    echo $this->partial('listings/listing/details.phtml', array(
        'listing' => $listingModel,
        'seller'  => $listingModel->findParentRow('\Ppb\Db\Table\Users'),
        'live'    => false
    )); ?>

    <div class="clearfix"></div>
<?php } ?>


<form action="<?php echo $this->form->getAction(); ?>" method="<?php echo $this->form->getMethod(); ?>"
      enctype="multipart/form-data" class="form-horizontal">
    <?php echo $this->form->getHiddenElements(true); ?>

    <?php if ($currentStep == 'preview') { ?>
        <h4 class="headline">
            <i class="fa fa-angle-right"></i>
            <span><?php echo $this->_('Listing Setup Fees'); ?></span>
        </h4>

        <div class="col-sm-6">
            <?php echo $this->partial('partials/voucher-code.phtml', array('userId' => null)); ?>
        </div>
        <div class="clearfix"></div>

        <div>
            <dl class="dl-horizontal">
                <?php if (count($listingFees) > 0) { ?>
                    <?php foreach ($listingFees as $row) { ?>
                        <dt><?php echo $this->_($row['name']); ?></dt>
                        <dd><?php echo $this->amount($row['amount']); ?></dd>
                    <?php } ?>
                <?php } ?>
                <dt class="fees-total"><?php echo $this->_('Total'); ?></dt>
                <dd class="fees-total"><?php echo $this->amount($listingSetupService->getTotalAmount()); ?>
                </dd>
            </dl>
        </div>


        <?php if ($this->settings['listing_terms_box']) { ?>
            <h4 class="headline">
                <i class="fa fa-angle-right"></i>
                <span><?php echo $this->_('Terms and Conditions'); ?></span>
            </h4>
            <div class="well well-sm well-scrollable">
                <?php
                $listingTerms = explode("\n", $this->settings['listing_terms_content']);
                foreach ($listingTerms as $key => $paragraph) {
                    $listingTerms[$key] = $this->_(trim($paragraph));
                }

                echo implode('<br>', $listingTerms);
                ?>
            </div>
        <?php } ?>
    <?php } ?>

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