Fix: agregar validación para registros vacíos en Inscription, Package y Tags
This commit is contained in:
parent
6425aa5cc1
commit
ffed4cbde5
@ -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();
|
||||
|
||||
@ -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([
|
||||
|
||||
@ -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([
|
||||
|
||||
@ -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;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
@ -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 @@
|
||||
<div class="tag-list">
|
||||
@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
|
||||
<div class="tag-columns {{ $columnClass }}">
|
||||
@foreach($tags as $index => $tag)
|
||||
<div class="tag-item">
|
||||
{{ $index + 1 }}. {{ $tag->folio }}
|
||||
</div>
|
||||
|
||||
<table class="tag-table">
|
||||
@foreach($tagMatrix as $row)
|
||||
<tr>
|
||||
@foreach($row as $cell)
|
||||
<td>
|
||||
@if($cell)
|
||||
<div class="tag-item">
|
||||
{{ $cell['index'] }}. {{ $cell['tag']->folio }}
|
||||
</div>
|
||||
@endif
|
||||
</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
</div>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="firmas-container">
|
||||
@ -284,17 +307,34 @@
|
||||
<div>
|
||||
<div class="firma-titulo">RECIBEN</div>
|
||||
<div class="reciben-wrapper">
|
||||
@foreach($responsables as $responsable)
|
||||
{{-- Mostrar primero el responsable del módulo --}}
|
||||
@if($module->responsible)
|
||||
<div class="firma-reciben-item">
|
||||
<div class="firma-linea">
|
||||
<p class="firma-nombre">
|
||||
{{ strtoupper($responsable->full_name) }}
|
||||
{{ strtoupper($module->responsible->full_name) }}
|
||||
</p>
|
||||
<p class="firma-cargo">
|
||||
{{ strtoupper($responsable->roles->first()->description ?? 'RESPONSABLE') }} MÓDULO {{ $module->id }}
|
||||
RESPONSABLE MÓDULO {{ $module->id }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@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)
|
||||
<div class="firma-reciben-item">
|
||||
<div class="firma-linea">
|
||||
<p class="firma-nombre">
|
||||
{{ strtoupper($responsable->full_name) }}
|
||||
</p>
|
||||
<p class="firma-cargo">
|
||||
{{ strtoupper($responsable->roles->first()->description ?? 'USUARIO') }} MÓDULO {{ $module->id }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
@ -224,31 +206,31 @@
|
||||
|
||||
<!-- Datos del vehículo -->
|
||||
<div class="data-row">
|
||||
<span class="data-label">Marca: </span><span class="data-underline">{{ strtoupper($marca ?? '') }}</span>
|
||||
<span class="data-label">Marca: </span><span >{{ strtoupper($marca ?? '') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="data-row">
|
||||
<span class="data-label">Modelo: </span><span class="data-underline">{{ strtoupper($linea ?? '') }}</span>
|
||||
<span class="data-label">Modelo: </span><span >{{ strtoupper($linea ?? '') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="data-row">
|
||||
<span class="data-label">Año Modelo: </span><span class="data-underline">{{ $modelo ?? '' }}</span>
|
||||
<span class="data-label">Año Modelo: </span><span >{{ $modelo ?? '' }}</span>
|
||||
</div>
|
||||
|
||||
<div class="data-row">
|
||||
<span class="data-label">Número de Identificación (NIV): </span><span class="data-underline-long">{{ strtoupper($niv ?? '') }}</span>
|
||||
<span class="data-label">Número de Identificación (NIV): </span><span>{{ strtoupper($niv ?? '') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="data-row">
|
||||
<span class="data-label">Número de Motor: </span><span class="data-underline-long">{{ strtoupper($numero_motor ?? '') }}</span>
|
||||
<span class="data-label">Número de Motor: </span><span>{{ strtoupper($numero_motor ?? '') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="data-row">
|
||||
<span class="data-label">Placas: </span><span class="data-underline">{{ strtoupper($placa ?? '') }}</span>
|
||||
<span class="data-label">Placas: </span><span >{{ strtoupper($placa ?? '') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="data-row">
|
||||
<span class="data-label">Folio de Constancia de Inscripción: </span><span class="data-underline">{{ strtoupper($folio ?? '') }}</span>
|
||||
<span class="data-label">Folio de Constancia de Inscripción: </span><span >{{ strtoupper($folio ?? '') }}</span>
|
||||
</div>
|
||||
|
||||
<!-- Sección MOTIVO -->
|
||||
@ -278,7 +260,7 @@
|
||||
|
||||
<!-- Teléfono -->
|
||||
<div class="telefono-row">
|
||||
<span class="telefono-label">Teléfono:</span><span class="telefono-underline">{{ $telefono ?? '' }}</span>
|
||||
<span class="telefono-label">Teléfono:</span><span>{{ $telefono ?? '' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user