<?php
/* @var $this ArticleController */
/* @var $model Article */
/* @var $form CActiveForm */
?>
<?php
$article_id = $model->id;
if ($model->isNewRecord) {
    $article_id = Yii::app()->request->getPost('article_id', rand(1000000, 1999999));
}
?>
<div class="col-xs-12">
    <?php
    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
        'id' => 'article-form',
        // Please note: When you enable ajax validation, make sure the corresponding
        // controller action is handling ajax validation correctly.
        // There is a call to performAjaxValidation() commented in generated controller code.
        // See class documentation of CActiveForm for details on this.
        'enableAjaxValidation' => false,
        'htmlOptions' => array('enctype' => 'multipart/form-data'),
    ));
    ?>
    <?php echo $form->errorSummary($model); ?>

    <?php echo $form->textFieldControlGroup($model, 'title', array('size' => 60, 'maxlength' => 200)); ?>
    <?php echo $form->textFieldControlGroup($model, 'en_title'); ?>
    <?php echo $form->textFieldControlGroup($model, 'description_ar',array('size' => 100, 'maxlength' => 100)); ?>
    <span class='message'>
      <?php echo $form->error($model,'description_ar'); ?>
    </span>
    <?php echo $form->textFieldControlGroup($model, 'description_en',array('size' => 100, 'maxlength' => 100)); ?>
    <span class='message'>
      <?php echo $form->error($model,'description_en'); ?>
    </span>
    <?php echo $form->textFieldControlGroup($model, 'slug', array('size' => 60, 'maxlength' => 100)); ?>



    <?php echo CHtml::hiddenField('article_id', $article_id); ?>


    <?php $this->renderPartial('_dialog_select_widget'); ?>


    <div class="widget-box">
        <div class="widget-header  widget-header-flat">
            <h4><?php echo $model->generateAttributeLabel('content') ?></h4>
            <div class="widget-toolbar">
                <?php echo CHtml::link(Yii::t('admin', 'Insert Widget'), '#', array('onclick' => '$("#select-widget-dialog").dialog("open"); return true;', 'class' => 'btn btn-xs btn-success')); ?>

                <button class="btn btn-xs dropdown-toggle" data-toggle="dropdown">
                    Gallery
                    <i class="icon-chevron-down icon-on-right"></i>
                </button>

                <ul class="dropdown-menu pull-right dropdown-caret dropdown-close">
                    <li>
                        <?php echo CHtml::link(Yii::t('admin', 'Upload'), '#', array('onclick' => '$("#article-album-upload").dialog("open"); return false;')); ?>
                    </li>
                    <li>
                        <?php echo CHtml::link(Yii::t('admin', 'Manage'), array('articleAlbum/admin', 'ArticleAlbum[article_id]' => $article_id), array('target' => "_blank")); ?>
                    </li>
                </ul>
            </div>
        </div>
        <div class="widget-body">
            <div class="control-group clearfix ">
                <div class="clearfix clear">
                    <?php
                    $this->widget('ext.fckeditor.FCKEditor', array(
                        'model' => $model,
                        'attribute' => 'content',
                    ));
                    ?>
                </div>
            </div>
        </div>
    </div>
    <br/>



 <div class="widget-box">
        <div class="widget-header  widget-header-flat">
            <h4><?php echo $model->generateAttributeLabel('en_content') ?></h4>
            <div class="widget-toolbar">
                <?php echo CHtml::link(Yii::t('admin', 'Insert Widget'), '#', array('onclick' => '$("#select-widget-dialog").dialog("open"); return false;', 'class' => 'btn btn-xs btn-success')); ?>

                <button class="btn btn-xs dropdown-toggle" data-toggle="dropdown">
                    Gallery
                    <i class="icon-chevron-down icon-on-right"></i>
                </button>

                <ul class="dropdown-menu pull-right dropdown-caret dropdown-close">
                    <li>
                        <?php echo CHtml::link(Yii::t('admin', 'Upload'), '#', array('onclick' => '$("#article-album-upload").dialog("open"); return false;')); ?>
                    </li>
                    <li>
                        <?php echo CHtml::link(Yii::t('admin', 'Manage'), array('articleAlbum/admin', 'ArticleAlbum[article_id]' => $article_id), array('target' => "_blank")); ?>
                    </li>
                </ul>
            </div>
        </div>
        <div class="widget-body">
            <div class="control-group clearfix ">
                <div class="clearfix clear">
                    <?php
                    $this->widget('ext.fckeditor.FCKEditor', array(
                        'model' => $model,
                        'attribute' => 'en_content',
                    ));
                    ?>
                </div>
            </div>
        </div>
    </div>
    <br/>



    <?php echo $form->textareaControlGroup($model, 'meta'); ?>
    <br />
    <br />
    <?php echo $form->fileFieldControlGroup($model, 'image'); ?>
    <?php echo $form->textFieldControlGroup($model, 'image',array('readonly'=> true)); ?>
    <br />
    <br />

    <?php echo $form->fileFieldControlGroup($model, 'attachment_url'); ?>
    <?php echo $form->textFieldControlGroup($model, 'attachment_title', array('readonly'=> true,'size' => 60, 'maxlength' => 100)); ?>
    <br />
    <br />

     <?php echo $form->fileFieldControlGroup($model, 'flash_file'); ?>
     <?php echo $form->textFieldControlGroup($model, 'flash_file',array('readonly'=> true)); ?>
     <br />
     <br />



    <?php echo $form->dropDownListControlGroup($model, 'status', $model->getStatuses(), array('empty' => '')); ?>
    
    <?php echo $form->dropDownListControlGroup($model, 'featured', ['false','true'], array('empty' => '')); ?>

    <div class="form-group">
        <?php echo $form->labelEx($model, 'categories', array('class' => 'col-md-3 control-label required')); ?>
        <div class="col-md-5 controls">
            <?php
            $this->widget('ext.chosen.Chosen', array(
                'model' => $model,
                'attribute' => 'categories',
                'multiple' => true,
                'placeholderMultiple' => ' ',
                'htmlOptions' => array(
                    'class' => 'form-control tag-input-style',
                ),
                'data' => Category::model()->getTabList(),
            ));
            ?>
        </div>
    </div>

    <div class="form-group">
        <?php echo $form->labelEx($model, 'published_time', array('class' => 'col-md-3 control-label')); ?>
        <div class="col-md-5 controls">
            <?php
            if ($model->isNewRecord) {
                $model->published_time = date('d-m-Y');
            } else {
                $model->published_time = date('d-m-Y', $model->create_datetime);
            }
            $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                'model' => $model,
                'attribute' => 'published_time',
                'options' => array(
                    'dateFormat' => 'dd-mm-yy',
                ),
                'htmlOptions' => array(
                    'size' => '10', // textField size
                    'maxlength' => '10', // textField maxlength
                    'class' => 'form-control',
                ),
            ));
            ?>
        </div>
        <?php echo $form->error($model, 'published_time'); ?>
    </div>


    <?php // echo $form->dropDownListControlGroup($model, 'category_id', Category::model()->getTabList(), array('empty' => ''));     ?>

    <?php if (Yii::app()->options->get('I18N_MULTILINGUAL', 0) == 1): ?>

        <?php //echo $form->dropDownListControlGroup($model, 'language', FlexLocale::getActiveLocales(), array('empty' => '')); ?>

    <?php endif; ?>
    

    <br/>
    <?php echo TbHtml::formActions(array(TbHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('color' => TbHtml::BUTTON_COLOR_PRIMARY)), TbHtml::resetButton('Reset'),)); ?>
    <br/>
    <!-- <p class="note">Fields with <span class="required">*</span> are required.</p> -->

    <?php $this->endWidget(); ?>
</div>
<?php $this->renderPartial('_dialog_article_album', array('uploader' => $uploader, 'article_id' => $article_id)); ?>