From 8e19aaf526ee34e67803536052bb8378f0409b46 Mon Sep 17 00:00:00 2001 From: engel <> Date: Fri, 7 Apr 2023 09:38:25 +0000 Subject: [PATCH 01/40] restructuration et correction inexactitude FossilOrigin-Name: 43b3c9482d218f8e655a0fd54931824b1f51c9c40a767c637a6e7f5202f4944d --- lib/Utils.php | 23 +++++++++++++---------- www/admin/versements_activites.php | 10 +++++++++- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/Utils.php b/lib/Utils.php index 103c144..fac6190 100644 --- a/lib/Utils.php +++ b/lib/Utils.php @@ -185,18 +185,20 @@ class Utils /** * @return versements correspondants à : - * @param $annee : année fiscale - * @param array $tarifsComptes : tarifs sélectionnés et comptes associés - * @param array $champsNom : liste non vide des champs de nom/prénom + * @param $annee : année fiscale + * @param array $tarifs : tarifs sélectionnés + * @param array $comptes : comptes associés aux tarifs + * @param array $champsNom : liste non vide des champs de nom/prénom * @remarks tri par tarif, nom, compte, date */ public static function getVersementsTarifsComptes($annee, - $tarifsComptes, + $tarifs, + $comptes, $champsNom) { $db = DB::getInstance(); $tri = Utils::combinerTri($champsNom); - $condition = Utils::combinerTarifsComptes($tarifsComptes); + $condition = Utils::combinerTarifsComptes($tarifs, $comptes); $sql = sprintf( 'SELECT services_fees.id as idTarif, @@ -369,16 +371,17 @@ class Utils /** * combiner chaque tarif avec le numéro de compte associé */ - private static function combinerTarifsComptes($tarifsComptes) + private static function combinerTarifsComptes($tarifs, $comptes) { $condition = '('; + $lesCond = array_map(fn($e1, $e2) : string => + "(services_fees.id = '$e1' AND acc_accounts.id = '$e2')", + $tarifs, $comptes); $nb = 0; - foreach ($tarifsComptes as $elem) + foreach ($lesCond as $cond) { - $tarif = substr($elem, 0, strpos($elem, '_')); - $compte = substr($elem, 1 + strpos($elem, '_')); if ($nb > 0) { $condition .= ' OR '; } - $condition .= "(services_fees.id = '$tarif' AND acc_accounts.id = '$compte')"; + $condition .= $cond; ++$nb; } $condition .= ')'; diff --git a/www/admin/versements_activites.php b/www/admin/versements_activites.php index 9e8b5f2..20aae12 100644 --- a/www/admin/versements_activites.php +++ b/www/admin/versements_activites.php @@ -55,11 +55,19 @@ if (isset($_SESSION['comptesSelectionnes'])) } $_SESSION['tauxSelectionnes'] = $tauxSelectionnes; +$lesTarifs = array_map(fn($elem) : string => + strpos($elem, '_') !== false ? substr($elem, 0, strpos($elem, '_')) : "", + $tarifsSelectionnes); +$lesComptes = array_map(fn($elem) : string => + strpos($elem, '_') !== false ? substr($elem, 1 + strpos($elem, '_')) : "", + $tarifsSelectionnes); + # versements des tarifs sélectionnées et de leur compte associé $_SESSION['lesVersements'] = Utils::getVersementsTarifsComptes( $_SESSION['annee_recu'], - array_keys($_SESSION['tauxSelectionnes']), + $lesTarifs, + $lesComptes, $champsNom); // ajouter les versements sans tarif (tri par nom, compte, date) From e75c56b7366f50e4f0f07569c897e6a299ab87a8 Mon Sep 17 00:00:00 2001 From: engel <> Date: Sat, 8 Apr 2023 08:44:31 +0000 Subject: [PATCH 02/40] =?UTF-8?q?Correction=20erreur=20=C3=A9criture=20en?= =?UTF-8?q?=20double=20(http://localhost:8080/tktview/ae62f4cde5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FossilOrigin-Name: ada31d7d5a3cc60b40e4bada4afd0eab57ca48eb4bac4b4d5f34fda5f8feca6e --- lib/Utils.php | 21 +++++++++------------ www/admin/index.php | 2 +- www/admin/versements_activites.php | 5 ++++- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Utils.php b/lib/Utils.php index fac6190..d9416f7 100644 --- a/lib/Utils.php +++ b/lib/Utils.php @@ -63,13 +63,12 @@ class Utils INNER JOIN acc_accounts ON acc_transactions_lines.id_account = acc_accounts.id WHERE - (strftime(%s, acc_transactions.date) = "%d" + (strftime("%%Y", acc_transactions.date) = "%d" AND acc_accounts.%s ) GROUP by acc_accounts.code ORDER by acc_accounts.code', - '"%Y"', $annee, $db->where('code', $op, $comptes) ); @@ -104,14 +103,13 @@ class Utils INNER JOIN acc_accounts ON acc_transactions_lines.id_account = acc_accounts.id WHERE - (strftime(%s, acc_transactions.date) = "%d" + (strftime("%%Y", acc_transactions.date) = "%d" AND acc_accounts.%s ) GROUP BY services_fees.id, acc_accounts.code ORDER BY acc_accounts.code ', - '"%Y"', $annee, $db->where('code', $op, $comptes) ); @@ -170,12 +168,12 @@ class Utils INNER JOIN acc_accounts ON acc_transactions_lines.id_account = acc_accounts.id WHERE - (strftime(%s, acc_transactions.date) = "%d" + (strftime("%%Y", acc_transactions.date) = "%d" AND acc_accounts.%s ) + GROUP BY acc_transactions.id, acc_accounts.id ORDER by %s, acc_accounts.code, acc_transactions.date', - '"%Y"', $annee, $db->where('code', $op, $comptes), $tri @@ -225,7 +223,8 @@ class Utils AND %s ) - ORDER by services_fees.id, %s, acc_accounts.code, acc_transactions.date', + GROUP BY acc_transactions.id, acc_accounts.id + ORDER by %s, acc_accounts.code, acc_transactions.date', $annee, $condition, $tri @@ -265,14 +264,13 @@ class Utils INNER JOIN acc_accounts ON acc_transactions_lines.id_account = acc_accounts.id WHERE - (strftime(%s, acc_transactions.date) = "%d" + (strftime("%%Y", acc_transactions.date) = "%d" AND acc_accounts.%s ) - + GROUP BY acc_transactions.id, acc_accounts.id ORDER by %s, acc_accounts.code, acc_transactions.date ', - '"%Y"', $annee, $db->where('id', 'in', $comptesIsoles), $tri @@ -308,7 +306,7 @@ class Utils INNER JOIN acc_transactions_lines ON acc_transactions_lines.id_transaction = acc_transactions.id WHERE ( - strftime(%s, acc_transactions.date) = "%d" + strftime("%%Y", acc_transactions.date) = "%d" AND acc_transactions_users.id_transaction = acc_transactions.id AND @@ -319,7 +317,6 @@ class Utils ', $tri, $nom, - '"%Y"', $annee ); $donateurs = array(); diff --git a/www/admin/index.php b/www/admin/index.php index 9125c0c..2b4fb14 100644 --- a/www/admin/index.php +++ b/www/admin/index.php @@ -37,7 +37,7 @@ if (null !== $champsNom) // pendant l'année fiscale choisie $_SESSION['comptes'] = Utils::getComptes($_SESSION['annee_recu'], 'like', '7%'); -// liste des activités, cotisations et comptes associés +// liste des activités, tarifs et comptes associés $activitesTarifsComptes = Utils::getTarifsComptes($_SESSION['annee_recu'], 'like', '7%'); $_SESSION['lesTarifs'] = Utils::getTarifs(); $_SESSION['lesActivites'] = Utils::getActivites(); diff --git a/www/admin/versements_activites.php b/www/admin/versements_activites.php index 20aae12..7ffc9ec 100644 --- a/www/admin/versements_activites.php +++ b/www/admin/versements_activites.php @@ -63,12 +63,15 @@ $lesComptes = array_map(fn($elem) : string => $tarifsSelectionnes); # versements des tarifs sélectionnées et de leur compte associé -$_SESSION['lesVersements'] = +if (count($lesTarifs) != 0) +{ + $_SESSION['lesVersements'] = Utils::getVersementsTarifsComptes( $_SESSION['annee_recu'], $lesTarifs, $lesComptes, $champsNom); +} // ajouter les versements sans tarif (tri par nom, compte, date) if (isset($_SESSION['comptesSelectionnes'])) From bc4739877c544c5039ba1227f4222548a7cf43fa Mon Sep 17 00:00:00 2001 From: engel <> Date: Thu, 28 Sep 2023 09:08:46 +0000 Subject: [PATCH 03/40] =?UTF-8?q?D=C3=A9but=20restructuration=20pour=20com?= =?UTF-8?q?patibilit=C3=A9=20version=201.3=20de=20paheko?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FossilOrigin-Name: 467790c5738a867592117ea6b3a7ac6c61738dab3b8e29a48fed8f19b9df2b38 --- README.md | 6 +-- {www/admin => admin}/action.php | 0 {www/admin => admin}/choix_annee.php | 0 {www/admin => admin}/config.php | 0 {www/admin => admin}/generer_recus.php | 48 ++++++++++++++----- {www/admin => admin}/imprimer_recu.css | 0 {www/admin => admin}/index.php | 0 {www/admin => admin}/previs_recu.css | 0 {www/admin => admin}/script.js | 0 {www/admin => admin}/style.css | 0 {www/admin => admin}/upload.php | 0 {www/admin => admin}/versements_activites.php | 6 ++- {www/admin => admin}/versements_personnes.php | 0 install.php | 4 +- lib/Personne.php | 2 +- lib/Utils.php | 17 +++---- lib/Versement.php | 2 +- garradin_plugin.ini => plugin.ini | 8 ++-- templates/_nav.tpl | 2 +- templates/choix_annee.tpl | 4 +- templates/index.tpl | 2 +- templates/recu_html.tpl | 2 +- templates/upload.tpl | 4 +- templates/versements_activites.tpl | 2 +- templates/versements_personnes.tpl | 2 +- uninstall.php | 8 ++-- upgrade.php | 4 +- 27 files changed, 77 insertions(+), 46 deletions(-) rename {www/admin => admin}/action.php (100%) rename {www/admin => admin}/choix_annee.php (100%) rename {www/admin => admin}/config.php (100%) rename {www/admin => admin}/generer_recus.php (91%) rename {www/admin => admin}/imprimer_recu.css (100%) rename {www/admin => admin}/index.php (100%) rename {www/admin => admin}/previs_recu.css (100%) rename {www/admin => admin}/script.js (100%) rename {www/admin => admin}/style.css (100%) rename {www/admin => admin}/upload.php (100%) rename {www/admin => admin}/versements_activites.php (90%) rename {www/admin => admin}/versements_personnes.php (100%) rename garradin_plugin.ini => plugin.ini (63%) diff --git a/README.md b/README.md index d6a1513..a564a1e 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# Plugin reçus fiscaux pour Garradin/Paheko +# Plugin reçus fiscaux pour Paheko -Plugin de reçus fiscaux pour le logiciel de gestion d'association [Garradin/Paheko](https://paheko.cloud). +Plugin de reçus fiscaux pour le logiciel de gestion d'association [Paheko](https://paheko.cloud). ## Installation -**Attention :** les archives disponibles sur ce gitlab n'ont pas un format compatible avec Garradin/Paheko et ne peuvent donc être utilisées telles quelles ; il faut soit les transformer pour les rendre compatibles, soit télécharger [cette archive](https://ncloud6.zaclys.com/index.php/s/RZQK2So8HemkH3w), et la copier dans le dossier plugins de Garradin/Paheko. +**Attention :** les archives disponibles sur ce gitlab n'ont pas un format compatible avec Paheko et ne peuvent donc être utilisées telles quelles ; il faut soit les transformer pour les rendre compatibles, soit télécharger [cette archive](https://ncloud6.zaclys.com/index.php/s/RZQK2So8HemkH3w), et la copier dans le dossier plugins de Paheko. ## Fonctionnalités - Créer des reçus fiscaux pour les dons des membres diff --git a/www/admin/action.php b/admin/action.php similarity index 100% rename from www/admin/action.php rename to admin/action.php diff --git a/www/admin/choix_annee.php b/admin/choix_annee.php similarity index 100% rename from www/admin/choix_annee.php rename to admin/choix_annee.php diff --git a/www/admin/config.php b/admin/config.php similarity index 100% rename from www/admin/config.php rename to admin/config.php diff --git a/www/admin/generer_recus.php b/admin/generer_recus.php similarity index 91% rename from www/admin/generer_recus.php rename to admin/generer_recus.php index a17eb44..a930188 100644 --- a/www/admin/generer_recus.php +++ b/admin/generer_recus.php @@ -97,6 +97,9 @@ function genererRecusPDF($totalPersonnes, $libelles_taux ) { + // + $fichierHTML = sprintf('%s/print-%s.html', CACHE_ROOT, md5(random_bytes(16))); + // $listeFichiersPDF = array(); $fmt = new \NumberFormatter('fr_FR', \NumberFormatter::SPELLOUT); $prefixeNum = getNumPrefixe($configNum); @@ -162,22 +165,44 @@ function genererRecusPDF($totalPersonnes, } } ); - + + // + // récupérer les reçus au format html + $recuHTML = $tpl->fetch(); + // enregistrer dans le fichier + file_put_contents($fichierHTML, $recuHTML, FILE_APPEND); + // + // fabriquer le fichier PDF genererPDF($tpl->fetch(), $personne->nomPrenom, $listeFichiersPDF); } - // faire une archive zip - $fichierZip = Utils::makeArchive( - $listeFichiersPDF, - $_SESSION['annee_recu'], - PLUGIN_ROOT . "/zip" - ); + // afficher dans un dialog + //marche pas + // printf(' + // + // + // + // + // ', $fichierHTML, "90%", "90%"); - //supprimer les fichiers pdf (utile ?) - foreach ($listeFichiersPDF as $f) { - // Utils::safe_unlink($f); - } + // affiche une page vide + // $link = ""; + // echo $link; + + // faire une archive zip + // $fichierZip = Utils::makeArchive( + // $listeFichiersPDF, + // $_SESSION['annee_recu'], + // PLUGIN_ROOT . "/zip" + // ); + + //supprimer les fichiers pdf + // foreach ($listeFichiersPDF as $f) { + // \Garradin\Utils::safe_unlink($f); + // } } // genererRecusPDF function generererRecusHTML($tpl, @@ -298,6 +323,7 @@ function cumulerVersementsTarif($versements) $dateMax = -1; $totalVersements = 0; foreach ($versements as $ligne) { + error_log("\nligne=" . print_r($ligne, true)); if ( $ligne->idTarif != $idTarifCourant || $ligne->idUser != $idPersonneCourant || diff --git a/www/admin/imprimer_recu.css b/admin/imprimer_recu.css similarity index 100% rename from www/admin/imprimer_recu.css rename to admin/imprimer_recu.css diff --git a/www/admin/index.php b/admin/index.php similarity index 100% rename from www/admin/index.php rename to admin/index.php diff --git a/www/admin/previs_recu.css b/admin/previs_recu.css similarity index 100% rename from www/admin/previs_recu.css rename to admin/previs_recu.css diff --git a/www/admin/script.js b/admin/script.js similarity index 100% rename from www/admin/script.js rename to admin/script.js diff --git a/www/admin/style.css b/admin/style.css similarity index 100% rename from www/admin/style.css rename to admin/style.css diff --git a/www/admin/upload.php b/admin/upload.php similarity index 100% rename from www/admin/upload.php rename to admin/upload.php diff --git a/www/admin/versements_activites.php b/admin/versements_activites.php similarity index 90% rename from www/admin/versements_activites.php rename to admin/versements_activites.php index 7ffc9ec..6930a8e 100644 --- a/www/admin/versements_activites.php +++ b/admin/versements_activites.php @@ -25,10 +25,11 @@ if (null !== f('tarifs')) { } else if (! isset($_SESSION['tauxSelectionnes'])) { $tarifsSelectionnes = []; } - +error_log("\ntarifsSelectionnes=" . print_r($tarifsSelectionnes, true)); // comptes sélectionnés if (null !== f('comptes')) { $_SESSION['comptesSelectionnes'] = f('comptes'); + error_log("\ncomptesSelectionnes=" . print_r($_SESSION['comptesSelectionnes'], true)); } /* else if (! isset($_SESSION['tauxSelectionnes'])) { $_SESSION['comptesSelectionnes'] = []; @@ -71,6 +72,7 @@ if (count($lesTarifs) != 0) $lesTarifs, $lesComptes, $champsNom); + error_log("lesVersements=" . print_r($_SESSION['lesVersements'], true)); } // ajouter les versements sans tarif (tri par nom, compte, date) @@ -84,6 +86,8 @@ if (isset($_SESSION['comptesSelectionnes'])) $_SESSION['lesVersements'][] = $versement; } } +error_log("lesVersements=" . print_r($_SESSION['lesVersements'], true)); + // préparation de l'affichage $tpl->assign('lesVersements', $_SESSION['lesVersements']); $tpl->assign('annee_recu', $_SESSION['annee_recu']); diff --git a/www/admin/versements_personnes.php b/admin/versements_personnes.php similarity index 100% rename from www/admin/versements_personnes.php rename to admin/versements_personnes.php diff --git a/install.php b/install.php index 1117fa6..6fe5a5a 100644 --- a/install.php +++ b/install.php @@ -1,6 +1,6 @@ get($sql); } @@ -417,7 +418,7 @@ class Utils /** * récupérer dans la config du plugin les champs des membres * utilisés pour le nom et le prénom ; ajouter/supprimer les - * modifications par rapport à la config garradin + * modifications par rapport à la config paheko * @return array tableau des champs : clé = nom, valeur = { titre, position } */ public static function getChampsNom($config, $plugin) : array @@ -426,11 +427,11 @@ class Utils // pour le nom et le prénom (le tableau est vide si pas mémorisé) $champsNom = (array) $plugin->getConfig('champsNom'); - // récupérer dans la config Garradin les champs des membres + // récupérer dans la config Paheko les champs des membres // utilisés pour le nom et le préno - $champsGarradin = $config->get('champs_membres')->listAssocNames(); + $champsPaheko = $config->get('champs_membres')->listAssocNames(); - foreach ($champsGarradin as $name => $title) + foreach ($champsPaheko as $name => $title) { if (stristr($title, 'nom')) { @@ -447,10 +448,10 @@ class Utils } } // opération symétrique : un champ mémorisé dans la config du - // plugin a-t-il disparu de la config garradin ? + // plugin a-t-il disparu de la config paheko ? foreach ($champsNom as $nom => $champ) { - if (! array_key_exists($nom, $champsGarradin)) + if (! array_key_exists($nom, $champsPaheko)) { // absent => le supprimer unset($champsNom[$nom]); diff --git a/lib/Versement.php b/lib/Versement.php index e52f98c..35fa9ec 100644 --- a/lib/Versement.php +++ b/lib/Versement.php @@ -1,6 +1,6 @@ -{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id} +{include file="_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}