Génération reçus avec squelette brindille
FossilOrigin-Name: d9f628dbf847efbfe4cbd9fbaf67a88c50375b0edafd9e7fe4259eb0d03e0230
This commit is contained in:
parent
5033a3bce6
commit
8bde972727
4 changed files with 243 additions and 311 deletions
|
|
@ -130,6 +130,7 @@ $tpl->register_function('afficher_versement', function ($params)
|
|||
});
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// aiguillage
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ($_GET['action'] == 'personne') {
|
||||
|
|
|
|||
|
|
@ -4,15 +4,54 @@ namespace Garradin;
|
|||
|
||||
use Garradin\Files\Files;
|
||||
use Garradin\Entities\Files\File;
|
||||
use Garradin\UserTemplate\UserTemplate;
|
||||
|
||||
use Garradin\Plugin\RecusFiscaux\RecusHTML;
|
||||
//use Garradin\Plugin\RecusFiscaux\RecusHTML;
|
||||
use Garradin\Plugin\RecusFiscaux\Utils;
|
||||
use Garradin\Plugin\RecusFiscaux\Personne;
|
||||
|
||||
// récupérer les lignes sélectionnées
|
||||
$lesLignes = f('selected');
|
||||
// signature
|
||||
$signature =
|
||||
(null !== $plugin->getConfig('signature')) ?
|
||||
Files::get($plugin->getConfig('signature'))->fullpath() :
|
||||
"";
|
||||
|
||||
// logo
|
||||
$logo_file = Files::get(File::CONTEXT_CONFIG . '/logo.png');
|
||||
$logo_asso =
|
||||
(null !== $logo_file) ?
|
||||
Files::get($logo_file->path)->fullpath() :
|
||||
"";
|
||||
|
||||
// articles du CGI
|
||||
$articlesCGI = array();
|
||||
foreach ($plugin->getConfig('articlesCGI') as $article)
|
||||
{
|
||||
if ($article->valeur == 1) {
|
||||
$articlesCGI[] = $article->titre;
|
||||
}
|
||||
}
|
||||
$nbArticles = count($articlesCGI);
|
||||
if ($nbArticles == 1)
|
||||
{
|
||||
$texteArticles = 'à l’article ' . $articlesCGI[0];
|
||||
}
|
||||
elseif ($nbArticles > 1)
|
||||
{
|
||||
$texteArticles = 'aux articles ';
|
||||
for ($i = 0; $i < $nbArticles; ++$i) {
|
||||
$texteArticles .= $articlesCGI[$i];
|
||||
if ($i < $nbArticles - 2) {
|
||||
$texteArticles .= ", ";
|
||||
}
|
||||
else if ($i == $nbArticles - 2) {
|
||||
$texteArticles .= " et ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// filtrer les versements sélectionnés
|
||||
$lesLignes = f('selected');
|
||||
$versementsSelectionnes = array();
|
||||
foreach ($lesLignes as $ligne) {
|
||||
$versementsSelectionnes[] = $_SESSION['lesVersements'][$ligne];
|
||||
|
|
@ -28,69 +67,77 @@ elseif ($_GET['type'] == 'activite')
|
|||
$totalPersonnes = cumulerVersementsTarif($versementsSelectionnes);
|
||||
}
|
||||
|
||||
// informations pour les reçus
|
||||
$nomAsso = $config->get('nom_asso');
|
||||
$adresseAsso = $config->get('adresse_asso');
|
||||
$signature =
|
||||
(null !== $plugin->getConfig('signature')) ?
|
||||
Files::get($plugin->getConfig('signature'))->fullpath() :
|
||||
"";
|
||||
|
||||
// logo
|
||||
$logo_file = Files::get(File::CONTEXT_CONFIG . '/logo.png');
|
||||
$logoAsso =
|
||||
(null !== $logo_file) ?
|
||||
Files::get($logo_file->path)->fullpath() :
|
||||
"";
|
||||
|
||||
// articles du CGI
|
||||
$articlesCGI = array();
|
||||
foreach ($plugin->getConfig('articlesCGI') as $article)
|
||||
{
|
||||
if ($article->valeur == 1) {
|
||||
$articlesCGI[] = $article->titre;
|
||||
}
|
||||
}
|
||||
|
||||
// générer les reçus
|
||||
$listeFichiers = array(); // fichiers pdf générés
|
||||
$listeFichiersPDF = array();
|
||||
foreach ($totalPersonnes as $idPersonne => $personne)
|
||||
{
|
||||
$html = new RecusHTML(
|
||||
$nomAsso,
|
||||
$adresseAsso,
|
||||
$logoAsso,
|
||||
$plugin->getConfig('objet_asso'),
|
||||
$plugin->getConfig('nom_responsable'),
|
||||
$plugin->getConfig('fonction_responsable'),
|
||||
$plugin->getConfig('ville_asso'),
|
||||
$articlesCGI,
|
||||
$signature
|
||||
);
|
||||
$tpl = new UserTemplate();
|
||||
$tpl->setSource(PLUGIN_ROOT . '/templates/recu.skel');
|
||||
|
||||
$html->imprimer_recu(
|
||||
$_SESSION['annee_recu'],
|
||||
$personne->id,
|
||||
$personne->nomPrenom,
|
||||
$personne->versements,
|
||||
$personne->adresse,
|
||||
$personne->codePostal,
|
||||
$personne->ville
|
||||
$tpl->assignArray(compact('signature', 'logo_asso', 'texteArticles'));
|
||||
$tpl->assign('objet_asso', $plugin->getConfig('objet_asso'));
|
||||
$tpl->assign('nom_responsable', $plugin->getConfig('nom_responsable'));
|
||||
$tpl->assign('fonction_responsable', $plugin->getConfig('fonction_responsable'));
|
||||
$tpl->assign('ville_asso', $plugin->getConfig('ville_asso'));
|
||||
$tpl->assign('annee_recu', $_SESSION['annee_recu']);
|
||||
$tpl->assign('numero', $personne->id);
|
||||
$tpl->assign('nom', $personne->nomPrenom);
|
||||
$tpl->assign('adresse', $personne->adresse);
|
||||
$tpl->assign('code_postal', $personne->codePostal);
|
||||
$tpl->assign('ville', $personne->ville);
|
||||
$tpl->assign('date', date("j/m/Y"));
|
||||
|
||||
// les versements
|
||||
$tpl->registerSection('versements',
|
||||
function () use($personne)
|
||||
{
|
||||
foreach ($personne->versements as $taux => $montant)
|
||||
{
|
||||
$ligne['montant'] = $montant;
|
||||
$ligne['libelle'] = Utils::getLigneReduction($taux);
|
||||
yield $ligne;
|
||||
}
|
||||
});
|
||||
|
||||
// mentions complémentaires
|
||||
$donnees = array(
|
||||
'Date des versements : ' => "année " . $_SESSION['annee_recu'],
|
||||
'Nature du don : ' => "Numéraire",
|
||||
'Mode de versement : ' => "chèque et/ou virement"
|
||||
);
|
||||
$infos = array();
|
||||
foreach ($donnees as $titre => $libelle)
|
||||
{
|
||||
$elem = new \stdClass();
|
||||
$elem->titre = $titre;
|
||||
$elem->libelle = $libelle;
|
||||
$infos[] = $elem;
|
||||
}
|
||||
|
||||
$tpl->registerSection('informations',
|
||||
function () use ($infos)
|
||||
{
|
||||
foreach ($infos as $elem)
|
||||
{
|
||||
yield (array) $elem;
|
||||
}
|
||||
});
|
||||
|
||||
// fabriquer le fichier PDF
|
||||
$nomPDF = \Garradin\Utils::filePDF($html->get());
|
||||
$result = $tpl->fetch();
|
||||
$nomPDF = \Garradin\Utils::filePDF($result);
|
||||
// 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;
|
||||
$listeFichiersPDF[] = $nomFichier;
|
||||
}
|
||||
|
||||
// faire une archive zip
|
||||
$fichierZip = Utils::makeArchive(
|
||||
$listeFichiers,
|
||||
$listeFichiersPDF,
|
||||
$_SESSION['annee_recu'],
|
||||
PLUGIN_ROOT . "/zip"
|
||||
);
|
||||
|
|
@ -114,7 +161,7 @@ function cumulerVersementsPersonne($versements)
|
|||
{
|
||||
$totalPersonnes[$idPersonneCourant]->ajouterVersement(
|
||||
$_SESSION['taux_reduction'],
|
||||
$totalVersements/100
|
||||
$totalVersements
|
||||
);
|
||||
}
|
||||
$idPersonneCourant = $ligne->idUser;
|
||||
|
|
@ -132,7 +179,7 @@ function cumulerVersementsPersonne($versements)
|
|||
// et le dernier
|
||||
$totalPersonnes[$idPersonneCourant]->ajouterVersement(
|
||||
$_SESSION['taux_reduction'],
|
||||
$totalVersements/100
|
||||
$totalVersements
|
||||
);
|
||||
return $totalPersonnes;
|
||||
}
|
||||
|
|
@ -160,7 +207,7 @@ function cumulerVersementsTarif($versements)
|
|||
// changement de tarif ou de personne
|
||||
$totalPersonnes[$idPersonneCourant]->ajouterVersement(
|
||||
$_SESSION['tauxSelectionnes'][$idTarifCourant],
|
||||
$totalVersements/100
|
||||
$totalVersements
|
||||
);
|
||||
}
|
||||
$idTarifCourant = $ligne->idTarif;
|
||||
|
|
@ -179,7 +226,7 @@ function cumulerVersementsTarif($versements)
|
|||
// et le dernier
|
||||
$totalPersonnes[$idPersonneCourant]->ajouterVersement(
|
||||
$_SESSION['tauxSelectionnes'][$idTarifCourant],
|
||||
$totalVersements/100
|
||||
$totalVersements
|
||||
);
|
||||
return $totalPersonnes;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue