<?php defined('MW_PATH') || exit('No direct script access allowed');

/**
 * This file is part of the MailWizz EMA application.
 * 
 * @package MailWizz EMA
 * @author Serban George Cristian <cristian.serban@mailwizz.com> 
 * @link http://www.mailwizz.com/
 * @copyright 2013-2014 MailWizz EMA (http://www.mailwizz.com)
 * @license http://www.mailwizz.com/license/
 * @since 1.0
 */
 
?>

<div class="callout">
    <?php
    $text = 'Please note, once you select a template, the existing content of the campaign template will be overridden by the one you have selected.<br />
    If you don\'t want this, then just click on the cancel button and you will be redirect back to the inital template page.';
    echo Yii::t('campaigns', StringHelper::normalizeTranslationString($text));
    ?>
</div>

<div class="panel panel-default">
    <div class="panel-heading">
        <div class="pull-left">
            <h3 class="panel-title">
                <span class="glyphicon glyphicon-envelope"></span> <?php echo $pageHeading;?>
            </h3>
        </div>
        <div class="pull-right">
            <?php echo CHtml::link(Yii::t('app', 'Cancel'), array('campaigns/template', 'campaign_uid' => $campaign->campaign_uid), array('class' => 'btn btn-default btn-xs', 'title' => Yii::t('app', 'Cancel')));?>
        </div>
        <div class="clearfix"><!-- --></div>
    </div>
    <div class="panel-body">
        
        <?php foreach ($templates as $model) { ?>
        <div class="panel panel-default panel-template-box">
            <div class="panel-heading"><h3 class="panel-title"><?php echo $model->shortName;?></h3></div>
            <div class="panel-body">
                <a title="<?php echo Yii::t('email_templates',  'Preview');?> <?php echo CHtml::encode($model->name);?>" href="javascript:;" onclick="window.open('<?php echo $this->createUrl('templates/preview', array('template_uid' => $model->template_uid));?>','<?php echo Yii::t('email_templates',  'Preview') . ' '.CHtml::encode($model->name);?>', 'height=600, width=600'); return false;">
                    <img class="img-rounded" src="<?php echo $model->screenshotSrc;?>" />
                </a>
            </div>
            <div class="panel-footer">
                <a href="<?php echo Yii::app()->createUrl("campaigns/template", array("campaign_uid" => $campaign->campaign_uid, "do" => "select", "template_uid" => $model->template_uid));?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-screenshot"></span> <?php echo Yii::t('app', 'Choose');?></a>
            </div>
        </div>
        <?php } ?>
        
    </div>
    
    <?php if ($pages->pageCount > 1) {?>
    <div class="panel-footer">
        <div class="pull-right">
        <?php $this->widget('CLinkPager', array(
            'pages'         => $pages,
            'htmlOptions'   => array('id' => 'templates-pagination', 'class' => 'pagination'),
            'header'        => false,
            'cssFile'       => false                    
        )); ?>
        </div>
        <div class="clearfix"><!-- --></div>
    </div>
    <?php } ?>
    
    <div class="panel-footer">
        <div class="wizard">
            <ul class="steps">
                <li class="complete"><a href="<?php echo $this->createUrl('campaigns/update', array('campaign_uid' => $campaign->campaign_uid));?>"><?php echo Yii::t('campaigns', 'Name &amp; recipients');?></a><span class="chevron"></span></li>
                <li class="complete"><a href="<?php echo $this->createUrl('campaigns/setup', array('campaign_uid' => $campaign->campaign_uid));?>"><?php echo Yii::t('campaigns', 'Setup');?></a><span class="chevron"></span></li>
                <li class="active"><a href="<?php echo $this->createUrl('campaigns/template', array('campaign_uid' => $campaign->campaign_uid));?>"><?php echo Yii::t('campaigns', 'Template');?></a><span class="chevron"></span></li>
                <li><a href="<?php echo $this->createUrl('campaigns/confirm', array('campaign_uid' => $campaign->campaign_uid));?>"><?php echo Yii::t('campaigns', 'Confirmation');?></a><span class="chevron"></span></li>
                <li><a href="javascript:;"><?php echo Yii::t('app', 'Done');?></a><span class="chevron"></span></li>
            </ul>
        </div>
    </div>
</div>