-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategorias.php
148 lines (137 loc) · 6.09 KB
/
categorias.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
<?php
session_start();
if(!isset($_SESSION["usuario"]) && !isset($_SESSION['codigoValido'])){
header("Location:login.php");
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Categorias | Denuncias Ciudadanas</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Kanit:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/ciudadanos.css">
<link rel="stylesheet" href="css/normalize.css">
<link rel="icon" href="logo.ico">
</head>
<body>
<nav class="navbar navbar-expand-lg" data-bs-theme="dark">
<div class="container-sm">
<a class="navbar-brand" href="">Categorías</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item dropdown">
<a class="nav-link" href="index.php" role="button">
Inicio
</a>
</li>
</li>
</ul>
</div>
</div>
</nav>
<div class="container-lg ciudadanos">
<?php
echo '<p style="color: #d6f3ff;">Hola '.ucwords($_SESSION["usuario"]). '. Aquí puedes administrar las categorías.<br><br></p>';
?>
<div class="formCiudadano form">
<div class="mt-4">
<form class="needs-validation" action="categoriaInsertar.php" method="post" >
<div class="row">
<h3 style="color:#d6f3ff;">Agregar categoría</h3>
<div class="col-auto">
<input type="text" class="form-control" name="idCategoria" id="id" placeholder="ID Categoría" required>
</div>
<div class="col-auto">
<input type="text" name="nombre" placeholder="Nombre categoría" requiered>
</div>
<div class="col-auto">
<input type="text" name="entidad" placeholder="Entidad Responsable" requiered>
</div>
<div class="col-auto">
<input type="text" name="correo" placeholder="Correo" requiered>
</div>
</div>
<input type="submit" value="Agregar" name="submit">
</form>
</div>
</div>
<div class="ciudadano">
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Nombre</th>
<th scope="col">Entidad Responsable</th>
<th scope="col">Correo</th>
<th scope="col">Acciones</th>
</tr>
</thead>
<?php
try {
$conn = new mysqli("localhost", "root", "", "clinica");
$conn->set_charset("utf8");
$sql = "SELECT * FROM categoria";
$result=$conn->query($sql);
while($datos = $result->fetch_object()) { ?>
<tbody>
<tr>
<th scope="row"><?= $datos->id_categoria?></th>
<td><?= $datos->nombre_categoria?></td>
<td><?= $datos->entidad_responsable?></td>
<td><?= $datos->correo?></td>
<td><a href="categoriaEditarForm.php?id=<?=$datos->id_categoria?>">Editar</a>
<a onclick="return confirmDelete(<?=$datos->id_categoria?>)" href="">Borrar</a></td>
</tr>
</tbody>
<?php }
} catch (Exception $e) {
die('Error: ' . $e->GetMessage());
}?>
</table>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-BBtl+eGJRgqQAUMxJ7pMwbEyER4l1g+O15P+16Ep7Q9Q+zqX6gSbd85u4mG4QzX+" crossorigin="anonymous"></script>
<!-- Script confirmación eliminar -->
<script>
function confirmDelete(id) {
Swal.fire({
title: "Deseas eliminar esta categoría?",
text: "Esta acción no es reversible!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Si, eliminar!",
cancelButtonText: "Cancelar",
allowOutsideClick: true
}).then((result) => {
if (result.isConfirmed) {
// Manejar la respuesta y redirigir si es necesario
Swal.fire('Eliminado', 'La categoría ha sido eliminada', 'success').then(() => {
window.location.href = 'categoriaEliminar.php?id=' + id;
});
}
});
return false;
}
</script>
<!-- Copos nieves -->
<!-- <script
defer
src="https://app.embed.im/snow.js"
></script> -->
<footer>Copyright © - Orlie Macías</footer>
</body>
</html>