-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusuarios-add.php
More file actions
183 lines (169 loc) · 7.1 KB
/
usuarios-add.php
File metadata and controls
183 lines (169 loc) · 7.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
include 'layout/header.php';
if(isset($_POST)){
$number = $_POST['number'];
}
?>
<body>
<?php include 'layout/aside.php'; ?>
<section class="home-section">
<?php include 'layout/perfil.php';?>
<div class="home-content">
<div class="center ">
<div class="box-titles">
<h1 class="title">Administración de Usuarios / Docentes / Alumnos</h1>
<div class="box-botones">
<a class="btn" href="javascript:history.back()" title="Atras"><i class="fas fa-arrow-left"></i></a>
</div>
</div>
<?php if(isset($_SESSION['completado'])): ?>
<div class="alerta-exito">
<?=$_SESSION['completado']?>
</div>
<?php elseif(isset($_SESSION['fallo'])): ?>
<div class="alerta-error">
<?=$_SESSION['fallo']?>
</div>
<?php endif; ?>
<div class="box-message" id="info"></div>
<div class="container-wrap w100">
<form action="models/add/usuarios-add.php" class="box-formulario" id="" method="post">
<?php for($i = 1; $i <= $number; $i++): ?>
<div class="box-formulario-register mg-bt10" >
<div class="box-input w25">
<label for="nombre">Nombre: </label>
<input class="text50" type="text" name="nombre[]" maxlength="50" data-maxlength="50" required>
<!-- <span class="counterNombre">16</span> -->
</div>
<div class="box-input w25">
<label for="apepaterno">Ape. Paterno: </label>
<input class=" text50" type="text" name="apepaterno[]" maxlength="50" data-maxlength="50" required>
<!-- <span class="counterApePaterno">16</span> -->
</div>
<div class="box-input w25">
<label for="apematerno">Ape. Materno: </label>
<input class=" text50" type="text" name="apematerno[]" maxlength="50" data-maxlength="50" required>
<!-- <span class="counterApeMaterno">16</span> -->
</div>
<div class="box-input w25">
<label for="doc">Documento Identidad: </label>
<input class="number" type="text" name="doc[]" minlength="8" required>
</div>
<div class="box-input w25">
<label for="email">Correo: </label>
<input id="email<?=$i?>" type="email" name="email[]" maxlength="80" required>
<?php echo isset($_SESSION['errores']) ? mostrarError($_SESSION['errores'], 'email') : ''; ?>
</div>
<div class="box-input w25">
<label for="password">Contraseña:</label>
<input type="text" name="password[]" minlength="8" value="cambiame123" readonly>
</div>
<div class="box-input w25">
<label for="sexo">Sexo: </label>
<select class="w70" name="sexo[]" required>
<option value="" disabled selected>Seleccionar Sexo</option>
<?php
$instituciones = selectalldatos($db, 'sexo');
if(!empty($instituciones) && mysqli_num_rows($instituciones) >= 1):
while($dato = mysqli_fetch_assoc($instituciones)):
?>
<option value="<?=$dato['id']?>"><?=$dato['nombre']?></option>
<?php endwhile; endif; ?>
</select>
</div>
<div class="box-input w25">
<label for="fecnac">Fecha Nacimiento: </label>
<input class="" type="date" name="fecnac[]" value="<?php echo date("Y-m-d");?>" required >
</div>
<div class="box-input w25">
<label for="">Celular / Whatapp: </label>
<input class="number" type="text" name="celular[]" required>
</div>
<div class="box-input w25">
<label for="">Pais: </label>
<input class="texto " type="text" name="pais[]" id="pais" required></div>
<div class="box-input w25">
<label for="perfil">Perfil: </label>
<select class="w65" name="perfil[]" id="perfil" required>
<option value="" disabled >Seleccionar perfil</option>
<?php
$perfiles = selectalldatos($db, 'perfil');
if(!empty($perfiles) && mysqli_num_rows($perfiles) >= 1):
while($dato = mysqli_fetch_assoc($perfiles)):
?>
<?php if($dato['id'] <= '2' ): ?>
<option value="<?=$dato['id']?>" disabled><?=$dato['nombre']?></option>
<?php elseif($dato['id'] == '4' ): ?>
<option value="<?=$dato['id']?>" selected><?=$dato['nombre']?></option>
<?php else: ?>
<option value="<?=$dato['id']?>"><?=$dato['nombre']?></option>
<?php endif; ?>
<?php endwhile; endif; ?>
<?php echo isset($_SESSION['errores']) ? mostrarError($_SESSION['errores'], 'perfil') : ''; ?>
</select>
</div>
<div class="box-input w25">
<label for="institucion">Institución : </label>
<select class="w65" name="institucion[]" id="institucion" required>
<option value="" disabled selected>Seleccionar Institución</option>
<?php
$instituciones = selectalldatos($db, 'instituciones');
if(!empty($instituciones) && mysqli_num_rows($instituciones) >= 1):
while($dato = mysqli_fetch_assoc($instituciones)):
?>
<option value="<?=$dato['id']?>"><?=$dato['nombre']?></option>
<?php endwhile; endif; ?>
<?php echo isset($_SESSION['errores']) ? mostrarError($_SESSION['errores'], 'institucion') : ''; ?>
</select>
</div>
</div>
<hr class="w100">
<?php endfor; ?>
<?php if($number > 1 ): ?>
<input type="submit" value="Añadir Usuarios" class="btn" name="anadirusuarios" id="anadirusuarios">
<?php else : ?>
<input type="submit" value="Añadir Usuario" class="btn" name="anadirusuarios" id="anadirusuarios">
<?php endif; ?>
</form>
</div>
</div>
<!--fin center -->
<?php borrarErrores(); ?>
</div>
</section>
<?php include 'layout/footer.php'; ?>
</main>
<script>
for(var i = 1; i <= <?=$number?>; i++){
$("#email"+i).on("keyup", function(){
var email = $(this).val();
var correolength = $(this).val().length;
if(correolength >= 6 ){
var dataString = 'email='+ email;
$.ajax({
url: 'models/searchs/verificarEmail.php',
type: "GET",
data: dataString,
dataType: "JSON",
success: function(respuesta){
if(respuesta.success == 1){
$("#info").html(respuesta.message);
$("#info").fadeOut(10000, function(){
$(this).html("");
$(this).fadeIn(5000);
});
//$("#nickname").css("border-color","red");
$("#anadirusuarios").addClass("btn-none");
$("#anadirusuarios").attr('disabled',true);
}else{
$("#info").html(respuesta.message);
//$("#nickname").css("border-color","rgba(28, 117, 188, 0.5)");
$("#anadirusuarios").removeClass("btn-none");
$("#anadirusuarios").attr('disabled',false);
}
}
});
}
});
}
</script>