fix: excluir actualización al generar excel vista consulta para admin

This commit is contained in:
Juan Felipe Zapata Moreno 2026-01-21 19:35:07 -06:00
parent c725072291
commit 43c1400e7c

View File

@ -1181,7 +1181,7 @@ public function exportSearchRecords(Request $request)
'vin' => 'nullable|string', 'vin' => 'nullable|string',
'tag_number' => 'nullable|string', 'tag_number' => 'nullable|string',
'module_id' => 'nullable|integer|exists:modules,id', 'module_id' => 'nullable|integer|exists:modules,id',
'action_type' => 'nullable|string|in:inscripcion,actualizacion,sustitucion,cancelacion', 'action_type' => 'nullable|string|in:inscripcion,sustitucion,cancelacion',
'status' => 'nullable|string', 'status' => 'nullable|string',
'start_date' => 'nullable|date', 'start_date' => 'nullable|date',
'end_date' => 'nullable|date|after_or_equal:start_date', 'end_date' => 'nullable|date|after_or_equal:start_date',
@ -1277,8 +1277,10 @@ public function exportSearchRecords(Request $request)
$moduleName = $record->module->name ?? ''; $moduleName = $record->module->name ?? '';
$operador = $record->user->name ?? $record->user->username ?? ''; $operador = $record->user->name ?? $record->user->username ?? '';
// Obtener todos los logs ordenados por fecha ascendente // Obtener logs ordenados por fecha, excluyendo actualizaciones
$vehicleLogs = $vehicle->vehicleTagLogs->sortBy('created_at'); $vehicleLogs = $vehicle->vehicleTagLogs
->whereIn('action_type', ['inscripcion', 'sustitucion', 'cancelacion'])
->sortBy('created_at');
// Generar una fila por cada log (cada acción en el historial) // Generar una fila por cada log (cada acción en el historial)
foreach ($vehicleLogs as $log) { foreach ($vehicleLogs as $log) {
@ -1408,7 +1410,7 @@ public function exportSearchRecords(Request $request)
$sheet->setCellValue('L' . $row, $item['tag']); $sheet->setCellValue('L' . $row, $item['tag']);
// Aplicar estilos a todas las columnas // Aplicar estilos a todas las columnas
foreach (range('A', 'M') as $col) { foreach (range('A', 'L') as $col) {
$sheet->getStyle("{$col}{$row}")->applyFromArray($cellStyle); $sheet->getStyle("{$col}{$row}")->applyFromArray($cellStyle);
} }