From d32c589a4aa742a13852524916a29924b2a5212a Mon Sep 17 00:00:00 2001 From: Noizette Date: Fri, 4 Aug 2023 18:00:08 +0200 Subject: [PATCH] Fix plugin config --- admin/config.php | 53 ++++++++++++++++++---------------------- templates/config.tpl | 57 ++++++++++++++------------------------------ 2 files changed, 41 insertions(+), 69 deletions(-) diff --git a/admin/config.php b/admin/config.php index 2e9198a..0987bde 100644 --- a/admin/config.php +++ b/admin/config.php @@ -6,43 +6,36 @@ require_once __DIR__ . '/_inc.php'; $session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_ADMIN); -if (f('save') && $form->check('facturation_config')) -{ - try { - $plugin->setConfig('rna_asso', trim(f('rna_asso'))); - $plugin->setConfig('siret_asso', trim(f('siret_asso'))); - $plugin->setConfig('ttc', (bool)trim(f('ttc'))); +$form->runIf('save', function () use ($plugin) { + $plugin->setConfigProperty('rna_asso', trim(f('rna_asso'))); + $plugin->setConfigProperty('siret_asso', trim(f('siret_asso'))); + $plugin->setConfigProperty('ttc', (bool) f('ttc')); - $plugin->setConfig('numero_rue_asso', trim(f('numero_rue_asso'))); - $plugin->setConfig('rue_asso', trim(f('rue_asso'))); - $plugin->setConfig('cp_asso', trim(f('cp_asso'))); - $plugin->setConfig('ville_asso', trim(f('ville_asso'))); + $plugin->setConfigProperty('numero_rue_asso', trim(f('numero_rue_asso'))); + $plugin->setConfigProperty('rue_asso', trim(f('rue_asso'))); + $plugin->setConfigProperty('cp_asso', trim(f('cp_asso'))); + $plugin->setConfigProperty('ville_asso', trim(f('ville_asso'))); - $plugin->setConfig('droit_art200', (bool)f('droit_art200')); - $plugin->setConfig('droit_art238bis', (bool)f('droit_art238bis')); - $plugin->setConfig('droit_art885-0VbisA', (bool)f('droit_art885-0VbisA')); - $plugin->setConfig('objet_0', trim(f('objet_0'))); - $plugin->setConfig('objet_1', trim(f('objet_1'))); - $plugin->setConfig('objet_2', trim(f('objet_2')));; + $plugin->setConfigProperty('droit_art200', (bool)f('droit_art200')); + $plugin->setConfigProperty('droit_art238bis', (bool)f('droit_art238bis')); + $plugin->setConfigProperty('droit_art885_0VbisA', (bool)f('droit_art885_0VbisA')); + $plugin->setConfigProperty('objet_0', trim(f('objet_0'))); + $plugin->setConfigProperty('objet_1', trim(f('objet_1'))); + $plugin->setConfigProperty('objet_2', trim(f('objet_2')));; - $plugin->setConfig('footer', f('footer')); - - $plugin->setConfig('validate_cp', (bool)f('validate_cp')); - $plugin->setConfig('unique_client_name', (bool)f('unique_client_name')); + $plugin->setConfigProperty('footer', f('footer')); + + $plugin->setConfigProperty('validate_cp', (bool)f('validate_cp')); + $plugin->setConfigProperty('unique_client_name', (bool)f('unique_client_name')); - $plugin->setConfig('pattern', f('pattern')); + $plugin->setConfigProperty('pattern', f('pattern')); - Utils::redirect(PLUGIN_ADMIN_URL . 'config.php?ok'); - } - catch (UserException $e) - { - $form->addError($e->getMessage()); - } -} + $plugin->save(); +}, 'facturation_config', PLUGIN_ADMIN_URL . 'config.php?ok'); $tpl->assign('ok', qg('ok') !== null); - +$tpl->assign('conf', $plugin->getConfig()); $tpl->assign('patterns', \Paheko\Plugin\Facturation\PATTERNS_LIST); -$tpl->display(PLUGIN_ROOT . '/templates/config.tpl'); +$tpl->display(PLUGIN_ROOT . '/templates/config.tpl'); \ No newline at end of file diff --git a/templates/config.tpl b/templates/config.tpl index b5e676c..de55d71 100644 --- a/templates/config.tpl +++ b/templates/config.tpl @@ -1,4 +1,4 @@ -{include file="_head.tpl" title="Configuration — %s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id} +{include file="_head.tpl" title="Configuration — %s"|args:$plugin.name current="plugin_%s"|args:$plugin.id} {include file="%s/templates/_menu.tpl"|args:$plugin_root current="config"} {if $ok && !$form->hasErrors()} @@ -13,27 +13,27 @@
Informations de l'association
- {input type="text" name="rna_asso" label="RNA de l'association" source=$plugin.config} - {input type="text" name="siret_asso" label="SIRET de l'association" source=$plugin.config} - {input type="checkbox" name="ttc" value="1" label="L'association émet des factures TTC (TVA)" source=$plugin.config} + {input type="text" name="rna_asso" label="RNA de l'association" source=$conf} + {input type="text" name="siret_asso" label="SIRET de l'association" source=$conf} + {input type="checkbox" name="ttc" value="1" label="L'association émet des factures TTC (TVA)" source=$conf}

Adresse
- {input type="text" name="numero_rue_asso" source=$plugin.config label="Numéro de rue" maxlength=5} - {input type="text" name="rue_asso" source=$plugin.config label="Nom de rue"} - {input type="text" name="cp_asso" source=$plugin.config label="Code postal"} - {input type="text" name="ville_asso" source=$plugin.config label="Ville"} + {input type="text" name="numero_rue_asso" source=$conf label="Numéro de rue" maxlength=5} + {input type="text" name="rue_asso" source=$conf label="Nom de rue"} + {input type="text" name="cp_asso" source=$conf label="Code postal"} + {input type="text" name="ville_asso" source=$conf label="Ville"}
Objet
obligatoire pour reçus fiscaux
- {input type="text" name="objet_0" source=$plugin.config label="Ligne 1" maxlength=95} - {input type="text" name="objet_1" source=$plugin.config label="Ligne 2" maxlength=95} - {input type="text" name="objet_2" source=$plugin.config label="Ligne 3" maxlength=95} + {input type="text" name="objet_0" source=$conf label="Ligne 1" maxlength=95} + {input type="text" name="objet_1" source=$conf label="Ligne 2" maxlength=95} + {input type="text" name="objet_2" source=$conf label="Ligne 3" maxlength=95}
@@ -41,9 +41,9 @@ Droit à la réduction d'impôt
obligatoire pour reçus fiscaux
- {input type="checkbox" name="droit_art200" value="1" source=$plugin.config label="Article 200"} - {input type="checkbox" name="droit_art238bis" value="1" source=$plugin.config label="Article 238 bis"} - {input type="checkbox" name="droit_art885-0VbisA" value="1" source=$plugin.config label="Article 885-0V bis A"} + {input type="checkbox" name="droit_art200" value="1" source=$conf label="Article 200"} + {input type="checkbox" name="droit_art238bis" value="1" source=$conf label="Article 238 bis"} + {input type="checkbox" name="droit_art885_0VbisA" value="1" source=$conf label="Article 885-0V bis A"}
@@ -52,16 +52,16 @@
Factures
- {input type="textarea" class="full-width" rows="10" name="footer" source=$plugin.config label="Pied de document — informations légales" required=true} + {input type="textarea" class="full-width" rows="10" name="footer" source=$conf label="Pied de document — informations légales" required=true}
Configuration du plugin
- {input type="checkbox" name="validate_cp" value="1" source=$plugin.config label="Vérifier le code postal lors de saisie/modification de client (seulement FR)"} - {input type="checkbox" name="unique_client_name" value="1" source=$plugin.config label="Noms des clients uniques"} - {input type="select" name="pattern" label="Format de numéro de document" required=false options=$patterns source=$plugin.config} + {input type="checkbox" name="validate_cp" value="1" source=$conf label="Vérifier le code postal lors de saisie/modification de client (seulement FR)"} + {input type="checkbox" name="unique_client_name" value="1" source=$conf label="Noms des clients uniques"} + {input type="select" name="pattern" label="Format de numéro de document" required=false options=$patterns source=$conf}
F = Facture, D = Devis, RF = Reçu fiscal, RC = Reçu cotisation
@@ -75,25 +75,4 @@

- -
-
- Signature du responsable -

- Uploadez votre signature dans les documents, onglet Squelettes du site web, sous plugin/facturation/sign.png -
- Il est préférable d'avoir un fond transparent. -

-
- -

- La signature actuelle : -
- -

- -

A cause de l'implémentation de la signature, votre signature est acessible publiquement à l'adresse suivante : {$www_url}plugin/facturation/sign.png !

-
-
- {include file="_foot.tpl"} \ No newline at end of file