<div class="wide form">

    <?php
    $this->widget('application.extensions.moneymask.MMask', array('element' => '#Contratos_COT_VLRMENSAL, #Contratos_COT_VLRMENSAL_FINAL'));

    $form = $this->beginWidget('GxActiveForm', array(
        'action' => Yii::app()->createUrl($this->route),
        'method' => 'get',
    ));
    if(empty($model->TOKEN)) {
        $model->TOKEN = Util::uid();
    }
    echo $form->hiddenField($model, 'TOKEN');
    ?>

    <div class="row">
        <?php echo $form->label($model, 'COT_IDCONTRATO', array('label' => 'Código')); ?>
        <?php echo $form->textField($model, 'COT_IDCONTRATO'); ?>
    </div>

    <div class="row">
        <?php echo $form->label($model, 'COT_TIPOASSINATURA'); ?>
        <?php echo $form->dropDownList($model, 'COT_TIPOASSINATURA', Contratos::model()->getTiposAssinatura(), array('prompt' => 'Todos')); ?>
    </div>

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

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

    <div class="row">
        <?php echo $form->label($model, 'COT_CLI_NOME'); ?>
        <?php
        $this->widget('ext.Utils.widgets.CrmAutoComplete', array(
            'model' => $model,
            'attribute' => 'COT_CLI_NOME',
            'url' => 'autocomplete/documentos',
            'params' => array(
                'revenda: $("#Contratos_COT_IDREVENDA").val()',
                'documento: ' . Contratos::ADENDO,
                'field: "COT_CLI_NOME"'
                )
            )
        );
        ?>
    </div>

    <div class="row">
        <?php echo $form->label($model, 'COT_CLI_CNPJCPF'); ?>
        <?php
        $this->widget('ext.Utils.widgets.CrmAutoComplete', array(
            'model' => $model,
            'attribute' => 'COT_CLI_CNPJCPF',
            'url' => 'autocomplete/documentos',
            'params' => array(
                'revenda: $("#Contratos_COT_IDREVENDA").val()',
                'documento: ' . Contratos::ADENDO,
                'field: "COT_CLI_CNPJCPF"'
                ),
            'htmlOptions' => array(
                'maxlength' => '19',
                )
            )
        );
        ?>
    </div>

    <?php if (!User::isRevenda()) { ?>
        <div class="row">
            <?php echo $form->label($model, 'COT_IDREVENDA'); ?>
            <?php echo $form->dropDownList($model, 'COT_IDREVENDA', GxHtml::listDataEx(Revendas::model()->findAll('REV_SITUACAO="A" order by REV_NOME')), array('prompt' => 'Todas')); ?>
            <?php echo $form->error($model, 'COT_IDREVENDA'); ?>
        </div><!-- row -->
    <?php } ?>

    <div class="row">
        <?php echo $form->label($model, 'CLI_SITUACAO'); ?>
        <?php echo $form->dropDownList($model, 'CLI_SITUACAO', array('A' => 'Ativo', 'I' => 'Inativo'), array('prompt' => 'Todas')); ?>
        <?php echo $form->error($model, 'CLI_SITUACAO'); ?>
    </div><!-- row -->

    <div class="row">
        <?php echo $form->label($model, 'COT_VLRMENSAL', array('label' => 'Valor negociado')); ?>
        <?php echo $form->textField($model, 'COT_VLRMENSAL', array('maxlength' => 14, 'style' => 'width:100px')); ?> à
        <?php echo $form->textField($model, 'COT_VLRMENSAL_FINAL', array('maxlength' => 14, 'style' => 'width:100px')); ?>
    </div>

    <div class="row">
        <?php echo $form->label($model, 'COT_STATUS_FATURAMENTO', array('label' => 'Faturamento')); ?>
        <?php echo $form->dropDownList($model, 'COT_STATUS_FATURAMENTO', array(0 => 'Não faturar', 1 => 'Faturar', 2 => 'Faturado', 3 => 'Fechado'), array('prompt' => 'Todos')); ?>
    </div>

    <div class="row buttons">
        <input type="hidden" name="busca" value="1" />
        <?php echo FaHtml::searchButton(); ?>
    </div>

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

</div><!-- search-form -->