create payment for the last loanschedule
This commit is contained in:
parent
582608cc57
commit
6a3661586f
@ -795,7 +795,7 @@ if ($id > 0)
|
||||
// Emit payment
|
||||
if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&action=create">'.$langs->trans("DoPayment").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&action=create&last=true">'.$langs->trans("DoPayment").'</a>';
|
||||
}
|
||||
|
||||
// Classify 'paid'
|
||||
|
||||
@ -34,6 +34,7 @@ $chid=GETPOST('id','int');
|
||||
$action=GETPOST('action','aZ09');
|
||||
$cancel=GETPOST('cancel','alpha');
|
||||
$line_id = GETPOST('line_id', 'int');
|
||||
$last=GETPOST('last');
|
||||
|
||||
// Security check
|
||||
$socid=0;
|
||||
@ -45,6 +46,26 @@ if ($user->societe_id > 0)
|
||||
$loan = new Loan($db);
|
||||
$loan->fetch($chid);
|
||||
|
||||
if($last)
|
||||
{
|
||||
$ls = new LoanSchedule($db);
|
||||
// grab all loanschedule
|
||||
$res = $ls->fetchAll($chid);
|
||||
if ($res > 0)
|
||||
{
|
||||
foreach ($ls->lines as $l)
|
||||
{
|
||||
// get the last unpaid loanschedule
|
||||
if (empty($l->fk_bank))
|
||||
{
|
||||
$line_id = $l->id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!empty($line_id))
|
||||
{
|
||||
$line = new LoanSchedule($db);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user