Integration contrib @DDgallo sur CERFA
This commit is contained in:
parent
637c493671
commit
61f40e100d
@ -42,6 +42,25 @@ INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('ES', 'Esp
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('PR', 'Prélèvement');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('TI', 'TIP');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('VI', 'Virement');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('HA', 'HelloAsso');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('AU', 'Autre');
|
||||
|
||||
-- Modif DD -- ajout de la table des textes associés aux CERFA
|
||||
CREATE TABLE IF NOT EXISTS plugin_facturation_txt_cerfa
|
||||
-- Textes explicatifs associés aux CERFA
|
||||
(
|
||||
id PRIMARY KEY,
|
||||
menu TEXT NOT NULL UNIQUE,
|
||||
texte TEXT NOT NULL
|
||||
);
|
||||
|
||||
----
|
||||
-- Data dump for plugin_facturation_txt_cerfa, a total of 4 rows
|
||||
----
|
||||
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');
|
||||
|
||||
-- CREATE TABLE IF NOT EXISTS plugin_facturation_produits (
|
||||
-- id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||
|
@ -1,4 +1,5 @@
|
||||
DROP TABLE `plugin_facturation_factures`;
|
||||
DROP TABLE `plugin_facturation_clients`;
|
||||
DROP TABLE `plugin_facturation_paiement`;
|
||||
DROP TABLE `plugin_facturation_txt_cerfa`;
|
||||
-- DROP TABLE `plugin_facturation_produits`;
|
@ -384,11 +384,15 @@ class Facture
|
||||
Utils::date_fr($content->souscription, 'd/m/Y')
|
||||
);
|
||||
}
|
||||
else {
|
||||
elseif ($row->type_facture != CERFA) {
|
||||
$row->contenu = implode("\n", array_map(function ($row) use ($currency) {
|
||||
return sprintf('%s : %s %s', $row->designation, Utils::money_format($row->prix), $currency);
|
||||
}, (array)$content));
|
||||
}
|
||||
else
|
||||
{
|
||||
$row->contenu = '';
|
||||
}
|
||||
});
|
||||
|
||||
$list->setPageSize(1000);
|
||||
@ -498,6 +502,17 @@ class Facture
|
||||
}
|
||||
}
|
||||
|
||||
/* modif DD -- lecture et retour des textes de CERFA -- */
|
||||
public function listTextesCerfa($menu = true)
|
||||
{
|
||||
$db = DB::getInstance();
|
||||
|
||||
$sel = ($menu) ? 'id, menu' : 'id, texte';
|
||||
$query = 'SELECT '.$sel.' FROM "plugin_facturation_txt_cerfa" WHERE 1 ORDER BY id ;';
|
||||
|
||||
return $db->getAssoc($query);
|
||||
}
|
||||
|
||||
public function getMoyenPaiement($code)
|
||||
{
|
||||
$db = DB::getInstance();
|
||||
|
@ -84,7 +84,7 @@
|
||||
{/if}
|
||||
</fieldset>
|
||||
|
||||
<fieldset data-types="t0 t1 t2">
|
||||
<fieldset data-types="t0 t1">
|
||||
<legend>Contenu</legend>
|
||||
|
||||
<dl>
|
||||
@ -140,6 +140,19 @@
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<fieldset data-types="t2">
|
||||
<legend>Contenu</legend>
|
||||
<p><b>Montant du don</b>
|
||||
{input type="money" name="total" label="Montant" required=1 source=$doc}
|
||||
<dl>
|
||||
{input type="select" name="forme_don" required=1 label="Forme du don" source=$doc options=$formes_don default=$doc.forme_don}
|
||||
{input type="select" name="nature_don" required=1 label="Nature du don" source=$doc options=$natures_don default=$doc.nature_don}
|
||||
{input type="select" name="texte_don" required=1 label="Texte explicatif" source=$doc options=$textes_don default=$doc.texte_don}
|
||||
{input type="select" name="moyen_paiement" required=1 label="Moyen de paiement" source=$doc options=$moyens_paiement default=$doc.moyen_paiement}
|
||||
</dl>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<p class="submit" data-types="t0 t1 t2">
|
||||
{csrf_field key=$csrf_key}
|
||||
{button type="submit" name="save" label="Enregistrer" shape="right" class="main"}
|
||||
|
57
upgrade.php
57
upgrade.php
@ -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;');
|
||||
@ -114,7 +114,8 @@ if (version_compare($infos->version, '0.6.0', '<'))
|
||||
EOT
|
||||
);
|
||||
|
||||
foreach($factures = $facture->listAll() as $k=>$f)
|
||||
$factures = $facture->listAll();
|
||||
foreach($factures as $k=>$f)
|
||||
{
|
||||
foreach($f->contenu as $line => $content)
|
||||
{
|
||||
@ -142,3 +143,53 @@ EOT
|
||||
$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);
|
||||
}
|
||||
}
|
@ -35,6 +35,12 @@ if (qg('copy') !== null && $f = $facture->get((int)qg('copy'))) {
|
||||
$doc['base_receveur'] = $f->receveur_membre ? 'membre' : 'client';
|
||||
$doc['client'] = $f->receveur_id;
|
||||
$doc['membre'] = $f->receveur_id;
|
||||
|
||||
if ( $f->type_facture == CERFA ) {
|
||||
$doc['forme_don'] = $f->contenu['forme'];
|
||||
$doc['nature_don'] = $f->contenu['nature'];
|
||||
$doc['texte_don'] = $f->contenu['texte'];
|
||||
}
|
||||
}
|
||||
|
||||
$tpl->assign('require_number', $require_number);
|
||||
@ -43,6 +49,15 @@ $tpl->assign('number_pattern', PATTERNS_LIST[$plugin->getConfig('pattern')]);
|
||||
$tpl->assign('moyens_paiement', $moyens_paiement);
|
||||
$tpl->assign('moyen_paiement', f('moyen_paiement') ?: 'ES');
|
||||
|
||||
$tpl->assign('formes_don', array('1' => 'Acte authentique',
|
||||
'2' => 'Acte sous seing privé',
|
||||
'3' => 'Don manuel',
|
||||
'4' => 'Autres'));
|
||||
$tpl->assign('natures_don', array('1' => 'Numéraire',
|
||||
'2' => 'Chèque',
|
||||
'3' => 'Virement, CB; ...'));
|
||||
$tpl->assign('textes_don', $facture->listTextesCerfa());
|
||||
|
||||
if (f('save'))
|
||||
{
|
||||
$form->check($csrf_key, [
|
||||
@ -78,21 +93,29 @@ if (f('save'))
|
||||
'moyen_paiement' => f('moyen_paiement'),
|
||||
'toto' => 0
|
||||
];
|
||||
|
||||
if (in_array(f('type'), [DEVIS, FACT, CERFA]))
|
||||
$truc['type_facture'] = f('type');
|
||||
if (in_array(f('type'), [DEVIS, FACT]))
|
||||
{
|
||||
$truc['type_facture'] = f('type');
|
||||
}
|
||||
|
||||
foreach(f('designation') as $k=>$value)
|
||||
{
|
||||
$truc['contenu'][$k]['designation'] = $value;
|
||||
$truc['contenu'][$k]['prix'] = Utils::moneyToInteger(f('prix')[$k]);
|
||||
$truc['toto'] += Utils::moneyToInteger(f('prix')[$k]);
|
||||
}
|
||||
$truc['total'] = $truc['toto'];
|
||||
unset($truc['toto']);
|
||||
|
||||
foreach(f('designation') as $k=>$value)
|
||||
{
|
||||
$truc['contenu'][$k]['designation'] = $value;
|
||||
$truc['contenu'][$k]['prix'] = Utils::moneyToInteger(f('prix')[$k]);
|
||||
$truc['toto'] += Utils::moneyToInteger(f('prix')[$k]);
|
||||
}
|
||||
$truc['total'] = $truc['toto'];
|
||||
unset($truc['toto']);
|
||||
}
|
||||
elseif (f('type') == CERFA)
|
||||
{
|
||||
$truc['contenu'] = [
|
||||
'forme' => f('forme_don'),
|
||||
'nature' => f('nature_don'),
|
||||
'texte' => f('texte_don')];
|
||||
unset($truc['toto']);
|
||||
$truc['total'] = Utils::moneyToInteger(f('total'));
|
||||
}
|
||||
if (f('base_receveur') == 'client')
|
||||
{
|
||||
$truc['receveur_membre'] = 0;
|
||||
|
@ -18,6 +18,15 @@ $moyens_paiement = $facture->listMoyensPaiement(true);
|
||||
$tpl->assign('moyens_paiement', $moyens_paiement);
|
||||
$tpl->assign('moyen_paiement', f('moyen_paiement') ?: 'ES');
|
||||
|
||||
$tpl->assign('formes_don', array('1' => 'Acte authentique',
|
||||
'2' => 'Acte sous seing privé',
|
||||
'3' => 'Don manuel',
|
||||
'4' => 'Autres'));
|
||||
$tpl->assign('natures_don', array('1' => 'Numéraire',
|
||||
'2' => 'Chèque',
|
||||
'3' => 'Virement, CB; ...'));
|
||||
$tpl->assign('textes_don', $facture->listTextesCerfa());
|
||||
|
||||
qv(['id' => 'required|numeric']);
|
||||
$id = (int) qg('id');
|
||||
|
||||
@ -66,21 +75,30 @@ if(f('save'))
|
||||
'moyen_paiement' => f('moyen_paiement'),
|
||||
'toto' => 0
|
||||
];
|
||||
$truc['type_facture'] = f('type');
|
||||
|
||||
if (in_array(f('type'), [DEVIS, FACT, CERFA]))
|
||||
if (in_array(f('type'), [DEVIS, FACT]))
|
||||
{
|
||||
$truc['type_facture'] = f('type');
|
||||
foreach(f('designation') as $k=>$value)
|
||||
{
|
||||
$truc['contenu'][$k]['designation'] = $value;
|
||||
$truc['contenu'][$k]['prix'] = Utils::moneyToInteger(f('prix')[$k]);
|
||||
$truc['toto'] += Utils::moneyToInteger(f('prix')[$k]);
|
||||
|
||||
}
|
||||
$truc['total'] = $truc['toto'];
|
||||
unset($truc['toto']);
|
||||
}
|
||||
elseif ( f('type') == CERFA )
|
||||
{
|
||||
$truc['contenu'] = [
|
||||
'forme' => f('forme_don'),
|
||||
'nature' => f('nature_don'),
|
||||
'texte' => f('texte_don')];
|
||||
$truc['total'] = Utils::moneyToInteger(f('total'));
|
||||
unset($truc['toto']);
|
||||
}
|
||||
|
||||
foreach(f('designation') as $k=>$value)
|
||||
{
|
||||
$truc['contenu'][$k]['designation'] = $value;
|
||||
$truc['contenu'][$k]['prix'] = Utils::moneyToInteger(f('prix')[$k]);
|
||||
$truc['toto'] += Utils::moneyToInteger(f('prix')[$k]);
|
||||
|
||||
}
|
||||
$truc['total'] = $truc['toto'];
|
||||
unset($truc['toto']);
|
||||
|
||||
if (f('base_receveur') == 'client')
|
||||
{
|
||||
@ -206,7 +224,13 @@ $doc['membre'] = $f->receveur_id;
|
||||
|
||||
$doc['date_emission'] = strtotime(f('date_emission')) ?: $f->date_emission;
|
||||
$doc['date_echeance'] = strtotime(f('date_echeance')) ?: $f->date_echeance; // Smarty m'a saoulé pour utiliser form_field|date_fr:---
|
||||
|
||||
/* modif DD -- CERFA -------------------------------------- */
|
||||
if ( $f->type_facture == CERFA ) {
|
||||
$doc['total'] = $f->total;
|
||||
$doc['forme_don'] = $f->contenu['forme'];
|
||||
$doc['nature_don'] = $f->contenu['nature'];
|
||||
$doc['texte_don'] = $f->contenu['texte'];
|
||||
}
|
||||
$tpl->assign('doc', $doc);
|
||||
|
||||
$radio['type'] = f('type')??$doc['type'];
|
||||
@ -223,7 +247,7 @@ $prix = [];
|
||||
// C'est un peu l'équivalent de form_field, mais j'avais écrit ça avant
|
||||
// et oulala, c'est un peu complexe, faudrait réfléchir keskivomieux
|
||||
$from_user = false;
|
||||
if ($f->type_facture != COTIS)
|
||||
if (in_array($f->type_facture, [DEVIS, FACT]))
|
||||
{
|
||||
if (($d = f('designation')) && ($p = f('prix')))
|
||||
{
|
||||
|
@ -309,6 +309,7 @@ elseif ($f->type_facture == CERFA)
|
||||
|
||||
$doc = 'Reçu de don n°'. $f->numero;
|
||||
$url = WWW_URL;
|
||||
$libelles = $facture->listTextesCerfa(false);
|
||||
|
||||
$t['numero'] = $f->numero;
|
||||
$t['nom_asso'] = $config->get('nom_asso');
|
||||
@ -332,6 +333,10 @@ elseif ($f->type_facture == CERFA)
|
||||
$t['m'] = utf8_decode($f->date_emission->format('m'));
|
||||
$t['Y'] = utf8_decode($f->date_emission->format('Y'));
|
||||
|
||||
$t['forme'] = $f->contenu['forme'];
|
||||
$t['nature'] = $f->contenu['nature'];
|
||||
$t['texte'] = $libelles[$f->contenu['texte']];
|
||||
|
||||
$t['art200'] = $t['art238'] = $t['art885'] = '';
|
||||
if($plugin->getConfig('droit_art200')){
|
||||
$t['art200'] = 'X';
|
||||
@ -343,15 +348,41 @@ elseif ($f->type_facture == CERFA)
|
||||
$t['art885'] = 'X';
|
||||
}
|
||||
|
||||
// forme du don
|
||||
switch ($t['forme']){
|
||||
case '1':
|
||||
$t['frm'] = 'left: 15mm;';
|
||||
break;
|
||||
case '2':
|
||||
$t['frm'] = 'left: 57.3mm;';
|
||||
break;
|
||||
case '3':
|
||||
$t['frm'] = 'left: 115.2mm;';
|
||||
break;
|
||||
case '4':
|
||||
$t['frm'] = 'left: 175.2mm;';
|
||||
}
|
||||
// nature du don
|
||||
switch ($t['nature']){
|
||||
case '1':
|
||||
$t['nat'] = 'left: 15mm;';
|
||||
break;
|
||||
case '2':
|
||||
$t['nat'] = 'left: 57.3mm;';
|
||||
break;
|
||||
case '3':
|
||||
$t['nat'] = 'left: 115.2mm;';
|
||||
}
|
||||
// moyen de paiement
|
||||
switch ($f->moyen_paiement){
|
||||
case 'ES':
|
||||
$t['pos'] = ' top: 158.2mm; left: 15mm;';
|
||||
$t['pos'] = 'left: 15mm;';
|
||||
break;
|
||||
case 'CH':
|
||||
$t['pos'] = ' top: 158.2mm; left: 57.3mm;';
|
||||
$t['pos'] = 'left: 57.3mm;';
|
||||
break;
|
||||
default:
|
||||
$t['pos'] = ' top: 158.2mm; left: 115.2mm;';
|
||||
$t['pos'] = 'left: 115.2mm;';
|
||||
}
|
||||
|
||||
$t['d2'] = utf8_decode($f->date_echeance->format('d'));
|
||||
@ -436,11 +467,10 @@ elseif ($f->type_facture == CERFA)
|
||||
<div style="top: 96mm; left: 53mm;">${t['art200']}</div>
|
||||
<div style="top: 96mm; left: 103mm;">${t['art238']}</div>
|
||||
<div style="top: 96mm; left: 153.0mm;">${t['art885']}</div>
|
||||
|
||||
<div style="top: 113mm; left: 115mm;">X</div>
|
||||
<div style="top: 136mm; left: 15mm;">X</div>
|
||||
|
||||
<div style="${t['pos']}">X</div>
|
||||
<div style="top: 113mm; ${t['frm']}">X</div>
|
||||
<div style="top: 136mm; ${t['nat']}">X</div>
|
||||
<div style="top: 142mm; left: 25mm;">${t['texte']}</div>
|
||||
<div style="top: 158.2mm; ${t['pos']}">X</div>
|
||||
|
||||
<div style="top: 239mm; left: 139mm;">${t['d2']}</div>
|
||||
<div style="top: 239mm; left: 148mm;">${t['m2']}</div>
|
||||
|
Loading…
Reference in New Issue
Block a user