<?php
    $form = $this->beginWidget('GxActiveForm', array(
        'id' => 'situacao-form',
        'enableAjaxValidation' => false,
        // 'focus' => array($model, 'INT_IDVENDEDOR'),
        'htmlOptions' => array('class'=>'col-xs-12 form-cadastro inline-addon')
    ));
?>
    <div class="form">
        <div class="form-group col-xs-12 col-sm-6 col-md-4">
            <h2>
                A atual situação desse usuário é:
                <?php
                    if ($model->REV_SITUACAO == "A"){
                        echo "<b id='situacao' style='color: green'>Ativo</b>";
                    } else {
                        echo "<b id='situacao' style='color: red'>Inativo</b>";
                    }
                ?>
            </h2>
        </div>
        <div class="clearfix"></div>
        <div class="form-group col-xs-12 col-sm-6 col-md-4" id="alterar_situacao">
            <?php echo $form->checkBox($model_situacoes, "REVS_ALTSITUACAO"); ?>
            <?php echo $form->labelEx($model_situacoes,'REVS_ALTSITUACAO'); ?>
            <?php echo $form->error($model_situacoes,'REVS_ALTSITUACAO'); ?>
        </div>
        <div class="clearfix"></div>
        <div id="acoes_situacao" <?php if (!$model_situacoes->REVS_ALTSITUACAO){ echo 'style="display:none;"'; } ?>>
            <div class="form-group col-xs-12 col-sm-6 col-md-4">
                <?php echo $form->labelEx($model_situacoes, 'REVS_OBSERVACOES', array('required' => true));?>
                <?php
                    echo $form->textArea($model_situacoes, 'REVS_OBSERVACOES', array('class' => 'col-xs-12 col-sm-6 col-md-4'))
                ?>
                <?php echo $form->error($model_situacoes, 'REVS_OBSERVACOES');?>
            </div>
        </div>
        <?php echo FaHtml::saveButton(); ?>
    </div>
<?php $this->endWidget(); ?>

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

$script = <<<JAVASCRIPT
    jQuery(document).ready(function($) {
        $(document).on('change', '#alterar_situacao input', function(event) {
            if ($(this).is(":checked")){
                $("#situacao-form").find('#acoes_situacao').show();
            } else {
                $("#situacao-form").find('#acoes_situacao').hide();
            }
        });
    });
JAVASCRIPT;
$cs->registerScript('_formsituacao_script', $script);

$css = <<<CSS
    #alterar_situacao label,#alterar_situacao input{
        display: inline;
    }
    #alterar_situacao input{
        margin-bottom:  3px;
        margin-right: 5px;
    }
CSS;
$cs->registerCss('_formsituacao_css', $css);
