diff --git a/app/Http/Controllers/Repuve/ExcelController.php b/app/Http/Controllers/Repuve/ExcelController.php index 489aaf2..20d8092 100644 --- a/app/Http/Controllers/Repuve/ExcelController.php +++ b/app/Http/Controllers/Repuve/ExcelController.php @@ -182,7 +182,20 @@ public function constanciasSustituidas(Request $request) $sheet->getStyle('B9')->getFont()->setBold(false)->setSize(14); Carbon::setLocale('es'); - $periodoTexto = 'del ' . $fechaInicio->format('d') . ' al ' . $fechaFin->format('d') . ' de ' . $fechaFin->translatedFormat('F'); + // Formato completo para manejar diferentes meses/años + if ($fechaInicio->format('m/Y') === $fechaFin->format('m/Y')) { + // Mismo mes y año + $periodoTexto = 'del ' . $fechaInicio->format('d') . ' al ' . $fechaFin->format('d') . ' de ' . $fechaFin->translatedFormat('F'); + $anioTexto = $fechaFin->format('Y'); + } elseif ($fechaInicio->format('Y') === $fechaFin->format('Y')) { + // Diferente mes, mismo año + $periodoTexto = 'del ' . $fechaInicio->format('d') . ' de ' . $fechaInicio->translatedFormat('F') . ' al ' . $fechaFin->format('d') . ' de ' . $fechaFin->translatedFormat('F'); + $anioTexto = $fechaFin->format('Y'); + } else { + // Diferente año + $periodoTexto = 'del ' . $fechaInicio->format('d') . ' de ' . $fechaInicio->translatedFormat('F') . ' ' . $fechaInicio->format('Y') . ' al ' . $fechaFin->format('d') . ' de ' . $fechaFin->translatedFormat('F'); + $anioTexto = $fechaFin->format('Y'); + } // Fechas $sheet->mergeCells('C9:F9'); @@ -197,7 +210,7 @@ public function constanciasSustituidas(Request $request) // Año $sheet->mergeCells('H9:I9'); - $sheet->setCellValue('H9', $fechaFin->format('Y')); + $sheet->setCellValue('H9', $anioTexto); $sheet->getStyle('H9:I9')->applyFromArray($styleBox); $sheet->getStyle('H9')->getFont()->setSize(14); @@ -448,7 +461,20 @@ public function constanciasCanceladas(Request $request) $sheet->getStyle('A9')->getFont()->setBold(false)->setSize(14); Carbon::setLocale('es'); - $periodoTexto = 'del ' . $fechaInicio->format('d') . ' al ' . $fechaFin->format('d') . ' de ' . $fechaFin->translatedFormat('F'); + // Formato completo para manejar diferentes meses/años + if ($fechaInicio->format('m/Y') === $fechaFin->format('m/Y')) { + // Mismo mes y año + $periodoTexto = 'del ' . $fechaInicio->format('d') . ' al ' . $fechaFin->format('d') . ' de ' . $fechaFin->translatedFormat('F'); + $anioTexto = $fechaFin->format('Y'); + } elseif ($fechaInicio->format('Y') === $fechaFin->format('Y')) { + // Diferente mes, mismo año + $periodoTexto = 'del ' . $fechaInicio->format('d') . ' de ' . $fechaInicio->translatedFormat('F') . ' al ' . $fechaFin->format('d') . ' de ' . $fechaFin->translatedFormat('F'); + $anioTexto = $fechaFin->format('Y'); + } else { + // Diferente año + $periodoTexto = 'del ' . $fechaInicio->format('d') . ' de ' . $fechaInicio->translatedFormat('F') . ' ' . $fechaInicio->format('Y') . ' al ' . $fechaFin->format('d') . ' de ' . $fechaFin->translatedFormat('F'); + $anioTexto = $fechaFin->format('Y'); + } // Fechas (Movemos a D-G) $sheet->mergeCells('D9:G9'); @@ -463,7 +489,7 @@ public function constanciasCanceladas(Request $request) // Año (Movemos a I-J) $sheet->mergeCells('I9:J9'); - $sheet->setCellValue('I9', $fechaFin->format('Y')); + $sheet->setCellValue('I9', $anioTexto); $sheet->getStyle('I9:J9')->applyFromArray($styleBox); $sheet->getStyle('I9')->getFont()->setSize(14); @@ -750,7 +776,20 @@ public function excelGeneral(Request $request) $sheet->getStyle('A9')->applyFromArray($styleLabel); Carbon::setLocale('es'); - $periodoTexto = 'del ' . $fechaInicio->format('d') . ' al ' . $fechaFin->format('d') . ' de ' . $fechaFin->translatedFormat('F'); + // Formato completo para manejar diferentes meses/años + if ($fechaInicio->format('m/Y') === $fechaFin->format('m/Y')) { + // Mismo mes y año + $periodoTexto = 'del ' . $fechaInicio->format('d') . ' al ' . $fechaFin->format('d') . ' de ' . $fechaFin->translatedFormat('F'); + $anioTexto = $fechaFin->format('Y'); + } elseif ($fechaInicio->format('Y') === $fechaFin->format('Y')) { + // Diferente mes, mismo año + $periodoTexto = 'del ' . $fechaInicio->format('d') . ' de ' . $fechaInicio->translatedFormat('F') . ' al ' . $fechaFin->format('d') . ' de ' . $fechaFin->translatedFormat('F'); + $anioTexto = $fechaFin->format('Y'); + } else { + // Diferente año + $periodoTexto = 'del ' . $fechaInicio->format('d') . ' de ' . $fechaInicio->translatedFormat('F') . ' ' . $fechaInicio->format('Y') . ' al ' . $fechaFin->format('d') . ' de ' . $fechaFin->translatedFormat('F'); + $anioTexto = $fechaFin->format('Y'); + } // Fechas (D-G) $sheet->mergeCells('D9:G9'); @@ -765,7 +804,7 @@ public function excelGeneral(Request $request) // Año (I-J) $sheet->mergeCells('I9:J9'); - $sheet->setCellValue('I9', $fechaFin->format('Y')); + $sheet->setCellValue('I9', $anioTexto); $sheet->getStyle('I9:J9')->applyFromArray($styleBox); $sheet->getStyle('I9')->getFont()->setSize(14); @@ -1169,6 +1208,7 @@ public function exportSearchRecords(Request $request) $sheet->getStyle("A{$row}")->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); $sheet->getStyle("D{$row}")->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); $sheet->getStyle("I{$row}")->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); + $sheet->getStyle("J{$row}")->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); $sheet->getStyle("K{$row}")->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); $sheet->getStyle("L{$row}")->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); $sheet->getStyle("M{$row}")->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); diff --git a/app/Http/Controllers/Repuve/InscriptionController.php b/app/Http/Controllers/Repuve/InscriptionController.php index c60e888..d00c612 100644 --- a/app/Http/Controllers/Repuve/InscriptionController.php +++ b/app/Http/Controllers/Repuve/InscriptionController.php @@ -167,7 +167,7 @@ public function vehicleInscription(VehicleStoreRequest $request) VehicleTagLog::create([ 'vehicle_id' => $vehicle->id, 'tag_id' => $tag->id, - 'action_type' => 'inscripcion', + 'action_type' => 'sustitucion', 'performed_by' => Auth::id(), ]); @@ -445,7 +445,7 @@ public function searchRecord(Request $request) 'created_at' => $record->created_at, // TIPO DE TRÁMITE - 'action_type' => $latestLog?->action_type ?? 'inscripcion', + 'action_type' => $latestLog?->action_type ?? 'sustitución', 'action_date' => $latestLog?->created_at ?? $record->created_at, // HISTORIAL DE TAGS