From 950a6b8b2cb88b0fcab158de4cabb32004293244 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Sat, 22 Mar 2025 18:21:00 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20champ=20note=20=C3=A0=20la=20fiche=20cl?= =?UTF-8?q?ient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/client_modifier.php | 41 ++++++++++++++------------- admin/clients.php | 3 +- data/schema.sql | 3 +- lib/Client.php | 6 +++- templates/client.tpl | 11 +++++++- templates/client_modifier.tpl | 3 +- templates/clients.tpl | 1 + upgrade.php | 53 ++++++++++++++++++++++++++++------- 8 files changed, 86 insertions(+), 35 deletions(-) diff --git a/admin/client_modifier.php b/admin/client_modifier.php index c3b8e3a..5f98dd1 100644 --- a/admin/client_modifier.php +++ b/admin/client_modifier.php @@ -17,27 +17,28 @@ if (!$c) } $form->runIf(f('save') && !$form->hasErrors(), - function () use ($client, $id, $form) - { - try - { - $r = $client->edit($id,[ - 'nom' => f('nom'), - 'adresse' => f('adresse'), - 'code_postal' => f('code_postal'), - 'ville' => f('ville'), - 'siret' => f('siret'), - 'telephone' => f('telephone'), - 'email' => f('email') - ]); + function () use ($client, $id, $form) + { + try + { + $r = $client->edit($id,[ + 'nom' => f('nom'), + 'adresse' => f('adresse'), + 'code_postal' => f('code_postal'), + 'ville' => f('ville'), + 'siret' => f('siret'), + 'telephone' => f('telephone'), + 'email' => f('email'), + 'note' => f('note') + ]); - $r ? Utils::redirect(PLUGIN_ADMIN_URL . 'client.php?id='.(int)$id):''; - } - catch (UserException $e) - { - $form->addError($e->getMessage()); - } - }, 'edit_client'); + $r ? Utils::redirect(PLUGIN_ADMIN_URL . 'client.php?id='.(int)$id):''; + } + catch (UserException $e) + { + $form->addError($e->getMessage()); + } + }, 'edit_client'); $tpl->assign('client', $c); diff --git a/admin/clients.php b/admin/clients.php index 24fe497..c8c1a4c 100644 --- a/admin/clients.php +++ b/admin/clients.php @@ -18,7 +18,8 @@ $form->runIf(f('add') && !$form->hasErrors(), 'ville' => f('ville'), 'siret' => f('siret'), 'telephone' => f('telephone'), - 'email' => f('email') + 'email' => f('email'), + 'note' => f('note') ]); $id ? Utils::redirect(PLUGIN_ADMIN_URL . 'client.php?id='.(int)$id):''; diff --git a/data/schema.sql b/data/schema.sql index 0d9431a..f3119bc 100644 --- a/data/schema.sql +++ b/data/schema.sql @@ -24,7 +24,8 @@ CREATE TABLE IF NOT EXISTS plugin_facturation_clients ( siret TEXT, date_creation TEXT NOT NULL DEFAULT CURRENT_DATE CHECK (date(date_creation) IS NOT NULL AND date(date_creation) = date_creation), -- Date d\'inscription telephone TEXT, - email TEXT + email TEXT, + note TEXT ); diff --git a/lib/Client.php b/lib/Client.php index 66aabf3..edb4994 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -17,7 +17,8 @@ class Client 'ville', 'siret', 'telephone', - 'email' + 'email', + 'note' ]; private $config = [ @@ -136,6 +137,9 @@ class Client 'email' => [ 'label' => 'E-Mail', ], + 'note' => [ + 'label' => 'Note', + ], 'nb_documents' => [ 'label' => 'Nombre de documents', 'select' => '(SELECT COUNT(*) FROM plugin_facturation_factures WHERE receveur_id = c.id)', diff --git a/templates/client.tpl b/templates/client.tpl index 6b8db5b..0d72337 100644 --- a/templates/client.tpl +++ b/templates/client.tpl @@ -48,6 +48,15 @@ {/if} +
Note
+
+ {if empty($client.note)} + (Non renseigné) + {else} + {$client.note} + {/if} +
+
Date d'ajout
{$client.date_creation|date:'d/m/Y'}
@@ -94,4 +103,4 @@

Ce client n'a pas de document associé.

{/if} -{include file="_foot.tpl"} \ No newline at end of file +{include file="_foot.tpl"} diff --git a/templates/client_modifier.tpl b/templates/client_modifier.tpl index 42e6f1c..ba611dd 100644 --- a/templates/client_modifier.tpl +++ b/templates/client_modifier.tpl @@ -14,6 +14,7 @@ {input type="text" name="siret" label="SIREN/SIRET" source=$client} {input type="tel" name="telephone" label="Téléphone" source=$client} {input type="email" name="email" label="Adresse e-mail" source=$client} + {input type="textarea" cols="60" rows="3" name="note" label="Note" source=$client} @@ -24,4 +25,4 @@ -{include file="_foot.tpl"} \ No newline at end of file +{include file="_foot.tpl"} diff --git a/templates/clients.tpl b/templates/clients.tpl index 9c40f2c..9514d68 100644 --- a/templates/clients.tpl +++ b/templates/clients.tpl @@ -61,6 +61,7 @@ {input type="text" name="siret" label="SIREN/SIRET"} {input type="tel" name="telephone" label="Téléphone"} {input type="email" name="email" label="Adresse e-mail"} + {input type="textarea" cols="60" rows="3" name="note" label="Note"} diff --git a/upgrade.php b/upgrade.php index feb994f..385f171 100644 --- a/upgrade.php +++ b/upgrade.php @@ -12,7 +12,7 @@ error_log("upgrade::version = " . $old_version); if (version_compare($old_version, '0.2.0', '<')) { $r = (array) DB::getInstance()->get('SELECT * FROM plugin_facturation_factures'); - + foreach ($r as $e) { $e->contenu =json_encode(unserialize((string) $e->contenu)); $db->update('plugin_facturation_factures', $e, $db->where('id', (int)$e->id)); @@ -33,7 +33,7 @@ if (version_compare($old_version, '0.3.0', '<')) $db->exec('DROP TABLE `plugin_facturation_config`;'); } -// 0.4.0 - +// 0.4.0 - if (version_compare($old_version, '0.4.0', '<')) { $db->exec(<<contenu as $line => $content) { // Petit bug qui peut arriver avec des contenus mal enregistrés en db - if (is_int($content)) + if (is_int($content)) { continue; } @@ -143,7 +143,7 @@ EOT } } -// 0.6.2 - +// 0.6.2 - if (version_compare($old_version, '0.6.2', '<')) { define('DEVIS', 0); @@ -168,14 +168,14 @@ if (version_compare($old_version, '0.6.2', '<')) INSERT OR IGNORE INTO plugin_facturation_txt_cerfa ("id","menu","texte") VALUES ('0','Aucun',''); INSERT OR IGNORE INTO plugin_facturation_txt_cerfa - ("id","menu","texte") + ("id","menu","texte") VALUES ('1','HelloAsso','Don via HelloAsso'); INSERT OR IGNORE INTO plugin_facturation_txt_cerfa - ("id","menu","texte") + ("id","menu","texte") VALUES ('2','Frais de déplacement', 'Renonciation aux remboursements de frais de déplacement'); INSERT OR IGNORE INTO plugin_facturation_txt_cerfa - ("id","menu","texte") + ("id","menu","texte") VALUES ('3','Don en nature','Don en nature'); EOT ); @@ -251,3 +251,36 @@ if (version_compare($old_version, '0.12', '<')) EOT ); } + +// version 0.15 (?) Ajout champ note à la table client +if (version_compare($old_version, '0.15', '<')) +{ + $db->exec(<<iterate($sql) as $client) + { + $db->insert('plugin_facturation_clients_tmp', $client); + } + // remplacer l'ancienne table par la nouvelle + $db->exec(<<