diff --git a/upgrade.php b/upgrade.php index c2ec1b8..ec88e50 100644 --- a/upgrade.php +++ b/upgrade.php @@ -4,18 +4,12 @@ namespace Paheko; use Paheko\Plugin\Facturation\Facture; use Paheko\Entities\Files\File; -define('DEVIS', 0); -define('FACT', 1); -define('CERFA', 2); -define('COTIS', 3); - $db = DB::getInstance(); -$facture = new Facture; -$version = $plugin->get('version'); - +$old_version = $plugin->oldVersion(); +error_log("upgrade::version = " . $old_version); // 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'); @@ -26,7 +20,7 @@ if (version_compare($version, '0.2.0', '<')) } // 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;'); foreach($conf as $k=>$v) @@ -40,7 +34,7 @@ if (version_compare($version, '0.3.0', '<')) } // 0.4.0 - -if (version_compare($version, '0.4.0', '<')) +if (version_compare($old_version, '0.4.0', '<')) { $db->exec(<<first('SELECT id, total FROM plugin_facturation_factures;'); if (strpos($r->total,'.')) { @@ -145,8 +144,13 @@ EOT } // 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(<<setConfig('ttc', false); } -// 0.7.4 - Signal menu item -if (version_compare($version, '0.8.1', '<')) +// 0.8.1 - Signal menu item +if (version_compare($old_version, '0.8.1', '<')) { $plugin->unregisterSignal('menu.item'); -} \ No newline at end of file +}