fix: se agregó actualizaciones al excel general

This commit is contained in:
Juan Felipe Zapata Moreno 2026-01-21 12:11:10 -06:00
parent 6eeba6f9fe
commit 69727724d3

View File

@ -857,16 +857,16 @@ public function excelGeneral(Request $request)
// Obtener información del módulo // Obtener información del módulo
$module = $moduleId ? Module::find($moduleId) : null; $module = $moduleId ? Module::find($moduleId) : null;
// QUERY 1: VehicleTagLogs (Inscripciones, Sustituciones, Cancelaciones de Vehículo) // QUERY 1: VehicleTagLogs (Inscripciones, Sustituciones, Actualizaciones, Cancelaciones de Vehículo)
$logs = VehicleTagLog::with([ $logs = VehicleTagLog::with([
'vehicle.records.module', 'vehicle.records.module',
'tag', 'tag',
'cancellationReason' 'cancellationReason'
]) ])
->whereIn('action_type', ['inscripcion', 'sustitucion', 'cancelacion']) ->whereIn('action_type', ['inscripcion', 'sustitucion', 'actualizacion', 'cancelacion'])
->where(function ($query) use ($fechaInicio, $fechaFin) { ->where(function ($query) use ($fechaInicio, $fechaFin) {
$query->where(function ($q) use ($fechaInicio, $fechaFin) { $query->where(function ($q) use ($fechaInicio, $fechaFin) {
$q->whereIn('action_type', ['inscripcion', 'sustitucion']) $q->whereIn('action_type', ['inscripcion', 'sustitucion', 'actualizacion'])
->whereBetween('created_at', [$fechaInicio, $fechaFin]); ->whereBetween('created_at', [$fechaInicio, $fechaFin]);
}) })
->orWhere(function ($q) use ($fechaInicio, $fechaFin) { ->orWhere(function ($q) use ($fechaInicio, $fechaFin) {
@ -942,6 +942,7 @@ public function excelGeneral(Request $request)
$motivo = $log->cancellationReason->reason ?? $log->cancellationReason->name ?? ''; $motivo = $log->cancellationReason->reason ?? $log->cancellationReason->name ?? '';
if ($log->action_type == 'sustitucion') $motivo = 'SUSTITUCIÓN'; if ($log->action_type == 'sustitucion') $motivo = 'SUSTITUCIÓN';
if ($log->action_type == 'inscripcion') $motivo = 'INSCRIPCIÓN'; if ($log->action_type == 'inscripcion') $motivo = 'INSCRIPCIÓN';
if ($log->action_type == 'actualizacion') $motivo = 'ACTUALIZACIÓN';
if ($log->action_type == 'cancelacion' && empty($motivo)) $motivo = 'DAÑADA'; if ($log->action_type == 'cancelacion' && empty($motivo)) $motivo = 'DAÑADA';
return [ return [
@ -953,7 +954,7 @@ public function excelGeneral(Request $request)
'placa' => $vehicle->placa ?? '', 'placa' => $vehicle->placa ?? '',
'modelo' => $vehicle->modelo ?? '', 'modelo' => $vehicle->modelo ?? '',
'folio' => $log->tag->folio ?? $log->new_tag_folio ?? '', 'folio' => $log->tag->folio ?? $log->new_tag_folio ?? '',
'chip' => $log->tag->rfid ?? '', 'chip' => $log->tag->tag_number ?? '',
'fecha' => $fecha, 'fecha' => $fecha,
'motivo' => mb_strtoupper($motivo, 'UTF-8'), 'motivo' => mb_strtoupper($motivo, 'UTF-8'),
'observaciones' => $log->observations ?? '' 'observaciones' => $log->observations ?? ''