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

<?php $form = $this->beginWidget('GxActiveForm', array(
		'id'                   => 'sugestoes-form',
		'enableAjaxValidation' => false,
		'focus'                => array($model, 'SUG_DESCRICAO'),
	));
?>

	<?php echo FaHtml::getFormInfo($form, $model); ?>
		<div class="row">
		<?php echo $form->labelEx($model,'SUG_DESCRICAO'); ?>
		<?php echo $form->textField($model, 'SUG_DESCRICAO', array('maxlength' => 50)); ?>
		<?php echo $form->error($model,'SUG_DESCRICAO'); ?>
		</div><!-- row -->

		<?php if ($model->isNewRecord) { ?>
			<?php echo $form->hiddenField($model, 'SUG_IDFUNCIONARIO', array('type' => "hidden", 'value' => User::getId()));?>
			<?php echo $form->hiddenField($model, 'SUG_SITUACAO', array('type' => "hidden", 'value' => "A")); ?>
		<?php } else if(User::isAdmin() || in_array(User::getPrivilergi(), array(7, 20))) { ?>

			<div class="row">
			<?php echo $form->labelEx($model,'SUG_IDFUNCIONARIO'); ?>
	        <?php echo $form->dropDownList($model, 'SUG_IDFUNCIONARIO', GxHtml::listDataEx(Funcionarios::model()->findAll('FUN_SITUACAO="A" OR FUN_IDFUNCIONARIO = "'.$model->SUG_IDFUNCIONARIO.'" order by FUN_NOME')), array('prompt'=>'Selecione')); ?>
			<?php echo $form->error($model,'SUG_IDFUNCIONARIO'); ?>
			</div><!-- row -->

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

		<div class="row">
		<?php echo $form->labelEx($model,'SUG_IDCLIENTE'); ?>
		<?php echo $form->dropDownList($model, 'SUG_IDCLIENTE', GxHtml::listDataEx(Clientes::model()->findAll('CLI_SITUACAO="A" order by CLI_NOME')), array('prompt'=>'Selecione')); ?>

		<?php echo $form->error($model,'SUG_IDCLIENTE'); ?>
		</div><!-- row -->

		<div class="row">
		<?php echo $form->labelEx($model,'SUG_IDPRODUTO'); ?>
		<?php echo $form->dropDownList($model, 'SUG_IDPRODUTO', GxHtml::listDataEx(Modulos::model()->findAll('MOD_SITUACAO="A" order by MOD_DESCRICAO')), array('prompt'=>'Selecione')); ?>
		<?php echo $form->error($model,'SUG_IDPRODUTO'); ?>
		</div><!-- row -->
		<div class="row">
		<?php echo $form->labelEx($model,'SUG_IDFORMULARIO'); ?>
		<?php echo $form->dropDownList($model, 'SUG_IDFORMULARIO', GxHtml::listDataEx(Formularios::model()->findAll(array('order' => 'FRM_DESCRICAO'))), array('prompt'=>'Selecione')); ?>
		<?php echo $form->error($model,'SUG_IDFORMULARIO'); ?>
		</div><!-- row -->

		<div class="row">
		<?php echo $form->labelEx($model,'SUG_TIPO'); ?>
		<?php echo $form->dropDownList($model, 'SUG_TIPO', array('C' => 'Cliente','F' => 'Funcionário'), array('prompt' => 'Selecione')); ?>
		<?php echo $form->error($model,'SUG_TIPO'); ?>
		</div><!-- row -->

		<?php if ($model->isNewRecord) { ?>
			<div class="row">
			<?php echo $form->labelEx($model,'SUG_OBSERVACOES'); ?>
			<?php echo $form->textArea($model, 'SUG_OBSERVACOES'); ?>
			<?php echo $form->error($model,'SUG_OBSERVACOES'); ?>
			</div><!-- row -->
		<?php } else { ?>
			<div class="textarea-like-disabled"><?php echo Util::niceTextAtendimentos($model->SUG_OBSERVACOES); ?></div>
		<?php } ?>

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