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
|
// Paginación
|
||||||
$paginatedRecords = $records->paginate(config('app.pagination'));
|
$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
|
// Transformación de datos
|
||||||
$paginatedRecords->getCollection()->transform(function ($record) {
|
$paginatedRecords->getCollection()->transform(function ($record) {
|
||||||
$latestLog = $record->vehicle->vehicleTagLogs->first();
|
$latestLog = $record->vehicle->vehicleTagLogs->first();
|
||||||
|
|||||||
@ -29,8 +29,18 @@ public function index(Request $request)
|
|||||||
$packages->where('box_number', 'LIKE', '%' . $request->caja . '%');
|
$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([
|
return ApiResponse::OK->response([
|
||||||
'packages' => $packages->paginate(config('app.pagination'))
|
'Paquetes' => $paginatedPackages,
|
||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return ApiResponse::INTERNAL_ERROR->response([
|
return ApiResponse::INTERNAL_ERROR->response([
|
||||||
|
|||||||
@ -45,8 +45,18 @@ public function index(Request $request)
|
|||||||
$tags->where('module_id', $request->module_id);
|
$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([
|
return ApiResponse::OK->response([
|
||||||
'tag' => $tags->paginate(config('app.pagination')),
|
'tag' => $paginatedTags,
|
||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return ApiResponse::INTERNAL_ERROR->response([
|
return ApiResponse::INTERNAL_ERROR->response([
|
||||||
|
|||||||
@ -26,32 +26,32 @@
|
|||||||
/* COLUMNA IZQUIERDA */
|
/* COLUMNA IZQUIERDA */
|
||||||
.left-col-vin {
|
.left-col-vin {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 20mm;
|
left: 5mm;
|
||||||
top: 40mm;
|
top: 15mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.left-col-placa {
|
.left-col-placa {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 20mm;
|
left: 5mm;
|
||||||
top: 65mm;
|
top: 28mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.left-col-marca {
|
.left-col-marca {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 20mm;
|
left: 5mm;
|
||||||
top: 72mm;
|
top: 35mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.left-col-linea-modelo {
|
.left-col-linea-modelo {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 20mm;
|
left: 5mm;
|
||||||
top: 79mm;
|
top: 41mm;
|
||||||
width: 70mm;
|
width: 75mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.left-col-linea {
|
.left-col-linea {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 40mm;
|
width: 10mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.left-col-modelo {
|
.left-col-modelo {
|
||||||
@ -62,52 +62,52 @@
|
|||||||
|
|
||||||
.left-col-propietario {
|
.left-col-propietario {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 20mm;
|
left: 5mm;
|
||||||
top: 86mm;
|
top: 45mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.left-col-direccion {
|
.left-col-direccion {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 20mm;
|
left: 5mm;
|
||||||
top: 93mm;
|
top: 55mm;
|
||||||
font-size: 8pt;
|
font-size: 8pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
.left-col-municipio {
|
.left-col-municipio {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 20mm;
|
left: 5mm;
|
||||||
top: 100mm;
|
top: 50mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* COLUMNA DERECHA */
|
/* COLUMNA DERECHA */
|
||||||
.right-col-vin {
|
.right-col-vin {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 115mm;
|
left: 90mm;
|
||||||
top: 40mm;
|
top: 15mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.right-col-placa {
|
.right-col-placa {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 115mm;
|
left: 90mm;
|
||||||
top: 65mm;
|
top: 28mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.right-col-marca {
|
.right-col-marca {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 115mm;
|
left: 90mm;
|
||||||
top: 72mm;
|
top: 33mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.right-col-linea-modelo {
|
.right-col-linea-modelo {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 115mm;
|
left: 90mm;
|
||||||
top: 79mm;
|
top: 38mm;
|
||||||
width: 70mm;
|
width: 75mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.right-col-linea {
|
.right-col-linea {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 40mm;
|
width: 10mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.right-col-modelo {
|
.right-col-modelo {
|
||||||
@ -118,8 +118,8 @@
|
|||||||
|
|
||||||
.right-col-particular {
|
.right-col-particular {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 115mm;
|
left: 90mm;
|
||||||
top: 86mm;
|
top: 42mm;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@ -91,31 +91,23 @@
|
|||||||
.tag-list {
|
.tag-list {
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
font-size: 9pt;
|
font-size: 9pt;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-columns {
|
.tag-table {
|
||||||
column-gap: 15px;
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-columns-1 {
|
.tag-table td {
|
||||||
column-count: 1;
|
width: 25%;
|
||||||
}
|
vertical-align: top;
|
||||||
|
padding: 0 10px 0 0;
|
||||||
.tag-columns-2 {
|
|
||||||
column-count: 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag-columns-3 {
|
|
||||||
column-count: 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag-columns-4 {
|
|
||||||
column-count: 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-item {
|
.tag-item {
|
||||||
margin: 2px 0;
|
margin: 2px 0;
|
||||||
break-inside: avoid;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --- ZONA DE FIRMAS (CSS IMPORTANTE AQUÍ) --- */
|
/* --- ZONA DE FIRMAS (CSS IMPORTANTE AQUÍ) --- */
|
||||||
@ -246,25 +238,56 @@
|
|||||||
<div class="tag-list">
|
<div class="tag-list">
|
||||||
@php
|
@php
|
||||||
$tagCount = count($tags);
|
$tagCount = count($tags);
|
||||||
$columnClass = 'tag-columns-3'; // Por defecto 3 columnas
|
$numColumns = 1;
|
||||||
|
|
||||||
if ($tagCount <= 5) {
|
// Determinar número de columnas según cantidad de tags
|
||||||
$columnClass = 'tag-columns-1';
|
if ($tagCount <= 10) {
|
||||||
} elseif ($tagCount <= 10) {
|
$numColumns = 1;
|
||||||
$columnClass = 'tag-columns-2';
|
|
||||||
} elseif ($tagCount <= 20) {
|
} elseif ($tagCount <= 20) {
|
||||||
$columnClass = 'tag-columns-3';
|
$numColumns = 2;
|
||||||
|
} elseif ($tagCount <= 40) {
|
||||||
|
$numColumns = 3;
|
||||||
} else {
|
} 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
|
@endphp
|
||||||
<div class="tag-columns {{ $columnClass }}">
|
|
||||||
@foreach($tags as $index => $tag)
|
<table class="tag-table">
|
||||||
|
@foreach($tagMatrix as $row)
|
||||||
|
<tr>
|
||||||
|
@foreach($row as $cell)
|
||||||
|
<td>
|
||||||
|
@if($cell)
|
||||||
<div class="tag-item">
|
<div class="tag-item">
|
||||||
{{ $index + 1 }}. {{ $tag->folio }}
|
{{ $cell['index'] }}. {{ $cell['tag']->folio }}
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="firmas-container">
|
<div class="firmas-container">
|
||||||
@ -284,17 +307,34 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="firma-titulo">RECIBEN</div>
|
<div class="firma-titulo">RECIBEN</div>
|
||||||
<div class="reciben-wrapper">
|
<div class="reciben-wrapper">
|
||||||
|
{{-- Mostrar primero el responsable del módulo --}}
|
||||||
|
@if($module->responsible)
|
||||||
|
<div class="firma-reciben-item">
|
||||||
|
<div class="firma-linea">
|
||||||
|
<p class="firma-nombre">
|
||||||
|
{{ strtoupper($module->responsible->full_name) }}
|
||||||
|
</p>
|
||||||
|
<p class="firma-cargo">
|
||||||
|
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)
|
@foreach($responsables as $responsable)
|
||||||
|
@if(!$module->responsible || $responsable->id !== $module->responsible->id)
|
||||||
<div class="firma-reciben-item">
|
<div class="firma-reciben-item">
|
||||||
<div class="firma-linea">
|
<div class="firma-linea">
|
||||||
<p class="firma-nombre">
|
<p class="firma-nombre">
|
||||||
{{ strtoupper($responsable->full_name) }}
|
{{ strtoupper($responsable->full_name) }}
|
||||||
</p>
|
</p>
|
||||||
<p class="firma-cargo">
|
<p class="firma-cargo">
|
||||||
{{ strtoupper($responsable->roles->first()->description ?? 'RESPONSABLE') }} MÓDULO {{ $module->id }}
|
{{ strtoupper($responsable->roles->first()->description ?? 'USUARIO') }} MÓDULO {{ $module->id }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -112,18 +112,6 @@
|
|||||||
display: inline;
|
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 {
|
.section-title {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@ -166,12 +154,6 @@
|
|||||||
.telefono-label {
|
.telefono-label {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.telefono-underline {
|
|
||||||
display: inline-block;
|
|
||||||
border-bottom: 1px solid #000;
|
|
||||||
min-width: 100px;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@ -224,31 +206,31 @@
|
|||||||
|
|
||||||
<!-- Datos del vehículo -->
|
<!-- Datos del vehículo -->
|
||||||
<div class="data-row">
|
<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>
|
||||||
|
|
||||||
<div class="data-row">
|
<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>
|
||||||
|
|
||||||
<div class="data-row">
|
<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>
|
||||||
|
|
||||||
<div class="data-row">
|
<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>
|
||||||
|
|
||||||
<div class="data-row">
|
<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>
|
||||||
|
|
||||||
<div class="data-row">
|
<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>
|
||||||
|
|
||||||
<div class="data-row">
|
<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>
|
</div>
|
||||||
|
|
||||||
<!-- Sección MOTIVO -->
|
<!-- Sección MOTIVO -->
|
||||||
@ -278,7 +260,7 @@
|
|||||||
|
|
||||||
<!-- Teléfono -->
|
<!-- Teléfono -->
|
||||||
<div class="telefono-row">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user