Skip to content

Commit 329b7ac

Browse files
committed
first commit
1 parent 4661b79 commit 329b7ac

File tree

12 files changed

+412
-0
lines changed

12 files changed

+412
-0
lines changed

ProyectoMovilidad/index.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!doctype html>
2+
<html lang="es">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Gestión de movilidad</title>
6+
<style>
7+
body {font-family: Arial, sans-serif; margin: 40px;}
8+
h1 {color: #486fdb;}
9+
10+
.principal{
11+
background-color: rgb(230, 227, 224);
12+
width: 500px;
13+
padding: 50px;
14+
color: rgb(20, 20, 20);
15+
border: 1px solid;
16+
border-color: #333;
17+
border-radius: 5%;
18+
}
19+
.menu {margin-top: 20px;
20+
}
21+
.menu a {
22+
display: inline-block;
23+
padding: 15px 30px;
24+
margin: 10px;
25+
background: #486fdb;;
26+
color: rgb(255, 255, 255);
27+
text-decoration: none;
28+
border-radius: 5px;
29+
font-weight: bold;
30+
}
31+
.menu a:hover {background: #4478bb;}
32+
</style>
33+
</head>
34+
<body>
35+
36+
<div class="principal">
37+
<h1>Gestión de Movilidad - Área Restringida</h1>
38+
39+
<div class="menu">
40+
<a href="movilidad.php">Registrar Permiso</a>
41+
<a href="infractores.php">Ver Infractores</a>
42+
</div>
43+
</div>
44+
45+
</body>
46+
</html>

ProyectoMovilidad/infractores.php

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
// Función para leer un archivo y devolver array de líneas
3+
function leerArchivo($archivo) {
4+
return file_exists($archivo) ? file($archivo, FILE_IGNORE_NEW_LINES) : [];
5+
}
6+
7+
// Función para determinar si un vehículo está autorizado
8+
function estaAutorizado($vehiculo, $residentes, $logistica) {
9+
10+
$partes = explode(" ", $vehiculo);
11+
$matricula = $partes[0];
12+
$tipo = $partes[5];
13+
$fecha = $partes[3];
14+
$hora = $partes[4];
15+
16+
$tiposLibres = ["eléctrico","emt","taxis","servicios"];
17+
if (in_array($tipo,$tiposLibres)) return true;
18+
19+
// Residente/hotel
20+
foreach ($residentes as $linea) {
21+
$p = explode(" ", $linea);
22+
if (($p[0] ?? '') === $matricula) {
23+
$fechaInicio = $p[2];
24+
$fechaFin = $p[3];
25+
if ($fecha >= $fechaInicio && $fecha <= $fechaFin) return true;
26+
else return false;
27+
}
28+
}
29+
30+
// Logística
31+
foreach ($logistica as $linea) {
32+
$p = explode(" ", $linea);
33+
if (($p[0]) === $matricula) {
34+
$horaInt = intval(explode(":", $hora)[0]);
35+
if ($horaInt >= 6 && $horaInt <= 11) return true;
36+
else return false;
37+
}
38+
}
39+
40+
// Si no cumple ninguna regla → infractor
41+
return false;
42+
}
43+
44+
// Leer archivos
45+
$vehiculos = leerArchivo("vehiculos.txt");
46+
$residentes = leerArchivo("residentesYHoteles.txt");
47+
$logistica = leerArchivo("logistica.txt");
48+
49+
$infractores = [];
50+
51+
// Comprobar cada vehículo
52+
foreach ($vehiculos as $v) {
53+
if (!estaAutorizado($v, $residentes, $logistica)) {
54+
$infractores[] = $v;
55+
}
56+
}
57+
58+
// Guardar en infractores.txt
59+
file_put_contents("infractores.txt", implode(PHP_EOL, $infractores).PHP_EOL, LOCK_EX);
60+
?>
61+
62+
<!doctype html>
63+
<html lang="es">
64+
<head>
65+
<meta charset="utf-8">
66+
<title>Listado de Infractores</title>
67+
<style>
68+
table {border-collapse: collapse; width: 100%;}
69+
th, td {border:1px solid #000; padding:5px;}
70+
th {background:#486fdb;}
71+
</style>
72+
</head>
73+
<body>
74+
<h1 style="color: #486fdb;">Listado de infractores</h1>
75+
76+
<?php if (empty($infractores)): ?>
77+
<p>No hay infractores.</p>
78+
<?php else: ?>
79+
<table>
80+
<tr>
81+
<th>Matrícula</th><th>Propietario</th><th>Dirección</th><th>Fecha</th><th>Hora</th><th>Tipo</th>
82+
</tr>
83+
<?php foreach ($infractores as $l):
84+
$p = explode(" ", $l);
85+
?>
86+
<tr>
87+
<td><?=$p[0] ?></td>
88+
<td><?= $p[1] ?></td>
89+
<td><?=$p[2]?></td>
90+
<td><?= $p[3]?></td>
91+
<td><?= $p[4] ?></td>
92+
<td><?= $p[5]?></td>
93+
</tr>
94+
<?php endforeach; ?>
95+
</table><br>
96+
<?php endif; ?>
97+
98+
<b><a href="index.html">Volver al menú principal</b></p>
99+
</body>
100+
</html>

ProyectoMovilidad/infractores.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1044-BPF Juan_García C/Goya,123 2016/12/22 15:30 diesel
2+
7211-DLL Antonio_Gómez C/Países_Bajos,12 2016/12/23 14:25 diesel
3+
6372-JVK Fátima_Rodriguez Avenida_Arcentales,45 2016/12/28 12:15 diesel

ProyectoMovilidad/logistica.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
2673KNZ Madrid 2025/11/20 2025/11/23
3+
2789DBC Madrid 2025/11/20 2025/11/23 18:00
4+
2789DBC Madrid 2025/11/20 2025/11/23 18:00

ProyectoMovilidad/movilidad.php

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<!doctype html>
2+
<html lang="es">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>Solicitud de permisos</title>
7+
<style>
8+
body {
9+
font-family: Arial;
10+
margin: 20px;
11+
}
12+
13+
label {
14+
display: block;
15+
margin: 10px 0 4px;
16+
}
17+
</style>
18+
</head>
19+
<body>
20+
<?php
21+
22+
// 1) Leemos tipoVehiculos.txt
23+
$tipos = []; //Aqui guardamos los tipos leidos del archivo que luego usaremos para el input
24+
25+
if (file_exists("tipoVehiculos.txt")) {
26+
$lineas = file("tipoVehiculos.txt");
27+
28+
foreach ($lineas as $l) {
29+
$tipos[] = trim($l); //Hay que trimear por los saltos de linea
30+
}
31+
} else {
32+
echo "<p style='color:red;'>No existe el archivo vehiculos.txt</p>";
33+
}
34+
35+
// 2) Mostrar formulario con tipo de permisos
36+
37+
$permisoElegido = $_POST["permiso"] ?? "";
38+
?>
39+
40+
<!-- FORMULARIO PRINCIPAL -->
41+
<div style="border: 2px solid #666; padding: 20px; width: 500px; border-radius: 8px; background-color: #f4f4f4;">
42+
<h1 style="color: #486fdb">Solicitud de permisos</h1>
43+
<form method="post" action="movilidad.php">
44+
45+
<!-- PRIMER BLOQUE: selector -->
46+
<label>Seleccione tipo de permiso:</label>
47+
<select name="permiso">
48+
<?php foreach ($tipos as $t) { ?>
49+
<option value="<?= $t ?>"><?= $t ?></option>
50+
<?php } ?>
51+
</select>
52+
<input type="submit" name="avanzar" value="Enviar">
53+
</form>
54+
</div>
55+
56+
<?php
57+
// 3) Si ya se eligió un tipo, mostrar el segundo formulario
58+
59+
if ($permisoElegido !== "") {
60+
echo "<div style='border: 2px solid #666; padding: 20px; width: 500px; border-radius: 8px; background-color: #f4f4f4;'>";
61+
echo "<h2 style='color:#486fdb'>Formulario para: " . $permisoElegido . "</h2>";
62+
63+
echo '<form method="post" action="registrarPermiso.php">';
64+
65+
// Formulario para todos los tipos menos logistica
66+
67+
echo '
68+
<input type="hidden" name="permiso" value="' . $permisoElegido . '">
69+
70+
<label>Matrícula:</label>
71+
<input type="text" name="matricula" required>
72+
73+
<label>Dirección / Zona:</label>
74+
<input type="text" name="direccion" required>
75+
76+
<label>Fecha inicio (AAAA/MM/DD):</label>
77+
<input type="text" name="inicio" required>
78+
79+
<label>Fecha fin (AAAA/MM/DD):</label>
80+
<input type="text" name="fin" required>
81+
82+
<input type="hidden" name="hora" value="">
83+
';
84+
85+
86+
// Campo adicional SOLO si el tipo es logística
87+
if ($permisoElegido === "Logistica") {
88+
89+
echo '
90+
<label>Hora (HH:MM):</label>
91+
<input type="text" name="hora" required>
92+
';
93+
"</div>";
94+
}
95+
96+
/*if ($permisoElegido === "ResidentesYHoteles") {
97+
98+
echo '
99+
<label>Hora (HH:MM):</label>
100+
<input type="text" name="hora" required>
101+
<label>Justificante de estadia (img,jpg,pdf):</label>
102+
<input type="file" name"justificante" value="justificante"><br>
103+
';
104+
}*/
105+
106+
echo '<br><br><input type="submit" name="enviar" value="Enviar">';
107+
echo '</form>';
108+
echo "</div>";
109+
}
110+
?>
111+
112+
</body>
113+
114+
</html>

0 commit comments

Comments
 (0)