requireAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN); $art_sel = f('articlesCGI') ?: []; $taux_sel = f('tauxReduction') ?: []; $noms_sel = f('champsNom') ?: []; // récupérer les champs des noms $champsNom = Utils::getChampsNom($config, $plugin); if (f('save') && $form->check('recusfiscaux_config')) { try { // objet de l'association if ($plugin->getConfig('objet_asso') != trim(f('objet_asso'))) { $plugin->setConfig('objet_asso', trim(f('objet_asso'))); } // articles du CGI $confArticles = $plugin->getConfig('articlesCGI'); // effacer l'ancienne configuration for ($i = 0; $i < count($confArticles); ++$i) { $confArticles[$i]->valeur = false; // 0 } // et copier la nouvelle foreach ($art_sel as $article) { $confArticles[$article]->valeur = true; // 1 } $plugin->setConfig("articlesCGI", $confArticles); // taux de réduction $confTaux = $plugin->getConfig('reduction'); // effacer l'ancienne configuration for ($i = 0; $i < count($confTaux); ++$i) { $confTaux[$i]->valeur = false; // 0 } // et copier la nouvelle foreach ($taux_sel as $taux) { $confTaux[$taux]->valeur = true; // 1 } $plugin->setConfig("reduction", $confTaux); // Informations au sujet du responsable if ($plugin->getConfig('nom_responsable') != trim(f('nom_responsable'))) { $plugin->setConfig('nom_responsable', trim(f('nom_responsable'))); } if ($plugin->getConfig('fonction_responsable') != trim(f('fonction_responsable'))) { $plugin->setConfig('fonction_responsable', trim(f('fonction_responsable'))); } // ville if ($plugin->getConfig('ville_asso') != trim(f('ville_asso'))) { $plugin->setConfig('ville_asso', trim(f('ville_asso'))); } // signature // error_log("SESSION['sig_file'] = " . print_r($_SESSION['sig_file'], true)); // error_log("plugin->getConfig('signature') = " . $plugin->getConfig('signature')); if (isset($_SESSION['sig_file']) && count($_SESSION['sig_file']) > 0) { // supprimer la signature précédente, si besoin if ( null !== $plugin->getConfig('signature') && $plugin->getConfig('signature') != $_SESSION['sig_file'][0]->path ) { $sig_file = \Garradin\Files\Files::get($plugin->getConfig('signature')); if (null !== $sig_file) { $sig_file->delete(); } } // puis installer la nouvelle $plugin->setConfig('signature', $_SESSION['sig_file'][0]->path); } // autres informations // numérotation des reçus $configNum = $plugin->getConfig('numerotation'); error_log("configNum=" . print_r($configNum, true)); $formNum = clone $configNum; if ($configNum->prefixe != trim(f('prefixe'))) { $formNum->prefixe = trim(f('prefixe')); } $formNum->annee = f('annee'); $formNum->membre = f('membre'); $formNum->sequentiel = f('sequentiel'); $formNum->valeur_init = f('valeur_init'); $plugin->setConfig('numerotation', $formNum); // impression des adresses de courriel $plugin->setConfig('imprimerCourriel', f('imprimerCourriel')); // champs pour le nom et prénom foreach ($champsNom as $nom => $champ) { $champ->position = 0; } $i = -count($noms_sel); foreach ($noms_sel as $nom) { $champsNom[$nom]->position = $i++; } $plugin->setConfig('champsNom', $champsNom); \Garradin\Utils::redirect(PLUGIN_URL . 'config.php?ok'); } catch (UserException $e) { $form->addError($e->getMessage()); } } // trier les champs de nom pour l'affichage uasort($champsNom, function ($a, $b) { return $a->position - $b->position; }); $tpl->assign('ok', qg('ok') !== null); $path = qg('path') ?: File::CONTEXT_CONFIG; $tpl->assign('default_signature', \Garradin\WWW_URL . "plugin/recusfiscaux/default_signature.png"); $tpl->assign('plugin_config', $plugin->getConfig()); $tpl->assign('plugin_css', ['style.css']); $tpl->assign('numerotation', $plugin->getConfig('numerotation')); $tpl->assign(compact('path', 'champsNom')); $tpl->display(PLUGIN_ROOT . '/templates/config.tpl');