-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
79 lines (75 loc) · 3.1 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Consulta Beneficios</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
<div class="container mt-5">
<h1 class="text-center">Consulta de Beneficios</h1>
<form id="consulta-form" class="my-4">
<div class="mb-3">
<label for="cedula" class="form-label">Cédula</label>
<input type="text" class="form-control" id="cedula" required>
</div>
<div class="mb-3">
<label for="fecha_inicio" class="form-label">Fecha Inicio</label>
<input type="date" class="form-control" id="fecha_inicio" required>
</div>
<div class="mb-3">
<label for="fecha_fin" class="form-label">Fecha Fin</label>
<input type="date" class="form-control" id="fecha_fin" required>
</div>
<button type="submit" class="btn btn-primary">Consultar</button>
</form>
<table class="table table-striped">
<thead>
<tr>
<th>Cédula</th>
<th>Nombre</th>
<th>Código Desc.</th>
<th>Valor</th>
<th>Fecha Liquidación</th>
<th>Descuento</th>
<th>Número</th>
<th>Tipo</th>
<th>Código E</th>
<th>Sección</th>
</tr>
</thead>
<tbody id="resultados">
</tbody>
</table>
</div>
<script>
document.getElementById('consulta-form').addEventListener('submit', function (e) {
e.preventDefault();
const cedula = document.getElementById('cedula').value;
const fecha_inicio = document.getElementById('fecha_inicio').value;
const fecha_fin = document.getElementById('fecha_fin').value;
axios.get('http://localhost:5000/consulta', {
params: { cedula, fecha_inicio, fecha_fin }
}).then(response => {
const resultados = response.data;
const tbody = document.getElementById('resultados');
tbody.innerHTML = '';
resultados.forEach(row => {
const tr = document.createElement('tr');
for (const key in row) {
const td = document.createElement('td');
td.textContent = row[key];
tr.appendChild(td);
}
tbody.appendChild(tr);
});
}).catch(error => {
console.error(error);
alert('Error al realizar la consulta.');
});
});
</script>
</body>
</html>