Skip to content

Commit d1a9322

Browse files
committed
feat: Add fields for direct responsible person's name and position in configuracion component
1 parent 0a513ce commit d1a9322

File tree

2 files changed

+139
-20
lines changed

2 files changed

+139
-20
lines changed

src/app/pages/configuracion/configuracion.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,28 @@ <h2 class="text-2xl font-bold text-gray-800">Información del Prestador</h2>
102102
(input)="updateEndDate($any($event.target).value)"
103103
class="w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition duration-150 ease-in-out bg-gray-50 placeholder-gray-400"/>
104104
</div>
105+
<div>
106+
<label class="block text-sm font-medium text-gray-700 mb-2">
107+
<span class="material-symbols-outlined mr-1">person_celebrate</span>
108+
Nombre del responsable directo
109+
</label>
110+
<input type="text"
111+
[value]="config().nombreResponsableDirecto"
112+
(input)="updateNombreResponsableDirecto($any($event.target).value)"
113+
class="w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition duration-150 ease-in-out bg-gray-50 placeholder-gray-400"
114+
placeholder="Pancracia Hernandez"/>
115+
</div>
116+
<div>
117+
<label class="block text-sm font-medium text-gray-700 mb-2">
118+
<span class="material-symbols-outlined mr-1">orders</span>
119+
Cargo del responsable directo
120+
</label>
121+
<input type="text"
122+
[value]="config().cargoResponsableDirecto"
123+
(input)="updateCargoResponsableDirecto($any($event.target).value)"
124+
class="w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition duration-150 ease-in-out bg-gray-50 placeholder-gray-400"
125+
placeholder="Director"/>
126+
</div>
105127
</div>
106128
</div>
107129
}

src/app/pages/configuracion/configuracion.ts

