Utiliser des entiers au lieu de float tel Garradin
This commit is contained in:
parent
11974482f2
commit
ede7c789d7
13 changed files with 189 additions and 139 deletions
|
|
@ -43,60 +43,52 @@ if (f('add'))
|
|||
if ( count(f('designation')) !== count(f('prix')) )
|
||||
{
|
||||
throw new UserException('Nombre de désignations et de prix reçus différent.');
|
||||
}
|
||||
|
||||
$truc = [
|
||||
'numero' =>f('numero_facture'),
|
||||
'date_emission' => f('date_emission'),
|
||||
'date_echeance' => f('date_echeance'),
|
||||
'reglee' => f('reglee') == 1?1:0,
|
||||
'archivee' => f('archivee') == 1?1:0,
|
||||
'moyen_paiement' => f('moyen_paiement'),
|
||||
'toto' => 0
|
||||
];
|
||||
}
|
||||
|
||||
$truc = [
|
||||
'numero' =>f('numero_facture'),
|
||||
'date_emission' => f('date_emission'),
|
||||
'date_echeance' => f('date_echeance'),
|
||||
'reglee' => f('reglee') == 1?1:0,
|
||||
'archivee' => f('archivee') == 1?1:0,
|
||||
'moyen_paiement' => f('moyen_paiement'),
|
||||
'toto' => 0
|
||||
];
|
||||
|
||||
if (f('type') == DEVIS)
|
||||
if (in_array(f('type'), [DEVIS, FACT, CERFA]))
|
||||
{
|
||||
$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']);
|
||||
|
||||
if (f('base_receveur') == 'client')
|
||||
{
|
||||
$truc['receveur_membre'] = 0;
|
||||
$truc['receveur_id'] = f('client');
|
||||
}
|
||||
elseif (f('base_receveur') == 'membre')
|
||||
{
|
||||
$truc['receveur_membre'] = 1;
|
||||
$truc['receveur_id'] = f('membre');
|
||||
}
|
||||
|
||||
$id = $facture->add($truc);
|
||||
|
||||
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
|
||||
|
||||
}
|
||||
catch(UserException $e)
|
||||
{
|
||||
$truc['type_facture'] = DEVIS;
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
elseif (f('type') == FACT)
|
||||
{
|
||||
$truc['type_facture'] = FACT;
|
||||
}
|
||||
elseif (f('type') == CERFA)
|
||||
{
|
||||
$truc['type_facture'] = CERFA;
|
||||
}
|
||||
|
||||
foreach(f('designation') as $k=>$value)
|
||||
{
|
||||
$truc['contenu'][$k]['designation'] = $value;
|
||||
$truc['contenu'][$k]['prix'] = f('prix')[$k];
|
||||
$truc['toto'] += f('prix')[$k];
|
||||
}
|
||||
$truc['total'] = $truc['toto'];
|
||||
unset($truc['toto']);
|
||||
|
||||
if (f('base_receveur') == 'client')
|
||||
{
|
||||
$truc['receveur_membre'] = 0;
|
||||
$truc['receveur_id'] = f('client');
|
||||
}
|
||||
elseif (f('base_receveur') == 'membre')
|
||||
{
|
||||
$truc['receveur_membre'] = 1;
|
||||
$truc['receveur_id'] = f('membre');
|
||||
}
|
||||
|
||||
$id = $facture->add($truc);
|
||||
|
||||
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
|
||||
|
||||
}
|
||||
catch(UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -197,21 +189,23 @@ $tpl->assign('membre_id', f('membre') ?: -1);
|
|||
|
||||
$designations = [];
|
||||
$prix = [];
|
||||
$from_user = false;
|
||||
if (($d = f('designation')) && ($p = f('prix')) && implode($d))
|
||||
{
|
||||
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 {
|
||||
$designations = ['Exemple'];
|
||||
$prix = [1.5];
|
||||
$prix = [250];
|
||||
}
|
||||
|
||||
$tpl->assign(compact('liste', 'radio', 'step'));
|
||||
|
|
@ -220,9 +214,7 @@ $date = new \DateTime;
|
|||
$date->setTimestamp(time());
|
||||
$tpl->assign('date', $date->format('d/m/Y'));
|
||||
|
||||
$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;'));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue