From ffed4cbde517784d3f4d6e561bd3ad0721cfec56 Mon Sep 17 00:00:00 2001 From: Juan Felipe Zapata Moreno Date: Mon, 8 Dec 2025 11:48:42 -0600 Subject: [PATCH] =?UTF-8?q?Fix:=20agregar=20validaci=C3=B3n=20para=20regis?= =?UTF-8?q?tros=20vac=C3=ADos=20en=20Inscription,=20Package=20y=20Tags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repuve/InscriptionController.php | 7 ++ .../Controllers/Repuve/PackageController.php | 12 +- .../Controllers/Repuve/TagsController.php | 12 +- resources/views/pdfs/constancia.blade.php | 56 ++++----- resources/views/pdfs/delivery.blade.php | 106 ++++++++++++------ resources/views/pdfs/form.blade.php | 34 ++---- 6 files changed, 138 insertions(+), 89 deletions(-) diff --git a/app/Http/Controllers/Repuve/InscriptionController.php b/app/Http/Controllers/Repuve/InscriptionController.php index a687000..1b713b0 100644 --- a/app/Http/Controllers/Repuve/InscriptionController.php +++ b/app/Http/Controllers/Repuve/InscriptionController.php @@ -370,6 +370,13 @@ public function searchRecord(Request $request) // Paginación $paginatedRecords = $records->paginate(config('app.pagination')); + if ($paginatedRecords->isEmpty()) { + return ApiResponse::NOT_FOUND->response([ + 'message' => 'No se encontraron registros con los criterios de búsqueda proporcionados.', + 'filters_applied' => array_filter($request->only(['folio', 'placa', 'vin', 'module_id', 'action_type', 'status'])) + ]); + } + // Transformación de datos $paginatedRecords->getCollection()->transform(function ($record) { $latestLog = $record->vehicle->vehicleTagLogs->first(); diff --git a/app/Http/Controllers/Repuve/PackageController.php b/app/Http/Controllers/Repuve/PackageController.php index 0bb12be..3668101 100644 --- a/app/Http/Controllers/Repuve/PackageController.php +++ b/app/Http/Controllers/Repuve/PackageController.php @@ -29,8 +29,18 @@ public function index(Request $request) $packages->where('box_number', 'LIKE', '%' . $request->caja . '%'); } + $paginatedPackages = $packages->paginate(config('app.pagination')); + + // Validación si no hay resultados + if ($paginatedPackages->isEmpty()) { + return ApiResponse::NOT_FOUND->response([ + 'message' => 'No se encontraron tags con los criterios de búsqueda proporcionados.', + 'filters_applied' => array_filter($request->only(['lot', 'box_number'])) + ]); + } + return ApiResponse::OK->response([ - 'packages' => $packages->paginate(config('app.pagination')) + 'Paquetes' => $paginatedPackages, ]); } catch (\Exception $e) { return ApiResponse::INTERNAL_ERROR->response([ diff --git a/app/Http/Controllers/Repuve/TagsController.php b/app/Http/Controllers/Repuve/TagsController.php index b1edcf0..72ffe90 100644 --- a/app/Http/Controllers/Repuve/TagsController.php +++ b/app/Http/Controllers/Repuve/TagsController.php @@ -45,8 +45,18 @@ public function index(Request $request) $tags->where('module_id', $request->module_id); } + $paginatedTags = $tags->paginate(config('app.pagination')); + + // Validación si no hay resultados + if ($paginatedTags->isEmpty()) { + return ApiResponse::NOT_FOUND->response([ + 'message' => 'No se encontraron tags con los criterios de búsqueda proporcionados.', + 'filters_applied' => array_filter($request->only(['status', 'lot', 'package_id', 'module_id'])) + ]); + } + return ApiResponse::OK->response([ - 'tag' => $tags->paginate(config('app.pagination')), + 'tag' => $paginatedTags, ]); } catch (\Exception $e) { return ApiResponse::INTERNAL_ERROR->response([ diff --git a/resources/views/pdfs/constancia.blade.php b/resources/views/pdfs/constancia.blade.php index 573a093..2b94b81 100644 --- a/resources/views/pdfs/constancia.blade.php +++ b/resources/views/pdfs/constancia.blade.php @@ -26,32 +26,32 @@ /* COLUMNA IZQUIERDA */ .left-col-vin { position: absolute; - left: 20mm; - top: 40mm; + left: 5mm; + top: 15mm; } .left-col-placa { position: absolute; - left: 20mm; - top: 65mm; + left: 5mm; + top: 28mm; } .left-col-marca { position: absolute; - left: 20mm; - top: 72mm; + left: 5mm; + top: 35mm; } .left-col-linea-modelo { position: absolute; - left: 20mm; - top: 79mm; - width: 70mm; + left: 5mm; + top: 41mm; + width: 75mm; } .left-col-linea { display: inline-block; - width: 40mm; + width: 10mm; } .left-col-modelo { @@ -62,52 +62,52 @@ .left-col-propietario { position: absolute; - left: 20mm; - top: 86mm; + left: 5mm; + top: 45mm; } .left-col-direccion { position: absolute; - left: 20mm; - top: 93mm; + left: 5mm; + top: 55mm; font-size: 8pt; } .left-col-municipio { position: absolute; - left: 20mm; - top: 100mm; + left: 5mm; + top: 50mm; } /* COLUMNA DERECHA */ .right-col-vin { position: absolute; - left: 115mm; - top: 40mm; + left: 90mm; + top: 15mm; } .right-col-placa { position: absolute; - left: 115mm; - top: 65mm; + left: 90mm; + top: 28mm; } .right-col-marca { position: absolute; - left: 115mm; - top: 72mm; + left: 90mm; + top: 33mm; } .right-col-linea-modelo { position: absolute; - left: 115mm; - top: 79mm; - width: 70mm; + left: 90mm; + top: 38mm; + width: 75mm; } .right-col-linea { display: inline-block; - width: 40mm; + width: 10mm; } .right-col-modelo { @@ -118,8 +118,8 @@ .right-col-particular { position: absolute; - left: 115mm; - top: 86mm; + left: 90mm; + top: 42mm; } diff --git a/resources/views/pdfs/delivery.blade.php b/resources/views/pdfs/delivery.blade.php index c20e2b4..51a469f 100644 --- a/resources/views/pdfs/delivery.blade.php +++ b/resources/views/pdfs/delivery.blade.php @@ -91,31 +91,23 @@ .tag-list { margin: 10px 0; font-size: 9pt; + width: 100%; } - .tag-columns { - column-gap: 15px; + .tag-table { + width: 100%; + border-collapse: collapse; } - .tag-columns-1 { - column-count: 1; - } - - .tag-columns-2 { - column-count: 2; - } - - .tag-columns-3 { - column-count: 3; - } - - .tag-columns-4 { - column-count: 4; + .tag-table td { + width: 25%; + vertical-align: top; + padding: 0 10px 0 0; } .tag-item { margin: 2px 0; - break-inside: avoid; + line-height: 1.5; } /* --- ZONA DE FIRMAS (CSS IMPORTANTE AQUÍ) --- */ @@ -246,25 +238,56 @@
@php $tagCount = count($tags); - $columnClass = 'tag-columns-3'; // Por defecto 3 columnas + $numColumns = 1; - if ($tagCount <= 5) { - $columnClass = 'tag-columns-1'; - } elseif ($tagCount <= 10) { - $columnClass = 'tag-columns-2'; + // Determinar número de columnas según cantidad de tags + if ($tagCount <= 10) { + $numColumns = 1; } elseif ($tagCount <= 20) { - $columnClass = 'tag-columns-3'; + $numColumns = 2; + } elseif ($tagCount <= 40) { + $numColumns = 3; } else { - $columnClass = 'tag-columns-4'; + $numColumns = 4; + } + + // Calcular filas necesarias + $tagsPerColumn = ceil($tagCount / $numColumns); + + // Reorganizar tags en array bidimensional [fila][columna] + $tagMatrix = []; + $tagIndex = 0; + + for ($row = 0; $row < $tagsPerColumn; $row++) { + for ($col = 0; $col < $numColumns; $col++) { + if ($tagIndex < $tagCount) { + $tagMatrix[$row][$col] = [ + 'index' => $tagIndex + 1, + 'tag' => $tags[$tagIndex] + ]; + $tagIndex++; + } else { + $tagMatrix[$row][$col] = null; + } + } } @endphp -
- @foreach($tags as $index => $tag) -
- {{ $index + 1 }}. {{ $tag->folio }} -
+ + + @foreach($tagMatrix as $row) + + @foreach($row as $cell) + + @endforeach + @endforeach - +
+ @if($cell) +
+ {{ $cell['index'] }}. {{ $cell['tag']->folio }} +
+ @endif +
@@ -284,17 +307,34 @@
RECIBEN
- @foreach($responsables as $responsable) + {{-- Mostrar primero el responsable del módulo --}} + @if($module->responsible)

