-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModificarReserva.php
More file actions
632 lines (505 loc) · 25 KB
/
Copy pathModificarReserva.php
File metadata and controls
632 lines (505 loc) · 25 KB
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
<?php
session_start();
require_once 'funciones/corroborar_usuario.php';
Corroborar_Usuario();
include('head.php');
include('conn/conexion.php');
$conexion = ConexionBD();
// Primero se traen los datos de la reserva y de vehículos disponibles para mostrar en pantalla y permitir la selección
if (isset($_GET['id'])) {
$idReserva = $_GET['id'];
$reserva = array();
// Obtener los datos de la reserva (Se añade r.activo)
$ConsultaReservas = "SELECT r.idReserva,
r.numeroReserva as NumeroReserva,
r.fechaInicioReserva as FechaRetiro,
r.FechaFinReserva as FechaDevolucion,
r.precioPorDiaReserva as PrecioDiario,
r.idCliente as IDCliente,
r.idVehiculo as IDVehiculo,
r.idContrato as IDContrato,
r.activo as ActivoReserva, /* <--- CAMBIO: AÑADIDO CAMPO ACTIVO */
c.idCliente,
c.nombreCliente as NombreCliente,
c.apellidoCliente as ApellidoCliente,
c.nacionalidadCliente,
c.dniCliente as DocumentoCliente,
v.idVehiculo,
v.matricula as Matricula,
v.disponibilidad as Disponibilidad,
v.idModelo,
v.idGrupoVehiculo,
m.idModelo,
m.nombreModelo as Modelo,
m.descripcionModelo,
g.idGrupo,
g.nombreGrupo as Grupo,
g.descripcionGrupo
FROM `reservas-vehiculos` r, clientes c, vehiculos v, modelos m, `grupos-vehiculos` g
WHERE r.idReserva = $idReserva
AND r.idCliente = c.idCliente
AND r.idVehiculo = v.idVehiculo
AND v.idModelo = m.idModelo
AND v.idGrupoVehiculo = g.idGrupo; ";
$rs = mysqli_query($conexion, $ConsultaReservas);
$reserva = mysqli_fetch_array($rs);
// Determinar si la reserva está cancelada (0 = Cancelada)
$esCancelada = ($reserva['ActivoReserva'] == 0);
// Además se trae el contrato asociado a la reserva, en caso de existir, para corroborar si el estado es "En Preparación"
$estadoContrato = "";
if(!empty($reserva['IDContrato'])) {
$idContrato = $reserva['IDContrato'];
$contrato = array();
// Obtener los datos del contrato
$ConsultaContrato = "SELECT co.idContrato,
co.idEstadoContrato as IdEstadoContrato,
e.idEstadoContrato,
e.estadoContrato as EstadoContrato,
e.descripcionEstadoContrato as DescripcionEstado
FROM `contratos-alquiler` co, `estados-contratos` e
WHERE co.idContrato = $idContrato
AND e.idEstadoContrato = co.idEstadoContrato; ";
$rs = mysqli_query($conexion, $ConsultaContrato);
$contrato = mysqli_fetch_array($rs);
if ($contrato['EstadoContrato'] == "En Preparación") {
$estadoContrato = "En Preparación";
}
}
else {
$estadoContrato = "No existe";
}
// Se traen todos los vehículos disponibles para dropdown list:
$vehiculosDisponibles = array();
require_once 'funciones/Select_Tablas.php';
$vehiculosDisponibles = Listar_Vehiculos_Disponibles($conexion);
$cantidadVehiculos = count($vehiculosDisponibles);
// Necesitamos además traer el vehículo no disponible que ya fue reservado por el cliente, para incluirlo en el listado
// Verificar si el vehículo reservado ya está en el listado de disponibles
$vehiculoReservadoId = (int)$reserva['IDVehiculo'];
$estaIncluido = false;
foreach ($vehiculosDisponibles as $v) {
if ((int)$v['IdVehiculo'] === $vehiculoReservadoId) {
$estaIncluido = true;
break;
}
}
// Si no está incluido (porque está marcado como No disponible), lo traemos aparte
if (!$estaIncluido) {
$SQLvehiculoReservado = "SELECT v.idVehiculo as IdVehiculo,
v.matricula as matricula,
v.disponibilidad,
m.nombreModelo as modelo,
g.nombreGrupo as grupo
FROM vehiculos v
JOIN modelos m ON v.idModelo = m.idModelo
JOIN `grupos-vehiculos` g ON v.idGrupoVehiculo = g.idGrupo
WHERE v.idVehiculo = $vehiculoReservadoId";
$rsVehiculo = mysqli_query($conexion, $SQLvehiculoReservado);
if ($rsVehiculo && $data = mysqli_fetch_array($rsVehiculo)) {
// Agregar el vehículo reservado (no disponible) al listado de disponibles, es un append sobre el array previamente creado
$vehiculosDisponibles[] = [
'IdVehiculo' => $data['IdVehiculo'],
'matricula' => $data['matricula'],
'modelo' => $data['modelo'],
'grupo' => $data['grupo'],
'disponibilidad' => $data['disponibilidad']
];
$cantidadVehiculos++;
}
}
}
else {
// Si no se pasa un ID, se redirige al listado de reservas
header('Location: reservas.php');
exit();
}
// A continuación se hace UPDATE de los datos luego de cliquear el botón "Guardar Cambios" (los elementos POST proceden de este mismo archivo)
$mensajeError = "";
// -------------------------------------------------------------
// NUEVO: Lógica para REACTIVAR la Reserva (activo = 1)
// -------------------------------------------------------------
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['BotonReactivarReserva'])) {
// El ID de la reserva se pasa como campo oculto
$idReserva = $_POST['idReservaReactivar'];
$numreserva = $reserva['NumeroReserva'];
// Consulta para reactivar: activo=1 y limpiar el comentario de cancelación
$SQLupdate = "UPDATE `reservas-vehiculos`
SET activo = 1, comentario = NULL
WHERE idReserva = $idReserva";
$rs = mysqli_query($conexion, $SQLupdate);
if (!$rs) {
$mensajeError = "No se pudo acceder a la base de datos. Error al intentar reactivar la reserva.";
} else {
$mensajeError = "Reserva número " . trim($numreserva) . " reactivada exitosamente. Ahora está activa.";
// Redirigir para recargar la página con el nuevo estado
header("Location: ModificarReserva.php?id=$idReserva&mensaje=" . urlencode($mensajeError));
exit();
}
}
// -------------------------------------------------------------
// FIN: Lógica para REACTIVAR la Reserva
// -------------------------------------------------------------
if ($_SERVER['REQUEST_METHOD'] == 'POST' || !empty($_POST['BotonModificarReserva'])) {
$idCliente = $reserva['IDCliente'];
$numreserva = $reserva['NumeroReserva'];
$idVehiculo = $_POST['VehiculosDisponibles'];
$precioDiarioReserva = $_POST['PrecioPorDia'];
// Validaciones de fechas
$errores = [];
if (empty($_POST['FechaRetiro'])) {
$errores[] = "La fecha de retiro es obligatoria.";
}
if (empty($_POST['FechaDevolucion'])) {
$errores[] = "La fecha de devolución es obligatoria.";
}
if (!empty($_POST['FechaRetiro']) && !empty($_POST['FechaDevolucion'])) {
$fechaRetiro = new DateTime($_POST['FechaRetiro']);
$fechaDevolucion = new DateTime($_POST['FechaDevolucion']);
if ($fechaRetiro > $fechaDevolucion) {
$errores[] = "La fecha de retiro no puede ser posterior a la fecha de devolución.";
}
else {
// Validación de duración máxima de reserva (1 mes)
$intervalo = $fechaRetiro->diff($fechaDevolucion);
if ($intervalo->days > 30) {
$errores[] = "Las reservas no pueden superar 1 mes de duración.";
}
}
}
// Si hay errores, redirigir con el mensaje de error
if (!empty($errores)) {
$mensajeDeError = implode(' ', $errores);
// Redirigir con mensaje de error para que lo muestre el modal
header("Location: reservas.php?status=error&mensaje=" . urlencode($mensajeDeError));
exit();
}
// Se calcula cantidad de días de reserva
$fechaInicial = new DateTime($_POST['FechaRetiro']);
$fechaFinal = new DateTime($_POST['FechaDevolucion']);
// Calcular la diferencia de días
$intervalo = $fechaInicial->diff($fechaFinal);
$diferenciaDias = $intervalo->days; // Obtiene la cantidad de días exacta
// Se calcula monto total
$montoTotal = $precioDiarioReserva * $diferenciaDias;
// Se cambia formato de las fechas y se almacenan para el update:
$fechaEspanol = $_POST['FechaRetiro'];
$fechaEspanol = date_parse($fechaEspanol);
$year = $fechaEspanol['year'];
$mo = $fechaEspanol['month'];
$day = $fechaEspanol['day'];
$fechaIngles = "$year-$mo-$day";
$fecharetiro = $fechaIngles;
$fechaEspanol = $_POST['FechaDevolucion'];
$fechaEspanol = date_parse($fechaEspanol);
$year = $fechaEspanol['year'];
$mo = $fechaEspanol['month'];
$day = $fechaEspanol['day'];
$fechaIngles = "$year-$mo-$day";
$fechadevolucion = $fechaIngles;
require_once 'funciones/CRUD-Reservas.php';
if ($idVehiculo) {
// Actualizar los datos de la reserva
$ModificacionReserva = "UPDATE `reservas-vehiculos`
SET fechaReserva = NOW(),
fechaInicioReserva = '$fecharetiro',
FechaFinReserva = '$fechadevolucion',
precioPorDiaReserva = '$precioDiarioReserva',
cantidadDiasReserva = '$diferenciaDias',
totalReserva = '$montoTotal',
idCliente = $idCliente,
idVehiculo = $idVehiculo
WHERE idReserva = ?";
$stmt = $conexion->prepare($ModificacionReserva);
if (!$stmt) {
$mensajeError = "Error al preparar la consulta: " . $conexion->error;
header("Location: reservas.php?status=error&mensaje=" . urlencode($mensajeError));
exit();
}
$stmt->bind_param("i", $idReserva);
$rs = $stmt->execute();
if (!$rs) {
$mensajeError = "No se pudo acceder a la base de datos. Error al intentar modificar la reserva";
//si surge un error, finalizo la ejecucion del script con un mensaje
header("Location: reservas.php?status=error&mensaje=" . urlencode($mensajeError) . "&NumeroReserva=" . urlencode($idReserva));
$stmt->close();
exit();
}
else {
// Redirigir después de la actualización
$mensajeExito = "Reserva modificada exitosamente.";
// Redirigir con mensaje de éxito para que lo muestre el modal
header("Location: reservas.php?status=success&mensaje=" . urlencode($mensajeExito) . "&NumeroReserva=" . urlencode($idReserva));
$stmt->close();
exit();
}
}
else {
$mensajeError = "No se puede realizar la reserva.";
}
}
// -------------------------------------------------------------
// Lógica para deshabilitar campos y botones:
// -------------------------------------------------------------
// Determinar la condición general de deshabilitación de campos
$isDisabledGeneral = false;
// 1. Contrato firmado (lógica existente)
$contratoFirmado = ($estadoContrato != "En Preparación" && $estadoContrato != "No existe");
// 2. Si el contrato está firmado O si la reserva está cancelada, deshabilitar
if ($contratoFirmado || $esCancelada) {
$isDisabledGeneral = true;
}
$disabledAttr = $isDisabledGeneral ? 'disabled' : '';
?>
<body class="bg-light" style="margin: 0 auto;">
<div class="wrapper" style="margin-bottom: 100px; min-height: 100%;">
<?php
include('sidebarGOp.php');
include('topNavBar.php');
?>
<div class="p-5 mb-4 bg-white shadow-sm"
style="margin-top: 150px; margin-bottom: 100px; margin-left: 1%; max-width: 98%; border: 1px solid #444444; border-radius: 14px;">
<?php
if ($mensajeError) { ?>
<div class="alert alert-danger mt-3">
<?php
echo "Error al intentar modificar el vehículo. <br><br>";
echo $mensajeError;
?>
</div>
<?php }
if (isset($_GET['mensaje'])) { ?>
<div class="alert alert-success mt-3">
<?php
echo htmlspecialchars($_GET['mensaje']);
?>
</div>
<?php }
?>
<h5 class="mb-4 text-secondary"><strong>Modificar Reserva</strong></h5>
<?php
$alerta = "success";
$mensajeAlerta = "";
if ($esCancelada) {
$alerta = "danger";
$mensajeAlerta = "Esta reserva figura como CANCELADA. Para realizar modificaciones, primero debe reactivarla.";
} elseif ($contratoFirmado) {
$alerta = "danger";
$mensajeAlerta = "El contrato ya fue firmado o cancelado. Los campos están deshabilitados.";
} else {
$alerta = "success";
$mensajeAlerta = "Todos los campos son obligatorios para la modificación.";
}
?>
<div class="alert alert-<?php echo $alerta; ?> mt-5">
<br>
<h6 class='mb-4 text-secondary'><?php echo $mensajeAlerta; ?></h6>
</div><br><br>
<form method="POST" onsubmit="return validarFechasModificacion()">
<input type="hidden" name="idReservaReactivar" value="<?php echo $idReserva; ?>">
<div class="mb-3">
<label for="nombre" class="form-label">Nombre</label>
<input type="text" class="form-control" id="nombre" name="NombreCliente"
value="<?php echo htmlspecialchars(trim($reserva['NombreCliente'])); ?> " disabled>
</div>
<div class="mb-3">
<label for="apellido" class="form-label">Apellido</label>
<input type="text" class="form-control" id="apellido" name="ApellidoCliente"
value="<?php echo htmlspecialchars(trim($reserva['ApellidoCliente'])); ?>" disabled>
</div>
<div class="mb-3">
<label for="documento" class="form-label">Documento</label>
<input type="text" class="form-control" id="documento" name="DocumentoCliente"
value="<?php echo htmlspecialchars(trim($reserva['DocumentoCliente'])); ?> " disabled>
</div>
<div class="mb-3">
<label for="numero" class="form-label">Número de Reserva</label>
<input type="text" class="form-control" id="numero" name="NumeroReserva"
value="<?php echo htmlspecialchars(trim($idReserva)); ?> " disabled>
</div>
<div class="mb-3">
<label for="vehiculosdisponibles" class="form-label"> Vehículos disponibles </label>
<select class="form-select" aria-label="Selector" id="vehiculosdisponibles"
name="VehiculosDisponibles" <?php echo $disabledAttr; ?>
<?php if (!$isDisabledGeneral) { echo "required"; } ?>
onchange="obtenerPrecioSugeridoModificacion()">
<option value="" selected>Selecciona una opción</option>
<?php
if (!empty($vehiculosDisponibles)) {
$selected = '';
for ($i = 0; $i < $cantidadVehiculos; $i++) {
// Lógica para verificar si el grupo debe estar seleccionado
$selected = (!empty($reserva['IDVehiculo']) && $reserva['IDVehiculo'] == $vehiculosDisponibles[$i]['IdVehiculo']) ? 'selected' : '';
echo "<option value='{$vehiculosDisponibles[$i]['IdVehiculo']}' $selected >
MATRÍCULA: {$vehiculosDisponibles[$i]['matricula']} - {$vehiculosDisponibles[$i]['modelo']}, {$vehiculosDisponibles[$i]['grupo']}
</option>";
}
}
else {
echo "<option value=''> En este momento no existen vehículos disponibles. </option>";
}
?>
</select>
</div>
<div class="mb-3">
<label for="fecharetiro" class="form-label">Fecha de Retiro</label>
<input type="date" class="form-control" id="fecharetiro" name="FechaRetiro"
value="<?php echo htmlspecialchars($reserva['FechaRetiro']); ?>" <?php echo $disabledAttr; ?>
<?php if (!$isDisabledGeneral) { echo "required"; } ?>>
</div>
<div class="mb-3">
<label for="fechadevolucion" class="form-label">Fecha de Devolución</label>
<input type="date" class="form-control" id="fechadevolucion" name="FechaDevolucion"
value="<?php echo htmlspecialchars($reserva['FechaDevolucion']); ?>"
<?php echo $disabledAttr; ?> <?php if (!$isDisabledGeneral) { echo "required"; } ?>>
</div>
<div class="mb-3 col-md-4">
<label for="inputPrecioPorDiaMod" class="form-label">Precio por Día</label>
<input type="number" min="20" max="1000" step="0.01" class="form-control" id="inputPrecioPorDiaMod"
name="PrecioPorDia" value="<?php echo $reserva['PrecioDiario']; ?>" required
oninput="calcularTotalReservaModificacion()">
</div>
<div class="mb-3 col-md-4">
<label for="inputTotalReservaMod" class="form-label">Monto Total</label>
<input type="number" class="form-control" id="inputTotalReservaMod" name="MontoTotal" readonly
placeholder="Calculado Automáticamente">
</div>
<div class="d-flex justify-content-start gap-2 mt-5">
<?php if (!$esCancelada): ?>
<button type="submit" class="btn btn-primary" name="BotonModificarReserva"
value="modificandoReserva" <?php echo $disabledAttr; ?>>
Guardar Cambios
</button>
<?php else: ?>
<button type="submit" class="btn btn-success" name="BotonReactivarReserva"
value="reactivandoReserva">
Reactivar Reserva
</button>
<?php endif; ?>
<a href="reservas.php" class="btn btn-secondary">Volver</a>
</div>
</form>
</div>
<div style="margin-top: 100px;">
<?php require_once "foot.php"; ?>
</div>
</div>
<script>
const MAX_DAYS = 30;
function validarFechasModificacion() {
const fechaRetiroInput = document.getElementById('fecharetiro');
const fechaDevolucionInput = document.getElementById('fechadevolucion');
if (!fechaRetiroInput.value || !fechaDevolucionInput.value) {
alert('Ambas fechas son obligatorias.');
return false;
}
const fechaRetiro = new Date(fechaRetiroInput.value);
const fechaDevolucion = new Date(fechaDevolucionInput.value);
if (fechaDevolucion <= fechaRetiro) {
alert('La fecha de devolución debe ser posterior a la fecha de retiro.');
return false;
}
const diffTime = Math.abs(fechaDevolucion - fechaRetiro);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
if (diffDays > MAX_DAYS) {
alert(`La duración máxima de la reserva es de ${MAX_DAYS} días. Su selección es de ${diffDays} días.`);
return false;
}
return true; // Envía el formulario si todo es correcto
}
document.addEventListener('DOMContentLoaded', () => {
const fechaRetiroInput = document.getElementById('fecharetiro');
const fechaDevolucionInput = document.getElementById('fechadevolucion');
if (fechaRetiroInput && fechaDevolucionInput) {
fechaRetiroInput.addEventListener('change', () => {
fechaDevolucionInput.min = fechaRetiroInput.value;
});
}
});
function diferenciaEnDias(fecha1, fecha2) {
const date1 = new Date(fecha1);
const date2 = new Date(fecha2);
if (isNaN(date1.getTime()) || isNaN(date2.getTime()) || date2 < date1) {
return 0;
}
const diffTime = Math.abs(date2 - date1);
const diffDays = Math.round(diffTime / (1000 * 60 * 60 * 24));
return diffDays;
}
/**
* 1. Calcula el monto total de la reserva: Precio * Días.
*/
function calcularTotalReservaModificacion() {
// IDs de los campos en el formulario de ModificarReserva.php
const inputPrecio = document.getElementById('inputPrecioPorDiaMod');
const inputRetiro = document.getElementById('fecharetiro');
const inputDevolucion = document.getElementById('fechadevolucion');
const inputTotal = document.getElementById('inputTotalReservaMod');
if (!inputPrecio || !inputRetiro || !inputDevolucion || !inputTotal) {
return;
}
const precio = parseFloat(inputPrecio.value);
const fechaRetiro = inputRetiro.value;
const fechaDevolucion = inputDevolucion.value;
if (isNaN(precio) || precio <= 0 || !fechaRetiro || !fechaDevolucion) {
inputTotal.value = '0.00';
return;
}
const dias = diferenciaEnDias(fechaRetiro, fechaDevolucion);
if (dias > 0) {
const total = precio * dias;
inputTotal.value = total.toFixed(2);
} else {
inputTotal.value = '0.00';
}
}
/**
* 2. Obtiene el precio sugerido por AJAX al cambiar el vehículo.
*/
function obtenerPrecioSugeridoModificacion() {
const selectVehiculo = document.getElementById('vehiculosdisponibles');
const inputPrecio = document.getElementById('inputPrecioPorDiaMod');
const idVehiculo = selectVehiculo.value;
if (!idVehiculo || idVehiculo === "") {
inputPrecio.value = '';
calcularTotalReservaModificacion();
return;
}
// Lógica AJAX (reutilizando obtener_precio_grupo.php)
const formData = new FormData();
formData.append('idVehiculo', idVehiculo);
fetch('obtener_precio_grupo.php', {
method: 'POST',
body: formData
})
.then(response => {
if (!response.ok) {
throw new Error('Error de red al obtener el precio: ' + response.statusText);
}
return response.json();
})
.then(data => {
if (data.success) {
inputPrecio.value = parseFloat(data.precio).toFixed(2);
} else {
console.error('Error del servidor:', data.message);
inputPrecio.value = '';
}
calcularTotalReservaModificacion();
})
.catch(error => {
console.error('Error de la solicitud AJAX:', error);
inputPrecio.value = '';
alert('Ocurrió un error al obtener el precio sugerido para la modificación.');
calcularTotalReservaModificacion();
});
}
// ===================================================================
// INICIALIZACIÓN Y FUNCIONES ORIGINALES
// ===================================================================
// Inicializa el cálculo del total con los datos de la reserva actual al cargar la página
document.addEventListener('DOMContentLoaded', function() {
setTimeout(calcularTotalReservaModificacion, 100);
});
</script>
</body>
</html>