<div class="form">


    <?php $form = $this->beginWidget('GxActiveForm', array(
        'id' => 'report-form',
        'enableAjaxValidation' => false,
    ));
    ?>

    <p class="note">
        <?php echo Yii::t('app', 'Fields with'); ?> <span
            class="required">*</span> <?php echo Yii::t('app', 'are required'); ?>.
    </p>

    <?php echo $form->errorSummary($model); ?>


    <!-- form-group -->

    <?php echo $form->labelEx($model, 'name'); ?>

    <?php echo $form->textField($model, 'name', array('size' => 100, 'maxlength' => 100)); ?>
    <?php echo $form->error($model, 'name'); ?>


        <?php echo $form->labelEx($model, 'sql_query'); ?>
        <?php echo $form->textArea($model, 'sql_query', array('cols' => 70, 'rows' => 15, 'maxlength' => 2000)); ?>
        <?php echo $form->error($model, 'sql_query'); ?>


    <!-- form-group -->
    <div class="col-md-6">
        <!-- row -->
        <div class="form-group">
            <?php echo $form->labelEx($model, 'pivot_config'); ?>
            <?php echo $form->textArea($model, 'pivot_config', array('cols' => 30, 'rows' => 23, 'maxlength' => 2000, 'class' => 'form-control')); ?>
            <?php echo $form->error($model, 'pivot_config'); ?>
        </div>
    </div>
    <!-- row -->

    <div class="col-md-16">
        <div class="form-group">
            <?php echo $form->labelEx($model, 'disable_edit'); ?>
            <?php echo $form->checkBox($model, 'disable_edit'); ?>
            <?php echo $form->error($model, 'disable_edit'); ?>
        </div>
        <!-- row -->
        <div class="form-group">
            <?php echo $form->labelEx($model, 'date_range'); ?>
            <?php echo $form->checkBox($model, 'date_range'); ?>
            <?php echo $form->error($model, 'date_range'); ?>
        </div>
        <!-- row -->
        <div class="form-group">
            <?php echo $form->labelEx($model, 'date_field'); ?>
            <?php echo $form->textField($model, 'date_field', array('maxlength' => 50, 'class' => 'form-control')); ?>
            <?php echo $form->error($model, 'date_field'); ?>
        </div>
        <div class="form-group">
            <?php echo $form->labelEx($model, 'date_from'); ?>
            <?php $form->widget('zii.widgets.jui.CJuiDatePicker', array(
                'model' => $model,
                'attribute' => 'date_from',
                'value' => $model->date_from,
                'options' => array(
                    'showButtonPanel' => true,
                    'changeYear' => true,
                    'dateFormat' => 'yy-mm-dd',
                ),
                'htmlOptions' => array('class' => 'form-control')
            ));; ?>
            <?php echo $form->error($model, 'date_from'); ?>
        </div>
        <!-- row -->
        <div class="form-group">
            <?php echo $form->labelEx($model, 'date_to'); ?>
            <?php $form->widget('zii.widgets.jui.CJuiDatePicker', array(
                'model' => $model,
                'attribute' => 'date_to',
                'value' => $model->date_to,
                'options' => array(
                    'showButtonPanel' => true,
                    'changeYear' => true,
                    'dateFormat' => 'yy-mm-dd',
                ),
                'htmlOptions' => array('class' => 'form-control')
            ));; ?>
            <?php echo $form->error($model, 'date_to'); ?>
        </div>
        <!-- row -->

        <?php
        //        $this->widget('ext.EDateRangePicker.EDateRangePicker',array(
        //            'id'=>'Filter_date',
        //            'name'=>'Filter[date]',
        //            'value'=>'10/02/2011',
        //            'language'=> 'sr_latn',
        //            'options'=>array('arrows'=>true),
        //            'htmlOptions'=>array('class'=>'inputClass'),
        //        ));
        ?>
        <!-- row -->
        <div class="form-group">
            <?php echo $form->labelEx($model, 'active'); ?>
            <?php echo $form->checkBox($model, 'active'); ?>
            <?php echo $form->error($model, 'active'); ?>
        </div>
    </div>
    <hr/>
    <!-- form-group -->

    <div class="form-group">
        <?php echo $form->labelEx($model, 'note'); ?>
        <?php echo $form->textField($model, 'note', array('maxlength' => 400, 'class' => 'form-control')); ?>
        <?php echo $form->error($model, 'note'); ?>
    </div>
    <!-- form-group -->
    <div class="form-group">
        <?php echo $form->labelEx($model, 'order_number'); ?>
        <?php echo $form->textField($model, 'order_number', array('class' => 'form-control')); ?>
        <?php echo $form->error($model, 'order_number'); ?>
    </div>
    <!-- form-group -->

    <!-- form-group -->


    <?php
    echo GxHtml::submitButton(Yii::t('app', 'Save'), array('class' => 'btn btn-lg btn-primary')); ?>


    <?php
    $this->endWidget();
    ?>
</div>

<?php

if ($model->isValidSQL()) {

    if ($model->sql_query) {
        $this->widget('ext.digpivot.DigPivot', array(
            'data' => $pivot_sorce,
            'edit_mode' => true,
            'config' => $model->pivotConfigRenders(),

        ));
    }
}
?>
<?php
if (!$model->isValidSQL()) {
?>
<div class="alert alert-danger">
    <strong>Warning!</strong> SQL kod nije ispravan ili nije definisan. Pivot tabela ne može biti prikazana.
</div>
<?php
}
?><!-- form -->

