Integration contrib @DDgallo sur CERFA

This commit is contained in:
Noizette 2022-01-07 01:24:32 +01:00
parent 637c493671
commit 61f40e100d
8 changed files with 218 additions and 42 deletions

View file

@ -39,7 +39,7 @@ if (version_compare($infos->version, '0.3.0', '<'))
$db->exec('DROP TABLE `plugin_facturation_config`;');
}
// 0.4.0 - Migration Facturation\Config vers la table plugins
// 0.4.0 -
if (version_compare($infos->version, '0.4.0', '<'))
{
$db->exec(<<<EOT
@ -84,7 +84,7 @@ EOT
}
// 0.6.0 - Migration Facturation\Config vers la table plugins
// 0.6.0 -
if (version_compare($infos->version, '0.6.0', '<'))
{
$r = $db->first('SELECT id, total FROM plugin_facturation_factures;');
@ -113,8 +113,9 @@ if (version_compare($infos->version, '0.6.0', '<'))
ALTER TABLE plugin_facturation_factures_tmp RENAME TO plugin_facturation_factures;
EOT
);
foreach($factures = $facture->listAll() as $k=>$f)
$factures = $facture->listAll();
foreach($factures as $k=>$f)
{
foreach($f->contenu as $line => $content)
{
@ -141,4 +142,54 @@ EOT
$path = __DIR__.'/data/default_sign.png';
$png = (new File)->createAndStore('skel/plugin/facturation','sign.png', $path, null);
}
}
// 0.6.2 -
if (version_compare($infos->version, '0.6.2', '<'))
{
$db->exec(<<<EOT
INSERT OR IGNORE INTO plugin_facturation_paiement
(code, nom) VALUES ('HA', 'HelloAsso');
INSERT OR IGNORE INTO plugin_facturation_paiement
(code, nom) VALUES ('AU', 'Autre');
CREATE TABLE IF NOT EXISTS
plugin_facturation_txt_cerfa
(
id PRIMARY KEY,
menu TEXT NOT NULL UNIQUE,
texte TEXT NOT NULL
);
INSERT OR IGNORE INTO plugin_facturation_txt_cerfa
("id","menu","texte") VALUES ('0','Aucun','');
INSERT OR IGNORE INTO plugin_facturation_txt_cerfa
("id","menu","texte")
VALUES ('1','HelloAsso','Don via HelloAsso');
INSERT OR IGNORE INTO plugin_facturation_txt_cerfa
("id","menu","texte")
VALUES ('2','Frais de déplacement',
'Renonciation aux remboursements de frais de déplacement');
INSERT OR IGNORE INTO plugin_facturation_txt_cerfa
("id","menu","texte")
VALUES ('3','Don en nature','Don en nature');
EOT
);
// Migration CERFA
$factures = $facture->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);
}
}