Correction erreurs, sécurisation code, personnalisation présentation (Jordan)
This commit is contained in:
parent
717fc5320f
commit
fffbfcac93
19 changed files with 822 additions and 471 deletions
|
|
@ -11,6 +11,17 @@ $champsPaheko = DynamicFields::getInstance()->listAssocNames();
|
|||
$champsPaheko = array('' => '- Choisir un champ -') + $champsPaheko;
|
||||
|
||||
$form->runIf('save', function () use ($plugin) {
|
||||
$invoice_theme = f('invoice_theme') ?: 'modern';
|
||||
$invoice_accent_color = trim(f('invoice_accent_color') ?: '#4656A5');
|
||||
|
||||
if (!in_array($invoice_theme, ['modern', 'classic', 'minimal'], true)) {
|
||||
throw new UserException('Le style de facture sélectionné est invalide.');
|
||||
}
|
||||
|
||||
if (!preg_match('/^#[0-9A-Fa-f]{6}$/', $invoice_accent_color)) {
|
||||
throw new UserException('La couleur d\'accent doit être au format hexadécimal, par exemple #4656A5.');
|
||||
}
|
||||
|
||||
$plugin->setConfigProperty('rna_asso', trim(f('rna_asso')));
|
||||
$plugin->setConfigProperty('siret_asso', trim(f('siret_asso')));
|
||||
$plugin->setConfigProperty('ttc', (bool) f('ttc'));
|
||||
|
|
@ -22,6 +33,14 @@ $form->runIf('save', function () use ($plugin) {
|
|||
|
||||
$plugin->setConfigProperty('logo', (bool)f('logo'));
|
||||
$plugin->setConfigProperty('footer', f('footer'));
|
||||
$plugin->setConfigProperty('invoice_theme', $invoice_theme);
|
||||
$plugin->setConfigProperty('invoice_accent_color', strtoupper($invoice_accent_color));
|
||||
$plugin->setConfigProperty('invoice_note', trim(f('invoice_note') ?: ''));
|
||||
$plugin->setConfigProperty('payment_terms', trim(f('payment_terms') ?: ''));
|
||||
$plugin->setConfigProperty('invoice_show_status', (bool) f('invoice_show_status'));
|
||||
$plugin->setConfigProperty('invoice_show_address_borders', (bool) f('invoice_show_address_borders'));
|
||||
$plugin->setConfigProperty('invoice_show_email', (bool) f('invoice_show_email'));
|
||||
$plugin->setConfigProperty('invoice_show_web', (bool) f('invoice_show_web'));
|
||||
|
||||
$plugin->setConfigProperty('adresse_client', f('adresse_client'));
|
||||
$plugin->setConfigProperty('code_postal_client', f('code_postal_client'));
|
||||
|
|
@ -36,8 +55,21 @@ $form->runIf('save', function () use ($plugin) {
|
|||
|
||||
|
||||
$tpl->assign('ok', qg('ok') !== null);
|
||||
$tpl->assign('conf', $plugin->getConfig());
|
||||
$conf = $plugin->getConfig();
|
||||
|
||||
foreach (['invoice_show_status', 'invoice_show_address_borders', 'invoice_show_email', 'invoice_show_web'] as $key) {
|
||||
if (!isset($conf->$key)) {
|
||||
$conf->$key = true;
|
||||
}
|
||||
}
|
||||
|
||||
$tpl->assign('conf', $conf);
|
||||
$tpl->assign('patterns', \Paheko\Plugin\Facturation\PATTERNS_LIST);
|
||||
$tpl->assign('champsPaheko', $champsPaheko);
|
||||
$tpl->assign('invoice_themes', [
|
||||
'modern' => 'Moderne',
|
||||
'classic' => 'Classique',
|
||||
'minimal' => 'Minimal',
|
||||
]);
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/config.tpl');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue