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

<?php $form = $this->beginWidget('CActiveForm'); ?>

<div class="panel panel-default">
    
    <div class="panel-heading">
        <h3 class="panel-title"><?php echo Yii::t('settings', 'Campaign attachments settings')?></h3>
    </div>
    
    <div class="panel-body">

        <div class="form-group col-lg-4">
            <?php echo $form->labelEx($model, 'enabled');?>
            <?php echo $form->dropDownList($model, 'enabled', $model->getEnabledOptions(), $model->getHtmlOptions('enabled')); ?>
            <?php echo $form->error($model, 'enabled');?>
        </div>    
        <div class="form-group col-lg-4">
            <?php echo $form->labelEx($model, 'allowed_file_size');?>
            <?php echo $form->dropDownList($model, 'allowed_file_size', $model->getFileSizeOptions(), $model->getHtmlOptions('allowed_file_size')); ?>
            <?php echo $form->error($model, 'allowed_file_size');?>
        </div>
        <div class="form-group col-lg-4">
            <?php echo $form->labelEx($model, 'allowed_files_count');?>
            <?php echo $form->textField($model, 'allowed_files_count', $model->getHtmlOptions('allowed_files_count')); ?>
            <?php echo $form->error($model, 'allowed_files_count');?>
        </div>
        <div class="clearfix"><!-- --></div>

        <div class="form-group col-lg-12">
            <hr />
            <div class="pull-left">
                <h5><?php echo Yii::t('settings', 'Allowed extensions');?>:</h5>
            </div>
            <div class="pull-right">
                <a href="javascript:;" class="btn btn-xs btn-primary add-campaign-allowed-extension"><?php echo Yii::t('settings', 'Add new extension');?></a>
            </div>
            <div class="clearfix"><!-- --></div>
            <?php echo $form->error($model, 'allowed_extensions');?>
        </div>
        <div class="form-group">
            <div id="campaign-allowed-ext-list">
            <?php foreach ($model->allowed_extensions as $ext) { ?>
                <div class="form-group col-lg-3">
                    <div class="col-lg-9">
                        <?php echo CHtml::textField($model->modelName . '[allowed_extensions][]', $ext, $model->getHtmlOptions('allowed_extensions'));?>
                    </div>
                    <div class="col-lg-3">
                        <a href="javascript:;" class="btn btn-sm btn-danger remove-campaign-allowed-ext"><?php echo Yii::t('app', 'Remove');?></a>
                    </div>
                </div>
            <?php } ?>
            </div>
        </div>
        
        <div class="clearfix"><!-- --></div>

        <div class="form-group col-lg-12">
            <hr />
            <div class="pull-left">
                <h5><?php echo Yii::t('settings', 'Allowed mime types');?>:</h5>
            </div>
            <div class="pull-right">
                <a href="javascript:;" class="btn btn-xs btn-primary add-campaign-allowed-mime"><?php echo Yii::t('settings', 'Add new mime type');?></a>
            </div>
            <div class="clearfix"><!-- --></div>
            <?php echo $form->error($model, 'allowed_mime_types');?>
        </div>
        <div class="form-group">
            <div id="campaign-allowed-mime-list">
                <?php foreach ($model->allowed_mime_types as $mime) { ?>
                    <div class="form-group col-lg-3">
                        <div class="col-lg-9">
                            <?php echo CHtml::textField($model->modelName . '[allowed_mime_types][]', $mime, $model->getHtmlOptions('allowed_mime_types'));?>
                        </div>
                        <div class="col-lg-3">
                            <a href="javascript:;" class="btn btn-sm btn-danger remove-campaign-allowed-mime"><?php echo Yii::t('app', 'Remove');?></a>
                        </div>
                    </div>
                <?php } ?>
            </div>
        </div>
        
        <div class="clearfix"><!-- --></div>
    </div>

</div>

<div class="panel panel-default">
    <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 style="display: none;" id="campaign-allowed-ext-item">
    <div class="form-group col-lg-3">
        <div class="col-lg-9">
            <?php echo CHtml::textField($model->modelName . '[allowed_extensions][]', null, $model->getHtmlOptions('allowed_extensions'));?>
        </div>
        <div class="col-lg-3">
            <a href="javascript:;" class="btn btn-sm btn-danger remove-campaign-allowed-ext"><?php echo Yii::t('app', 'Remove');?></a>
        </div>
    </div>
</div>

<div style="display: none;" id="campaign-allowed-mime-item">
    <div class="form-group col-lg-3">
        <div class="col-lg-9">
            <?php echo CHtml::textField($model->modelName . '[allowed_mime_types][]', null, $model->getHtmlOptions('allowed_mime_types'));?>
        </div>
        <div class="col-lg-3">
            <a href="javascript:;" class="btn btn-sm btn-danger remove-campaign-allowed-mime"><?php echo Yii::t('app', 'Remove');?></a>
        </div>
    </div>
</div>