<?php
/**
 * YAWIK
 *
 * @filesource
 * @copyright https://yawik.org/COPYRIGHT.php
 * @author bleek@cross-solution.de
 * @license   MIT
 */
/*
 * Information Mail to the Approval Team
 */
?>
<?php echo $this->partial('mail/header'); ?>
<?php
$channels = $this->services('Jobs/Options/Provider'); /* @var Jobs\Options\ProviderOptions $channels  */
$options = $this->services('Core/Options');
$defaultCurrencyCode = $options->defaultCurrencyCode;
$defaultTaxRate = $options->defaultTaxRate;
$job=$this->job; /* @var Jobs\Entity\Job $job */
?>
<h2><?php echo $this->translate("Job details")?></h2>
<table>
    <tr>
        <td><?=$this->translate("Title of the job")?></td>
        <td><?=$job->getTitle() ?></td>
    </tr>
    <tr>
        <td><?=$this->translate("Location")?></td>
        <td><?=$job->getLocation() ?></td>
    </tr>
    <tr>
        <td><?=$this->translate("Companyname")?></td>
        <td><?=$job->getCompany() ?></td>
    </tr>
</table>

<h2><?=$this->translate("Publisher details")?></h2>

<table>
    <tr>
        <td><?=$this->translate("Name")?></td>
        <td><?=$job->getUser()->getInfo()->getDisplayName() ?></td>
    </tr>
    <tr>
        <td><?=$this->translate("Email")?></td>
        <td><?=$job->getUser()->getInfo()->getEmail() ?></td>
    </tr>
</table>


<?php
/**
 * following Variables are accessible
 * - template string
 * - job JobEntity
 */
?>

<?php $total = 0;?>

<?php if (empty($job->getPortals())) : ?>
    <?php echo $this->translate('no Portal chosen') ?>
<?php else:  ?>
    <h2><?php echo $this->translate("Selected Channels") ?></h2>
    <p>
        <?php foreach ($job->getPortals() as $portalName): ?>
                <?php $channelData=$channels->getChannel($portalName); ?>
                <?=$channelData->getLabel() ?>,
        <?php endforeach; $priceFilter = $this->services('FilterManager.Jobs/ChannelPrices');
                            $total = $priceFilter->filter($job->getPortals());?>
    </p>
    <table>
        <tr>
            <td><?=$this->translate("Price")?>:</td>
            <td><?=$this->currencyFormat((round($total,2)), $defaultCurrencyCode) ?></td>
        </tr>
        <tr>
            <td><?=$this->translate("plus VAT")?> (<?php echo $defaultTaxRate?>%)</td>
            <td><?=$this->currencyFormat((round($total * $defaultTaxRate/100,2)), $defaultCurrencyCode) ?></td>
        </tr>
        <tr>
            <td><?=$this->translate("Invoice amount")?>:</td>
            <td><?=$this->currencyFormat((round(($total * $defaultTaxRate/100)+$total,2)), $defaultCurrencyCode) ?></td>
        </tr>
    </table>
<?php endif; ?>

<a href="<?=$this->serverUrl() . $this->url('lang/jobs/approval', array(), true)?>?id=<?php echo $this->job->getId()?>">
    <?=$this->translate("Click here to accept or reject the job opening")?>
</a>


<?php echo $this->partial('mail/footer'); ?>