Ajout numéro SIREN/SIRET pour un client
This commit is contained in:
parent
438e9c6116
commit
b6bb4fd80d
12 changed files with 65 additions and 6 deletions
35
upgrade.php
35
upgrade.php
|
|
@ -209,3 +209,38 @@ if (version_compare($old_version, '0.8.1', '<'))
|
|||
{
|
||||
$plugin->unregisterSignal('menu.item');
|
||||
}
|
||||
|
||||
// 0.8.5 Ajout champs SIREN/SIRET à la table clients
|
||||
|
||||
if (version_compare($old_version, '0.8.5', '<'))
|
||||
{
|
||||
$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 NOT NULL,
|
||||
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
|
||||
);
|
||||
EOT
|
||||
);
|
||||
// copier les clients dans la table temporaire en ajoutant un siret fictif
|
||||
$sql = 'SELECT * FROM plugin_facturation_clients';
|
||||
foreach ($db->iterate($sql) as $client)
|
||||
{
|
||||
$client->siret = "";
|
||||
$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
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue