-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovincias.php
137 lines (127 loc) · 5.56 KB
/
provincias.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
<?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>Provincias | 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="">Provincias</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 provincias.<br><br></p>';
?>
<div class="formCiudadano form">
<div class="mt-4">
<form class="needs-validation" action="provinciaInsertar.php" method="post" >
<div class="row">
<h3 style="color:#d6f3ff;">Agregar provincia</h3>
<div class="col-auto">
<input type="text" class="form-control" name="idProvincia" id="id" placeholder="ID Provincia" required>
</div>
<div class="col-sm-4 ">
<input type="text" name="provincia" placeholder="Nombre provincia" 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">Acciones</th>
</tr>
</thead>
<?php
try {
$conn = new mysqli("localhost", "root", "", "clinica");
$conn->set_charset("utf8");
$sql = "SELECT * FROM provincia";
$result=$conn->query($sql);
while($datos = $result->fetch_object()) { ?>
<tbody>
<tr>
<th scope="row"><?= $datos->id_provincia?></th>
<td><?= $datos->nombre_provincia?></td>
<td><a href="provinciaEditarForm.php?id=<?=$datos->id_provincia?>">Editar</a>
<a onclick="return confirmDelete(<?=$datos->id_provincia?>)" 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 provincia?",
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 provincia ha sido eliminada', 'success').then(() => {
window.location.href = 'provinciaEliminar.php?id=' + id;
});
}
});
return false;
}
</script>
<!-- Copos nieves -->
<!-- <script
defer
src="https://app.embed.im/snow.js"
></script> -->
<footer>Copyright © - Orlie Macías, Abraham Guttierez, Kevin Luo </footer>
</body>
</html>