<?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 (!$category->isNewRecord) { ?>
            <?php echo CHtml::link(Yii::t('app', 'Create new'), array('article_categories/create'), array('class' => 'btn btn-default btn-xs', 'title' => Yii::t('app', 'Create new')));?>
            <?php } ?>
            <?php echo CHtml::link(Yii::t('app', 'Cancel'), array('article_categories/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($category, 'name');?>
            <?php echo $form->textField($category, 'name', $category->getHtmlOptions('name', array('data-category-id' => (int)$category->category_id, 'data-slug-url' => $this->createUrl('article_categories/slug')))); ?>
            <?php echo $form->error($category, 'name');?>
        </div>
        
        <div class="form-group">
            <?php echo $form->labelEx($category, 'description');?>
            <?php echo $form->textArea($category, 'description', $category->getHtmlOptions('description', array('rows' => 5))); ?>
            <?php echo $form->error($category, 'description');?>
        </div>

        <div class="form-group col-lg-5">
            <?php echo $form->labelEx($category, 'parent_id');?>
            <?php echo $form->dropDownList($category, 'parent_id', CMap::mergeArray(array('' => Yii::t('app', 'Choose')), $category->getRelationalCategoriesArray()), $category->getHtmlOptions('name')); ?>
            <?php echo $form->error($category, 'parent_id');?>
        </div>    
        
        <div class="form-group col-lg-5 slug-wrapper"<?php if (empty($category->slug)){ echo ' style="display:none"';}?>>
            <?php echo $form->labelEx($category, 'slug');?>
            <?php echo $form->textField($category, 'slug', $category->getHtmlOptions('slug')); ?>
            <?php echo $form->error($category, 'slug');?>
        </div>
        
        <div class="form-group col-lg-2">
            <?php echo $form->labelEx($category, 'status');?>
            <?php echo $form->dropDownList($category, 'status', $category->getStatusesArray(), $category->getHtmlOptions('status')); ?>
            <?php echo $form->error($category, 'status');?>
        </div>
        
        <div class="clearfix"><!-- --></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(); ?>