<div class="form">
    <?php
        $form = $this->beginWidget('GxActiveForm', array(
            'id' => 'enderecos-form',
            'enableAjaxValidation' => false,
            'focus'=>array($model,'END_DESCRICAO'),
             'htmlOptions' => array('class'=>'col-xs-12 form-cadastro inline-addon')
        ));
    ?>
        <?php echo FaHtml::getFormInfo($form, $model); ?>

        <div class="row">
            <?php echo $form->labelEx($model, 'FEC_TIPO'); ?>
            <?php
                $opcoes = $model->tipos;
                echo $form->dropDownList($model, 'FEC_TIPO', $opcoes, array(
                    'prompt' => 'Selecione'
                ));
            ?>
            <?php echo $form->error($model, 'FEC_TIPO'); ?>
        </div>

        <?php $display = ($model->FEC_TIPO == "UNIDADE") ? "block" : "none"; ?>
        <div class="row" style="display: <?= $display; ?>">
            <?php echo $form->labelEx($model, 'FEC_IDREVENDA', array('required' => true)); ?>
            <?php
                $revendas = Revendas::model()->findAll(array('order' => 'REV_SITUACAO, REV_TIPO, REV_FANTASIA'));
                $opcoes = CHtml::listData($revendas, 'REV_IDREVENDA', 'REV_FANTASIA', 'SituacaoPlural');
                echo $form->dropDownList($model, 'FEC_IDREVENDA', $opcoes, array(
                    'prompt' => 'Selecione'
                ));
            ?>
            <?php echo $form->error($model, 'FEC_IDREVENDA'); ?>
        </div>

        <div class="row">
            <?php echo $form->labelEx($model,'FEC_VALOR'); ?>
            <?php
                echo $form->numberField($model, 'FEC_VALOR', array(
                    'min' => 0
                ));
            ?>
            <?php echo $form->error($model,'FEC_VALOR'); ?>
        </div>

        <div class="row">
            <?php echo $form->labelEx($model,'FEC_DATA'); ?>
            <?php
                $form->widget('ext.Utils.widgets.CrmDatePicker', array(
                    'model' => $model,
                    'attribute' => 'FEC_DATA'
                ));
            ?>
            <?php echo $form->error($model,'FEC_DATA'); ?>
        </div>

        <?= FaHtml::saveButton(); ?>
    <?php $this->endWidget(); ?>
</div>

<?php
$cs = Yii::app()->getClientScript();

$script = <<<JAVASCRIPT
    jQuery(document).ready(function($) {
        $("#FechamentosEvolucaoClientes_FEC_TIPO").on('change', function() {
            var revenda = $("#FechamentosEvolucaoClientes_FEC_IDREVENDA").parent();
            if ($(this).val() == 'UNIDADE') {
                revenda.fadeIn(400);
            } else {
                revenda.fadeOut(400);
            }
        });
    });
JAVASCRIPT;
$cs->registerScript(Util::uid(), $script);
