<?php
/**
 * YAWIK
 *
 * @filesource
 * @copyright (c) 2013-2015 Cross Solution (http://cross-solution.de)
 * @license       MIT
 */
/**
 * renders the list of ordered products
 */

$multipostLink = $this->url(
                      'lang/jobs/manage',
                      array(),
                      array(
                          'query' => array(
                              'id'   => $this->jobId,
                              'page' => 0
                          ),
                      )
);

?>

    <h3><?php echo $this->translate('Summary') ?></h3>

    <div class="row">
        <div class="col-md-8">
            <div class="panel panel-default">
                <?php $this->translate('Your job opening is ready to be published to the following channels'); ?>
                <?php $total = 0; $sum         = 0; ?>
                <?php

                $this->plugin('currencyFormat')->setCurrencyCode($this->defaultCurrencyCode);

                $products=array();
                foreach ($this->portals as $channelName):
                    $channelData = $channels->getChannel($channelName);
                    if (is_object($channelData)) {
                        $products[$channelData->getCategory()][] = $channelData;
                    }
                endforeach;

                ?>
                <div class="panel-body"><?php
                    foreach ($products as $category => $channels):?>
                        <h5><?php echo $category ?></h5>
                        <div class="row">
                            <?php foreach ($channels as $channel): ?>

                                <div class="col-md-6" style="height: 34px; padding:  5px 15px;">

                                    <?php if ($channel->logo): ?>
                                        <img src="<?php echo $this->basepath($channel->logo) ?>"
                                             alt="<?php echo $channel->description ?>" class="img-thumbnail"
                                             style="max-width: 60px; max-height: 24px;">
                                    <?php endif ?> <?php echo $channel->label ?>
                                </div>
                            <?php endforeach ?>
                        </div>
                    <?php endforeach;
                    $priceFilter = $this->services('FilterManager.Jobs/ChannelPrices');
                    $total       = $priceFilter->filter($this->portals); ?>
                </div>
                <table class="table table-condensed table-bordered">
                    <thead>
                    <tr>
                        <th><?php echo $this->translate('Price') ?></th>
                        <th class="text-right"><?php echo $this->currencyFormat($total); ?></th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td><?php echo $this->translate('plus VAT') ?> (<?php echo $this->defaultTaxRate ?>%)</td>
                        <td class="text-right"><?php echo $this->currencyFormat($total * ($this->defaultTaxRate / 100)
                            ); ?></td>
                    </tr>
                    </tbody>
                    <tfoot>
                    <tr>
                        <th><?php echo $this->translate('Invoice amount') ?></th>
                        <th class="text-right"><?php echo $this->currencyFormat($total * (1 +
                                                                                          $this->defaultTaxRate / 100)
                            ); ?></th>
                    </tr>
                    </tfoot>
                </table>

            </div>
        </div>
        <div class="col-md-4">
            <div class="alert alert-info">
                <?php echo sprintf($this->translate('Please check your selected channels. Click %s to modify the channels'
                                   ),
                                   '<a href="' . $multipostLink . '">' . $this->translate("here") . '</a>'
                ); ?>
            </div>
        </div>
    </div>
