<?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 $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-filter"></span> <?php echo $pageHeading;?></h3>
        </div>
        <div class="pull-right">
            <?php echo CHtml::link(Yii::t('app', 'Cancel'), array('bounce_servers/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-4">
            <?php echo $form->labelEx($server, 'hostname');?>
            <?php echo $form->textField($server, 'hostname', $server->getHtmlOptions('hostname')); ?>
            <?php echo $form->error($server, 'hostname');?>
        </div>
        
        <div class="form-group col-lg-4">
            <?php echo $form->labelEx($server, 'username');?>
            <?php echo $form->textField($server, 'username', $server->getHtmlOptions('username')); ?>
            <?php echo $form->error($server, 'username');?>
        </div>
        
        <div class="form-group col-lg-4">
            <?php echo $form->labelEx($server, 'password');?>
            <?php echo $form->textField($server, 'password', $server->getHtmlOptions('password', array('value' => ''))); ?>
            <?php echo $form->error($server, 'password');?>
        </div>
        
        <div class="clearfix"><!-- --></div>
        
        <div class="form-group col-lg-3">
            <?php echo $form->labelEx($server, 'service');?>
            <?php echo $form->dropDownList($server, 'service', $server->getServicesArray(), $server->getHtmlOptions('service')); ?>
            <?php echo $form->error($server, 'service');?>
        </div>
        
        <div class="form-group col-lg-3">
            <?php echo $form->labelEx($server, 'port');?>
            <?php echo $form->textField($server, 'port', $server->getHtmlOptions('port')); ?>
            <?php echo $form->error($server, 'port');?>
        </div>
        
        <div class="form-group col-lg-3">
            <?php echo $form->labelEx($server, 'protocol');?>
            <?php echo $form->dropDownList($server, 'protocol', $server->getProtocolsArray(), $server->getHtmlOptions('protocol')); ?>
            <?php echo $form->error($server, 'protocol');?>
        </div>
        
        <div class="form-group col-lg-3">
            <?php echo $form->labelEx($server, 'validate_ssl');?>
            <?php echo $form->dropDownList($server, 'validate_ssl', $server->getValidateSslOptions(), $server->getHtmlOptions('validate_ssl')); ?>
            <?php echo $form->error($server, 'validate_ssl');?>
        </div>
                                        
    </div>
    
    <div class="panel-footer">
        <div class="pull-right">
            <button type="submit" class="btn btn-default btn-submit" data-loading-text="<?php echo Yii::t('app', 'Please wait, processing...');?>"><?php echo Yii::t('app', 'Save changes');?></button>
        </div>
        <div class="clearfix"><!-- --></div>
    </div>
    
</div>
<?php $this->endWidget(); ?>

<div class="callout">
    <?php 
    $text = 'Please note that the server settings will be checked when you save the server and the save process will be denied if there are any connection errors.<br />
    Also, this is a good chance to see how long it takes from the moment you hit the save button till the moment the changes are saved  because this is the same amount of time it will take the script to connect to the server and retrieve the bounced emails.<br />
    Some of the servers, like gmail for example, are very slow if you use a hostname(i.e: imap.gmail.com). If that\'s the case, then simply instead of the hostname, use the IP address.<br />
    You can use a service like <a target="_blank" href="http://www.hcidata.info/host2ip.htm">hcidata.info</a> to find out the IP address of any hostname.';
    echo Yii::t('servers', StringHelper::normalizeTranslationString($text));
    ?>
</div>