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