<?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-book"></span> <?php echo $pageHeading;?></h3>
        </div>
        <div class="pull-right">
            <?php if (!$article->isNewRecord) { ?>
            <?php echo CHtml::link(Yii::t('app', 'Create new'), array('articles/create'), array('class' => 'btn btn-default btn-xs', 'title' => Yii::t('app', 'Create new')));?>
            <?php } ?>
            <?php echo CHtml::link(Yii::t('app', 'Cancel'), array('articles/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">
            <?php echo $form->labelEx($article, 'title');?>
            <?php echo $form->textField($article, 'title', $article->getHtmlOptions('title', array('data-article-id' => (int)$article->article_id, 'data-slug-url' => $this->createUrl('articles/slug')))); ?>
            <?php echo $form->error($article, 'title');?>
        </div>

        <div class="form-group">
            <?php echo $form->labelEx($article, 'content');?>
            <?php echo $form->textArea($article, 'content', $article->getHtmlOptions('content', array('rows' => 15))); ?>
            <?php echo $form->error($article, 'content');?>
        </div>
        
        <div class="form-group col-lg-8">
            <?php echo $form->labelEx($articleToCategory, 'category_id');?>
            <div class="article-categories-scrollbox">
                <ul class="list-group">
                <?php echo CHtml::checkBoxList($articleToCategory->modelName, $article->getSelectedCategoriesArray(), $article->getAvailableCategoriesArray(), $articleToCategory->getHtmlOptions('category_id', array(
                    'class'        => '',
                    'template'     => '<li class="list-group-item">{beginLabel}{input} <span>{labelTitle}</span> {endLabel}</li>',
                    'container'    => '',
                    'separator'    => '',
                    'labelOptions' => array('style' => 'margin-right: 10px;')
                ))); ?>
                </ul>
            </div>
            <?php echo $form->error($articleToCategory, 'category_id');?>
        </div>
        
        <div class="col-lg-4">
            <div class="form-group slug-wrapper"<?php if (empty($article->slug)){ echo ' style="display:none"';}?>>
                <?php echo $form->labelEx($article, 'slug');?>
                <?php echo $form->textField($article, 'slug', $article->getHtmlOptions('slug')); ?>
                <?php echo $form->error($article, 'slug');?>
            </div>
            
            <div class="form-group">
                <?php echo $form->labelEx($article, 'status');?>
                <?php echo $form->dropDownList($article, 'status', $article->getStatusesArray(), $article->getHtmlOptions('status')); ?>
                <?php echo $form->error($article, 'status');?>
            </div>
        </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(); ?>