<?php include('casa/setup.casa.php');
$codigo = DataForms::GET('id');
$titulo = 'Crear Nuevo Usuario';
include('inc_head.php');

$sql = "SELECT * FROM rol_usuarios 
	WHERE us_id='$codigo';";
$db = new DB();	
$db->dbSQL($sql);
$db->next();
					
											$urol_id= $db->dbField('rol_id');												
											$uus_ci= $db->dbField('us_ci');
											$uus_nombres= $db->dbField('us_nombres');
											$uus_apellidos= $db->dbField('us_apellidos');																									 
											$uus_user= $db->dbField('us_user');																									 

?>
<style>
.input-group-text{
	color:white;
	text-align:left;
	font-weight:bold;
}	
</style>
</head>
<body>
	<div class="wrapper">
	
	<?php include('inc_menu.php');?>

		<div class="main-panel">
			<div class="content">
				
				<div class="page-inner">						
				<div class="row">
					<div class="col-md-12">
						<form>
							<div class="card">
								<div class="card-header">
									<div class="card-title"><?php echo $titulo;?></div>
								</div>
								<div class="card-body">
									<div class="row">										
										<div class="col-md-4">														
											<div class="form-group">
												<div class="input-group mb-2">													
													<div class="input-group-prepend">
														<span class="input-group-text bg-dark">Nombres:</span></div>												
													<input id='txtNombres' value='<?php echo $uus_nombres;?>' type="text" class="form-control">
												</div>																																																																																																											
											</div>																					
											<div class="form-group">
												<div class="input-group mb-2">													
													<div class="input-group-prepend">
														<span class="input-group-text bg-dark">Apellidos:</span></div>												
													<input id='txtApellidos' value='<?php echo $uus_apellidos;?>' type="text" class="form-control">
												</div>																																																																																																											
											</div>	
											<div class="form-group">
												<div class="input-group mb-2">													
													<div class="input-group-prepend">
														<span class="input-group-text bg-dark">C.I.:</span></div>												
													<input id='txtCI' value='<?php echo $uus_ci;?>' type="text" class="form-control">
												</div>																																																																																																											
											</div>																						
										</div>											
										<div class="col-md-4">																																																															
											<div class="form-group">
												<div class="input-group mb-2">													
													<div class="input-group-prepend">
														<span class="input-group-text bg-dark">Tipo:</span></div>												
													<select id='txtROL' class="form-control">
														<option value="">ROL de Usuarios</option>
														<option value="1">Administrador</option>
														<option value="2">Técnico</option>														
													</select>
												</div>																																																																																																											
											</div>
											<div class="form-group">
												<div class="input-group mb-2">													
													<div class="input-group-prepend">
														<span class="input-group-text bg-dark">Nombre Usuario:</span></div>												
													<input id='txtUSER' value='<?php echo $uus_user;?>' type="text" class="form-control">
												</div>																																																																																																											
											</div>
										</div>																				
										
									</div>
								</div>
								<div class="card-action"><center>
									<div id='res'></div>
									<a href='<?php echo PATH_HOME.'usuarios/ver'; ?>' class="btn btn-info"><b> CANCELAR </b></a>
									<button class="btn btn-dark" type='submit'><b> GUARDAR DATOS </b></button>	</center>								
								</div>
							</div>
						</form>
						</div>
					</div>
				</div>
				
			</div>
			<?php include('inc_pie.php');?>
		</div>
		
		
	</div>
</body>
</html>
<script>
$('form').on('submit', function(event) {
  event.preventDefault();

  $.post('<?php echo PATH_HOME.'usuarios-ins2/'. md5(uniqid()); ?>',{
	 'txtNombres': $('#txtNombres').val(), 	 	 	 
	 'txtApellidos': $('#txtApellidos').val(), 	 	 	 
	 'txtCI': $('#txtCI').val(), 	 	 	 
	 'txtROL': $('#txtROL').val(), 	 	 	 
	 'txtUSER': $('#txtUSER').val(), 	 	 	 
	 'MxEncoder': '<?php echo sha1(uniqid()); ?>'
  },function(data){
    $('#res').html(data);
  });  
});
</script>