Fix plugin config

This commit is contained in:
Noizette 2023-08-04 18:00:08 +02:00
parent 899bf02775
commit d32c589a4a
2 changed files with 41 additions and 69 deletions

View File

@ -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');

View File

@ -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 @@
<fieldset>
<legend>Informations de l'association</legend>
<dl>
{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}
</dl>
<br>
<fieldset>
<legend>Adresse</legend>
<dl>
{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"}
</dl>
</fieldset>
<fieldset>
<legend>Objet</legend>
<dl>
<dt><label>L'objet (but) de l'association doit tenir sur 3 lignes, chaque ligne pouvant accueillir un maximum de 100 caractères.</label><b title="(Champ obligatoire)">obligatoire pour reçus fiscaux</b></dt>
{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}
</dl>
</fieldset>
@ -41,9 +41,9 @@
<legend>Droit à la réduction d'impôt</legend>
<dl>
<dt><label>Articles concernés par l'association :</label> <b title="(Champ obligatoire)">obligatoire pour reçus fiscaux</b></dt>
{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"}
</dl>
</fieldset>
@ -52,16 +52,16 @@
<fieldset>
<legend>Factures</legend>
<dl>
{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}
</dl>
</fieldset>
<fieldset>
<legend>Configuration du plugin</legend>
<dl>
{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}
<dd class="help">
F = Facture, D = Devis, RF = Reçu fiscal, RC = Reçu cotisation
</dd>
@ -75,25 +75,4 @@
</p>
</form>
<form method="post" enctype="multipart/form-data" action="{$self_url|escape}" id="f_upload">
<fieldset>
<legend>Signature du responsable</legend>
<p>
Uploadez votre signature dans les documents, onglet Squelettes du site web, sous plugin/facturation/sign.png
<br>
Il est préférable d'avoir un fond transparent.
</p>
<br>
<p>
La signature actuelle :
<br>
<img src="{$www_url}plugin/facturation/sign.png">
</p>
<p>A cause de l'implémentation de la signature, votre signature est acessible publiquement à l'adresse suivante : {$www_url}plugin/facturation/sign.png !</p>
</fieldset>
</form>
{include file="_foot.tpl"}