Lines changed: 117 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Component, computed, LOCALE_ID, model, OnInit, signal} from '@angular/core';
22
import {FormsModule} from '@angular/forms';
3-
import {PDFDocument} from 'pdf-lib';
3+
import {PDFDocument, rgb} from 'pdf-lib';
44
import {DomSanitizer, SafeResourceUrl} from '@angular/platform-browser';
55
import moment from 'moment';
66
import 'moment/locale/es';
@@ -20,9 +20,6 @@ export interface ReportConfig {
2020
vacationDates: string[];
2121
reportType: string;
2222
department: string;
23-
includeStatistics: boolean;
24-
25-
// Nuevos campos
2623
reporteNo: string;
2724
nombrePrestador: string;
2825
unidadAcademica: string;
@@ -31,6 +28,8 @@ export interface ReportConfig {
3128
noReporteMensual: string;
3229
periodoDel: string;
3330
periodoAl: string;
31+
nombreResponsableDirecto: string;
32+
cargoResponsableDirecto: string;
3433
asistencia: AsistenciaDia[];
3534
totalHorasMes: string;
3635
totalHorasAcumuladas: string;
@@ -80,7 +79,7 @@ interface ReporteGenerado {
8079
templateUrl: './configuracion.html',
8180
styleUrl: './configuracion.scss',
8281
})
83-
export class Configuracion{
82+
export class Configuracion {
8483
currentStep = signal(1);
8584
config = signal<ReportConfig>(config);
8685

@@ -97,10 +96,10 @@ export class Configuracion{
9796

9897
horariosServicio: hosrariosServicio[] = [
9998
{day: 'monday', entrada: '07:00', salida: '11:00'},
100-
{day: 'tuesday',entrada: '12:00', salida: '16:00'},
101-
{day: 'wednesday',entrada: '10:00', salida: '14:00'},
102-
{day: 'thursday',entrada: '07:00', salida: '11:00'},
103-
{day: 'friday',entrada: '16:00', salida: '20:00'},
99+
{day: 'tuesday', entrada: '12:00', salida: '16:00'},
100+
{day: 'wednesday', entrada: '10:00', salida: '14:00'},
101+
{day: 'thursday', entrada: '07:00', salida: '11:00'},
102+
{day: 'friday', entrada: '16:00', salida: '20:00'},
104103
];
105104

106105
days: daysOfWeek[] = [
@@ -295,6 +294,41 @@ export class Configuracion{
295294
form.getTextField('Carrera').setText(this.config().carrera);
296295
form.getTextField('Boleta').setText(this.config().boleta);
297296

297+
// Campos del responsable directo - agregar texto por coordenadas si no existen los campos
298+
// if (this.campoExiste(form, 'Nombre Responsable')) {
299+
// form.getTextField('Nombre Responsable').setText(this.config().nombreResponsableDirecto);
300+
// } else {
301+
// Agregar texto directamente por coordenadas (parte inferior izquierda)
302+
const pages = pdfDoc.getPages();
303+
const firstPage = pages[0];
304+
305+
if (this.config().nombreResponsableDirecto) {
306+
firstPage.drawText(`${this.config().nombreResponsableDirecto}`, {
307+
x: -20,
308+
y: 10,
309+
size: 12,
310+
color: rgb(0, 0, 0)
311+
});
312+
}
313+
// }
314+
315+
// if (this.campoExiste(form, 'Cargo Responsable')) {
316+
// form.getTextField('Cargo Responsable').setText(this.config().cargoResponsableDirecto);
317+
// } else {
318+
// Agregar texto directamente por coordenadas (debajo del nombre)
319+
// const pages = pdfDoc.getPages();
320+
// const firstPage = pages[0];
321+
322+
if (this.config().cargoResponsableDirecto) {
323+
firstPage.drawText(`Cargo: ${this.config().cargoResponsableDirecto}`, {
324+
x: -20,
325+
y: -5,
326+
size: 12,
327+
color: rgb(0, 0, 0)
328+
});
329+
}
330+
// }
331+
298332
// Campos de la Tabla de Asistencia - Limitar a los campos disponibles
299333
const maxCampos = this.obtenerMaximoCamposDisponibles(form);
300334
const diasAMostrar = Math.min(this.config().asistencia.length, maxCampos);
@@ -463,7 +497,7 @@ export class Configuracion{
463497
}
464498
}
465499

466-
const zipBlob = await zip.generateAsync({ type: 'blob' });
500+
const zipBlob = await zip.generateAsync({type: 'blob'});
467501

468502
const url = URL.createObjectURL(zipBlob);
469503
const a = document.createElement('a');
@@ -840,6 +874,28 @@ export class Configuracion{
840874
form.getTextField('Carrera').setText(report.student.career);
841875
form.getTextField('Boleta').setText(this.config().boleta);
842876

877+
878+
const pages = pdfDoc.getPages();
879+
const firstPage = pages[0];
880+
881+
if (this.config().nombreResponsableDirecto) {
882+
firstPage.drawText(`${this.config().nombreResponsableDirecto}`, {
883+
x: usarTestPdf ? 28 : 28,
884+
y: usarTestPdf ? 40 : 60,
885+
size: 12,
886+
color: rgb(0, 0, 0)
887+
});
888+
}
889+
890+
if (this.config().cargoResponsableDirecto) {
891+
firstPage.drawText(`${this.config().cargoResponsableDirecto}`, {
892+
x: usarTestPdf ? 28 : 28,
893+
y: usarTestPdf ? 25 : 45,
894+
size: 12,
895+
color: rgb(0, 0, 0)
896+
});
897+
}
898+
843899
// Campos de la Tabla de Asistencia
844900
const maxCampos = this.obtenerMaximoCamposDisponibles(form);
845901
const diasAMostrar = Math.min(report.asistencia.length, maxCampos);
@@ -884,14 +940,14 @@ export class Configuracion{
884940
.setText(horasAcumuladas.toString());
885941

886942
const pdfBytes = await pdfDoc.save();
887-
const blob = new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' });
943+
const blob = new Blob([new Uint8Array(pdfBytes)], {type: 'application/pdf'});
888944
const urlBlob = URL.createObjectURL(blob);
889945

890946
// Actualizar el reporte con la nueva URL
891947
const reportes = this.reports();
892948
const updatedReportes = reportes.map(r =>
893949
r.id === report.id
894-
? { ...r, pdfUrl: this.sanitizer.bypassSecurityTrustResourceUrl(urlBlob) }
950+
? {...r, pdfUrl: this.sanitizer.bypassSecurityTrustResourceUrl(urlBlob)}
895951
: r
896952
);
897953
this.reports.set(updatedReportes);
@@ -956,6 +1012,39 @@ export class Configuracion{
9561012
form.getTextField('Carrera').setText(report.student.career);
9571013
form.getTextField('Boleta').setText(this.config().boleta);
9581014

1015+
// Campos del responsable directo - agregar texto por coordenadas si no existen
1016+
if (this.campoExiste(form, 'Nombre Responsable')) {
1017+
form.getTextField('Nombre Responsable').setText(this.config().nombreResponsableDirecto);
1018+
} else {
1019+
const pages = pdfDoc.getPages();
1020+
const firstPage = pages[0];
1021+
1022+
if (this.config().nombreResponsableDirecto) {
1023+
firstPage.drawText(`Nombre del Responsable Directo: ${this.config().nombreResponsableDirecto}`, {
1024+
x: 50,
1025+
y: 80,
1026+
size: 10,
1027+
color: rgb(0, 0, 0)
1028+
});
1029+
}
1030+
}
1031+
1032+
if (this.campoExiste(form, 'Cargo Responsable')) {
1033+
form.getTextField('Cargo Responsable').setText(this.config().cargoResponsableDirecto);
1034+
} else {
1035+
const pages = pdfDoc.getPages();
1036+
const firstPage = pages[0];
1037+
1038+
if (this.config().cargoResponsableDirecto) {
1039+
firstPage.drawText(`Cargo: ${this.config().cargoResponsableDirecto}`, {
1040+
x: 50,
1041+
y: 65,
1042+
size: 10,
1043+
color: rgb(0, 0, 0)
1044+
});
1045+
}
1046+
}
1047+
9591048
const maxCampos = this.obtenerMaximoCamposDisponibles(form);
9601049
const diasAMostrar = Math.min(report.asistencia.length, maxCampos);
9611050

@@ -1002,27 +1091,35 @@ export class Configuracion{
10021091

10031092
// Métodos para actualizar los campos del config
10041093
updateBoleta(value: string) {
1005-
this.config.set({ ...this.config(), boleta: value });
1094+
this.config.set({...this.config(), boleta: value});
10061095
}
10071096

10081097
updateNombrePrestador(value: string) {
1009-
this.config.set({ ...this.config(), nombrePrestador: value });
1098+
this.config.set({...this.config(), nombrePrestador: value});
10101099
}
10111100

10121101
updateUnidadAcademica(value: string) {
1013-
this.config.set({ ...this.config(), unidadAcademica: value });
1102+
this.config.set({...this.config(), unidadAcademica: value});
10141103
}
10151104

10161105
updateCarrera(value: string) {
1017-
this.config.set({ ...this.config(), carrera: value });
1106+
this.config.set({...this.config(), carrera: value});
10181107
}
10191108

10201109
updateStartDate(value: string) {
1021-
this.config.set({ ...this.config(), startDate: value });
1110+
this.config.set({...this.config(), startDate: value});
10221111
}
10231112

10241113
updateEndDate(value: string) {
1025-
this.config.set({ ...this.config(), endDate: value });
1114+
this.config.set({...this.config(), endDate: value});
1115+
}
1116+
1117+
updateNombreResponsableDirecto(value: string) {
1118+
this.config.set({...this.config(), nombreResponsableDirecto: value});
1119+
}
1120+
1121+
updateCargoResponsableDirecto(value: string) {
1122+
this.config.set({...this.config(), cargoResponsableDirecto: value});
10261123
}
10271124
}
10281125

@@ -1041,11 +1138,11 @@ const config: ReportConfig = {
10411138
vacationDates: [],
10421139
reportType: '',
10431140
department: '',
1044-
includeStatistics: false,
1045-
10461141
reporteNo: '',
10471142
nombrePrestador: '',
10481143
unidadAcademica: '',
1144+
cargoResponsableDirecto: '',
1145+
nombreResponsableDirecto: '',
10491146
carrera: '',
10501147
boleta: '',
10511148
noReporteMensual: '',

0 commit comments

Comments
 (0)