Correction erreurs, sécurisation code, personnalisation présentation (Jordan)

This commit is contained in:
Jean-Christophe Engel 2026-07-02 13:38:15 +02:00
parent 717fc5320f
commit 4c71100366
19 changed files with 822 additions and 471 deletions

View file

@ -22,6 +22,42 @@ const PATTERNS_LIST = [
'%06{id}' => 'Numéro unique du document sur 6 chiffres ("000042")',
];
function ensureSchemaColumns(): void
{
$db = \Paheko\DB::getInstance();
$tables = [
'plugin_facturation_clients' => [
'siret' => 'siret TEXT',
'telephone' => 'telephone TEXT',
'email' => 'email TEXT',
'nom_contact' => 'nom_contact TEXT',
'note' => 'note TEXT',
],
'plugin_facturation_factures' => [
'nom_contact' => 'nom_contact TEXT',
'numero_commande' => 'numero_commande TEXT',
'reference_acheteur' => 'reference_acheteur TEXT',
],
];
foreach ($tables as $table => $columns) {
$schema = $db->getTableSchema($table);
if (!$schema) {
continue;
}
foreach ($columns as $column => $definition) {
if (!isset($schema['columns'][$column])) {
$db->exec(sprintf('ALTER TABLE %s ADD COLUMN %s;', $db->quoteIdentifier($table), $definition));
}
}
}
}
ensureSchemaColumns();
$client = new Client;
$facture = new Facture;
@ -63,7 +99,7 @@ $tpl->register_function('money_fac', function (array $params)
$current_value = htmlspecialchars($current_value, ENT_QUOTES, 'UTF-8');
}
$currency = Config::getInstance()->get('monnaie');
$currency = Config::getInstance()->get('currency');
return sprintf('<td><nobr><input type="text" pattern="[0-9]*([.,][0-9]{1,2})?" inputmode="decimal" size="8" class="money" style="width: 60%%" onchange="updateSum();" name="%s" value="%s" /><b>%s</b></nobr></td>', $name, $current_value, $currency);
}
);