-
Notifications
You must be signed in to change notification settings - Fork 4
/
admin.php
271 lines (227 loc) · 10.6 KB
/
admin.php
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<?php
$mysqli = new mysqli("localhost", "root", "", "hgcpi"); //conectar a la base de datos
/* comprobar la conexión */
if (mysqli_connect_errno()) {
printf("Falló la conexión: %s\n", mysqli_connect_error());
exit();
}
$conexion=mysqli_connect("localhost", "root", "", "hgcpi");
/*scripts de sesion*/
session_start();
if(!isset($_SESSION['usuario'])) { header("Location: index.php"); }
$usuario = $_SESSION['usuario'];
$sql="SELECT * FROM usuario WHERE idusuario='$usuario'";
$result=mysqli_query($conexion,$sql);
$mostrar=mysqli_fetch_array($result);
if($mostrar['tipo_usuario'] != "admin") { echo 'Error. Usted no es administrador de la plataforma. <a href="index.php">Regresar.</a>'; exit; }
/*scripts de sesion*/
?>
<!DOCTYPE html>
<html lang="es">
<head>
<title>Panel del Administrador | HGCPI</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=egde">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/flick/jquery-ui.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="index.php"><img src="img/logo.png" width="120" height="40" class="d-inline-block align-top"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" name="navbarNavAltMarkup">
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" name="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Convocatorias</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="estimulos.php">Estímulos UANL</a>
<a class="dropdown-item" href="prodep.php">PRODEP</a>
<a class="dropdown-item" href="sni.php">Sistema Nacional de Investigadores</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="perfil.php">Datos Personales</a>
</li>
</ul>
<span class="navbar-text"><a class="nav-link" href="perfil.php"><?php echo $mostrar['nombre']." ".$mostrar['ap_paterno']." ".$mostrar['ap_materno']; ?></a></span>
</div>
</nav>
</header>
<div class="container">
<div class="col-md-10 offset-md-1">
<br><br>
<center><h4>Panel del Administrador | HGCPI</h4></center>
<br><br>
<h5>Agregar nuevo usuario</h5><hr><br>
<form enctype="multipart/form-data" action="scripts/admin_agregar_usuario.php" method="POST">
<div class="form-group">
<label for="num_emp">Número de empleado UANL</label>
<input type="text" class="form-control" name="empleado" placeholder="1845127" required="true">
</div>
<div class="form-group">
<label for="num_emp">Contraseña</label>
<input type="password" class="form-control" name="clave" placeholder="9c4uk19o" required="true">
</div><br>
<center><input type="submit" class="btn btn-primary btn-large" value="Registrar usuario"></center>
<br><br>
</form>
<h5><center>Acciones sobre convocatorias</center></h5><hr><br>
<table class="table table-success">
<thead>
<tr>
<th>Convocatoria</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sistema Nacional de Investigadores</td>
<?php
$sql="SELECT * FROM convocatorias WHERE nombre='SNI'";
$result=mysqli_query($mysqli,$sql);
$mostrar=mysqli_fetch_array($result);
if($mostrar['estatus'] == 'Activa') {
?>
<td><center><button class="btn btn-danger" onclick="ActDesact('SNI')">Desactivar</button></center></td>
<?php
} else if($mostrar['estatus'] == 'Inactiva') {
?>
<td><center><button class="btn btn-success" onclick="ActDesact('SNI')">Activar</button></center></td>
<?php
}
?>
<td><center><button class="btn btn-secondary" data-toggle="modal" data-target="#ventanaFechas" onclick="validarCambiarFecha('SNI')">Cambiar fechas</button></center></td>
<tr>
<tr>
<td>PRODEP</td>
<?php
$sql="SELECT * FROM convocatorias WHERE nombre='PRODEP'";
$result=mysqli_query($mysqli,$sql);
$mostrar=mysqli_fetch_array($result);
if($mostrar['estatus'] == 'Activa') {
?>
<td><center><button class="btn btn-danger" onclick="ActDesact('PRODEP')">Desactivar</button></center></td>
<?php
} else if($mostrar['estatus'] == 'Inactiva') {
?>
<td><center><button class="btn btn-success" onclick="ActDesact('PRODEP')">Activar</button></center></td>
<?php
}
?>
<td><center><button class="btn btn-secondary" data-toggle="modal" data-target="#ventanaFechas" onclick="validarCambiarFecha('PRODEP')">Cambiar fechas</button></center></td>
<tr>
<tr>
<td>Estímulos UANL</td>
<?php
$sql="SELECT * FROM convocatorias WHERE nombre='Estimulos'";
$result=mysqli_query($mysqli,$sql);
$mostrar=mysqli_fetch_array($result);
if($mostrar['estatus'] == 'Activa') {
?>
<td><center><button class="btn btn-danger" onclick="ActDesact('Estimulos')">Desactivar</button></center></td>
<?php
} else if($mostrar['estatus'] == 'Inactiva') {
?>
<td><center><button class="btn btn-success" onclick="ActDesact('Estimulos')">Activar</button></center></td>
<?php
}
?>
<td><center><button class="btn btn-secondary" data-toggle="modal" data-target="#ventanaFechas" onclick="validarCambiarFecha('Estimulos')">Cambiar fechas</button></center></td>
<tr>
</tbody>
</table>
<br><br>
<div class="container">
<div class="row">
<div class="col">
<h5><center>Usuarios registrados</center></h5><hr><br>
<table class="table table-secondary">
<thead>
<tr>
<th><center>Nombre</center></th>
<th><center>Número de empleado</center></th>
</tr>
</thead>
<?php
$sql="SELECT * FROM usuario";
$result=mysqli_query($conexion,$sql);
while($mostrar=mysqli_fetch_array($result)){
?>
<tr>
<td><center><?php
if(isset($mostrar['nombre']))
{
echo $mostrar['nombre'];
echo " ";
echo $mostrar['ap_paterno'];
}
else
{
echo '<font style="color: slategray;">Indefinido</font>';
}
?></center></td>
<td><center><?php echo $mostrar['idusuario'] ?></center></td>
</tr>
<?php
}
?>
</table>
</div>
<div class="col">
<h5><center>Administradores Registrados</center></h5><hr><br>
<table class="table table-danger">
<thead>
<tr>
<th><center>Nombre</center></th>
<th><center>Número de empleado</center></th>
</tr>
</thead>
<?php
$sql="SELECT * FROM usuario WHERE tipo_usuario = 'admin'";
$result=mysqli_query($conexion,$sql);
while($mostrar=mysqli_fetch_array($result)){
?>
<tr>
<td><center><?php
if(isset($mostrar['nombre']))
{
echo $mostrar['nombre'];
echo " ";
echo $mostrar['ap_paterno'];
}
else
{
echo '<font style="color: slategray;">Indefinido</font>';
}
?></center></td>
<td><center><?php echo $mostrar['idusuario'] ?></center></td>
</tr>
<?php
}
?>
</table>
</div>
</div>
</div>
</div>
<br><br>
</div>
<div class="modal fade" id="ventanaFechas" tabindex="-1" role="dialog" aria-labelledby="ventanaFechas">
<div class="modal-dialog">
<div class="modal-content" id="ventanaCambiarFechas">
</div>
</div>
</div>
<script type="text/javascript">
<?php include("scripts/validadorCambiarFecha.php"); ?>
</script>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>