Annulation "fusion branche simplification"

This reverts commit 16daac2e24, reversing
changes made to 46d0c838ae.
This commit is contained in:
Jean-Christophe Engel 2024-10-19 14:26:06 +02:00
parent 201682f4d7
commit f6eef8897e
11 changed files with 619 additions and 98 deletions

View file

@ -43,10 +43,14 @@ $db = DB::getInstance();
$step = false;
$radio = $liste = $designations = $prix = [];
$fields = $facture->recu_fields;
$moyens_paiement = $facture->listMoyensPaiement(true);
$tpl->assign('moyens_paiement', $moyens_paiement);
$tpl->assign('moyen_paiement', f('moyen_paiement') ?: 'ES');
$tpl->assign('moyen_paiement_cerfa', f('moyen_paiement_cerfa') ?: 'ES');
$tpl->assign('formes_don', array('1' => 'Acte authentique',
'2' => 'Acte sous seing privé',
'3' => 'Don manuel',
@ -54,6 +58,7 @@ $tpl->assign('formes_don', array('1' => 'Acte authentique',
$tpl->assign('natures_don', array('1' => 'Numéraire',
'2' => 'Chèque',
'3' => 'Virement, CB; ...'));
$tpl->assign('textes_don', $facture->listTextesCerfa());
if ( !$target ) {
f(['id' => 'required|numeric']);
@ -102,6 +107,16 @@ $form->runIf(f('save') && !$form->hasErrors(),
$data['total'] = $data['toto'];
unset($data['toto']);
}
elseif ( f('type') == CERFA )
{
$data['moyen_paiement'] = f('moyen_paiement_cerfa');
$data['contenu'] = [
'forme' => f('forme_don'),
'nature' => f('nature_don'),
'texte' => f('texte_don')];
$data['total'] = Utils::moneyToInteger(f('total'));
unset($data['toto']);
}
if (f('base_receveur') == 'client')
{
$data['receveur_membre'] = 0;
@ -125,9 +140,62 @@ $form->runIf(f('save') && !$form->hasErrors(),
}, $csrf_key);
$form->runIf(f('select_cotis') && !$form->hasErrors(),
function () use ($step)
{
$step = true;
}, 'add_cotis_1');
$form->runIf(f('add_cotis') && !$form->hasErrors(),
function () use ($radio, $fields, $facture, $form)
{
$radio['type'] = f('cotisation');
try
{
$num = (int) str_replace('cotis_', '', $radio['type']);
foreach($fields as $field)
{
$cotis[$field] = f($field.'_'.$num);
}
$r = $facture->getCotis(f('membre_cotis'), $cotis['id']);
$r = $r[0];
$data = [
'type_facture' => COTIS,
'numero' => f('numero_facture'),
'receveur_membre' => 1,
'receveur_id' => f('membre_cotis'),
'date_emission' => f('date_emission'),
'moyen_paiement' => 'AU',
'total' => $r->paid_amount ?? $r->amount,
'contenu' => ['id' => $cotis['id'],
'intitule' => $cotis['label'],
'souscription' => $cotis['date'],
'expiration' => $cotis['expiry'] ]
];
}
catch (UserException $e)
{
$form->addError($e->getMessage());
}
}, 'add_cotis_2');
if (! $form->hasErrors())
{
if (count($data) > 0)
if ($step)
{
try
{
$liste = $facture->getCotis((int)f('membre_cotis'));
}
catch (UserException $e)
{
$form->addError($e->getMessage());
}
}
elseif (count($data) > 0)
{
if ($target)
{
@ -159,13 +227,19 @@ if ($target)
$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'];
}
}
// Type du document:
$type = qg('t') ? (int) qg('t') : null;
// Si le type est défini dans l'URL
if (in_array($type, [DEVIS, FACT], true))
if (in_array($type, [DEVIS, FACT, CERFA, COTIS], true))
{
$radio['type'] = $type;
} // ... s'il a été rempli dans le formulaire envoyé
@ -194,6 +268,14 @@ else
$doc['date_emission'] = f('date_emission') ?: $f->date_emission;
$doc['date_echeance'] = 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'];
}
$radio['type'] = f('type')??$doc['type'];
}
$tpl->assign('types_details', $facture->types);