- {{ strtoupper($responsable->full_name) }} + {{ strtoupper($module->responsible->full_name) }}

- {{ strtoupper($responsable->roles->first()->description ?? 'RESPONSABLE') }} MÓDULO {{ $module->id }} + RESPONSABLE MÓDULO {{ $module->id }}

+ @endif + + {{-- Mostrar los demás usuarios del módulo (excluyendo al responsable si ya está incluido) --}} + @foreach($responsables as $responsable) + @if(!$module->responsible || $responsable->id !== $module->responsible->id) +
+
+

+ {{ strtoupper($responsable->full_name) }} +

+

+ {{ strtoupper($responsable->roles->first()->description ?? 'USUARIO') }} MÓDULO {{ $module->id }} +

+
+
+ @endif @endforeach
diff --git a/resources/views/pdfs/form.blade.php b/resources/views/pdfs/form.blade.php index 72005ad..302bce3 100644 --- a/resources/views/pdfs/form.blade.php +++ b/resources/views/pdfs/form.blade.php @@ -112,18 +112,6 @@ display: inline; } - .data-underline { - display: inline-block; - border-bottom: 1px solid #000; - min-width: 150px; - } - - .data-underline-long { - display: inline-block; - border-bottom: 1px solid #000; - min-width: 300px; - } - .section-title { text-align: center; font-weight: bold; @@ -166,12 +154,6 @@ .telefono-label { font-weight: bold; } - - .telefono-underline { - display: inline-block; - border-bottom: 1px solid #000; - min-width: 100px; - } @@ -224,31 +206,31 @@
- Marca: {{ strtoupper($marca ?? '') }} + Marca: {{ strtoupper($marca ?? '') }}
- Modelo: {{ strtoupper($linea ?? '') }} + Modelo: {{ strtoupper($linea ?? '') }}
- Año Modelo: {{ $modelo ?? '' }} + Año Modelo: {{ $modelo ?? '' }}
- Número de Identificación (NIV): {{ strtoupper($niv ?? '') }} + Número de Identificación (NIV): {{ strtoupper($niv ?? '') }}
- Número de Motor: {{ strtoupper($numero_motor ?? '') }} + Número de Motor: {{ strtoupper($numero_motor ?? '') }}
- Placas: {{ strtoupper($placa ?? '') }} + Placas: {{ strtoupper($placa ?? '') }}
- Folio de Constancia de Inscripción: {{ strtoupper($folio ?? '') }} + Folio de Constancia de Inscripción: {{ strtoupper($folio ?? '') }}
@@ -278,7 +260,7 @@
- Teléfono:{{ $telefono ?? '' }} + Teléfono:{{ $telefono ?? '' }}