<?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
 */
 
?>

<?php if ($campaign->hasErrors()) { ?>
<div class="alert alert-block alert-danger">
    <button type="button" class="close" data-dismiss="alert">×</button>
    <?php echo CHtml::errorSummary($campaign);?>
</div>
<?php } ?>

<?php $form = $this->beginWidget('CActiveForm'); ?>
<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 Yii::t('campaigns', 'Campaign confirmation');?>
            </h3>
        </div>
        <div class="pull-right">
            <?php echo CHtml::link(Yii::t('app', 'Cancel'), array('campaigns/index'), array('class' => 'btn btn-default btn-xs', 'title' => Yii::t('app', 'Cancel')));?>
        </div>
        <div class="clearfix"><!-- --></div>
    </div>
    <div class="panel-body">
        <div class="form-group col-lg-6">
            <?php echo $form->labelEx($campaign, 'send_at');?>
            <?php echo $form->textField($campaign, 'send_at', $campaign->getHtmlOptions('send_at')); ?>
            <?php echo CHtml::textField('fake_send_at', $fakeSendAt, array(
                'data-date-format'  => 'yyyy-mm-dd hh:ii:ss', 
                'data-autoclose'    => true, 
                'data-language'     => LanguageHelper::getAppLanguageCode(),
                'data-syncurl'      => $this->createUrl('campaigns/sync_datetime'),
                'class'             => 'form-control',
                'style'             => 'visibility:hidden; height:1px; margin:0; padding:0;',
            )); ?>
            <?php echo $form->error($campaign, 'send_at');?>
        </div>
        <div class="clearfix"><!-- --></div>
        <hr />
        
        <div class="table-responsive">
            <?php
            $this->widget('zii.widgets.CDetailView', array(
                'data'          => $campaign,
                'cssFile'       => false,
                'htmlOptions'   => array('class' => 'table table-striped table-bordered table-hover table-condensed'),
                'attributes'    => array(
                    'name',
                    
                    array(
                        'label' => Yii::t('campaigns', 'List name'),
                        'value' => $campaign->list->name . ' ('.Yii::app()->format->formatNumber($listSubscribers).' subscribers)',
                    ),
                    
                    array(
                        'label' => Yii::t('campaigns', 'Segment name'),
                        'value' => empty($campaign->segment) ? '-' : $campaign->segment->name . ' ('.Yii::app()->format->formatNumber($segmentSubscribers).' subscribers)',
                    ),
                    
                    'from_name', 'reply_to', 'to_name', 'subject',
                    
                    array(
                        'label' => $campaign->getAttributeLabel('date_added'),
                        'value' => $campaign->dateAdded,
                    ),
                    
                    array(
                        'label' => $campaign->getAttributeLabel('last_updated'),
                        'value' => $campaign->lastUpdated,
                    ),
                    
                    array(
                        'label' => Yii::t('campaigns', 'Spam score'),
                        'value' => CHtml::link(Yii::t('campaigns', 'Click to check spam score (please note, score is approximate)'), array('campaigns/spamcheck', 'campaign_uid' => $campaign->campaign_uid), array('class' => 'check-spam-score', 'data-message' => Yii::t('campaigns', 'Please wait while running the spam checks...'))),
                        'type'  => 'raw',
                    )
                ),
            ));
            ?>
        </div>

        <div class="clearfix"><!-- --></div>    
    </div>
    <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="complete"><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 class="active"><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 class="actions">
                <button type="submit" id="is_next" name="is_next" value="1" class="btn btn-default btn-submit btn-go-next" data-loading-text="<?php echo Yii::t('app', 'Please wait, processing...');?>"><?php echo Yii::t('campaigns', 'Send campaign');?></button>
            </div>
        </div>
    </div>
</div>    
<?php $this->endWidget();?>