Rollback to eebcb648
This commit is contained in:
@@ -36,16 +36,9 @@ interface ApprenantPresence {
|
||||
dateFormationId: number;
|
||||
periode: 'matin' | 'apres_midi';
|
||||
signatureUrl: string | null;
|
||||
typeUtilisateur?: 'apprenant' | 'formateur';
|
||||
}>;
|
||||
}
|
||||
|
||||
interface FormateurPresence {
|
||||
dateFormationId: number;
|
||||
periode: 'matin' | 'apres_midi';
|
||||
signatureUrl: string | null;
|
||||
}
|
||||
|
||||
interface FeuillePresenceInfo {
|
||||
formationNom: string;
|
||||
sequenceNom: string;
|
||||
@@ -54,7 +47,6 @@ interface FeuillePresenceInfo {
|
||||
publicCible: string;
|
||||
formateur?: string;
|
||||
apprenants: ApprenantPresence[];
|
||||
presencesFormateur?: FormateurPresence[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,56 +301,14 @@ export function generateFeuillePresence(feuilleInfo: FeuillePresenceInfo): Buffe
|
||||
doc.text('Signatures du formateur :', 14, signatureY);
|
||||
doc.setFont('helvetica', 'normal');
|
||||
|
||||
// Trouver les signatures du formateur pour cette date
|
||||
const presenceFormateurMatin = feuilleInfo.presencesFormateur?.find(
|
||||
p => p.dateFormationId === dateInfo.id && p.periode === 'matin'
|
||||
);
|
||||
const presenceFormateurApresMidi = feuilleInfo.presencesFormateur?.find(
|
||||
p => p.dateFormationId === dateInfo.id && p.periode === 'apres_midi'
|
||||
);
|
||||
|
||||
// Signature Matin
|
||||
doc.setFontSize(9);
|
||||
doc.text('Matin :', 14, signatureY + 8);
|
||||
|
||||
if (presenceFormateurMatin?.signatureUrl) {
|
||||
try {
|
||||
const signaturePath = path.resolve(process.cwd(), presenceFormateurMatin.signatureUrl.substring(1));
|
||||
if (fs.existsSync(signaturePath)) {
|
||||
const signatureBuffer = fs.readFileSync(signaturePath);
|
||||
const signatureBase64 = `data:image/png;base64,${signatureBuffer.toString('base64')}`;
|
||||
doc.addImage(signatureBase64, 'PNG', 30, signatureY + 2, 55, 10);
|
||||
} else {
|
||||
doc.line(30, signatureY + 8, 90, signatureY + 8);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erreur lors du chargement de la signature formateur matin:', error);
|
||||
doc.line(30, signatureY + 8, 90, signatureY + 8);
|
||||
}
|
||||
} else {
|
||||
doc.line(30, signatureY + 8, 90, signatureY + 8);
|
||||
}
|
||||
doc.line(30, signatureY + 8, 90, signatureY + 8);
|
||||
|
||||
// Signature Après-midi
|
||||
doc.text('Après-midi :', 110, signatureY + 8);
|
||||
|
||||
if (presenceFormateurApresMidi?.signatureUrl) {
|
||||
try {
|
||||
const signaturePath = path.resolve(process.cwd(), presenceFormateurApresMidi.signatureUrl.substring(1));
|
||||
if (fs.existsSync(signaturePath)) {
|
||||
const signatureBuffer = fs.readFileSync(signaturePath);
|
||||
const signatureBase64 = `data:image/png;base64,${signatureBuffer.toString('base64')}`;
|
||||
doc.addImage(signatureBase64, 'PNG', 140, signatureY + 2, 55, 10);
|
||||
} else {
|
||||
doc.line(140, signatureY + 8, 200, signatureY + 8);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erreur lors du chargement de la signature formateur après-midi:', error);
|
||||
doc.line(140, signatureY + 8, 200, signatureY + 8);
|
||||
}
|
||||
} else {
|
||||
doc.line(140, signatureY + 8, 200, signatureY + 8);
|
||||
}
|
||||
doc.line(140, signatureY + 8, 200, signatureY + 8);
|
||||
};
|
||||
|
||||
// Générer une page pour chaque date
|
||||
|
||||
Reference in New Issue
Block a user