-
Notifications
You must be signed in to change notification settings - Fork 0
/
agresor-new.php
549 lines (435 loc) · 16.9 KB
/
agresor-new.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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
<?php
include("php/database.php");
session_start();
$user = $_SESSION["username"];
// Verificar si el usuario está autenticado
if (!isset($_SESSION["username"]) || empty($_SESSION["username"])) {
// Redirigir al usuario a index.php
header("Location: index.php");
exit; // Asegurarse de que el script se detenga después de redirigir
}
$user = $_SESSION["username"];
$consulta = "SELECT rol FROM users WHERE user = '$user'";
$resultado = mysqli_query($connection, $consulta);
$datos = mysqli_fetch_assoc($resultado);
$rol = $datos['rol'];
if ($rol == "Lector") {
header("Location: home.php");
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="icon" href="assets/icons/system.png" type="image/png">
<title>SIVIGE | Nuevo Agresor</title>
<!-- Font Awesome -->
<script src="https://kit.fontawesome.com/42b5b848d1.js" crossorigin="anonymous"></script>
<!-- Normalize V8.0.1 -->
<link rel="stylesheet" href="css/normalize.css">
<!-- Bootstrap V4.3 -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- Bootstrap Material Design V4.0 -->
<link rel="stylesheet" href="css/bootstrap-material-design.min.css">
<!-- Font Awesome V5.9.0 -->
<link rel="stylesheet" href="css/all.css">
<!-- Sweet Alerts V8.13.0 CSS file -->
<link rel="stylesheet" href="css/sweetalert2.min.css">
<!-- Sweet Alert V8.13.0 JS file-->
<script src="js/sweetalert2.min.js"></script>
<!-- jQuery Custom Content Scroller V3.1.5 -->
<link rel="stylesheet" href="css/jquery.mCustomScrollbar.css">
<!-- General Styles -->
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<!-- Main container -->
<main class="full-box main-container">
<!-- Nav lateral -->
<section class="full-box nav-lateral">
<div class="full-box nav-lateral-bg show-nav-lateral"></div>
<div class="full-box nav-lateral-content">
<!-- Avatar -->
<figure class="full-box nav-lateral-avatar">
<i class="far fa-times-circle show-nav-lateral"></i>
<?php
if ($resultado && mysqli_num_rows($resultado) > 0) {
if ($rol == "Administrador") {
?><img src="assets/avatar/admin.png" class="img-fluid" alt="Avatar"><?php
}
if ($rol == "Editor") {
?><img src="assets/avatar/edit.png" class="img-fluid" alt="Avatar"><?php
}
if ($rol == "Lector") {
?><img src="assets/avatar/read.png" class="img-fluid" alt="Avatar"><?php
}
}
?>
<figcaption class="roboto-medium text-center">
<?php
if ($resultado && mysqli_num_rows($resultado) > 0) {
// Mostrar el mensaje de bienvenida con el nombre de usuario y el rol
echo "Bienvenido $user <br><small class='roboto-condensed-light'>$rol</small>";
} else {
// Mostrar un mensaje genérico si no se puede obtener el rol del usuario
echo "Bienvenido $user <br><small class='roboto-condensed-light'>Rol desconocido</small>";
}
?>
</figcaption>
</figure>
<!-- Lista de Opciones -->
<div class="full-box nav-lateral-bar"></div>
<nav class="full-box nav-lateral-menu">
<ul>
<li>
<a href="home.php"><i class="fab fa-dashcube fa-fw"></i> Panel de Control</a>
</li>
<li>
<a href="#" class="nav-btn-submenu"><i class="fa-solid fa-venus-mars"></i> Víctimas <i class="fas fa-chevron-down"></i></a>
<ul>
<?php
if ($rol != "Lector") {
?>
<li>
<a href="victim-new.php"><i class="fas fa-plus fa-fw"></i> Agregar Víctima</a>
</li>
<?php
}
?>
<li>
<a href="victim-list.php"><i class="fas fa-clipboard-list fa-fw"></i> Lista de Víctimas</a>
</li>
<li>
<a href="victim-search.php"><i class="fas fa-search fa-fw"></i> Buscar Víctima</a>
</li>
</ul>
</li>
<li>
<a href="#" class="nav-btn-submenu"><i class="fa-solid fa-mars-and-venus-burst"></i> Agresores <i class="fas fa-chevron-down"></i></a>
<ul>
<?php
if ($rol != "Lector") {
?>
<li>
<a href="agresor-new.php"><i class="fas fa-plus fa-fw"></i> Agregar Agresor</a>
</li>
<?php
}
?>
<li>
<a href="agresor-list.php"><i class="fas fa-clipboard-list fa-fw"></i> Lista de Agresor</a>
</li>
<li>
<a href="agresor-search.php"><i class="fas fa-search fa-fw"></i> Buscar Agresor</a>
</li>
</ul>
</li>
<?php
if ($rol == "Administrador") {
?>
<li>
<a href="#" class="nav-btn-submenu"><i class="fa-solid fa-sliders"></i></i> Admin <i class="fas fa-chevron-down"></i></a>
<ul>
<li>
<a href="user-new.php"><i class="fa-solid fa-user-plus"></i> Nuevo Usuario</a>
</li>
<li>
<a href="user-list.php"><i class="fa-solid fa-users"></i> Lista de Usuarios</a>
</li>
</ul>
</li>
<?php
}
?>
<li>
<a href="#" class="btn-show-info"><i class="fa-solid fa-circle-info"></i> Informacíon</a>
</li>
</ul>
<div class="container-fluid footer">
<div class="row">
<div class="col-12 text-center text-white">
<a href="https://instagram.com/miltoncoronel__" class="mb-3 mb-md-0 text-body-secondary text-decoration-none lh-1">
</a>
<span class="mb-3 mb-md-0 text-body-secondary pr-5">© 2023 Milweb, Inc</span>
<a class="text-body-secondary" href="https://www.facebook.com/miltonagustin.coroneldean/"><img class="bi" width="24" height="24" src="assets/img/facebook.png" alt=""></a>
<a class="text-body-secondary" href="https://instagram.com/miltoncoronel__"><img class="bi" width="24" height="24" src="assets/img/instagram.png" alt=""></a>
<a class="text-body-secondary" href="mailto:[email protected]?subject=Consulta de Desarrollo Web"><img class="bi" width="24" height="24" src="assets/img/gmail.png" alt=""></a>
</div>
</div>
<div class=" row">
<div class="col-12 text-center">
</div>
</div>
</div>
</nav>
</div>
</section>
<!-- Page content -->
<section class="full-box page-content">
<nav class="full-box navbar-info">
<a href="#" class="float-left show-nav-lateral">
<i class="fas fa-exchange-alt"></i>
</a>
<?php
if($rol == "Administrador") {
?>
<a href="user-list.php">
<i class="fas fa-user-cog"></i>
</a>
<?php
}
?>
<a href="#" class="btn-exit-system">
<i class="fas fa-power-off"></i>
</a>
</nav>
<!-- Page header -->
<div class="full-box page-header">
<h3 class="text-left">
<i class="fas fa-plus fa-fw"></i> AGREGAR AGRESOR
</h3>
<p class="text-justify">
</p>
</div>
<div class="container-fluid">
<ul class="full-box list-unstyled page-nav-tabs">
<li>
<a class="active" href="agresor-new.php" class="option"><i class="fas fa-plus fa-fw"></i> AGREGAR AGRESOR</a>
</li>
<li>
<a href="agresor-list.php" class="option"><i class="fas fa-clipboard-list fa-fw"></i> LISTA DE AGRESORES</a>
</li>
<li>
<a href="agresor-search.php" class="option"><i class="fas fa-search fa-fw"></i> BUSCAR AGRESOR</a>
</li>
</ul>
</div>
<!-- Content here-->
<div class="container-fluid">
<form id="formulario" action="php/agresor-reg.php" method="POST" enctype="multipart/form-data" class="form-neon" autocomplete="off">
<fieldset>
<legend id="info"><i class="fas fa-user"></i> Información Del Agresor</legend>
<div class="container-fluid">
<div class="row">
<div class="col-12 col-md-3">
<div class="form-group">
<label for="img" class="bmd-label-floating">Foto</label>
<input type="file" class="form-control" name="img" id="img" accept="image/*">
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<label for="dni" class="bmd-label-floating">DNI</label>
<input type="number" class="form-control" name="dni" id="dni" required>
<small id="dniValidationMessage2" class="form-text text-muted"></small>
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<label for="nombre" class="bmd-label-floating">Nombre</label>
<input type="text" class="form-control" name="nombre" id="nombre" required>
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<label for="edad" class="bmd-label-floating">Edad</label>
<input type="number" class="form-control" name="edad" id="edad" required>
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<label for="gender" class="bmd-label-floating">Genero:</label>
<input type="text" class="form-control" name="gender" id="gender" required>
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<label for="direccion" class="bmd-label-floating">Dirección</label>
<input type="text" class="form-control input-group" name="direccion" id="direccion" required>
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<label for="contacto" class="bmd-label-floating">Contacto</label>
<input type="number" class="form-control" name="contacto" id="contacto" required>
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<label for="dnivictim" class="bmd-label-floating">DNI de la Víctima</label>
<input type="number" pattern="[0-9]{7,8}" class="form-control" name="dnivictim" id="dnivictim" required>
<small id="dniValidationMessage" class="form-text text-muted"></small>
</div>
</div>
</div>
<div class="row">
</div>
</div>
</fieldset>
<br><br><br>
<p class="text-center" style="margin-top: 40px;">
<button type="reset" class="btn btn-raised btn-secondary btn-sm"><i class="fas fa-paint-roller"></i> LIMPIAR</button>
<button type="submit" class="btn btn-raised btn-info btn-sm" name="guardar"><i class="far fa-save"></i> GUARDAR</button>
</p>
</form>
</div>
</section>
</main>
<!-- jQuery V3.4.1 -->
<script src="js/jquery-3.4.1.min.js"></script>
<!-- popper -->
<script src="js/popper.min.js"></script>
<!-- Bootstrap V4.3 -->
<script src="js/bootstrap.min.js"></script>
<!-- jQuery Custom Content Scroller V3.1.5 -->
<script src="js/jquery.mCustomScrollbar.concat.min.js"></script>
<!-- Bootstrap Material Design V4.0 -->
<script src="js/bootstrap-material-design.min.js"></script>
<script>
$(document).ready(function() {
$('body').bootstrapMaterialDesign();
});
</script>
<script src="js/main.js"></script>
<script src="js/agresor-reg.js"></script>
</body>
</html>
<?php
if($rol == "Administrador") {
?>
<style>
.footer {
margin-top: 65%;
}
@media screen and (max-width: 1024px){
.footer {
margin-top: 35%;
}
}
</style>
<?php
}
else {
?>
<style>
.footer {
margin-top: 80%;
}
@media screen and (max-width: 1024px){
.footer {
margin-top: 110%;
}
}
</style>
<?php
}
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
var dniInput = document.getElementById('dnivictim');
var dniValidationMessage = document.getElementById('dniValidationMessage');
dniInput.addEventListener('input', function() {
var dniValue = dniInput.value;
var dniLength = dniValue.length;
if (dniLength > 0 && dniLength < 7) {
dniValidationMessage.textContent = 'El número de DNI es demasiado corto.';
} else if (dniLength > 8) {
dniValidationMessage.textContent = 'El número de DNI es demasiado largo.';
} else {
dniValidationMessage.textContent = '';
}
});
var dniInput = document.getElementById('dni');
var dniValidationMessage2 = document.getElementById('dniValidationMessage2');
dniInput.addEventListener('input', function() {
var dniValue = dniInput.value;
var dniLength = dniValue.length;
if (dniLength > 0 && dniLength < 7) {
dniValidationMessage2.textContent = 'El número de DNI es demasiado corto.';
} else if (dniLength > 8) {
dniValidationMessage2.textContent = 'El número de DNI es demasiado largo.';
} else {
dniValidationMessage2.textContent = '';
}
});
</script>
<script>
// Función para limitar la longitud de un campo de entrada
function limitarLongitud(input, maxLength) {
if (input.value.length > maxLength) {
input.value = input.value.slice(0, maxLength);
}
}
// Configuración de longitud máxima para cada campo de entrada
var campos = [
{ id: 'dni', maxLength: 9 },
{ id: 'nombre', maxLength: 60 },
{ id: 'edad', maxLength: 2 },
{ id: 'gender', maxLength: 10 },
{ id: 'contacto', maxLength: 10 },
{ id: 'direccion', maxLength: 50 },
{ id: 'victima', maxLength: 60 },
{ id: 'dnivictim', maxLength: 9 },
];
// Agregar el evento oninput a cada campo de entrada
campos.forEach(function (campo) {
var input = document.getElementById(campo.id);
var maxLength = campo.maxLength;
if (input) {
input.addEventListener('input', function () {
limitarLongitud(this, maxLength);
});
}
});
</script>
<?php
include("php/database.php");
// Función para actualizar el estilo de la página según el modo
function updatePageStyle($toggleMode) {
if ($toggleMode == 1) {
?>
<script>
$(document).ready(function() {
var btnLightMode = $('.btn-light-mode');
var btnDarkMode = $('.btn-dark-mode');
btnDarkMode.hide();
btnLightMode.show();
$('body').css('--color-one', '#181818');
$('h1, h2, h3, h4, h5, h6, p').css('color', '#fff');
$('body, h1, h2, h3, h4, h5, h6, p').css('background-color', '#181818');
$('.tile:hover').css('color', '#fff');
$('.tile-tittle').css('color', '#fff !important');
$('.tile').css('border', '1px solid #272727');
$('.tile').css('background-color', '#181818');
$('.p-icon').css('color', '#fff');
$('.navbar-info a i').css('color', '#fff');
$('form').css('background-color', '#181818');
$('form label').css('color', '#fff');
$('form input').css('border-bottom', '1px solid #fff');
$('form legend').css('color', '#fff');
$('form select').css('color', '#fff');
$('form select').css('background-color', '#181818');
$('form select').css('background-color', '#181818');
$('.option').css('color', '#fff');
$('.save-btn').css('color', 'black');
$('.save-btn').css('font-weight', 'bolder');
$('#vivecon').css('background-color', '#060606');
$('#fliadata').css('background-color', '#060606');
$('input').css('color', '#fff');
// Aquí puedes agregar cualquier otra lógica o funciones relacionadas con el modo oscuro
});
</script>
<?php
}
}
// Verificar el valor actual de "togglemode" en la tabla "mode"
$consulta = "SELECT togglemode FROM mode WHERE id = 1";
$resultado = mysqli_query($connection, $consulta);
if ($resultado && mysqli_num_rows($resultado) > 0) {
$fila = mysqli_fetch_assoc($resultado);
$toggleMode = $fila['togglemode'];
updatePageStyle($toggleMode);
}
?>