Ajout champ note à la fiche client

This commit is contained in:
Jean-Christophe Engel 2025-03-22 18:21:00 +01:00
parent 4ee3f65d0a
commit 950a6b8b2c
8 changed files with 86 additions and 35 deletions

View File

@ -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);

View File

@ -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):'';

View File

@ -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
);

View File

@ -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)',

View File

@ -48,6 +48,15 @@
{/if}
</dd>
<dt>Note</dt>
<dd>
{if empty($client.note)}
<em>(Non renseigné)</em>
{else}
{$client.note}
{/if}
</dd>
<dt>Date d'ajout</dt>
<dd>{$client.date_creation|date:'d/m/Y'}</dd>

View File

@ -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}
</dl>
</fieldset>

View File

@ -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"}
</dl>
</fieldset>

View File

@ -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(<<<EOT
CREATE TABLE IF NOT EXISTS plugin_facturation_clients_tmp
(
id INTEGER PRIMARY KEY,
nom TEXT NOT NULL,
adresse TEXT NOT NULL,
code_postal TEXT NOT NULL,
ville TEXT NOT NULL,
siret TEXT,
date_creation TEXT NOT NULL DEFAULT CURRENT_DATE CHECK (date(date_creation) IS NOT NULL AND date(date_creation) = date_creation),
telephone TEXT,
email TEXT,
note TEXT
);
EOT
);
// copier les clients dans la table temporaire
$sql = 'SELECT * FROM plugin_facturation_clients';
foreach ($db->iterate($sql) as $client)
{
$db->insert('plugin_facturation_clients_tmp', $client);
}
// remplacer l'ancienne table par la nouvelle
$db->exec(<<<EOT
DROP TABLE plugin_facturation_clients;
ALTER TABLE plugin_facturation_clients_tmp RENAME TO plugin_facturation_clients;
EOT
);
}