<?php
require_once ("../../config/Cado.php");
require_once ("cModulo.php");
$oModulo = new cModulo();
if($_POST['action']=="editar")
{
	$dts = $oModulo->mostrarUno($_POST['mod_id']);
	$dt = mysqli_fetch_array($dts);
	$modulo  = $dt['tb_modulo_nom'];
	
	mysqli_free_result($dts);
}else{
	$modulo="";
	
}
?>
	
				<form role="form" id="for_mod" method="POST">
					<input name="action_modulo" id="action_modulo" type="hidden" value="<?php echo $_POST['action']?>">
					<input name="hdd_mod_id" id="hdd_mod_id" type="hidden" value="<?php echo $_POST['mod_id']?>">
					<div class="box-header">
						<h3 class="box-title">Información del Módulo</h3>
					</div>
					<div class="box-body">
						<div class="form-group">							
							<div class="row">
								<div class="col-lg-8 col-xs-12">
									<label for="txt_cli_con">Nombre:</label>
									<input name="txt_mod_nom" id="txt_mod_nom" autocomplete="off" type="text" value="<?php echo $modulo;?>" size="50" tabindex="1" class="form-control">
								</div>
							</div>
						</div>
					</div>
				</form>
				<div class="box-footer float-right  ">
				<button type="button" data-dismiss="modal" class="btn btn-default cancel">Cancelar</button>
				<button class="btn btn-primary" id="save_form">Guardar</button>
				</div>
				
<!--
<section class="content" id="form">
	<div class="row">
		<div class="col-xs-12">
			<div class="box box-info">
			
			</div>
		</div>
	</div>
</section>
-->
<script type="text/javascript">
	$('#txt_mod_nom').change(function(){
		$(this).val($(this).val().toUpperCase());
	});
	$("#save_form").click(function() {
		$("#for_mod").submit();
	});
	$(document).ready(function() {
		$('#for_mod').bootstrapValidator({
	      message: 'Valor no valido',
	      feedbackIcons: {
	      	valid: 'glyphicon glyphicon-ok',
	      	invalid: 'glyphicon glyphicon-remove',
	      	validating: 'glyphicon glyphicon-refresh'
	      },
	      fields: {	      	
	      	txt_mod_nom: {
	      		group: '.col-lg-4',
	      		validators: {
	      			notEmpty: {
	      				message: 'Este campo es requerido'
	      			}
	      		}
	      	}
	      }
	  }).on('success.form.bv', function(e) {
	  	$.ajax({
	  		type: "POST",
	  		url: "../modulo/modulo_reg.php",
	  		async:true,
	  		dataType: "json",
	  		data: $("#for_mod").serialize(),
	  		beforeSend: function() {					
	  			
	  		},
	  		success: function(data){
				$('.modal').modal('hide');
				$('.in').removeClass('modal-backdrop');			
				toastr["success"](data.mod_msj);	
	  		},
	  		complete: function(){
	  			modulo_tabla();
	  		}
	  	});	
	  });
	});
	
	$('#cmb_cli_tip').focus();
	$('#cmb_cli_tip').keydown(function(ev) {
		if(ev.keyCode==13){$('#txt_cli_doc').focus(); return false;}
	});
	$('#txt_cli_doc').keydown(function(ev) {
		if(ev.keyCode==13){$('#txt_cli_nom').focus(); return false;}
	});
	$('#txt_cli_nom').keydown(function(ev) {
		if(ev.keyCode==13){$('#txt_cli_dir').focus(); return false;}
	});
	$('#txt_cli_dir').keydown(function(ev) {
		if(ev.keyCode==13){$('#txt_cli_con').focus(); return false;}
	});
	$('#txt_cli_con').keydown(function(ev) {
		if(ev.keyCode==13){$('#txt_cli_tel').focus(); return false;}
	});
	$('#txt_cli_tel').keydown(function(ev) {
		if(ev.keyCode==13){$('#txt_cli_ema').focus(); return false;}
	});
	$('#txt_cli_ema').keydown(function(ev) {
		if(ev.keyCode==13){$('#save_form').focus(); return false;}
	});
	
</script>