<?php
/**
 * @version 7.3
 */
/** @var \Ppb\Service\Fees\ListingSetup $listingFees */
/** @var string $tab */
/** @var int $categoryId */
/** @var array $categoriesMultiOptions */

$element = $this->formElement('select', 'category_id')
    ->setLabel('Select Category')
    ->setMultiOptions($categoriesMultiOptions)
    ->setValue($categoryId)
    ->setAttributes(array(
        'class'    => 'form-control input-medium',
        'onchange' => 'this.form.submit();'
    ));
?>

<ul class="nav nav-tabs">
    <?php foreach ($tabs as $key => $value) { ?>
        <li <?php echo ($key == $tab) ? 'class="active"' : ''; ?>>
            <a href="<?php echo $this->url(array('tab' => $key), null, true, array('category_id')); ?>">
                <?php echo $this->_($value['name']); ?></a>
        </li>
    <?php } ?>
</ul>

<div class="fees-desc">
    <?php if ($tab == 'listings') { ?>
        <form action="" method="get">
            <input type="hidden" name="tab" value="<?php echo $tab; ?>">
            <?php echo $this->partial('partials/form-element.phtml', array('element' => $element)); ?>
        </form>
        <div class="clearfix"></div>
        <dl class="dl-horizontal site-fees">
            <?php foreach ($fees as $fee) { ?>
                <dt><?php echo $this->_($fee['desc']); ?></dt>
                <dd>
                    <?php if ($fee['tier_from'] > 0 || $fee['tier_to'] > 0) { ?>
                        <span class="fee-tier">
                        [ <?php echo $this->amount($fee['tier_from']); ?>
                            - <?php echo $this->amount($fee['tier_to']); ?> ]
                    </span>
                    <?php } ?>
                    <span class="fee-amount">
                        <?php echo ($fee['calculation_type'] == 'flat') ? $this->amount($fee['amount']) : $fee['amount'] . '%'; ?>
                    </span>
                </dd>
            <?php } ?>
        </dl>
    <?php
    }
    else if ($tab == 'stores') {
        ?>
        <h4><?php echo $this->_('Store Subscriptions'); ?></h4>
        <?php foreach ($storesSubscriptions as $subscription) { ?>
            <div><?php echo $this->_($subscription); ?></div>
        <?php } ?>
    <?php
    }
    else {
        ?>
        <h4><?php echo $this->_('User Fees'); ?></h4>
        <dl class="dl-horizontal">
            <?php foreach ($fees as $fee) { ?>
                <dt><?php echo $this->_($fee['desc']); ?></dt>
                <dd><?php echo $this->amount($fee['amount']); ?></dd>
            <?php } ?>
        </dl>
    <?php } ?>
</div>
