Résolution problèmes upgrade.php

This commit is contained in:
Jean-Christophe Engel 2024-01-10 17:35:07 +01:00
parent bf45ffd223
commit 6c3af00f16
1 changed files with 21 additions and 17 deletions

View File

@ -4,18 +4,12 @@ namespace Paheko;
use Paheko\Plugin\Facturation\Facture; use Paheko\Plugin\Facturation\Facture;
use Paheko\Entities\Files\File; use Paheko\Entities\Files\File;
define('DEVIS', 0);
define('FACT', 1);
define('CERFA', 2);
define('COTIS', 3);
$db = DB::getInstance(); $db = DB::getInstance();
$facture = new Facture; $old_version = $plugin->oldVersion();
$version = $plugin->get('version'); error_log("upgrade::version = " . $old_version);
// 0.2.0 - Stock le contenu en json plutôt qu'en serialized // 0.2.0 - Stock le contenu en json plutôt qu'en serialized
if (version_compare($version, '0.2.0', '<')) if (version_compare($old_version, '0.2.0', '<'))
{ {
$r = (array) DB::getInstance()->get('SELECT * FROM plugin_facturation_factures'); $r = (array) DB::getInstance()->get('SELECT * FROM plugin_facturation_factures');
@ -26,7 +20,7 @@ if (version_compare($version, '0.2.0', '<'))
} }
// 0.3.0 - Migration Facturation\Config vers la table plugins // 0.3.0 - Migration Facturation\Config vers la table plugins
if (version_compare($version, '0.3.0', '<')) if (version_compare($old_version, '0.3.0', '<'))
{ {
$conf = $db->getAssoc('SELECT cle, valeur FROM plugin_facturation_config ORDER BY cle;'); $conf = $db->getAssoc('SELECT cle, valeur FROM plugin_facturation_config ORDER BY cle;');
foreach($conf as $k=>$v) foreach($conf as $k=>$v)
@ -40,7 +34,7 @@ if (version_compare($version, '0.3.0', '<'))
} }
// 0.4.0 - // 0.4.0 -
if (version_compare($version, '0.4.0', '<')) if (version_compare($old_version, '0.4.0', '<'))
{ {
$db->exec(<<<EOT $db->exec(<<<EOT
CREATE TABLE IF NOT EXISTS plugin_facturation_paiement CREATE TABLE IF NOT EXISTS plugin_facturation_paiement
@ -85,8 +79,13 @@ EOT
} }
// 0.6.0 - // 0.6.0 -
if (version_compare($version, '0.6.0', '<')) if (version_compare($old_version, '0.6.0', '<'))
{ {
define('DEVIS', 0);
define('FACT', 1);
define('CERFA', 2);
define('COTIS', 3);
$facture = new Facture;
$r = $db->first('SELECT id, total FROM plugin_facturation_factures;'); $r = $db->first('SELECT id, total FROM plugin_facturation_factures;');
if (strpos($r->total,'.')) if (strpos($r->total,'.'))
{ {
@ -145,8 +144,13 @@ EOT
} }
// 0.6.2 - // 0.6.2 -
if (version_compare($version, '0.6.2', '<')) if (version_compare($old_version, '0.6.2', '<'))
{ {
define('DEVIS', 0);
define('FACT', 1);
define('CERFA', 2);
define('COTIS', 3);
$facture = new Facture;
$db->exec(<<<EOT $db->exec(<<<EOT
INSERT OR IGNORE INTO plugin_facturation_paiement INSERT OR IGNORE INTO plugin_facturation_paiement
(code, nom) VALUES ('HA', 'HelloAsso'); (code, nom) VALUES ('HA', 'HelloAsso');
@ -195,13 +199,13 @@ EOT
} }
// 0.7.1 - Ajout clé config TTC/HT // 0.7.1 - Ajout clé config TTC/HT
if (version_compare($version, '0.7.1', '<')) if (version_compare($old_version, '0.7.1', '<'))
{ {
$plugin->setConfig('ttc', false); $plugin->setConfig('ttc', false);
} }
// 0.7.4 - Signal menu item // 0.8.1 - Signal menu item
if (version_compare($version, '0.8.1', '<')) if (version_compare($old_version, '0.8.1', '<'))
{ {
$plugin->unregisterSignal('menu.item'); $plugin->unregisterSignal('menu.item');
} }