<?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' => 'form-cadastro',
	'enableAjaxValidation' => false,
    'focus'=>array($model,'MOD_DESCRICAO'),
));

$this->widget('application.extensions.moneymask.MMask',array('element'=>'#Modulos_MOD_VLRMENSAL, #Modulos_MOD_VLRIMPLANTACAO'));
$this->widget('application.extensions.emultiselect.EMultiSelect');
?>

	<?php echo FaHtml::getFormInfo($form, $model); ?>
		<div class="col-xs-12 col-sm-6 col-md-5 col-lg-4 col-container">
			<div class="row form-group">
			<?php echo $form->labelEx($model,'MOD_DESCRICAO'); ?>
			<?php echo $form->textField($model, 'MOD_DESCRICAO', array('maxlength' => 50)); ?>
			<?php echo $form->error($model,'MOD_DESCRICAO'); ?>
			</div><!-- row form-group -->
			<div class="row form-group">
			<?php echo $form->labelEx($model,'MOD_OBS'); ?>
			<?php echo $form->textArea($model, 'MOD_OBS'); ?>
			<?php echo $form->error($model,'MOD_OBS'); ?>
			</div><!-- row form-group -->
			<div class="row form-group">
			<?php echo $form->labelEx($model,'MOD_TIPO'); ?>
			<?php echo $form->dropDownList($model, 'MOD_TIPO', array('2' => 'Comercial', '1' => 'Sistema'), array('prompt' => 'Selecione')); ?>
			<?php echo $form->error($model,'MOD_TIPO'); ?>
			</div><!-- row form-group -->
		</div>
		<div class="col-xs-12 col-sm-6 col-md-5 col-lg-4 col-container">
			<div class="row form-group">
			<?php echo $form->labelEx($model,'MOD_COMPLEMENTO'); ?>
			<?php echo $form->dropDownList($model, 'MOD_COMPLEMENTO', array('S' => 'Sim','N' => 'Não')); ?>
			<?php echo $form->error($model,'MOD_COMPLEMENTO'); ?>
			</div><!-- row form-group -->
			<div class="row form-group mobile">
			<?php echo $form->labelEx($model,'MOD_MOBILE'); ?>
			<?php echo $form->dropDownList($model, 'MOD_MOBILE', array(0 => 'Não', 1 => 'Sim')); ?>
			<?php echo $form->error($model,'MOD_MOBILE'); ?>
			</div><!-- row -->
			<div class="row form-group">
			<?php echo $form->labelEx($model,'MOD_SITUACAO'); ?>
			<?php echo $form->dropDownList($model, 'MOD_SITUACAO', array('A' => 'Ativo','I' => 'Inativo')); ?>
			<?php echo $form->error($model,'MOD_SITUACAO'); ?>
			</div><!-- row form-group -->
			<div class="row form-group">
			<?php echo $form->labelEx($model,'IdsDocumentosFiscais'); ?>
			<?php 
			$data = CHtml::listData(DocumentosFiscais::model()->findAll('DFS_SITUACAO="A" order by DFS_DESCRICAO ASC'), 'DFS_IDDOCUMENTO', 'DFS_DESCRICAO');

			$model->IdsDocumentosFiscais = $model->listDocumentosFiscais(false, true);
			echo $form->dropDownList($model, 'IdsDocumentosFiscais', $data, array('multiple' => 'multiple', 'class' => 'multiselect','size' => '10'));
			?>
			<?php echo $form->error($model,'IdsDocumentosFiscais'); ?>
			</div><!-- row -->
		</div>
		<?php
		echo FaHtml::saveButton();
		$this->endWidget();
		?>
</div><!-- form -->
<style type="text/css">
input[type=text] {
	height: 24px;
}
input[type=text], textarea, select {
	width: 100%!important;
	max-width: 100%!important;
	min-width: 100%!important;
	box-sizing: border-box;
}
.col-container {
	padding-right: 30px;
	box-sizing: border-box;
}
</style>
<script type="text/javascript">
	function verificaMobile() {
		if($("#Modulos_MOD_COMPLEMENTO").val() == 'S') {
			$(".mobile").fadeIn();
			$("#Modulos_MOD_MOBILE").val('0');
		} else {
			$(".mobile").fadeOut();
		}
	}
	verificaMobile();
	$("#Modulos_MOD_COMPLEMENTO").change(function() {
		verificaMobile();
	});
</script>