diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index bfeef4c3a0f..6ec8bf2654a 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -67,10 +67,7 @@ if ($action == 'add_paiement') { $error = 0; - $datepaye = dol_mktime(12, 0 , 0, - $_POST['remonth'], - $_POST['reday'], - $_POST['reyear']); + $datepaye = dol_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $paiement_id = 0; $total = 0; @@ -149,7 +146,20 @@ if ($action == 'add_paiement') if (! $error) { $db->commit(); - $loc = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement_id; + + // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card + $invoiceid=0; + foreach ($paiement->amounts as $key => $amount) + { + $facid = $key; + if (is_numeric($amount) && $amount <> 0) + { + if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment + else $invoiceid=$facid; + } + } + if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$invoiceid; + else $loc = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$paiement_id; Header('Location: '.$loc); exit; } @@ -198,8 +208,8 @@ if ($action == 'create' || $action == 'add_paiement') print_fiche_titre($langs->trans('DoPayment')); - if ($mesg) print $mesg; - if ($errmsg) print $errmsg; + if ($mesg) dol_htmloutput_mesg($mesg); + if ($errmsg) dol_htmloutput_errors($errmsg); print '