<?php
$this->PageTitle = false;
$this->renderPartial('_menu', array('model' => $cliente));
Yii::app()->clientScript->registerScript('submit', '
    $(document).ready( function() {
       $("#submit_button").click(function() {
            $(this).prop("disabled",true).parents("form").submit();
        });
    })
');
$remove = array('AG', 'O');
if (!in_array(User::getPrivilegio(), [1, 7, 11])) {
    $remove = array_merge($remove, ['A', 'I']);
}
?>
<br />
<br />
<br />
<div class="form">

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

    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 form-group">
        <?php echo $form->labelEx($model, 'CST_SITUACAO'); ?>
        <?php echo $form->dropDownList($model, 'CST_SITUACAO', Util::getStatusClienteList($remove), array('prompt' => 'Selecione')); ?>
        <?php echo $form->error($model, 'CST_SITUACAO'); ?>
    </div>

    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 form-group">
        <?php echo $form->labelEx($model, 'CST_IDMOTIVO_FN', array('required' => true)); ?>
        <?php echo $form->dropDownList($model, 'CST_IDMOTIVO_FN', $model->getMotivosFN(), array('prompt' => 'Selecione')); ?>
        <?php echo $form->error($model, 'CST_IDMOTIVO_FN'); ?>
    </div>

    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 form-group">
        <?php echo $form->labelEx($model, 'CST_DEMONSTRACAO'); ?>
        <?php echo $form->dropDownList($model, 'CST_DEMONSTRACAO', array(ClientesSituacoes::DEMONSTRACAO_REALIZADA => 'Sim', ClientesSituacoes::DEMONSTRACAO_NAO_REALIZADA => 'Não') , array('prompt' => 'Selecione')); ?>
        <?php echo $form->error($model, 'CST_DEMONSTRACAO'); ?>
    </div>

    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 form-group">
        <?php echo $form->labelEx($model, 'CST_DESCRICAO'); ?>
        <?php echo $form->textArea($model, 'CST_DESCRICAO'); ?>
        <?php echo $form->error($model, 'CST_DESCRICAO'); ?>
    </div>

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

<script type="text/javascript">
    $(document).ready(function () {
        function toggleMotivoFN() {
            if($("#ClientesSituacoes_CST_SITUACAO").val() == 'FN') {
                $('#ClientesSituacoes_CST_IDMOTIVO_FN').parent().show();
            } else {
                $('#ClientesSituacoes_CST_IDMOTIVO_FN').parent().hide();
            }
        }

        $("#ClientesSituacoes_CST_SITUACAO").change(function () {
            toggleMotivoFN();
        });
        toggleMotivoFN();

    });
</script>
<?php
$this->widget('zii.widgets.CListView', array(
    'dataProvider' => $model->search(),
    'itemView' => "/clientes/abas/_trocas_status",
    'template'=>"{summary}{pager}{items}\n{summary}{pager}",
    'id'=>'subscriptionDiv',
    )
);

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

$css = <<<CSS
    #page .container #content {
        margin-top: 0px!important;
    }
    h1 {
        margin-bottom: 0px!important;
        padding:0!important;
        padding-bottom:0!important;
    }
    .color-red a {
        text-decoration: underline;
    }
    .color-red * {
        color: #ff0000;
        font-size: 13px;
    }
    .color-red a:hover {
        color: #6b3030;
    }
    .header i {
        font-size: 1.2em;
    }
    .form-group {
        clear:both;
        display:block;
        float:left;
    }
    #subscriptionDiv {
        float:left;
        width: 100%;
        margin-top: 5px;
    }
    .alert {
        margin-top: 30px;
    }
CSS;
$cs->registerCss('cliente', $css);