amélioration génération pdf depuis html

FossilOrigin-Name: 996c3a9ad1c56e94c83b77c74aa804ccc3ff2eb7e0f4ea90f885882a801a6a32
This commit is contained in:
engel 2022-02-22 09:47:54 +00:00
parent 057357a58d
commit 5d439d25af
5 changed files with 297 additions and 233 deletions

View file

@ -2,7 +2,7 @@
namespace Garradin;
use Garradin\Plugin\RecusFiscaux\HtmlPDF;
use Garradin\Plugin\RecusFiscaux\RecusHTML;
use Garradin\Plugin\RecusFiscaux\Utils;
use Garradin\Plugin\RecusFiscaux\Personne;
@ -21,21 +21,16 @@ $totalPersonnes = cumulerVersements($versementsSelectionnes);
$nomAsso = Utils::getNomAsso();
$adresseAsso = Utils::getAdresseAsso();
// TODO
// - associer le taux de réduction à chaque montant total
// récupérer le logo CERFA (bôf) et la signature
$logoCERFA = PLUGIN_ROOT . "/data/logoCerfa.png";
$signature = PLUGIN_ROOT . "/data/default_signature.png";
$listeFichiers = [];
foreach ($totalPersonnes as $idPersonne => $personne) {
foreach ($totalPersonnes as $idPersonne => $personne)
{
// générer un fichier par reçu
$pdf = new HtmlPDF(
$html = new RecusHTML(
$nomAsso,
$adresseAsso,
$plugin->getConfig('objet_asso'),
$logoCERFA,
$signature
);
// extraire les montants des versements
@ -49,7 +44,7 @@ foreach ($totalPersonnes as $idPersonne => $personne) {
$lesMontants[$versement->tauxReduction] = $versement->montant;
}
}
$pdf->imprimer_recu(
$html->imprimer_recu(
$_SESSION['annee_recu'],
$personne->id,
$personne->nomPrenom,
@ -58,10 +53,19 @@ foreach ($totalPersonnes as $idPersonne => $personne) {
$personne->codePostal,
$personne->ville
);
/*
$html->get();
*/
// fabriquer le fichier PDF
$nomFichier = \Garradin\Utils::filePDF($pdf->get());
$nomPDF = \Garradin\Utils::filePDF($html->get());
// changer le nom du fichier
$nom = str_replace(' ', '_', $personne->nomPrenom);
$nom = str_replace("'", "", $nom);
$nomFichier = "recu_" . $_SESSION['annee_recu'] . "_" . $nom . ".pdf";
rename($nomPDF, $nomFichier);
// ajouter le nom du fichier à la liste pour mettre dans une archive
$listeFichiers[] = $nomFichier;
}
// faire une archive zip