New: After creating supplier payment, go on supplier invoice if payment

was on one invoice only. This save one click.
This commit is contained in:
eldy 2011-09-29 13:53:17 +02:00
parent 51c94f7c7e
commit dde7a1f543

View File

@ -67,10 +67,7 @@ if ($action == 'add_paiement')
{ {
$error = 0; $error = 0;
$datepaye = dol_mktime(12, 0 , 0, $datepaye = dol_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
$_POST['remonth'],
$_POST['reday'],
$_POST['reyear']);
$paiement_id = 0; $paiement_id = 0;
$total = 0; $total = 0;
@ -149,7 +146,20 @@ if ($action == 'add_paiement')
if (! $error) if (! $error)
{ {
$db->commit(); $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); Header('Location: '.$loc);
exit; exit;
} }
@ -198,8 +208,8 @@ if ($action == 'create' || $action == 'add_paiement')
print_fiche_titre($langs->trans('DoPayment')); print_fiche_titre($langs->trans('DoPayment'));
if ($mesg) print $mesg; if ($mesg) dol_htmloutput_mesg($mesg);
if ($errmsg) print $errmsg; if ($errmsg) dol_htmloutput_errors($errmsg);
print '<form name="addpaiement" action="paiement.php" method="post">'; print '<form name="addpaiement" action="paiement.php" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -296,7 +306,7 @@ if ($action == 'create' || $action == 'add_paiement')
print '<td align="right">'.price($objp->total_ttc - $objp->am).'</td>'; print '<td align="right">'.price($objp->total_ttc - $objp->am).'</td>';
print '<td align="center">'; print '<td align="center">';
$namef = 'amount_'.$objp->facid; $namef = 'amount_'.$objp->facid;
print '<input type="text" size="8" name="'.$namef.'">'; print '<input type="text" size="8" name="'.$namef.'" value="'.GETPOST($namef).'">';
print "</td></tr>\n"; print "</td></tr>\n";
$total+=$objp->total; $total+=$objp->total;
$total_ttc+=$objp->total_ttc; $total_ttc+=$objp->total_ttc;