NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<?php
$parent_url_name = "Administrar";
$child_url_name = "Usuarios";
$page_name = 'Agregar Usuario';
?>
<!DOCTYPE html>
<html lang="es">
<head>
<?php include APPPATH.'../shared/links.php'; ?>
</head>

<body class="nav-md">
<div class="container body">
<div class="main_container">

<?php include APPPATH.'../shared/sidebar.php'; ?>
<?php include APPPATH.'../shared/nav_top.php'; ?>


<!-- page content -->
<div class="header-page">
<div class="clearfix">
<h1>Agregar usuario</h1>

<ul class="header-nav">
<li>
<a href="<?= site_url('Usuario'); ?>">Usuarios</a>
</li>
<li>Agregar Usuario</li>
</ul>
</div>
</div>

<div class="right_col clearfix" role="main">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="row x_panel ">
<div>
<h4 class="subheader">Agrega los datos en el siguiente formulario para registrar a un usuario.</h4>

<!-- start form for validation -->
<div class="row">
<form id="user-form" class="custom-form" method="post" role="form" enctype="multipart/form-data" accept-charset="utf-8">
<div class="bloque-datos clearfix">
<div class="bloque-header">
<p class="leyend">Datos de la persona:</p>
</div>

<div class="field-form col-sm-12">
<label for="Nombres">Nombres*:</label>
<input type="text" id="Nombres" class="form-control" name="Nombres" placeholder="Nombre del usuario" required="required" />
</div>
<div class="field-form col-sm-6">
<label for="Primer_apellido">Primer Apellido*:</label>
<input type="text" id="Primer_apellido" class="form-control" name="Primer_apellido" placeholder="Primer apellido del usuario" required="required"/>
</div>
<div class="field-form col-sm-6">
<label for="Segundo_apellido">Segundo Apellido:</label>
<input type="text" id="Segundo_apellido" class="form-control" name="Segundo_apellido" placeholder="Segundo apellido del usuario"/>
</div>
</div>

<div class="bloque-datos clearfix">
<div class="bloque-header">
<p class="leyend">Datos de la cuenta:</p>
</div>

<div class="field-form col-sm-6">
<label for="correo_gob">Correo laboral*:</label>
<input type="email" id="correo_gob" class="form-control" name="correo_gob" data-parsley-trigger="change" placeholder="[email protected]" required="required" />
</div>
<div class="field-form col-sm-6">
<label for="usuario_pwd">Contraseña*:</label>
<input type="password" id="usuario_pwd" class="form-control" name="usuario_pwd" placeholder="****" required="required"/>
</div>

<div class="field-form col-sm-6">
<label for="usuario_pwd_conf">Repetir Contraseña*:</label>
<input type="password" id="usuario_pwd_conf" class="form-control" name="usuario_pwd_conf" placeholder="****" required="required"/>
</div>
<div class="field-form col-sm-6">
<label for="rol_usr">Rol usuario*:</label>
<select class="form-control" id="rol_usr" name="rol_usr">
<option value="1">Administrador</option>
<option value="2">Abogado</option>
</select>
</div>
</div>

<div class="field-form col-sm-12">
<p class="form-fiel-footer">
<a href="<?php echo site_url('Usuario') ?>"><span class="btn btn-default cancelar">Cancelar</span></a>
<span class="btn btn-orange registrar">Registrar Usuario</span>
</p>
</div>
</form>
</div>
<!-- end form for validations -->
</div>
</div>
</div>

<!-- MODALS -->
<button type="button" class="btn btn-primary btn-agregar" data-toggle="modal" data-target=".bs-example-modal-lg" style="display: none;">Agregar</button>
<div id="modal-agregar" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">¡Correcto!</h4>
</div>
<div class="modal-body">
<img class="success-modal-img" src="<?= site_url('assets/images/exito-icon.png') ?>" alt="SECRE | Modal éxito">
<p>Se ha registrado un usuario corractamente.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Cerrar</button>
</div>
</div>
</div>
</div>
<!-- /end MODALS -->
</div>
<!-- /page content -->

<?php include APPPATH.'../shared/footer.php'; ?>
</div>
</div>

<div class="custom-alert danger">
<div class="custom-elements">
<div class="custom-alert-header">
<h4><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Error</h4>
<a href="#" class="pull-right close-custom-alert" title="Cerrar">
<i class="fa fa-times" aria-hidden="true"></i>
</a>
</div>
<div class="custom-alert-body">
<p>El correo ingresado ya existe, por favor ingrese otro.</p>
</div>
</div>
</div>

<?php include APPPATH.'../shared/scripts.php'; ?>
<script type="text/javascript" src="<?= base_url('assets/js/validation.js') ?>"></script>
<script type="text/javascript">
$('.registrar').click(function(e){
e.preventDefault();

//console.log($('#user-form').serialize());
$(".campo-invalido").removeClass("campo-invalido");
$(".msg-invalido").remove();
var campos_validados = validarCampos();

if (campos_validados) {
$.ajax({
url: "<?php echo site_url('Usuario/registrar'); ?>",
type: 'POST',
cache: false,
data: $('#user-form').serialize(),
success: function (data) {
//console.log(data);
if (data == "Registrado") {
$(".btn-agregar").click();
$('#user-form')[0].reset();
}else if (data == "Existe"){
$(".custom-alert").addClass('desplegado');
}
},
error: function(data){
console.log("error"+data.message);
}
});
}

});

function validarCampos(){
var campo_nombres = $('#user-form #Nombres').val();
var campo_pri_ape = $('#user-form #Primer_apellido').val();
var campo_correo = $('#user-form #correo_gob').val();
var campo_pwd = $('#user-form #usuario_pwd').val();
var campo_pwd_rep = $('#user-form #usuario_pwd_conf').val();

//console.log(campo_nombres +""+ campo_pri_ape +""+ campo_usuario);

if (campo_nombres!="" && campo_pri_ape!="") {
if (validaCorreo(campo_correo)) {
if (campo_pwd == campo_pwd_rep && campo_pwd!="" && campo_pwd_rep!="") {
return true;
console.log("se puede agregar");
}else {
console.log("No son iguales las contraseñas");
//No son iguales las contraseñas
muestraErrorCampo("#usuario_pwd_conf, #user-form #usuario_pwd_conf","No coinciden las contraseñas");
return false;
}
}else {
console.log("No es correo valido");
//No es correo valido
muestraErrorCampo("#correo_gob","Correo invalido");
return false;
}
}else {
if (campo_nombres=="") {
muestraErrorCampo("#Nombres","Escribe el nombre del usuario");
}else {
muestraErrorCampo("#Primer_apellido","Escribe un apellido al menos");
}
return false;
}
}

function validaCorreo(correo) {
var caract = new RegExp(/^([a-zA-Z0-9_.+-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/);

if (caract.test(correo) == false){
return false;
}else{
return true;
}
}
</script>
</body>
</html>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.