-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevolucionVehiculo.php
More file actions
782 lines (659 loc) · 38.5 KB
/
Copy pathdevolucionVehiculo.php
File metadata and controls
782 lines (659 loc) · 38.5 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
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
<?php
session_start();
require_once 'funciones/corroborar_usuario.php';
Corroborar_Usuario();
require_once "conn/conexion.php";
$conexion = ConexionBD();
// Obtener filtros del formulario
$filtros = [
'numero' => isset($_GET['NumeroContrato']) ? trim($_GET['NumeroContrato']) : '',
'matricula' => isset($_GET['MatriculaContrato']) ? trim($_GET['MatriculaContrato']) : '',
'apellido' => isset($_GET['ApellidoContrato']) ? trim($_GET['ApellidoContrato']) : '',
'nombre' => isset($_GET['NombreContrato']) ? trim($_GET['NombreContrato']) : '',
'documento' => isset($_GET['DocContrato']) ? trim($_GET['DocContrato']) : '',
'devoluciondesde' => isset($_GET['DevolucionDesde']) ? trim($_GET['DevolucionDesde']) : '',
'devolucionhasta' => isset($_GET['DevolucionHasta']) ? trim($_GET['DevolucionHasta']) : '',
];
// Generación del listado de Devolucion
require_once 'funciones/CRUD-Devolucion.php';
$ListadoDevolucion = Listar_Devolucion($conexion);
$CantidadDevolucion = count($ListadoDevolucion);
// Consulta por medio de formulario de Filtro
if (!empty($_GET['BotonFiltrar'])) {
// require_once 'funciones/vehiculo consulta.php';
Procesar_ConsultaDevolucion();
$ListadoDevolucion = array();
$CantidadDevolucion = '';
$ListadoDevolucion = Consulta_Devolucion($_GET['NumeroContrato'], $_GET['MatriculaContrato'], $_GET['ApellidoContrato'], $_GET['NombreContrato'], $_GET['DocContrato'], $_GET['DevolucionDesde'], $_GET['DevolucionHasta'], $conexion);
$CantidadDevolucion = count($ListadoDevolucion);
} else {
// Listo la totalidad de los registros en la tabla "Devolucion".
$ListadoDevolucion = Listar_Devolucion($conexion);
$CantidadDevolucion = count($ListadoDevolucion);
}
if (!empty($_GET['BotonLimpiarFiltros'])) {
header('Location: devolucionVehiculo.php');
die();
}
// SELECCIONES para combo boxes del modal para registrar "Nueva Devolucion"
require_once 'funciones/Select_Tablas.php';
$ListadoContratos = ListarContratos_ActivosRenovados($conexion);
$CantidadContratos = count($ListadoContratos);
// SELECCIONES para combo boxes del modal para generar reporte "Devolucion de vehículos según cliente"
require_once 'funciones/Select_Tablas.php';
$ListadoClientes = Listar_Clientes_AtoZ($conexion);
$CantidadClientes = count($ListadoClientes);
include('head.php');
?>
<body style="margin: 0 auto;">
<style>
.form-control:focus {
border-color: rgb(14, 94, 199);
}
</style>
<div class="wrapper" style="margin-bottom: 100px; min-height: 100%;">
<?php
include('sidebarGOp.php');
$tituloPagina = "DEVOLUCIONES DE VEHÍCULOS";
include('topNavBar.php');
if (isset($_GET['mensaje'])) {
echo '<div class="alert alert-info" role="alert">' . $_GET['mensaje'] . '</div>';
}
?>
<div class="container" style="margin-top: 10%; margin-left: 1%; margin-right: 1%;">
<!-- Algunos efectos moderno para el form de consultas ;) -->
<style>
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.filtro-consultas {
transition: all 0.4s ease-in-out;
border-radius: 15px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.3);
animation: fadeInUp 0.8s ease-in-out;
/* Hace que el cuadro "aparezca suavemente" */
}
.filtro-consultas:hover {
transform: translateY(-5px);
box-shadow: 0px 10px 20px rgba(198, 167, 31, 0.5);
}
.form-control {
transition: all 0.3s ease-in-out;
border: 1px solid;
}
.form-control:focus {
border: 2px solid rgb(160, 4, 4);
/* Resalta con dorado */
box-shadow: rgba(152, 10, 10, 0.81);
}
.btn-filtrar {
transition: transform 0.3s ease-in-out;
}
.btn-filtrar:hover {
transform: scale(1.1);
/* Botón se agranda ligeramente */
}
</style>
<div class="filtro-consultas"
style="margin-top: 20px; margin-bottom: 50px; padding: 35px; max-width: 97%; background-color: white; border: 1px solid rgb(14, 94, 199); border-radius: 14px;">
<div style='color:rgb(14, 94, 199); margin-bottom: 30px;'>
<h3 class="fw-bold"> Devolucion de vehículos </h3>
</div>
<!-- Formulario de filtros -->
<form class="row g-3" action="devolucionVehiculo.php" method="get" onsubmit="scrollToTable()">
<div class="col-md-2">
<label for="numero" class="form-label">Nº contrato</label>
<input type="text" class="form-control" id="numero" name="NumeroContrato"
value="<?= htmlspecialchars($filtros['numero']) ?>">
</div>
<div class="col-md-2">
<label for="matricula" class="form-label">Matrícula</label>
<input type="text" class="form-control" id="matricula" name="MatriculaContrato"
value="<?= htmlspecialchars($filtros['matricula']) ?>">
</div>
<div class="col-md-2">
<label for="apellido" class="form-label">Apellido</label>
<input type="text" class="form-control" id="apellido" name="ApellidoContrato"
value="<?= htmlspecialchars($filtros['apellido']) ?>">
</div>
<div class="col-md-2">
<label for="nombre" class="form-label">Nombre</label>
<input type="text" class="form-control" id="nombre" name="NombreContrato"
value="<?= htmlspecialchars($filtros['nombre']) ?>">
</div>
<div class="col-md-2">
<label for="documento" class="form-label">Documento</label>
<input type="text" class="form-control" id="documento" name="DocContrato"
value="<?= htmlspecialchars($filtros['documento']) ?>">
</div>
<div class="w-100"></div> <!-- salto de linea -->
<div class="col-md-4">
<label for="retiro" class="form-label">Devolucion entre</label>
<div class="d-flex">
<input type="date" id="devoluciondesde" class="form-control me-2" name="DevolucionDesde"
value="<?= htmlspecialchars($filtros['devoluciondesde']) ?>">
<input type="date" id="devolucionhasta" class="form-control" name="DevolucionHasta"
value="<?= htmlspecialchars($filtros['devolucionhasta']) ?>">
</div>
</div>
<div class="col-md-2">
</div>
<div class="col-md-2">
</div>
<div class="col-md-2">
</div>
<div class="w-100"></div> <!-- salto de linea -->
<div class="d-flex flex-wrap justify-content-between align-items-end mt-3">
<div class="d-flex flex-wrap gap-2">
<button type="submit" style="background-color: rgb(14, 94, 199); color: white;"
class="btn btn-filtrar" name="BotonFiltrar" value="FiltrandoDevolucion">
<i class="fas fa-filter"></i> Filtrar
</button>
<button type="submit" class="btn btn-warning btn-filtrar" name="BotonLimpiarFiltros"
value="LimpiandoFiltros">
<i class="fas fa-ban"></i> Limpiar Filtros
</button>
</div>
</div>
</form>
</div>
<div style="margin-top: 5%; padding-bottom: 100px;">
<!-- Listado de Devolucion -->
<h3 class="fw-bold" style="margin-top: 5%;"> Listado de Devoluciones </h3>
<div id="tablaDevolucionesContenedor" class="table-responsive mt-4"
style="max-width: 97%; max-height: 700px; border: 1px solid #444444; border-radius: 14px;">
<table class="table table-striped table-hover" id="tablaDevolucion">
<thead>
<tr>
<th style='color:rgb(14, 94, 199);'>
<h3>#</h3>
</th>
<th>Contrato</th>
<th
title="Fecha de finalización del contrato. No corresponde necesariamente con la fecha de devolución del vehículo. Formato de fecha: YYYY/mm/dd">
Finalización Contrato
</th>
<th
title="Fecha efectiva de devolución del vehículo por parte del cliente. Formato de fecha: YYYY/mm/dd">
Fecha Devolución
</th>
<th>Hora Devolución</th>
<th>Cliente</th>
<th>Vehículo</th>
<th>Oficina Dev.</th>
<th>Estado del vehículo</th>
<th>Aclaraciones</th>
<th>Infracciones</th>
<th>Monto extra</th>
</tr>
</thead>
<tbody>
<?php
$contador = 1;
for ($i = 0; $i < $CantidadDevolucion; $i++) { ?>
<tr class='Devolucion' data-id='<?php echo $ListadoDevolucion[$i]['IdDevolucion']; ?>'
onclick="selectRow(this, '<?= $ListadoDevolucion[$i]['IdDevolucion'] ?>')">
<td><span style='color: rgb(14, 94, 199);'>
<h4> <?php echo $contador; ?> </h4>
</span></td>
<td> <?php echo $ListadoDevolucion[$i]['IdContrato']; ?> </td>
<td
title="Fecha de finalización del contrato. No corresponde necesariamente con la fecha de devolución del vehículo. Formato de fecha: YYYY/mm/dd">
<?php echo $ListadoDevolucion[$i]['FechaFinContrato']; ?>
</td>
<td
title="Fecha efectiva de devolución del vehículo por parte del cliente. Formato de fecha: YYYY/mm/dd">
<?php echo $ListadoDevolucion[$i]['FechaDevolucion']; ?>
</td>
<td> <?php echo $ListadoDevolucion[$i]['HoraDevolucion']; ?> </td>
<td> <?php echo "{$ListadoDevolucion[$i]['apellidoCliente']}, {$ListadoDevolucion[$i]['nombreCliente']} </br> DNI: {$ListadoDevolucion[$i]['dniCliente']}"; ?>
</td>
<td> <?php echo "Patente {$ListadoDevolucion[$i]['vehiculoMatricula']} </br> {$ListadoDevolucion[$i]['vehiculoModelo']}, {$ListadoDevolucion[$i]['vehiculoGrupo']}"; ?>
</td>
<td> <?php echo "{$ListadoDevolucion[$i]['CiudadSucursal']}, {$ListadoDevolucion[$i]['DireccionSucursal']}"; ?>
</td>
<td title="Estado del vehículo al momento de la devolución">
<?php echo $ListadoDevolucion[$i]['EstadoDevolucion']; ?> </td>
<td title="Aclaraciones sobre el estado del vehículo al momento de la devolución">
<?php echo $ListadoDevolucion[$i]['AclaracionesDevolucion']; ?> </td>
<td title="Infracciones cometidas por el cliente">
<?php echo $ListadoDevolucion[$i]['InfraccionesDevolucion']; ?> <br><br>
<b>Costos asociados:</b> <br>
<?php
if (is_null($ListadoDevolucion[$i]['CostosInfracciones']) || $ListadoDevolucion[$i]['CostosInfracciones'] == 0) {
echo "Sin costos";
} else {
echo "$ ";
echo $ListadoDevolucion[$i]['CostosInfracciones'];
echo " USD";
}
?>
</td>
<td title="Monto extra a cobrar por infracciones">
<?php
if (is_null($ListadoDevolucion[$i]['MontoExtra']) || $ListadoDevolucion[$i]['MontoExtra'] == 0) {
echo "Sin costos";
} else {
echo "$ ";
echo $ListadoDevolucion[$i]['MontoExtra'];
echo " USD";
}
?>
</td>
</tr>
<?php $contador++; ?>
<?php
}
?>
</tbody>
</table>
</div>
<br><br>
<!-- Recuadro con cantidad total de registros encontrados -->
<style>
.no-btn-effect {
pointer-events: none;
/* Evita que se comporte como un botón */
box-shadow: none !important;
cursor: default !important;
/* Hace que el cursor no cambie */
border: none;
}
</style>
<p class="btn no-btn-effect"
style="background-color: rgb(153, 6, 6); color: #ffffff; margin-left: 25px;">
Total de registros encontrados: <?php echo $CantidadDevolucion; ?>
</p>
<!-- Botones de acción -->
<div style="margin-top: 8%;">
<div class="container d-flex justify-content-center">
<button class="btn btn-dark me-2" data-bs-toggle="modal" data-bs-target="#nuevoRegistroModal">
<i class="fas fa-plus-circle"></i> Nueva Devolucion
</button>
<button class="btn btn-warning me-2" id="btnModificar" onclick="modificarDevolucion()" disabled>
Modificar datos de Devolucion
</button>
<a href="ReporteDevoluciones.php"> <button class="btn btn-primary">
Imprimir listado
</button></a>
</div>
</div>
<!-- Reportes -->
<div style="margin: auto; max-width: 95%; padding: 150px 0 5px 0;">
<div class="p-4 mb-4 bg-white shadow-sm" style="border-radius: 14px; margin: 0; padding: 0;">
<h2 class="mb-1 " style="padding: 0; margin: 10px 0 0 0;">
<strong style="color: #a80a0a;">Reportes </strong>
</h2>
</div>
</div>
<style>
.hoverImage {
position: relative;
align-self: stretch;
height: 650px;
flex-shrink: 0;
object-fit: cover;
border-radius: 10px;
max-width: 100%;
}
.centrar {
display: flex;
justify-content: center;
align-items: center;
}
</style>
<div style="margin: auto; max-width: 95%; padding: 10px 0 40px 0;">
<div class="p-4 mb-4 bg-white shadow-sm" style="border-radius: 14px; margin: 0; padding: 0;">
<h4 class="mb-1 " style="padding: 0; margin: 30px 0 0 0;">
<strong style="color: #a80a0a;" data-bs-toggle="modal"
data-bs-target="#reporteDevolucionPorClienteModal">
Reporte:
</strong>
<a href="#" style="color: black;" data-bs-toggle="modal"
data-bs-target="#reporteDevolucionPorClienteModal">
Devolucion de vehículos por cliente
</a>
</h4>
<a href="#" style="color: black;" data-bs-toggle="modal"
data-bs-target="#reporteDevolucionPorClienteModal">
<div class="mb-1 hoverImageWrapper centrar" style="padding: 0; margin: 50px 0 0 0;">
<img class="hoverImage" src="assets/img/reports/reporte-devolucionesporcliente.png"
alt="Devolucion de vehículos a cliente seleccionado"
style="max-width: 99%; border-radius: 25px;">
</div>
</a>
<style>
.btn-inversion {
padding-left: 30px;
padding-right: 30px;
background-color: #262626;
color: #e04709;
font-weight: 500;
border: 1px solid #d64004;
border-radius: 20px;
transition: all 0.5s ease-in-out;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
}
.btn-inversion:hover {
background-color: #a80a0a;
color: white;
font-weight: 100;
border: 1px solid #a80a0a;
}
</style>
<div class="container d-flex justify-content-center" style="margin: 70px 0 50px 0;">
<a href="#" data-bs-toggle="modal" data-bs-target="#reporteDevolucionPorClienteModal">
<button class="btn btn-inversion">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-bar-chart" viewBox="0 0 16 16">
<path
d="M4 11H2v3h2zm5-4H7v7h2zm5-5v12h-2V2zm-2-1a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM6 7a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1zm-5 4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1z" />
</svg>
Reporte
</button>
</a>
</div>
</div>
</div>
<!-- Modal para Nueva Devolucion -->
<div class="modal fade" id="nuevoRegistroModal" tabindex="-1" aria-labelledby="nuevoRegistroModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="nuevoRegistroModalLabel">Agregar Nueva Devolución</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
<!-- Form -->
<form action="Nueva_Devolucion.php" method="post">
<div class="modal-body">
<div class="mb-3">
<label for="selectorDevolucion" class="form-label"
title="<?php echo $CantidadContratos ?> contratos encontrados (activos y renovados)">
Contrato
</label>
<select class="form-select" id="selectorDevolucion" name="idContrato" required>
<option value="" selected>Selecciona una opción</option>
<?php
if (!empty($ListadoContratos)) {
for ($i = 0; $i < $CantidadContratos; $i++) {
$selected = (!empty($_POST['idContrato']) && $_POST['idContrato'] == $ListadoContratos[$i]['IdContrato']) ? 'selected' : '';
echo "<option value='{$ListadoContratos[$i]['IdContrato']}' $selected>
NºContrato: {$ListadoContratos[$i]['IdContrato']} -
{$ListadoContratos[$i]['ApellidoCliente']} {$ListadoContratos[$i]['NombreCliente']} -
DNI: {$ListadoContratos[$i]['DniCliente']} -
Vehículo: {$ListadoContratos[$i]['matricula']} {$ListadoContratos[$i]['modelo']} {$ListadoContratos[$i]['grupo']}
</option>";
}
} else {
echo "<option value=''>No se encontraron contratos</option>";
}
?>
</select>
</div>
<div class="mb-3">
<label for="fechafincontrato" class="form-label">Fecha de Finalización del
contrato</label>
<input type="text" class="form-control" id="fechafincontrato"
name="fechaFinContrato"
value="La fecha registrada en el contrato aparecerá aquí"
title="La fecha registrada en el contrato puede no coincidir con fecha real de devolución. Formato de fecha en pantalla: mm/dd/YYYY"
readonly>
</div>
<div class="mb-3">
<label for="fechadevolucion" class="form-label">Fecha de Devolución
efectiva</label>
<input type="date" class="form-control" id="fechadevolucion"
name="fechadevolucion" title="Formato de fecha: YYYY/mm/dd" required>
</div>
<div class="mb-3">
<label for="horadevolucion" class="form-label">Hora de Devolución</label>
<input type="time" class="form-control" id="horadevolucion"
name="horadevolucion" title="Por favor complete también este campo"
required>
</div>
<div class="mb-3">
<label for="estadovehiculo" class="form-label">Estado del vehículo durante la
Devolución</label>
<select class="form-select" id="estadovehiculo" name="estadoDevolucion">
<option value="" selected>Selecciona una opción (Opcional)</option>
<option value="Excelente">Excelente</option>
<option value="Bueno">Bueno</option>
<option value="Regular">Regular</option>
<option value="Dañado">Dañado</option>
</select>
</div>
<div class="mb-3">
<label for="aclaraciones" class="form-label">Aclaraciones sobre el estado del
vehículo</label>
<textarea class="form-control" id="aclaraciones" name="aclaracionesDevolucion"
rows="2" placeholder="Notas sobre el estado físico..."></textarea>
</div>
<div class="mb-3">
<label for="infracciones" class="form-label">Infracciones asociadas a la
Devolución</label>
<textarea class="form-control" id="infracciones" name="infraccionesDevolucion"
rows="2" placeholder="Detalle de multas o infracciones..."></textarea>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="costoinfracciones" class="form-label">Costos de
infracciones</label>
<input type="number" step="0.01" class="form-control" id="costoinfracciones"
name="costosInfracciones" value="0.00">
</div>
<div class="col-md-6 mb-3">
<label for="montoextra" class="form-label">Monto adicional</label>
<input type="number" step="0.01" class="form-control" id="montoextra"
name="montoExtra" value="0.00">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary"
data-bs-dismiss="modal">Cerrar</button>
<button type="submit" class="btn btn-primary">Guardar</button>
</div>
</form>
</div>
</div>
</div>
<!-- Modal para Generar reporte de Devolucion de vehículos por Cliente -->
<div class="modal fade" id="reporteDevolucionPorClienteModal" tabindex="-1"
aria-labelledby="reporteDevolucionPorClienteModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="reporteDevolucionPorClienteModalLabel">Generar reporte:
Devolucion por cliente</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
<!-- Form -->
<form action="ReporteDevolucionPorCliente.php" method="post">
<div class="modal-body">
<div class="mb-3">
<label for="idCliente" class="form-label">Seleccionar cliente</label>
<select class="form-select" aria-label="Selector" id="selectorCliente"
name="idCliente"
title="<?php echo $CantidadClientes ?> clientes encontrados" required>
<option value="" selected>Selecciona una opción</option>
<?php
// Asegurate de que $ListadoClientes contiene datos antes de procesarlo
if (!empty($ListadoClientes)) {
$selected = '';
for ($i = 0; $i < $CantidadClientes; $i++) {
// Lógica para verificar si el grupo debe estar seleccionado
$selected = (!empty($_POST['idCliente']) && $_POST['idCliente'] == $ListadoClientes[$i]['idCliente']) ? 'selected' : '';
echo "<option value='{$ListadoClientes[$i]['idCliente']}' $selected>
{$ListadoClientes[$i]['apellidoCliente']} {$ListadoClientes[$i]['nombreCliente']} (DNI: {$ListadoClientes[$i]['dniCliente']})
</option>";
}
} else {
echo "<option value=''>No se encontraron clientes.</option>";
}
?>
</select>
</div>
<!--
<div class="mb-3">
<label for="numreserva" class="form-label">Número de reserva</label>
<input type="text" class="form-control" id="numreserva" name="numreserva" required>
</div>
-->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary"
data-bs-dismiss="modal">Cerrar</button>
<button type="submit" class="btn btn-dark">Generar</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div>
<?php require_once "foot.php"; ?>
</div>
</div>
<script>
// Efecto sobre la imagen del reporte
window.onload = function() {
const imageElement = document.querySelector('.hoverImage');
if (imageElement) {
const handleMouseMove = (e) => {
let rect = imageElement.getBoundingClientRect();
let x = e.clientX - rect.left;
let y = e.clientY - rect.top;
let dx = (x - rect.width / 2) / (rect.width / 2);
let dy = (y - rect.height / 2) / (rect.height / 2);
imageElement.style.transform =
`perspective(500px) rotateY(${dx * 5}deg) rotateX(${-dy * 5}deg)`;
};
const handleMouseLeave = () => {
imageElement.style.transform = "";
};
imageElement.addEventListener('mousemove', handleMouseMove);
imageElement.addEventListener('mouseleave', handleMouseLeave);
}
}
</script>
<script>
// Desplazamiento vertical al listado luego de consulta
function scrollToTable() {
localStorage.setItem('scrollToTable', 'true'); // Guardar indicador antes de enviar
}
document.addEventListener('DOMContentLoaded', () => {
if (localStorage.getItem('scrollToTable') === 'true') {
setTimeout(() => {
document.getElementById('tablaDevolucionesContenedor').scrollIntoView({
behavior: 'smooth',
block: 'start'
});
localStorage.removeItem('scrollToTable'); // Limpiar indicador después del scroll
}, 500);
}
});
let DevolucionSeleccionada = null;
// Selección de fila en la Tabla de Devolucion al hacer clic en la misma
document.querySelectorAll('#tablaDevolucion .Devolucion').forEach(row => {
row.addEventListener('click', () => {
// Desmarcar cualquier fila previamente seleccionada
document.querySelectorAll('.Devolucion').forEach(row => row.classList.remove(
'table-active'));
// Marcar la fila seleccionada
row.classList.add('table-active');
DevolucionSeleccionada = row.dataset.id;
// Habilitar los botones
document.getElementById('btnModificar').disabled = false;
// document.getElementById('btnEliminar').disabled = false;
});
});
// Función para redirigir a modificarDevolucion.php con el ID de la Devolucion seleccionado
function modificarDevolucion() {
if (DevolucionSeleccionada) {
window.location.href = 'modificarDevolucion.php?id=' + DevolucionSeleccionada;
}
}
</script>
<!-- Funcion para buscador en dropdown -->
<script>
$(document).ready(function() {
// Inicializar Select2 dentro del modal
$('#selectorDevolucion').select2({
dropdownParent: $('#nuevoRegistroModal'),
width: '100%',
minimumResultsForSearch: 0 // ⚠️ Forzar siempre el buscador aunque haya pocos elementos (forzar que siempre aparezca el buscador)
});
});
</script>
<script>
$(document).ready(function() {
// 1. Capturar fecha de fin de contrato y mostrarla en el input
$('#selectorDevolucion').on('change', function() {
var idContrato = $(this).val();
if (idContrato) {
$.ajax({
type: 'POST',
url: 'obtenerFechaFinContrato.php',
data: {
idContrato: idContrato
},
success: function(response) {
if (response) {
// Seteamos el valor que ya viene formateado d-m-Y desde el PHP
$('#fechafincontrato').val(response);
} else {
$('#fechafincontrato').val('');
}
}
});
} else {
$('#fechafincontrato').val('');
}
});
// 2. Validación al enviar el formulario (Nueva Devolución)
$('form[action="Nueva_Devolucion.php"]').on('submit', function(e) {
var finTexto = $('#fechafincontrato').val(); // Formato d-m-Y
var devTexto = $('#fechadevolucion').val(); // Formato YYYY-MM-DD (input date)
if (finTexto && devTexto && finTexto !==
"La fecha registrada en el contrato aparecerá aquí") {
// Convertimos Fin (DD-MM-AAAA) a número comparable (AAAAMMDD)
var pF = finTexto.split('-');
var nFin = parseInt(pF[2] + pF[1] + pF[0]);
// Convertimos Devolución (YYYY-MM-DD) a número comparable (AAAAMMDD)
var pD = devTexto.split('-');
var nDevolucion = parseInt(pD[0] + pD[1] + pD[2]);
// COMPARA: Si la devolución es numéricamente MENOR al fin, bloquea.
// Si son iguales, nDevolucion < nFin es FALSO y permite guardar.
if (nDevolucion > nFin) {
e.preventDefault();
alert("¡Atención!\n\nLa fecha de devolución efectiva no puede ser posterior a la fecha de finalización del contrato (" +
finTexto + ").");
$('#fechadevolucion').focus();
}
}
});
});
</script>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.min.js"></script>
<!-- Librería y estilo para agregar buscador al dropdown -->
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
</body>
</html>