2022-01-29 15:00:04 +01:00
|
|
|
<?php
|
|
|
|
|
2023-09-28 13:20:36 +02:00
|
|
|
namespace Paheko;
|
2023-11-10 12:31:18 +01:00
|
|
|
session_start();
|
2022-03-29 14:49:03 +02:00
|
|
|
|
2023-09-28 13:20:36 +02:00
|
|
|
use Paheko\Files\Files;
|
|
|
|
use Paheko\Entities\Files\File;
|
|
|
|
use Paheko\Plugin\RecusFiscaux\Utils;
|
2022-02-24 11:28:08 +01:00
|
|
|
|
2022-01-29 15:00:04 +01:00
|
|
|
$session->requireAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN);
|
2022-03-18 20:39:02 +01:00
|
|
|
|
2023-01-23 18:53:53 +01:00
|
|
|
// récupérer les champs des noms
|
2022-03-29 14:49:03 +02:00
|
|
|
$champsNom = Utils::getChampsNom($config, $plugin);
|
2022-02-18 12:51:13 +01:00
|
|
|
|
2023-10-04 14:27:56 +02:00
|
|
|
$csrf_key = 'recusfiscaux_config';
|
2022-02-24 11:28:08 +01:00
|
|
|
|
2023-10-04 14:27:56 +02:00
|
|
|
$form->runIf('save', function () use ($plugin, $champsNom) {
|
|
|
|
// Objet de l'asso
|
|
|
|
$plugin->setConfigProperty('objet_asso', trim(f('objet_asso')));
|
2022-02-24 11:28:08 +01:00
|
|
|
|
2023-10-04 14:27:56 +02:00
|
|
|
// Articles du CGI
|
|
|
|
$confArticles = $plugin->getConfig('articlesCGI');
|
|
|
|
// effacer l'ancienne configuration
|
|
|
|
for ($i = 0; $i < count($confArticles); ++$i) {
|
|
|
|
$confArticles[$i]->valeur = false;
|
|
|
|
}
|
|
|
|
// et copier la nouvelle
|
|
|
|
$art_sel = f('articlesCGI') ?: [];
|
|
|
|
foreach ($art_sel as $article) {
|
|
|
|
$confArticles[$article]->valeur = true;
|
|
|
|
}
|
|
|
|
$plugin->setConfigProperty('articlesCGI', $confArticles);
|
2022-03-03 12:09:52 +01:00
|
|
|
|
2023-10-04 14:27:56 +02:00
|
|
|
// Taux de réduction
|
|
|
|
$confTaux = $plugin->getConfig('reduction');
|
|
|
|
// effacer l'ancienne configuration
|
|
|
|
for ($i = 0; $i < count($confTaux); ++$i) {
|
|
|
|
$confTaux[$i]->valeur = false;
|
|
|
|
}
|
|
|
|
// et copier la nouvelle
|
|
|
|
$taux_sel = f('tauxReduction') ?: [];
|
|
|
|
foreach ($taux_sel as $taux) {
|
|
|
|
$confTaux[$taux]->valeur = true;
|
|
|
|
}
|
|
|
|
$plugin->setConfigProperty("reduction", $confTaux);
|
|
|
|
|
|
|
|
// Informations au sujet du responsable
|
|
|
|
$plugin->setConfigProperty('nom_responsable', trim(f('nom_responsable') ?: '') ?: null);
|
|
|
|
$plugin->setConfigProperty('fonction_responsable', trim(f('fonction_responsable') ?: '') ?: null);
|
|
|
|
$plugin->setConfigProperty('ville_asso', trim(f('ville_asso') ?: '') ?: null);
|
|
|
|
|
|
|
|
// 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 = \Paheko\Files\Files::get($plugin->getConfig('signature'));
|
|
|
|
if (null !== $sig_file) {
|
|
|
|
$sig_file->delete();
|
2022-03-03 12:09:52 +01:00
|
|
|
}
|
2022-02-24 11:28:08 +01:00
|
|
|
}
|
2023-10-04 14:27:56 +02:00
|
|
|
// puis installer la nouvelle
|
|
|
|
$plugin->setConfigProperty('signature', $_SESSION['sig_file'][0]->path);
|
|
|
|
}
|
2022-02-24 11:28:08 +01:00
|
|
|
|
2023-10-04 14:27:56 +02:00
|
|
|
// Numérotation des reçus
|
|
|
|
$configNum = $plugin->getConfig('numerotation');
|
|
|
|
$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->setConfigProperty('numerotation', $formNum);
|
|
|
|
|
|
|
|
// Impression des adresses de courriel
|
|
|
|
$plugin->setConfigProperty('imprimerCourriel', trim(f('imprimerCourriel') ?: '') ?: null);
|
2022-03-18 20:39:02 +01:00
|
|
|
|
2023-10-04 14:27:56 +02:00
|
|
|
// champs pour le nom et prénom
|
|
|
|
foreach ($champsNom as $nom => $champ) {
|
|
|
|
$champ->position = 0;
|
2022-01-29 15:00:04 +01:00
|
|
|
}
|
2023-10-04 14:27:56 +02:00
|
|
|
$noms_sel = f('champsNom') ?: [];
|
|
|
|
$i = -count($noms_sel);
|
|
|
|
foreach ($noms_sel as $nom) {
|
|
|
|
$champsNom[$nom]->position = $i++;
|
|
|
|
}
|
|
|
|
$plugin->setConfigProperty('champsNom', $champsNom);
|
|
|
|
|
|
|
|
// enregistrer la nouvelle config
|
|
|
|
$plugin->save();
|
|
|
|
}, $csrf_key, PLUGIN_ADMIN_URL . 'config.php?ok');
|
|
|
|
|
|
|
|
|
|
|
|
// test fonctions fichiers : voir files.sor
|
|
|
|
// $fichiers = Files::list('config');
|
|
|
|
// error_log("fichiers config = " . print_r($fichiers, true));
|
|
|
|
// $fichiers = Files::list('ext/recusfiscaux');
|
|
|
|
// error_log("fichiers ext/recusfiscaux = " . print_r($fichiers, true));
|
|
|
|
$sig_file = Files::get('ext/recusfiscaux/default_signature.png');
|
|
|
|
// error_log("sig_file = " . print_r($sig_file, true));
|
|
|
|
|
|
|
|
//error_log("config.php::config=" . print_r($plugin->getConfig(), true));
|
|
|
|
|
2022-01-29 15:00:04 +01:00
|
|
|
|
2022-03-18 20:39:02 +01:00
|
|
|
// trier les champs de nom pour l'affichage
|
2023-01-23 18:53:53 +01:00
|
|
|
uasort($champsNom, function ($a, $b) {
|
2022-03-18 20:39:02 +01:00
|
|
|
return $a->position - $b->position;
|
|
|
|
});
|
|
|
|
|
2022-03-24 19:00:39 +01:00
|
|
|
$path = qg('path') ?: File::CONTEXT_CONFIG;
|
2023-10-04 14:27:56 +02:00
|
|
|
$tpl->assign('default_signature', '/' . 'ext/recusfiscaux/default_signature.png');
|
|
|
|
// $tpl->assign('default_signature', \Paheko\WWW_URL . "plugin/recusfiscaux/default_signature.png");
|
2022-01-29 15:00:04 +01:00
|
|
|
$tpl->assign('plugin_config', $plugin->getConfig());
|
|
|
|
$tpl->assign('plugin_css', ['style.css']);
|
2023-01-23 18:53:53 +01:00
|
|
|
$tpl->assign('numerotation', $plugin->getConfig('numerotation'));
|
2023-10-04 14:27:56 +02:00
|
|
|
$tpl->assign(compact('csrf_key', 'path', 'champsNom'));
|
2022-01-29 15:00:04 +01:00
|
|
|
$tpl->display(PLUGIN_ROOT . '/templates/config.tpl');
|