-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasdadsad.html
196 lines (163 loc) · 9.17 KB
/
asdadsad.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<a href="{{ url_for('home') }}" class="btn btn-primary m-3">Inicio</a>
<h1 class="text-center mt-5 mb-5 text-primary">Gestión de viviendas</h1>
<div class="container">
<div class="card shadow">
<div class="card-body">
<form action="/vivienda_add" method="POST">
<div class="row mb-3">
<div class="col">
<label>Dirección</label>
<input type="text" class="form-control mb-3" name="direccion">
</div>
<div class="col">
<label>Municipio</label>
<input type="text" class="form-control mb-3" name="Municipio_name" id="input_municipio">
<input type="text" style="display: none;" name="Municipio" id="input_municipio_id">
<button type="button" class="btn btn-primary" onclick="abrirModal()">Seleccionar
municipio</button>
</div>
<div class="col">
<label for="">Capacidad</label>
<input type="number" class="form-control mb-3" name="capacidad">
</div>
<div class="col">
<label>Niveles</label>
<input type="number" class="form-control mb-3" name="niveles">
</div>
<div class="col">
<button class="btn btn-primary mb-3 mt-4" type="submit">Guardar</button>
</div>
</div>
</form>
<!-- Modal -->
<div id="modal_municipio" class="modal fade">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Seleccione el municipio</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Cerrar">
<span aria-hidden="true"></span>
</button>
</div>
<div class="modal-body">
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Municipio</th>
<th scope="col">seleccionar</th>
</tr>
</thead>
<tbody>
{% for municipio in list_municipios %}
<tr>
<td>{{municipio.id}}</td>
<td>{{municipio.nombre}}</td>
<td><button type="button" class="btn btn-primary"
onclick="selectMunicipio('{{municipio.id}}',' {{municipio.nombre}}')">Seleccionar</button>
</td>
</tr>
{% endfor %}
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Tabla -->
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Dirección</th>
<th scope="col">Municipio</th>
<th scope="col">Capacidad</th>
<th scope="col">Niveles</th>
<th scope="col">Editar</th>
<th scope="col">Borrar</th>
</tr>
</thead>
<tbody>
{% for d in data %}
<tr>
<td>{{d.id}}</td>
<td>{{d.direccion}}</td>
<td>{{d.id_municipio}}</td>
<td>{{d.capacidad}}</td>
<td>{{d.niveles}}</td>
<td><button class="btn btn-primary btn-sm" id="btn-edit{{d.id}}" data-bs-toggle="modal"
data-bs-target="#modal{{d.id}}">Editar</button></td>
<td><a href="{{url_for('vivienda_delete', id=d.id)}}"
class="btn btn-danger btn-sm">Borrar</a></td>
</tr>
<!-- modal -->
<div class="modal fade" id="modal{{d.id}}" tabindex="-1" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Vivienda de la dirección:
{{d.direccion}}</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
<div class="modal-body">
<form action="/vivienda_edit/{{d.id}}" method="post">
<label for="id">id</label>
<input type="number" class="form-control mb-3" name="id" value="{{d.id}}"
readonly>
<label for="direccion">Dirección</label>
<input type="text" class="form-control mb-3" name="direccion"
value="{{d.direccion}}">
<label for="municipio">Municipio</label>
<input type="number" class="form-control mb-3" name="id_municipio"
value="{{d.id_municipio}}">
<label for="capacidad">Capacidad</label>
<input type="number" class="form-control mb-3" name="capacidad"
value="{{d.capacidad}}">
<label for="niveles">Niveles</label>
<input type="number" class="form-control mb-3" name="niveles"
value="{{d.niveles}}">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Guardar cambios</button>
</div>
</form>
</div>
</div>
</div>
{% endfor %}
</tbody>
</table>
<!-- Agregar Bootstrap JS y jQuery (Requeridos por Bootstrap) -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
function abrirModal() {
$('#modal_municipio').modal('show');
}
function selectMunicipio(id, municipio) {
$('#input_municipio_id').val(id);
$('#input_municipio').val(municipio);
cerrarModal();
}
function cerrarModal() {
$('#modal_municipio').modal('hide');
}
</script>
</body>
</html>