Utiliser des entiers au lieu de float tel Garradin

This commit is contained in:
Noizette 2021-11-05 23:47:36 +01:00
parent 11974482f2
commit ede7c789d7
13 changed files with 189 additions and 139 deletions

View file

@ -65,28 +65,17 @@ if(f('save'))
'toto' => 0
];
if (f('type') == DEVIS)
if (in_array(f('type'), [DEVIS, FACT, CERFA]))
{
$truc['type_facture'] = DEVIS;
}
elseif (f('type') == FACT)
{
$truc['type_facture'] = FACT;
}
elseif (f('type') == CERFA)
{
$truc['type_facture'] = CERFA;
}
elseif (f('type') == COTIS)
{
$truc['type_facture'] = COTIS;
$truc['type_facture'] = f('type');
}
foreach(f('designation') as $k=>$value)
{
$truc['contenu'][$k]['designation'] = $value;
$truc['contenu'][$k]['prix'] = f('prix')[$k];
$truc['toto'] += f('prix')[$k];
$truc['contenu'][$k]['prix'] = Utils::moneyToInteger(f('prix')[$k]);
$truc['toto'] += Utils::moneyToInteger(f('prix')[$k]);
}
$truc['total'] = $truc['toto'];
unset($truc['toto']);
@ -229,39 +218,39 @@ $tpl->assign(compact('liste', 'radio', 'step'));
// 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 (($d = f('designation')) && ($p = f('prix')))
{
foreach($d as $k=>$v)
{
if ($v == '' && $p[$k] == 0)
if (empty($v) && empty($p[$k]))
{
continue;
}
$designations[] = $v;
$prix[] = $p[$k];
}
$from_user = true;
}
else
{
foreach($f->contenu as $k=>$v)
{
if ($v['designation'] == '' && $v['prix'] == 0)
if (empty($v['designation']) && empty($v['prix']))
{
continue;
}
$designations[] = $v['designation'];
$prix[] = $v['prix'];
}
$from_user = false;
}
}
$tpl->assign('designations', $designations??[]);
$tpl->assign('prix', $prix??[]);
$tpl->assign('identite', $identite);
$tpl->assign(compact('designations', 'prix', 'from_user', 'identite'));
$tpl->assign('membres', $db->getAssoc('SELECT id, '.$identite.' FROM membres WHERE id_category != -2 NOT IN (SELECT id FROM users_categories WHERE hidden = 1);'));
$tpl->assign('clients', $db->getAssoc('SELECT id, nom FROM plugin_facturation_clients;'));