requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_ADMIN); $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')); $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->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')); $plugin->setConfigProperty('ville_client', f('ville_client')); $plugin->setConfigProperty('validate_cp', (bool)f('validate_cp')); $plugin->setConfigProperty('unique_client_name', (bool)f('unique_client_name')); $plugin->setConfigProperty('pattern', f('pattern')); $plugin->save(); }, 'facturation_config', PLUGIN_ADMIN_URL . 'config.php?ok'); $tpl->assign('ok', qg('ok') !== null); $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');