-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
384 lines (342 loc) · 17.9 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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>Untitled</title>
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Oswald:400,700&display=swap">
<link rel="stylesheet" href="assets/fonts/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<link rel="stylesheet" href="assets/css/styles.min.css">
<link rel="stylesheet" href="assets/css/Login-Animate.css">
<link rel="stylesheet" href="assets/css/advertencia.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
</head>
<body style="margin-right: 20px;margin-left: 20px;border-color: var(--bs-red);">
<div class="bounce animated" style="min-height: 20px;max-height: 400px;background: var(--bs-gray-400);margin-top: 50px;margin-right: 20%;margin-left: 20%;min-width: 250px;border-radius: 5px;border-color: var(--bs-blue);border-bottom-color: var(--bs-gray-500);">
<h1 style="text-align: center;font-family: Oswald, sans-serif;font-size: 50px;margin-top: 0px;">Reservas de Laboratorios-EICT</h1>
</div>
<div class="text-start" style="background: var(--bs-gray-400);transform: perspective(0px) skew(0deg);"><button class="btn btn-primary d-xl-flex align-items-xl-center pull-left" style="text-align: justify;" onclick="toggleDiv()"><i class="fa fa-address-card"></i> Agregar</button> <button id="pasadosbtn" class="btn btn-primary pull-right" type="button" style="background: var(--bs-teal);border-color: var(--bs-teal);" onclick="cambiarEstado()"><i class="fa fa-hourglass-end"></i> Pasados</button>
<div class="col-md-12 search-table-col" style="border-color: rgba(37,71,106,0.56);text-align: left;background: var(--bs-white);margin-top: 50px; "><span class="counter pull-right"></span>
<div class="table-responsive table table-hover table-bordered results">
<table class="table table-hover table-bordered; margin-bottom: 0px;" id="miTabla">
<thead class="bill-header cs">
<tr>
<th id="trs-hd-1" class="col-lg-1">ID</th>
<th id="trs-hd-2" class="col-lg-2">Nombre</th>
<th id="trs-hd-3" class="col-lg-3">Laboratorio</th>
<th id="trs-hd-4" class="col-lg-2">Fecha y hora</th>
<th id="trs-hd-6" class="col-lg-2">Accion</th>
</tr>
</thead>
<tbody>
<tr class="warning no-result">
<td colspan="12"><i class="fa fa-warning"></i> No Result !!!</td>
</tr>
<!-- <tr style="text-align: center;">
<td style="text-align: left;">1014-0933</td>
<td>India</td>
<td>ITT-202</td>
<td>11/07/2023 10:00-12:00</td>
<td style="text-align: center;"><button class="btn btn-success" style="margin-left: 5px;padding: 3px 6px;" type="submit"><i class="fa fa-check" style="font-size: 15px;"></i></button><button class="btn btn-danger" style="margin-left: 5px;padding: 3px 6px;" type="submit"><i class="fa fa-trash" style="font-size: 15px;"></i></button></td>
</tr> -->
</tbody>
</table>
</div>
</div>
</div>
<div id="filtro" style="width: 390px; display: flex; justify-content: space-between;float: right; flex-direction: row; display: none; ">
<div style="width: 150px;">
<input type="text" class="form-control" id="fechaFil1" name="fechaHora" placeholder="Desde" style="background-color: rgb(255, 255, 255);">
</div>
<div style="width: 150px;">
<input type="text" class="form-control" id="fechaFil2" name="fechaHora" placeholder="Hasta" style="background-color: rgb(255, 255, 255);">
</div>
<button id="filtrobtn" class="btn btn-primary" onclick="filtrar()" >Ordenar</button>
</div>
<div id="miDiv" style=" position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color: rgba(96, 119, 124, 0.384); z-index: 1; display: none;">
<div data-aos="fade-down" data-aos-duration="1000" data-aos-delay="100" data-aos-once="true" class="login-card" style="font-family: Roboto, sans-serif;margin-top: 10%;text-align: justify;height: 450px; ">
<p class="profile-name-card"> <i class="fa fa-calendar-plus-o d-inline" style="width:0;height:0;font-size:56px;color:rgb(104,145,162);"></i></p>
<form class="form-signin"><span class="reauth-email" style="margin:11px;"> </span>
<input class="form-control" type="number" id="idsend" required="" placeholder="ID" autofocus="">
<input class="form-control" type="text" id="nombresend" required="" placeholder="Nombre" autofocus="">
<input class="form-control" type="text" id="carrerasend" required="" placeholder="Carrera">
<select id="frutas" class="form-control" name="frutas">
</select>
<input type="text" class="form-control" id="fechaHora" name="fechaHora" placeholder="Selecciona fecha y hora" style="background-color: rgb(255, 255, 255);">
</form>
<button class="btn btn-primary pull-left" type="button" style="margin-right: 0px;background: #9f000f;border-style: none;margin-top: 10px;" onclick="toggleDiv()"><i class="fa fa-times"></i>Cancel</button>
<button class="btn btn-primary pull-right" type="button" style="margin-bottom: 0px;background: rgb(1, 192, 160);border-style: none;border-color: var(--orange);margin-top: 10px;" onclick="enviarData()"><i class="fa fa-arrow-down"></i>Add</button>
</div>
</div>
<div class="advertencia" id="advertencia">
<h2>¡Advertencia!</h2>
<p>Laboratorio lleno</p>
</div>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/script.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script>
var final_url ='https://zpy2p91du7.execute-api.us-east-1.amazonaws.com/default/prueba';
var actuales = 0;
var ordenar = 0;
function filtrar(){
var btn = document.getElementById("filtrobtn");
var fechaFil1 = document.getElementById("fechaFil1");
var fechaFil2 = document.getElementById("fechaFil2");
if( ordenar === 0){
if((fechaFil1.value !== "" && fechaFil2.value !== "") ){
btn.style.background = "orange";
btn.innerHTML = `Cancelar`;
enviarFiltro();
ordenar = 1;
}
}else{
btn.style.background = "rgb(13,110,253)";
btn.innerHTML = `Ordenar`;
fechaFil1.value = "";
fechaFil2.value = "";
cargarDatosOld();
ordenar = 0;
}
}
function enviarFiltro(){
var fechaFil1 = document.getElementById("fechaFil1");
var fechaFil2 = document.getElementById("fechaFil2");
var formData = $.param({
"Desde": fechaFil1.value,
"Hasta": fechaFil2.value,
});
url_last = final_url+'?'+formData;
$.ajax({
type: "PUT",
url: url_last,
data: formData,
success: function (data) {
$('#miTabla tbody').empty();
$.each(data.data, function(index, item) {
$('#miTabla tbody').append('<tr><td>' + item.idEstudiante + '</td><td>' + item.nombre + '</td>'+'</td><td>' + item.fecha + '</td>'+'</td><td>' + item.laboratorio.nombre + '</td>'+'<td style="text-align: center;"><button class="btn btn-danger" style="margin-left: 5px;padding: 3px 6px;" type="submit"><i class="fa fa-trash" style="font-size: 15px;"></i><a> Delete</a></button></td>'+'</tr>');
});
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
}
});
}
function cambiarEstado(){
var btn = document.getElementById("pasadosbtn");
var filtrobtn = document.getElementById("filtro");
if( actuales === 0){
btn.style.background = "blue";
btn.innerHTML = `<i class="fa fa-hourglass-end"></i> Actuales`;
cargarDatosOld();
setTimeout(function() {
filtrobtn.style.display = "inline-flex";
}, 1200);
actuales = 1;
}else{
btn.style.background = " var(--bs-teal)";
btn.innerHTML = `<i class="fa fa-hourglass-end"></i> Pasados`;
filtrobtn.classList.remove("mostrar");
setTimeout(function() {
filtrobtn.style.display = "none";
}, 1200);
cargarDatos();
actuales = 0;
}
}
flatpickr("#fechaHora", {
enableTime: true,
dateFormat: "H:i d/m/Y",
time_24hr: true,
minuteIncrement: 60,
minDate: "today",
onChange: function(selectedDates, dateStr, instance) {
const selectedDate = selectedDates[0];
const minHour = 8;
const maxHour = 21;
if (selectedDate.getHours() < minHour) {
instance.setDate(new Date(selectedDate.setHours(minHour, 0, 0, 0)));
}
if (selectedDate.getHours() > maxHour) {
instance.setDate(new Date(selectedDate.setHours(maxHour, 0, 0, 0)));
}
}
});
flatpickr("#fechaFil1",{
enableTime: true,
dateFormat: "H:i d/m/Y",
time_24hr: true,
minuteIncrement: 60,
//minDate: "today",
maxDate: "today",
onChange: function(selectedDates, dateStr, instance) {
const selectedDate = selectedDates[0];
const minHour = 8;
const maxHour = 21;
if (selectedDate.getHours() < minHour) {
instance.setDate(new Date(selectedDate.setHours(minHour, 0, 0, 0)));
}
if (selectedDate.getHours() > maxHour) {
instance.setDate(new Date(selectedDate.setHours(maxHour, 0, 0, 0)));
}
}
});
flatpickr("#fechaFil2 ",{
enableTime: true,
dateFormat: "H:i d/m/Y",
time_24hr: true,
minuteIncrement: 60,
//minDate: "today",
maxDate: "today",
onChange: function(selectedDates, dateStr, instance) {
const selectedDate = selectedDates[0];
const minHour = 8;
const maxHour = 21;
if (selectedDate.getHours() < minHour) {
instance.setDate(new Date(selectedDate.setHours(minHour, 0, 0, 0)));
}
if (selectedDate.getHours() > maxHour) {
instance.setDate(new Date(selectedDate.setHours(maxHour, 0, 0, 0)));
}
}
});
function enviarData(){
console.log("Enviando");
var id = document.getElementById("idsend").value;
var nombre = document.getElementById("nombresend").value;
var carrera = document.getElementById("carrerasend").value;
var laboratorio = document.getElementById("frutas").value;
var fecha = document.getElementById("fechaHora").value;
var queryParams = $.param({
"IdEstudiante": id,
"NombreEstudiante": nombre,
"Carrera": carrera,
"Laboratorio": laboratorio,
"Fecha": fecha
});
url_last = final_url+'?'+queryParams;
function toggleAdvertencia() {
var advertencia = document.getElementById("advertencia");
advertencia.style.display = "block";
advertencia.classList.toggle("mostrar");
if (advertencia.classList.contains("mostrar")) {
setTimeout(function() {
//advertencia.style.display = "none";
advertencia.classList.remove("mostrar");
}, 1500);
}
setTimeout(function() {
advertencia.style.display = "none";
}, 2000);
//advertencia.style.display = "none";
}
$.ajax({
type: "POST",
url: url_last,
success: function (response) {
//console.log(response);
if(response.data === 0){
toggleDiv();
cargarDatos();
}else if(response.data === 1){
toggleAdvertencia();
}
console.log(response);
},
error: function (error) {
// Manejar errores (si es necesario)
console.error(error);
}
});
}
function toggleDiv() {
var miDiv = document.getElementById("miDiv");
if (miDiv.style.display === "none") {
miDiv.style.display = "block";
$.ajax({
url: final_url,
type: 'DELETE',
crossDomain: true,
dataType: 'json',
success: function (data) {
console.log(data);
$('#frutas').empty();
$.each(data.data, function(index, item) {
$('#frutas').append('<option>'+item.nombre+'</option>');
});
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
}
});
} else {
miDiv.style.display = "none";
}
}
function cargarDatos() {
document.body.style.cursor = 'wait';
document.body.classList.add('loading');
console.log("Cargando...");
$.ajax({
url: final_url,
type: 'GET',
crossDomain: true,
dataType: 'json',
success: function (data) {
console.log(data);
$('#miTabla tbody').empty();
$.each(data.data, function(index, item) {
$('#miTabla tbody').append('<tr><td style="text-align: center;">' + item.IdEstudiante + '</td><td style="text-align: center;">' + item.nombre + '</td>'+'</td><td style="text-align: center;">' + item.laboratorio.nombre + '</td>'+'</td><td style="text-align: center;">' + item.fecha + '</td>'+'<td style="text-align: center;"><button class="btn btn-danger" style="margin-left: 5px;padding: 3px 6px;" type="submit"><i class="fa fa-trash" style="font-size: 15px;"></i><a> Delete</a></button></td>'+'</tr>');
});
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
}
});
document.body.style.cursor = 'default';
document.body.classList.remove('loading');
}
function cargarDatosOld() {
document.body.style.cursor = 'wait';
document.body.classList.add('loading');
console.log("Cargando...");
$.ajax({
url: final_url,
type: 'PATCH',
crossDomain: true,
dataType: 'json',
success: function (data) {
console.log(data);
$('#miTabla tbody').empty();
$.each(data.data, function(index, item) {
$('#miTabla tbody').append('<tr><td style="text-align: center;">' + item.IdEstudiante + '</td><td style="text-align: center;">' + item.nombre + '</td>'+'</td><td style="text-align: center;">' + item.laboratorio.nombre + '</td>'+'</td><td style="text-align: center;">' + item.fecha + '</td>'+'<td style="text-align: center;"><button class="btn btn-danger" style="margin-left: 5px;padding: 3px 6px;" type="submit"><i class="fa fa-trash" style="font-size: 15px;"></i><a> Delete</a></button></td>'+'</tr>');
});
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
}
});
document.body.style.cursor = 'default';
document.body.classList.remove('loading');
}
function cargandoMientras(){
if(actuales === 0){
console.log("nuevos");
cargarDatos();
}else{
if(ordenar === 0 ){
console.log("viejos");
cargarDatosOld();
}
}
}
$(document).ready(function() {
cargarDatos();
setInterval(cargandoMientras, 60000);
});
</script>
</body>
</html>