From dfb60806cb1079186b8913e5e5c16b76c997725e Mon Sep 17 00:00:00 2001 From: Juan Felipe Zapata Moreno Date: Tue, 25 Nov 2025 22:09:37 -0600 Subject: [PATCH] feat: Add module_id to records and telefono to owners, implement PDF form generation, and update PDF views for better layout and data presentation. --- .../Repuve/InscriptionController.php | 1 + .../Controllers/Repuve/RecordController.php | 43 ++- app/Models/Owner.php | 1 + app/Models/Record.php | 6 + ..._200950_add_module_id_to_records_table.php | 33 ++ ...25_203741_add_telefono_to_owners_table.php | 28 ++ resources/views/pdfs/constancia.blade.php | 268 ++++++++-------- resources/views/pdfs/form.blade.php | 287 ++++++++++++++++++ resources/views/pdfs/record.blade.php | 77 ++--- resources/views/pdfs/verification.blade.php | 60 +--- routes/api.php | 1 + 11 files changed, 575 insertions(+), 230 deletions(-) create mode 100644 database/migrations/2025_11_25_200950_add_module_id_to_records_table.php create mode 100644 database/migrations/2025_11_25_203741_add_telefono_to_owners_table.php create mode 100644 resources/views/pdfs/form.blade.php diff --git a/app/Http/Controllers/Repuve/InscriptionController.php b/app/Http/Controllers/Repuve/InscriptionController.php index bb7ab69..ea05cec 100644 --- a/app/Http/Controllers/Repuve/InscriptionController.php +++ b/app/Http/Controllers/Repuve/InscriptionController.php @@ -133,6 +133,7 @@ public function vehicleInscription(VehicleStoreRequest $request) 'folio' => $folio, 'vehicle_id' => $vehicle->id, 'user_id' => Auth::id(), + 'module_id' => Auth::user()->module_id, ]); // Procesar archivos diff --git a/app/Http/Controllers/Repuve/RecordController.php b/app/Http/Controllers/Repuve/RecordController.php index e6e0ad0..094179a 100644 --- a/app/Http/Controllers/Repuve/RecordController.php +++ b/app/Http/Controllers/Repuve/RecordController.php @@ -14,7 +14,7 @@ class RecordController extends Controller { public function generatePdf($id) { - $record = Record::with('vehicle')->findOrFail($id); + $record = Record::with('vehicle.owner', 'user', 'module')->findOrFail($id); $pdf = Pdf::loadView('pdfs.record', compact('record')) ->setPaper('a4', 'portrait') @@ -179,6 +179,47 @@ public function generatePdfImages($id) } } + public function generatePdfForm(Request $request) + { + $request->validate([ + 'fecha' => 'nullable|string', + 'mes' => 'nullable|string', + 'anio' => 'nullable|string', + 'marca' => 'required|string', + 'linea' => 'required|string', + 'modelo' => 'required|string', + 'niv' => 'required|string', + 'numero_motor' => 'required|string', + 'placa' => 'required|string', + 'folio' => 'required|string', + 'telefono' => 'nullable|string', + ]); + + $data = [ + 'fecha' => $request->input('fecha', ''), + 'mes' => $request->input('mes', ''), + 'anio' => $request->input('anio', ''), + 'marca' => $request->input('marca'), + 'linea' => $request->input('linea'), + 'modelo' => $request->input('modelo'), + 'niv' => $request->input('niv'), + 'numero_motor' => $request->input('numero_motor'), + 'placa' => $request->input('placa'), + 'folio' => $request->input('folio'), + 'telefono' => $request->input('telefono', ''), + ]; + + $pdf = Pdf::loadView('pdfs.form', $data) + ->setPaper('a4', 'portrait') + ->setOptions([ + 'defaultFont' => 'sans-serif', + 'isHtml5ParserEnabled' => true, + 'isRemoteEnabled' => true, + ]); + + return $pdf->stream('solicitud-sustitucion-' . time() . '.pdf'); + } + public function errors(Request $request) { $request->validate([ diff --git a/app/Models/Owner.php b/app/Models/Owner.php index e372750..c5bbfeb 100644 --- a/app/Models/Owner.php +++ b/app/Models/Owner.php @@ -27,6 +27,7 @@ class Owner extends Model 'num_int', 'colonia', 'cp', + 'telefono', ]; protected $appends = [ diff --git a/app/Models/Record.php b/app/Models/Record.php index 574f21b..416e981 100644 --- a/app/Models/Record.php +++ b/app/Models/Record.php @@ -13,6 +13,7 @@ class Record extends Model 'folio', 'vehicle_id', 'user_id', + 'module_id', 'error_id', 'api_response', 'error_occurred_at', @@ -42,4 +43,9 @@ public function error() { return $this->belongsTo(Error::class); } + + public function module() + { + return $this->belongsTo(Module::class); + } } diff --git a/database/migrations/2025_11_25_200950_add_module_id_to_records_table.php b/database/migrations/2025_11_25_200950_add_module_id_to_records_table.php new file mode 100644 index 0000000..887c7b1 --- /dev/null +++ b/database/migrations/2025_11_25_200950_add_module_id_to_records_table.php @@ -0,0 +1,33 @@ +foreignId('module_id') + ->nullable() + ->after('user_id') + ->constrained('modules') + ->nullOnDelete(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('records', function (Blueprint $table) { + $table->dropForeign(['module_id']); + $table->dropColumn('module_id'); + }); + } +}; diff --git a/database/migrations/2025_11_25_203741_add_telefono_to_owners_table.php b/database/migrations/2025_11_25_203741_add_telefono_to_owners_table.php new file mode 100644 index 0000000..b8f6447 --- /dev/null +++ b/database/migrations/2025_11_25_203741_add_telefono_to_owners_table.php @@ -0,0 +1,28 @@ +string('telefono')->nullable()->after('cp'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('owners', function (Blueprint $table) { + $table->dropColumn('telefono'); + }); + } +}; diff --git a/resources/views/pdfs/constancia.blade.php b/resources/views/pdfs/constancia.blade.php index 70e789b..573a093 100644 --- a/resources/views/pdfs/constancia.blade.php +++ b/resources/views/pdfs/constancia.blade.php @@ -6,174 +6,192 @@ Etiquetas Vehiculares
- -
-
- -
- {!! DNS1D::getBarcodeHTML($record->vehicle->niv, 'C128', 2, 60) !!} -
- {{ $record->vehicle->niv }} -
-
+ - -
-
-
-
{{ $record->vehicle->placa }}
-
-
-
{{ strtoupper($record->vehicle->marca) }}
-
-
-
-
{{ strtoupper($record->vehicle->linea) }}
-
{{ $record->vehicle->modelo }}
-
-
-
{{ strtoupper($record->vehicle->tipo) }}
-
-
-
- - -
- {{ strtoupper($record->vehicle->owner->full_name) }} -
- - -
- {{ strtoupper($record->vehicle->owner->address) }} -
-
+ +
+ {{ $record->vehicle->niv }}
- -
-
- -
- {!! DNS1D::getBarcodeHTML($record->vehicle->niv, 'C128', 2, 60) !!} -
- {{ $record->vehicle->niv }} -
-
+ +
+ {{ strtoupper($record->vehicle->placa) }} +
- -
-
-
-
{{ $record->vehicle->placa }}
-
-
-
{{ strtoupper($record->vehicle->marca) }}
-
-
-
-
{{ strtoupper($record->vehicle->linea) }}
-
{{ $record->vehicle->modelo }}
-
-
-
{{ strtoupper($record->vehicle->tipo_veh) }}
-
-
-
+ +
+ {{ strtoupper($record->vehicle->marca) }} +
- -
- {{ strtoupper($record->vehicle->owner->full_name) }} -
+ +
+ {{ strtoupper($record->vehicle->linea) }} + {{ $record->vehicle->modelo }} +
- -
- {{ strtoupper($record->vehicle->owner->address) }} -
-
+ +
+ {{ strtoupper($record->vehicle->owner->full_name) }} +
+ + +
+ {{ strtoupper($record->vehicle->owner->callep ?? '') }} + {{ $record->vehicle->owner->num_ext }} +
+ + +
+ {{ strtoupper($record->vehicle->owner->colonia ?? '') }} +
+ + + + + +
+ {{ $record->vehicle->niv }} +
+ + +
+ {{ strtoupper($record->vehicle->placa) }} +
+ + +
+ {{ strtoupper($record->vehicle->marca) }} +
+ + +
+ {{ strtoupper($record->vehicle->linea) }} + {{ $record->vehicle->modelo }} +
+ + +
+ {{ strtoupper($record->vehicle->tipo_veh) }}
diff --git a/resources/views/pdfs/form.blade.php b/resources/views/pdfs/form.blade.php new file mode 100644 index 0000000..6176c6f --- /dev/null +++ b/resources/views/pdfs/form.blade.php @@ -0,0 +1,287 @@ + + + + + + Solicitud de Sustitución de Constancia de Inscripción + + + + +
+ +
+ + + + + + +
+ + + + SEGURIDAD + SECRETARÍA DE SEGURIDAD
Y PROTECCIÓN CIUDADANA +
+
+ + + + + +
+ Solicitud de Sustitución de Constancia de Inscripción +
+ + +
+ Departamento del REPUVE del Estado de Tabasco +
+
+ P R E S E N T E +
+ + +
+ Por este medio me permito solicitar el cambio de constancia de inscripción a mi vehículo + con los siguientes datos: +
+ + +
+ Marca: {{ strtoupper($marca ?? '') }} +
+ +
+ Modelo: {{ strtoupper($linea ?? '') }} +
+ +
+ Año Modelo: {{ $modelo ?? '' }} +
+ +
+ Número de Identificación (NIV): {{ strtoupper($niv ?? '') }} +
+ +
+ Número de Motor: {{ strtoupper($numero_motor ?? '') }} +
+ +
+ Placas: {{ strtoupper($placa ?? '') }} +
+ +
+ Folio de Constancia de Inscripción: {{ strtoupper($folio ?? '') }} +
+ + +
+ MOTIVO +
+ +
+
+
+
+
+
+
+ + +
+ PROPIETARIO +
+ + +
+
+
Nombre y firma
+
+
+ + +
+ Teléfono:{{ $telefono ?? '' }} +
+
+ + + diff --git a/resources/views/pdfs/record.blade.php b/resources/views/pdfs/record.blade.php index 55b3dd8..ce78447 100644 --- a/resources/views/pdfs/record.blade.php +++ b/resources/views/pdfs/record.blade.php @@ -94,28 +94,18 @@ } .owner-section { - margin: 25px 0; - border: 1px solid #000; - padding: 15px; - } - - .owner-section h3 { - font-size: 10pt; - font-weight: bold; - margin-bottom: 12px; - border-bottom: 1px solid #000; - padding-bottom: 5px; + margin: 15px 0; } .data-row { - margin-bottom: 10px; + margin-bottom: 9px; font-size: 10pt; } .data-label { font-weight: bold; display: inline-block; - width: 100px; + min-width: 100px; } .address-row { @@ -123,19 +113,16 @@ font-size: 10pt; } - .date-section { - text-align: center; - margin: 40px 0 80px 0; - font-size: 10pt; - } - - .date-section .underline { - text-decoration: underline; - padding: 0 5px; - } - .signatures { - margin-top: 100px; + margin-top: 60px; + } + + .footer-registro { + text-align: center; + margin-top: 15px; + color: red; + font-weight: bold; + font-size: 9pt; } .signature-table { @@ -210,42 +197,37 @@
-

DATOS DE PROPIETARIO

-
RFC: - {{ $record->vehicle->owner->rfc }} + {{ $record->vehicle->owner->rfc ?? '' }}
NOMBRE: - {{$record->vehicle->owner->full_name }} + {{ $record->vehicle->owner->full_name ?? '' }}
-
+
CALLE: - {{ $record->vehicle->owner->address }} + {{ $record->vehicle->owner->callep ?? '' }} + No Ext: {{ $record->vehicle->owner->num_ext ?? '' }} + No Int: {{ $record->vehicle->owner->num_int ?? '' }}
COLONIA: - {{ $record->vehicle->owner->address }} + {{ $record->vehicle->owner->colonia ?? '' }}
MUNICIPIO: - {{ $record->vehicle->municipio }} + {{ $record->vehicle->owner->munic ?? '' }}
-
- -
-

- VILLAHERMOSA, TAB - {{ now()->format('d') }} de - {{ ucfirst(now()->translatedFormat('F')) }} de - {{ now()->format('Y') }} -

+
+ NUMERO TELEFONICO: + {{ $record->vehicle->owner->telefono ?? '' }} +
@@ -254,17 +236,20 @@
-

{{ $record->vehicle->owner->full_name }}

-

Propietario

+

PROPIETARIO

-

{{ $record->user->full_name }}

-

Operador

+

OPERADOR

+ + +
diff --git a/resources/views/pdfs/verification.blade.php b/resources/views/pdfs/verification.blade.php index 8c1d02e..3ce9e1a 100644 --- a/resources/views/pdfs/verification.blade.php +++ b/resources/views/pdfs/verification.blade.php @@ -35,25 +35,6 @@ padding: 2px 0; } - .vehicle-info { - margin-bottom: 10px; - } - - .info-row { - display: table; - width: 100%; - margin-bottom: 5px; - } - - .info-cell { - display: table-cell; - width: 50%; - padding: 2px 5px; - } - - .info-label { - font-weight: bold; - } .signature-section { position: absolute; @@ -62,6 +43,7 @@ width: 180px; text-align: center; padding: 1px; + margin-bottom: 50px; } .signature-line { @@ -78,7 +60,7 @@ table { width: 100%; border-collapse: collapse; - margin-top: 1px; + margin-top: 86px; } table th { @@ -132,44 +114,6 @@

HOJA DE VERIFICACION VEHICULAR

- - -
-
-
- Placa: {{ $record->vehicle->placa }} -
-
- NIV: {{ $record->vehicle->niv }} -
-
- -
-
- Marca: {{ strtoupper($record->vehicle->marca) }} -
-
- Sub Marca: {{ strtoupper($record->vehicle->linea) }} -
-
- -
-
- Modelo: {{ $record->vehicle->modelo }} -
-
- Tipo: {{ strtoupper($record->vehicle->tipo_servicio) }} -
-
- -
-
-
- Tipo Vehi: {{ strtoupper($record->vehicle->tipo_veh) }} -
-
-
-
diff --git a/routes/api.php b/routes/api.php index 45957c6..253a3cb 100644 --- a/routes/api.php +++ b/routes/api.php @@ -38,6 +38,7 @@ Route::get('expediente/{id}/pdfVerificacion', [RecordController::class, 'generatePdfVerification']); Route::get('expediente/{id}/pdfConstancia', [RecordController::class, 'generatePdfConstancia']); Route::get('expediente/{id}/pdfImagenes', [RecordController::class, 'generatePdfImages']); + Route::post('expediente/pdfFormulario', [RecordController::class, 'generatePdfForm']); Route::get('RecordErrors', [RecordController::class, 'errors']); //Rutas de Actualización