getConfig('signature')) ? \Garradin\Files\Files::get($plugin->getConfig('signature'))->fullpath() : ""; // articles du CGI $articlesCGI = array(); foreach ($plugin->getConfig('articlesCGI') as $article) { if ($article->valeur == 1) { $articlesCGI[] = $article->titre; } } $listeFichiers = array(); // fichiers pdf générés foreach ($totalPersonnes as $idPersonne => $personne) { // générer un fichier par reçu $html = new RecusHTML( $nomAsso, $adresseAsso, $plugin->getConfig('objet_asso'), $plugin->getConfig('nom_responsable'), $plugin->getConfig('fonction_responsable'), $articlesCGI, $signature ); // extraire les montants des versements $lesMontants = array(); foreach ($personne->versements as $versement) { if (array_key_exists($versement->tauxReduction, $lesMontants)) { $lesMontants[$versement->tauxReduction] += $versement->montant; } else { $lesMontants[$versement->tauxReduction] = $versement->montant; } } $html->imprimer_recu( $_SESSION['annee_recu'], $personne->id, $personne->nomPrenom, $lesMontants, $personne->adresse, $personne->codePostal, $personne->ville ); // fabriquer le fichier PDF $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 $fichierZip = Utils::makeArchive( $listeFichiers, $_SESSION['annee_recu'], PLUGIN_ROOT . "/zip" ); /** * Cumuler les versements de chaque personne par tarif * @param tableau des versements triés par idTarif, idUser, date * @return tableau des versements cumulés : id => Personne */ function cumulerVersements($versements) { $totalPersonnes = array(); $idTarif_courant = -1; $idPersonne_courant = -1; $totalVersements = 0; foreach ($versements as $ligne) { if ( $ligne->idTarif != $idTarif_courant || $ligne->idUser != $idPersonne_courant ) { if ($idTarif_courant != -1) { $totalPersonnes[$idPersonne_courant]->ajouterVersement( $_SESSION['lesTarifs'][$idTarif_courant]->idActivite, $idTarif_courant, $totalVersements/100, $_SESSION['tauxSelectionnes'][$idTarif_courant] ); } $idTarif_courant = $ligne->idTarif; $idPersonne_courant = $ligne->idUser; $totalVersements = $ligne->versement; // créer les infos de la personne, sauf si elle est déjà présente if (!array_key_exists($idPersonne_courant, $totalPersonnes)) { $totalPersonnes["$idPersonne_courant"] = $_SESSION['membresDonateurs'][$ligne->idUser]->clone(); } } else { // cumuler versements $totalVersements += $ligne->versement; } } // et le dernier $totalPersonnes[$idPersonne_courant]->ajouterVersement( $_SESSION['lesTarifs'][$idTarif_courant]->idActivite, $idTarif_courant, $totalVersements/100, $_SESSION['tauxSelectionnes'][$idTarif_courant] ); return $totalPersonnes; }