<?php
$this->PageTitle = $modulo->MOD_DESCRICAO . ' - Tabela de valores';
?>

<div class="form">
<?php
Yii::app()->clientScript->registerScript('submit', '
$(document).ready( function() {
   $("#submit_button").click(function() {
      $(this).prop("disabled",true)
         .parents("form").submit();
      });
})
');

$form = $this->beginWidget('GxActiveForm', array(
    'id' => 'modulos-form',
    'enableAjaxValidation' => false,
    'focus'=>array($model,'VAL_VLRIMPLANTACAO'),
));

$this->widget('application.extensions.moneymask.MMask',array('element'=>'#Valores_VAL_VLRIMPLANTACAO, #Valores_VAL_VLRMENSAL, #Valores_VAL_ACRESCLOCACAO, #Valores_VAL_ACRESCADENDO'));
?>
    <?php 
    if(!$model->isNewRecord) {
        $documentos = Contratos::model()->count("COT_IDVALOR=".$model->VAL_IDVALOR);
        if($model->VAL_DEFAULT == 1 && $documentos > 0) { 
            echo FaHtml::alert("Esta tabela de valores é a que está sendo atualmente utilizada para o produto. Caso você altere as informações abaixo, <b>{$documentos}</b> contratos feitos baseados nela terão seus indicadores alterados.", 'danger');
        } else if($documentos > 0) {
            echo FaHtml::alert("Esta tabela de valores já foi utilizada como sendo tabela padrão para o produto. Caso você altere as informações abaixo, <b>{$documentos}</b> documentos que foram feitos baseados nela terão seus indicadores alterados.", 'danger');
        }
    }
    ?>

    <?php echo FaHtml::getFormInfo($form, $model); ?>

    <?php if(!$model->isNewRecord) echo $form->hiddenField($model,'VAL_IDVALOR'); ?>
    
    <div class="row">
        <?php echo $form->labelEx($model,'VAL_VLRIMPLANTACAO'); ?>
        <?php echo $form->textField($model,'VAL_VLRIMPLANTACAO', array('value' => Util::formatMoeda($model->VAL_VLRIMPLANTACAO))); ?>
        <?php echo $form->error($model,'VAL_VLRIMPLANTACAO'); ?>
    </div>
 
    <div class="row">
        <?php echo $form->labelEx($model,'VAL_VLRMENSAL'); ?>
        <?php echo $form->textField($model,'VAL_VLRMENSAL', array('value' => Util::formatMoeda($model->VAL_VLRMENSAL))); ?>
        <?php echo $form->error($model,'VAL_VLRMENSAL'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'VAL_HRSIMPLANTACAO'); ?>
        <?php echo $form->textField($model,'VAL_HRSIMPLANTACAO'); ?>
        <?php echo $form->error($model,'VAL_HRSIMPLANTACAO'); ?>
    </div>

    <?php if($modulo->MOD_MOBILE) { ?>
        <div class="row">
            <?php echo $form->labelEx($model,'VAL_ACRESCLOCACAO',['label' => 'Valor acréscimo usuários Mobile adicionais']); ?>
            <?php echo $form->textField($model,'VAL_ACRESCLOCACAO', array('value' => Util::formatMoeda($model->VAL_ACRESCLOCACAO))); ?>
            <?php echo $form->error($model,'VAL_ACRESCLOCACAO'); ?>
        </div>
    <?php } else if($modulo->MOD_COMPLEMENTO != 'S') { ?>
        <div class="row">
            <?php echo $form->labelEx($model,'VAL_ACRESCLOCACAO'); ?>
            <?php echo $form->textField($model,'VAL_ACRESCLOCACAO', array('value' => Util::formatMoeda($model->VAL_ACRESCLOCACAO))); ?>
            <?php echo $form->error($model,'VAL_ACRESCLOCACAO'); ?>
        </div>
        <div class="row">
            <?php echo $form->labelEx($model,'VAL_ACRESCADENDO'); ?>
            <?php echo $form->textField($model,'VAL_ACRESCADENDO', array('value' => Util::formatMoeda($model->VAL_ACRESCADENDO))); ?>
            <?php echo $form->error($model,'VAL_ACRESCADENDO'); ?>
        </div>

    <?php }?>
    <div class="row">
        <?php echo $form->labelEx($model,'VAL_DESCMAX'); ?>
        <?php echo $form->textField($model,'VAL_DESCMAX'); ?>
        <?php echo $form->error($model,'VAL_DESCMAX'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'VAL_PARCELAS'); ?>
        <?php echo $form->textField($model,'VAL_PARCELAS'); ?>
        <?php echo $form->error($model,'VAL_PARCELAS'); ?>
    </div>

    <div class="row" style="margin:10px 0 20px 0; height:15px;">
        <?php echo $form->labelEx($model,'VAL_DEFAULT', array('style' => 'display:inline-block;')); ?>
        <?php echo $form->checkBox($model,'VAL_DEFAULT', array('style' => 'display:inline;')); ?>
    </div>

        <?php echo FaHtml::saveButton(); ?>

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