oldVersion(); error_log("upgrade::version = " . $old_version); // 0.2.0 - Stock le contenu en json plutôt qu'en serialized 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)); } } // 0.3.0 - Migration Facturation\Config vers la table plugins 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) { if(!$plugin->setConfig($k, $v)) { throw new UserException('Erreur dans la conversion de la configuration pour la clé : '.$k); } } $db->exec('DROP TABLE `plugin_facturation_config`;'); } // 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,'.')) { // SQL -> total integer $db->exec(<<listAll(); foreach($factures as $k=>$f) { foreach($f->contenu as $line => $content) { // Petit bug qui peut arriver avec des contenus mal enregistrés en db if (is_int($content)) { continue; } $contenu[] = ['designation' => $content['designation'], 'prix' => (int) ($content['prix'] * 100) ]; } $f->contenu = $contenu; $data = (array) $f; $data['total'] = (int) ($data['total'] * 100); unset($data['id']); unset($data['date_emission']); unset($data['date_echeance']); $facture->edit($f->id, $data); unset($contenu); } $path = __DIR__.'/data/default_sign.png'; $png = (new File)->createAndStore('skel/plugin/facturation','sign.png', $path, null); } } // 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(<<listAll(); foreach($factures as $k=>$f) { if ($f->type_facture != CERFA) { continue; } $f->contenu = ['forme' => 1, 'nature' => 1, 'texte' => 0]; $data = (array) $f; unset($data['id']); unset($data['date_emission']); unset($data['date_echeance']); $facture->edit($f->id, $data); } } // 0.7.1 - Ajout clé config TTC/HT if (version_compare($old_version, '0.7.1', '<')) { $plugin->setConfig('ttc', false); } // 0.8.1 - Signal menu item 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(<<iterate($sql) as $client) { $db->insert('plugin_facturation_clients_tmp', $client); } // remplacer l'ancienne table par la nouvelle $db->exec(<<