<?php
/**
 * @version 7.8
 */
?>
<form method="<?php echo $this->form->getMethod(); ?>" action="<?php echo $this->form->getAction(); ?>"
      class="form-horizontal">
    <?php
    echo $this->form->hiddenElements;
    /** @var \Cube\Form\Element $element */
    $element = $this->form->getElement('category_id');

    if (!$element->isHidden()) {
        echo $this->partial('partials/form-element.phtml', array('element' => $element));
    }

    if ($feeName == 'sale') {
        $element = $this->form->getElement('sale_fee_payer');
        $element->setValue($this->settings['sale_fee_payer']);

        if (!$element->isHidden()) {
            echo $this->partial('partials/form-element.phtml', array('element' => $element));
        }
    } ?>

    <div class="table-responsive">
        <table class="table table-striped table-hover">
            <thead>
            <tr>
                <th class="size-mini"><?php echo $this->translate('Fee Amount'); ?></th>
                <th class="size-small"><?php echo $this->translate('Calculation Type'); ?></th>
                <th><?php echo $this->translate('Range [ From (>=) - To (<) ]'); ?></th>
                <th class="size-mini"><?php echo $this->translate('Delete'); ?></th>
            </tr>
            </thead>
            <tbody>
            <?php
            foreach ($this->form->getData() as $data) {
                if (array_key_exists('amount', (array)$data)) {
                    ?>
                    <tr>
                        <td>
                            <?php echo $this->form->getElement('amount')->setData($data['amount']); ?>
                        </td>
                        <td>
                            <?php echo $this->form->getElement('calculation_type')->setData($data['calculation_type']); ?>
                        </td>
                        <td>
                            <?php echo $this->form->getElement('tier_from')->setData($data['tier_from']); ?>
                            -
                            <?php echo $this->form->getElement('tier_to')->setData($data['tier_to']); ?>
                        </td>
                        <td>
                            <?php echo $this->form->getElement('id')->setData($data['id']); ?>
                            <?php echo $this->form->getElement('delete')->setMultiOptions(array($data['id'] => null)); ?>
                        </td>
                    </tr>
                <?php
                }
            } ?>
            <tr>
                <th colspan="4"><?php echo $this->translate('Insert New Fee Tier'); ?></th>
            </tr>
            <tr>
                <td>
                    <?php echo $this->form->getElement('amount')->clearData(); ?>
                </td>
                <td>
                    <?php echo $this->form->getElement('calculation_type')->clearData(); ?>
                </td>
                <td>
                    <?php echo $this->form->getElement('tier_from')->clearData(); ?>
                    -
                    <?php echo $this->form->getElement('tier_to')->clearData(); ?>
                </td>
                <td>
                    <?php echo $this->form->getElement('id')->clearData(); ?>
                </td>
            </tr>
            <tr>
                <td colspan="4"><?php echo $this->form->submit; ?></td>
            </tr>
            </tbody>
        </table>
    </div>
</form>