<?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="pull-left">
    <?php $this->widget('customer.components.web.widgets.MailListSubNavWidget', array(
        'list' => $list,
    ))?>
</div>
<div class="clearfix"><!-- --></div>
<hr />

<div class="callout">
    <?php 
    $text = 'Please note, you will have to style the forms below to match the place where you embed them.<br />
    You can create better forms by using the <a href="{sdkHref}" target="_blank">PHP-SDK</a> and connect to the provided api.';
    echo Yii::t('list_forms', StringHelper::normalizeTranslationString($text), array(
        '{sdkHref}' => 'https://github.com/twisted1919/mailwizz-php-sdk',
    ));
    ?>
</div>

<ul class="nav nav-tabs list-forms-nav" style="border-bottom: 0px;">
    <li class="active"><a href="#subscribe-form"><?php echo Yii::t('list_forms', 'Subscribe form');?></a></li>
    <li class="inactive"><a href="#unsubscribe-form"><?php echo Yii::t('list_forms', 'Unsubscribe form');?></a></li>
</ul>


<div class="form-container" id="subscribe-form">
    <div class="panel panel-default">
        <div class="panel-heading">
            <div class="pull-left">
                <h3 class="panel-title"><?php echo Yii::t('list_forms', 'Subscribe form');?></h3>
            </div>
            <div class="pull-right"></div>
            <div class="clearfix"><!-- --></div>
        </div>
        <div class="panel-body">
            <div class="form-group">
                <textarea class="form-control" rows="20">
<form action="<?php echo Yii::app()->apps->getAppUrl('frontend', 'lists/'.$list->list_uid.'/subscribe', true);?>" method="post" accept-charset="utf-8" target="_blank">
<?php foreach ($fields as $field) { ?>

    <div class="form-group"<?php if ($field->visibility == ListField::VISIBILITY_HIDDEN) {?> style="display:none"<?php }?>>
        <label><?php echo CHtml::encode($field->label);?><?php if ($field->required == ListField::TEXT_YES){?> <span class="required">*</span><?php }?></label>
        <input type="text" class="form-control" name="<?php echo CHtml::encode($field->tag);?>" placeholder="<?php echo CHtml::encode($field->help_text);?>" value="<?php echo CHtml::encode($field->default_value);?>"<?php if ($field->required == ListField::TEXT_YES) {?> required <?php }?>/>
    </div>
<?php } ?>
    
    <div class="clearfix"><!-- --></div>
    <div class="actions">
        <button type="submit" class="btn btn-default btn-submit"><?php echo Yii::t('list_forms', 'Subscribe');?></button>
    </div>
    <div class="clearfix"><!-- --></div>
            
</form>
                </textarea>
                <hr />
                <h5><?php echo Yii::t('list_forms', 'Iframe version');?></h5>
                <textarea class="form-control" rows="3">
<iframe src="<?php echo Yii::app()->apps->getAppUrl('frontend', 'lists/'.$list->list_uid.'/subscribe', true);?>?output=embed&width=400&height=400" width="400" height="400" frameborder="0" scrolling="no"></iframe>
                </textarea>
            </div>
        </div>
    </div>
</div>

<div class="form-container" id="unsubscribe-form" style="display: none;">
    <div class="panel panel-default">
        <div class="panel-heading">
            <div class="pull-left">
                <h3 class="panel-title"><?php echo Yii::t('list_forms', 'Unsubscribe form');?></h3>
            </div>
            <div class="pull-right"></div>
            <div class="clearfix"><!-- --></div>
        </div>
        <div class="panel-body">
            <div class="form-group">
                <textarea class="form-control" rows="20">
<form action="<?php echo Yii::app()->apps->getAppUrl('frontend', 'lists/'.$list->list_uid.'/unsubscribe', true);?>" method="post" accept-charset="utf-8" target="_blank">

    <div class="form-group">
        <label>Email <span class="required">*</span></label>
        <input type="text" class="form-control" name="EMAIL" placeholder="<?php echo Yii::t('list_forms', 'Please type your email address');?>" value="" required />
    </div>
    
    <div class="clearfix"><!-- --></div>
    <div class="actions pull-right">
        <button type="submit" class="btn btn-default btn-submit"><?php echo Yii::t('list_forms', 'Unsubscribe');?></button>
    </div>
    <div class="clearfix"><!-- --></div>
    
</form>
                </textarea>
                <hr />
                <h5><?php echo Yii::t('list_forms', 'Iframe version');?></h5>
                <textarea class="form-control" rows="3">
<iframe src="<?php echo Yii::app()->apps->getAppUrl('frontend', 'lists/'.$list->list_uid.'/unsubscribe', true);?>?output=embed&width=400&height=200" width="400" height="200" frameborder="0" scrolling="no"></iframe>
                </textarea>
            </div>
        </div>
    </div>
</div>
