<div class="form">
    <?php
        $form = $this->beginWidget('GxActiveForm', array(
            'htmlOptions' => array('enctype' => 'multipart/form-data'),
            'id' => 'atendimentos-form',
            'enableAjaxValidation' => false,
            'focus' => array($model, 'ATD_IDCLIENTE')
        ));
    ?>
        <?= FaHtml::getFormInfo($form, $model); ?>
        <?php
            if(empty($model->ATD_IDFUNCIONARIO)) {
                $model->ATD_IDFUNCIONARIO = User::getId();
            }
        ?>
        <div class="row">
            <?= $form->labelEx($model, 'ATD_DTCADASTRO'); ?>
            <?php $form->widget('ext.Utils.widgets.CrmDatePicker', array('model' => $model, 'attribute' => 'ATD_DTCADASTRO')); ?>
            <?= $form->error($model, 'ATD_DTCADASTRO'); ?>
        </div><!-- row -->
        <div class="row">
            <?= $form->labelEx($model, 'ATD_HORAINICIO'); ?>
            <?= $form->textField($model, 'ATD_HORAINICIO', array('maxlength' => 5, 'class' => 'format_hora hora_inicio')); ?>
            <?= $form->error($model, 'ATD_HORAINICIO'); ?>
        </div><!-- row -->
        <div class="row">
            <?= $form->labelEx($model, 'ATD_HORAFINAL', array('required' => true)); ?>
            <?= $form->textField($model, 'ATD_HORAFINAL', array('maxlength' => 5, 'class' => 'format_hora hora_final')); ?>
            <?= $form->error($model, 'ATD_HORAFINAL'); ?>
        </div><!-- row -->
        <div class="row">
            <?= $form->labelEx($model, 'ATD_TOTALHORAS'); ?>
            <?= $form->textField($model, 'ATD_TOTALHORAS', array('readonly' => 'enabled', 'class' => 'total_horas')); ?>
            <?= $form->error($model, 'ATD_TOTALHORAS'); ?>
        </div><!-- row -->

        <div class="row">
            <?= $form->labelEx($model, 'ATD_IDMOTIVO'); ?>
            <?php
                $motivos = GxHtml::listDataEx(
                    Motivos::model()->findAll("
                        MOT_SITUACAO = 'A' AND
                        MOT_TIPOCONTATO LIKE '%I%'
                        ORDER BY MOT_DESCRICAO
                    ")
                );
                if (in_array(User::getPrivilegio(), array(4, 10, 16, 17, 19, 21))) {
                    unset($motivos[558]);
                }
                echo $form->dropDownList($model, 'ATD_IDMOTIVO', $motivos, array('prompt' => 'Selecione', 'class' => 'echosen'));
            ?>
            <?= $form->error($model, 'ATD_IDMOTIVO'); ?>
        </div><!-- row -->

        <?php if (!in_array(User::getPrivilegio(), array(4, 10, 16, 17, 19, 21))) { ?>
            <div class="row">
                <?= $form->labelEx($model, 'ATD_IDFUNCIONARIO', array('label' => 'Responsável')); ?>
                <?php
                    $funcionarios = User::getFuncionariosComercial();
                    echo $form->dropDownList($model, 'ATD_IDFUNCIONARIO', $funcionarios, array('prompt' => 'Selecione'));
                ?>
                <?= $form->error($model, 'ATD_IDFUNCIONARIO'); ?>
            </div><!-- row -->
        <?php } else { ?>
            <?= $form->hiddenField($model, 'ATD_IDFUNCIONARIO', array('value' => $modelInteressado->INT_IDVENDEDOR)); ?>
        <?php } ?>

        <div class="row">
            <?= $form->labelEx($model, 'ATD_CONTATO'); ?>
            <?= $form->textField($model, 'ATD_CONTATO'); ?>
            <?= $form->error($model, 'ATD_CONTATO'); ?>
        </div><!-- row -->
        <div class="row atd_obs">
            <?= $form->labelEx($model, 'ATD_OBS'); ?>
            <?php
                if (empty($model->ATD_IDATENDIMENTO)) {
                    echo $form->textArea($model, 'ATD_OBS');
                } else {
                  echo '<div class="textarea-like-disabled">'.$model->ATD_OBS.'</div>';
                }
            ?>
            <?= $form->error($model, 'ATD_OBS'); ?>
        </div><!-- row -->
        <?= $form->hiddenField($model, 'ATD_IDUSUARIO',
                               array('type' => "hidden",
                                     'value' => ($model->isNewRecord ? User::getId() : $model->ATD_IDUSUARIO))); ?>
        <?php echo FaHtml::saveButton(); ?>
    <?php $this->endWidget(); ?>
</div><!-- form -->