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

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

View file

@ -4,7 +4,7 @@ namespace Paheko\Plugin\Facturation;
use Paheko\DB;
use Paheko\DynamicList;
use Paheko\Entities\Plugin;
use Paheko\Plugins;
use Paheko\UserException;
use Paheko\Utils;
@ -29,9 +29,12 @@ class Client
public function __construct()
{
$plugin = new Plugin('facturation');
$this->config['unique_client_name'] = $plugin->getConfig('unique_client_name') ?: false;
$this->config['validate_cp'] = $plugin->getConfig('validate_cp') ?: false;
$plugin = Plugins::get('facturation');
if ($plugin) {
$this->config['unique_client_name'] = (bool) $plugin->getConfig('unique_client_name');
$this->config['validate_cp'] = (bool) ($plugin->getConfig('validate_cp') ?? true);
}
}
public function _checkFields(&$data)
@ -102,8 +105,20 @@ class Client
{
$db = DB::getInstance();
return $db->first('SELECT *, strftime(\'%s\', date_creation) AS date_creation
$client = $db->first('SELECT *, strftime(\'%s\', date_creation) AS date_creation
FROM plugin_facturation_clients WHERE id = ? LIMIT 1;', (int)$id);
if (!$client) {
return null;
}
foreach (['siret', 'telephone', 'email', 'nom_contact', 'note'] as $key) {
if (!property_exists($client, $key)) {
$client->$key = null;
}
}
return $client;
}
public function listAll()