2014-09-29 20:37:51 +02:00
< ? php
2019-01-28 21:39:22 +01:00
/* Copyright ( C ) 2014 - 2018 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2018-09-09 09:56:33 +02:00
* Copyright ( C ) 2015 - 2018 Frédéric France < frederic . france @ netlogic . fr >
2020-06-02 14:42:57 +02:00
* Copyright ( C ) 2020 Maxime DEMAREST < maxime @ indelog . fr >
2014-09-29 20:37:51 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2014-09-29 20:37:51 +02:00
*/
/**
2015-03-22 20:19:22 +01:00
* \file htdocs / loan / payment / payment . php
2014-09-29 20:37:51 +02:00
* \ingroup Loan
* \brief Page to add payment of a loan
*/
2015-03-22 20:19:22 +01:00
require '../../main.inc.php' ;
require_once DOL_DOCUMENT_ROOT . '/loan/class/loan.class.php' ;
2018-10-19 15:36:13 +02:00
require_once DOL_DOCUMENT_ROOT . '/loan/class/loanschedule.class.php' ;
2015-03-22 20:19:22 +01:00
require_once DOL_DOCUMENT_ROOT . '/loan/class/paymentloan.class.php' ;
2014-09-29 20:37:51 +02:00
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
2020-06-02 14:42:57 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/loan.lib.php' ;
2014-09-29 20:37:51 +02:00
2020-04-10 10:59:32 +02:00
$langs -> loadLangs ( array ( " bills " , " loan " ));
2014-09-29 20:37:51 +02:00
2020-10-31 14:32:18 +01:00
$chid = GETPOST ( 'id' , 'int' );
$action = GETPOST ( 'action' , 'aZ09' );
$cancel = GETPOST ( 'cancel' , 'alpha' );
2020-06-02 14:42:57 +02:00
$datepaid = dol_mktime ( 12 , 0 , 0 , GETPOST ( 'remonth' , 'int' ), GETPOST ( 'reday' , 'int' ), GETPOST ( 'reyear' , 'int' ));
2014-09-29 20:37:51 +02:00
// Security check
2020-04-10 10:59:32 +02:00
$socid = 0 ;
2021-02-26 18:20:21 +01:00
if ( $user -> socid > 0 ) {
2019-10-31 20:46:31 +01:00
$socid = $user -> socid ;
2021-02-26 18:20:21 +01:00
} elseif ( GETPOSTISSET ( 'socid' )) {
$socid = GETPOST ( 'socid' , 'int' );
}
if ( empty ( $user -> rights -> loan -> write )) {
accessforbidden ();
}
2014-09-29 20:37:51 +02:00
2015-03-29 17:53:36 +02:00
$loan = new Loan ( $db );
$loan -> fetch ( $chid );
2020-06-02 14:42:57 +02:00
$echance = 0 ;
$ls = new LoanSchedule ( $db );
// grab all loanschedule
$res = $ls -> fetchAll ( $chid );
2021-02-26 18:20:21 +01:00
if ( $res > 0 ) {
foreach ( $ls -> lines as $l ) {
2020-10-31 14:32:18 +01:00
$echance ++ ; // Count term pos
// last unpaid term
2021-02-26 18:20:21 +01:00
if ( empty ( $l -> fk_bank )) {
2020-10-31 14:32:18 +01:00
$line_id = $l -> id ;
break ;
2021-02-26 18:20:21 +01:00
} elseif ( $line_id == $l -> id ) {
// If line_id provided, only count temp pos
2020-10-31 14:32:18 +01:00
break ;
}
}
2018-10-19 16:12:21 +02:00
}
2020-06-02 14:42:57 +02:00
// Set current line with last unpaid line (only if shedule is used)
2021-02-26 18:20:21 +01:00
if ( ! empty ( $line_id )) {
2020-10-31 14:32:18 +01:00
$line = new LoanSchedule ( $db );
$res = $line -> fetch ( $line_id );
if ( $res > 0 ) {
$amount_capital = price ( $line -> amount_capital );
$amount_insurance = price ( $line -> amount_insurance );
$amount_interest = price ( $line -> amount_interest );
2021-02-26 18:20:21 +01:00
if ( empty ( $datepaid )) {
$ts_temppaid = $line -> datep ;
}
2020-10-31 14:32:18 +01:00
}
2018-10-19 15:36:13 +02:00
}
2018-12-14 11:26:37 +01:00
2014-09-29 20:37:51 +02:00
/*
* Actions
*/
2018-12-14 11:26:37 +01:00
2021-02-26 18:20:21 +01:00
if ( $action == 'add_payment' ) {
2020-04-10 10:59:32 +02:00
$error = 0 ;
2014-09-29 20:37:51 +02:00
2021-02-26 18:20:21 +01:00
if ( $cancel ) {
2015-03-22 20:19:22 +01:00
$loc = DOL_URL_ROOT . '/loan/card.php?id=' . $chid ;
2014-09-29 20:37:51 +02:00
header ( " Location: " . $loc );
exit ;
}
2021-02-26 18:20:21 +01:00
if ( ! GETPOST ( 'paymenttype' , 'int' ) > 0 ) {
2015-10-17 17:09:34 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " PaymentMode " )), null , 'errors' );
2014-09-29 20:37:51 +02:00
$error ++ ;
}
2021-02-26 18:20:21 +01:00
if ( $datepaid == '' ) {
2015-10-17 17:09:34 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Date " )), null , 'errors' );
2014-09-29 20:37:51 +02:00
$error ++ ;
}
2021-02-26 18:20:21 +01:00
if ( ! empty ( $conf -> banque -> enabled ) && ! GETPOST ( 'accountid' , 'int' ) > 0 ) {
2018-12-14 11:26:37 +01:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " AccountToCredit " )), null , 'errors' );
$error ++ ;
}
2014-09-29 20:37:51 +02:00
2021-02-26 18:20:21 +01:00
if ( ! $error ) {
2014-09-29 20:37:51 +02:00
$paymentid = 0 ;
2020-10-31 14:32:18 +01:00
$pay_amount_capital = price2num ( GETPOST ( 'amount_capital' ));
$pay_amount_insurance = price2num ( GETPOST ( 'amount_insurance' ));
// User can't set interest him self if schedule is set (else value in schedule can be incoherent)
2021-02-26 18:20:21 +01:00
if ( ! empty ( $line )) {
$pay_amount_interest = $line -> amount_interest ;
} else {
$pay_amount_interest = price2num ( GETPOST ( 'amount_interest' ));
}
2020-10-31 14:32:18 +01:00
$remaindertopay = price2num ( GETPOST ( 'remaindertopay' ));
2020-10-31 18:51:30 +01:00
$amount = $pay_amount_capital + $pay_amount_insurance + $pay_amount_interest ;
2020-06-02 14:42:57 +02:00
2020-10-31 14:32:18 +01:00
// This term is allready paid
2021-02-26 18:20:21 +01:00
if ( ! empty ( $line ) && ! empty ( $line -> fk_bank )) {
2020-10-31 14:32:18 +01:00
setEventMessages ( $langs -> trans ( 'TermPaidAllreadyPaid' ), null , 'errors' );
$error ++ ;
}
2020-06-02 14:42:57 +02:00
2021-02-26 18:20:21 +01:00
if ( empty ( $remaindertopay )) {
2020-06-02 14:42:57 +02:00
setEventMessages ( 'Empty sumpaid' , null , 'errors' );
$error ++ ;
2020-10-31 14:32:18 +01:00
}
2020-06-02 14:42:57 +02:00
2021-02-26 18:20:21 +01:00
if ( $amount == 0 ) {
2018-12-14 11:26:37 +01:00
setEventMessages ( $langs -> trans ( 'ErrorNoPaymentDefined' ), null , 'errors' );
$error ++ ;
}
2021-02-26 18:20:21 +01:00
if ( ! $error ) {
2018-12-14 11:26:37 +01:00
$db -> begin ();
// Create a line of payments
$payment = new PaymentLoan ( $db );
2021-01-04 16:07:47 +01:00
$payment -> chid = $chid ;
2020-06-02 14:42:57 +02:00
$payment -> datep = $datepaid ;
$payment -> label = $loan -> label ;
2021-01-04 06:57:10 +01:00
$payment -> amount_capital = $pay_amount_capital ;
2021-01-04 06:57:56 +01:00
$payment -> amount_insurance = $pay_amount_insurance ;
$payment -> amount_interest = $pay_amount_interest ;
2021-01-04 06:57:10 +01:00
$payment -> fk_bank = GETPOST ( 'accountid' , 'int' );
2020-06-02 14:42:57 +02:00
$payment -> paymenttype = GETPOST ( 'paymenttype' , 'int' );
2021-01-04 06:57:10 +01:00
$payment -> num_payment = GETPOST ( 'num_payment' );
2020-09-18 01:29:17 +02:00
$payment -> note_private = GETPOST ( 'note_private' , 'restricthtml' );
$payment -> note_public = GETPOST ( 'note_public' , 'restricthtml' );
2018-12-14 11:26:37 +01:00
2021-02-26 18:20:21 +01:00
if ( ! $error ) {
2018-12-14 11:26:37 +01:00
$paymentid = $payment -> create ( $user );
2021-02-26 18:20:21 +01:00
if ( $paymentid < 0 ) {
2018-12-14 11:26:37 +01:00
setEventMessages ( $payment -> error , $payment -> errors , 'errors' );
$error ++ ;
}
}
2021-02-26 18:20:21 +01:00
if ( ! $error ) {
2021-01-04 16:07:47 +01:00
$result = $payment -> addPaymentToBank ( $user , $chid , 'payment_loan' , '(LoanPayment)' , $payment -> fk_bank , '' , '' );
2022-08-12 15:54:50 +02:00
if ( ! ( $result > 0 )) {
2018-12-14 11:26:37 +01:00
setEventMessages ( $payment -> error , $payment -> errors , 'errors' );
$error ++ ;
}
}
2020-10-31 14:32:18 +01:00
// Update loan schedule with payment value
2021-02-26 18:20:21 +01:00
if ( ! $error && ! empty ( $line )) {
2020-10-31 14:32:18 +01:00
// If payment values are modified, recalculate schedule
2021-02-26 18:20:21 +01:00
if (( $line -> amount_capital <> $pay_amount_capital ) || ( $line -> amount_insurance <> $pay_amount_insurance ) || ( $line -> amount_interest <> $pay_amount_interest )) {
2020-10-31 14:32:18 +01:00
$arr_term = loanCalcMonthlyPayment (( $pay_amount_capital + $pay_amount_interest ), $remaindertopay , ( $loan -> rate / 100 ), $echance , $loan -> nbterm );
2021-02-26 18:20:21 +01:00
foreach ( $arr_term as $k => $v ) {
2020-10-31 14:32:18 +01:00
// Update fk_bank for current line
2021-02-26 18:20:21 +01:00
if ( $k == $echance ) {
2020-10-31 18:51:30 +01:00
$ls -> lines [ $k - 1 ] -> fk_bank = $payment -> fk_bank ;
$ls -> lines [ $k - 1 ] -> fk_payment_loan = $payment -> id ;
2020-10-31 14:32:18 +01:00
}
2020-10-31 18:51:30 +01:00
$ls -> lines [ $k - 1 ] -> amount_capital = $v [ 'mens' ] - $v [ 'interet' ];
$ls -> lines [ $k - 1 ] -> amount_interest = $v [ 'interet' ];
$ls -> lines [ $k - 1 ] -> tms = dol_now ();
$ls -> lines [ $k - 1 ] -> fk_user_modif = $user -> id ;
$result = $ls -> lines [ $k - 1 ] -> update ( $user , 0 );
2021-02-26 18:20:21 +01:00
if ( $result < 1 ) {
2020-10-31 14:32:18 +01:00
setEventMessages ( null , $ls -> errors , 'errors' );
$error ++ ;
break ;
}
}
2021-02-26 18:20:21 +01:00
} else // Only add fk_bank bank to schedule line (mark as paid)
2020-10-31 14:32:18 +01:00
{
$line -> fk_bank = $payment -> fk_bank ;
$line -> fk_payment_loan = $payment -> id ;
$result = $line -> update ( $user , 0 );
2021-02-26 18:20:21 +01:00
if ( $result < 1 ) {
2020-10-31 14:32:18 +01:00
setEventMessages ( null , $line -> errors , 'errors' );
$error ++ ;
}
}
}
2021-02-26 18:20:21 +01:00
if ( ! $error ) {
2018-12-14 11:26:37 +01:00
$db -> commit ();
$loc = DOL_URL_ROOT . '/loan/card.php?id=' . $chid ;
header ( 'Location: ' . $loc );
exit ;
2020-05-21 15:05:19 +02:00
} else {
2018-12-14 11:26:37 +01:00
$db -> rollback ();
}
}
2014-09-29 20:37:51 +02:00
}
2016-06-05 16:15:04 +02:00
$action = 'create' ;
2014-09-29 20:37:51 +02:00
}
/*
* View
*/
llxHeader ();
2020-04-10 10:59:32 +02:00
$form = new Form ( $db );
2014-09-29 20:37:51 +02:00
// Form to create loan's payment
2021-02-26 18:20:21 +01:00
if ( $action == 'create' ) {
2014-09-29 20:37:51 +02:00
$total = $loan -> capital ;
2015-09-24 18:33:48 +02:00
print load_fiche_titre ( $langs -> trans ( " DoPayment " ));
2014-09-29 20:37:51 +02:00
2020-06-02 14:42:57 +02:00
$sql = " SELECT SUM(amount_capital) as total " ;
2020-10-31 14:32:18 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " payment_loan " ;
2021-03-30 19:12:07 +02:00
$sql .= " WHERE fk_loan = " . (( int ) $chid );
2020-06-02 14:42:57 +02:00
$resql = $db -> query ( $sql );
2021-02-26 18:20:21 +01:00
if ( $resql ) {
2020-10-31 14:32:18 +01:00
$obj = $db -> fetch_object ( $resql );
2020-06-02 14:42:57 +02:00
$sumpaid = $obj -> total ;
2022-05-15 22:29:19 +02:00
$db -> free ( $resql );
2020-06-02 14:42:57 +02:00
}
2014-09-29 20:37:51 +02:00
print '<form name="add_payment" action="' . $_SERVER [ 'PHP_SELF' ] . '" method="post">' ;
2019-12-01 10:20:11 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2014-09-29 20:37:51 +02:00
print '<input type="hidden" name="id" value="' . $chid . '">' ;
print '<input type="hidden" name="chid" value="' . $chid . '">' ;
2018-10-19 15:36:13 +02:00
print '<input type="hidden" name="line_id" value="' . $line_id . '">' ;
2020-10-15 10:15:37 +02:00
print '<input type="hidden" name="remaindertopay" value="' . ( $total - $sumpaid ) . '">' ;
2014-09-29 20:37:51 +02:00
print '<input type="hidden" name="action" value="add_payment">' ;
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ();
2016-06-05 16:08:40 +02:00
2020-10-15 10:15:37 +02:00
/*
print '<table class="border centpercent">' ;
2014-09-29 20:37:51 +02:00
2016-12-10 16:17:15 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Ref " ) . '</td><td colspan="2"><a href="' . DOL_URL_ROOT . '/loan/card.php?id=' . $chid . '">' . $chid . '</a></td></tr>' ;
2021-02-26 18:20:21 +01:00
if ( $echance > 0 )
{
print '<tr><td>' . $langs -> trans ( " Term " ) . '</td><td colspan="2"><a href="' . DOL_URL_ROOT . '/loan/schedule.php?loanid=' . $chid . '#n' . $echance . '">' . $echance . '</a></td></tr>' . " \n " ;
}
2019-01-27 11:55:16 +01:00
print '<tr><td>' . $langs -> trans ( " DateStart " ) . '</td><td colspan="2">' . dol_print_date ( $loan -> datestart , 'day' ) . " </td></tr> \n " ;
2014-09-29 20:37:51 +02:00
print '<tr><td>' . $langs -> trans ( " Label " ) . '</td><td colspan="2">' . $loan -> label . " </td></tr> \n " ;
2019-01-27 11:55:16 +01:00
print '<tr><td>' . $langs -> trans ( " Amount " ) . '</td><td colspan="2">' . price ( $loan -> capital , 0 , $outputlangs , 1 , - 1 , - 1 , $conf -> currency ) . '</td></tr>' ;
2014-09-29 20:37:51 +02:00
2015-03-29 11:39:55 +02:00
print '<tr><td>' . $langs -> trans ( " AlreadyPaid " ) . '</td><td colspan="2">' . price ( $sumpaid , 0 , $outputlangs , 1 , - 1 , - 1 , $conf -> currency ) . '</td></tr>' ;
2020-04-10 10:59:32 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " RemainderToPay " ) . '</td><td colspan="2">' . price ( $total - $sumpaid , 0 , $outputlangs , 1 , - 1 , - 1 , $conf -> currency ) . '</td></tr>' ;
2014-09-29 20:37:51 +02:00
print '</tr>' ;
print '</table>' ;
2020-10-15 10:15:37 +02:00
*/
2015-03-29 11:39:55 +02:00
2020-10-15 10:15:37 +02:00
print '<table class="border centpercent">' ;
2014-09-29 20:37:51 +02:00
2016-12-10 16:17:15 +01:00
print '<tr><td class="titlefield fieldrequired">' . $langs -> trans ( " Date " ) . '</td><td colspan="2">' ;
2021-02-26 18:20:21 +01:00
if ( empty ( $datepaid )) {
if ( empty ( $ts_temppaid )) {
$datepayment = empty ( $conf -> global -> MAIN_AUTOFILL_DATE ) ? - 1 : dol_now ();
} else {
$datepayment = $ts_temppaid ;
}
} else {
$datepayment = $datepaid ;
}
print $form -> selectDate ( $datepayment , '' , '' , '' , '' , " add_payment " , 1 , 1 );
print " </td> " ;
print '</tr>' ;
2014-09-29 20:37:51 +02:00
2021-02-26 18:20:21 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " PaymentMode " ) . '</td><td colspan="2">' ;
2022-07-26 11:53:00 +02:00
print img_picto ( '' , 'money-bill-alt' , 'class="pictofixedwidth"' );
2021-02-26 18:20:21 +01:00
$form -> select_types_paiements ( GETPOSTISSET ( " paymenttype " ) ? GETPOST ( " paymenttype " , 'alphanohtml' ) : $loan -> fk_typepayment , " paymenttype " );
print " </td> \n " ;
print '</tr>' ;
2014-09-29 20:37:51 +02:00
2021-02-26 18:20:21 +01:00
print '<tr>' ;
print '<td class="fieldrequired">' . $langs -> trans ( 'AccountToDebit' ) . '</td>' ;
print '<td colspan="2">' ;
2022-07-26 11:53:00 +02:00
print img_picto ( '' , 'bank_account' , 'class="pictofixedwidth"' );
2021-02-26 18:20:21 +01:00
$form -> select_comptes ( GETPOSTISSET ( " accountid " ) ? GETPOST ( " accountid " , 'int' ) : $loan -> accountid , " accountid " , 0 , 'courant = ' . Account :: TYPE_CURRENT , 1 ); // Show opend bank account list
print '</td></tr>' ;
2014-09-29 20:37:51 +02:00
2022-07-26 11:53:00 +02:00
// Number
2021-02-26 18:20:21 +01:00
print '<tr><td>' . $langs -> trans ( 'Numero' );
print ' <em>(' . $langs -> trans ( " ChequeOrTransferNumber " ) . ')</em>' ;
print '</td>' ;
print '<td colspan="2"><input name="num_payment" type="text" value="' . GETPOST ( 'num_payment' , 'alphanohtml' ) . '"></td>' . " \n " ;
print " </tr> " ;
2014-09-29 20:37:51 +02:00
2021-02-26 18:20:21 +01:00
print '<tr>' ;
print '<td class="tdtop">' . $langs -> trans ( " NotePrivate " ) . '</td>' ;
print '<td valign="top" colspan="2"><textarea name="note_private" wrap="soft" cols="60" rows="' . ROWS_3 . '"></textarea></td>' ;
print '</tr>' ;
2016-06-05 16:08:40 +02:00
2021-02-26 18:20:21 +01:00
print '<tr>' ;
print '<td class="tdtop">' . $langs -> trans ( " NotePublic " ) . '</td>' ;
print '<td valign="top" colspan="2"><textarea name="note_public" wrap="soft" cols="60" rows="' . ROWS_3 . '"></textarea></td>' ;
print '</tr>' ;
2014-09-29 20:37:51 +02:00
2021-02-26 18:20:21 +01:00
print '</table>' ;
2014-09-29 20:37:51 +02:00
2021-02-26 18:20:21 +01:00
print dol_get_fiche_end ();
2020-10-15 10:15:37 +02:00
2014-09-29 20:37:51 +02:00
2021-02-26 18:20:21 +01:00
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre">' ;
print '<td class="left">' . $langs -> trans ( " DateDue " ) . '</td>' ;
print '<td class="right">' . $langs -> trans ( " LoanCapital " ) . '</td>' ;
print '<td class="right">' . $langs -> trans ( " AlreadyPaid " ) . '</td>' ;
print '<td class="right">' . $langs -> trans ( " RemainderToPay " ) . '</td>' ;
print '<td class="right">' . $langs -> trans ( " Amount " ) . '</td>' ;
print " </tr> \n " ;
2015-03-29 11:39:55 +02:00
2021-02-26 18:20:21 +01:00
print '<tr class="oddeven">' ;
if ( $loan -> datestart > 0 ) {
2019-03-03 08:55:27 +01:00
print '<td class="left" valign="center">' . dol_print_date ( $loan -> datestart , 'day' ) . '</td>' ;
2020-05-21 15:05:19 +02:00
} else {
2019-03-03 08:55:27 +01:00
print '<td class="center" valign="center"><b>!!!</b></td>' ;
2015-03-29 11:39:55 +02:00
}
2021-02-26 18:20:21 +01:00
print '<td class="right" valign="center">' . price ( $loan -> capital ) . " </td> " ;
2015-03-29 11:39:55 +02:00
2021-02-26 18:20:21 +01:00
print '<td class="right" valign="center">' . price ( $sumpaid ) . " </td> " ;
2015-03-29 11:39:55 +02:00
2021-02-26 18:20:21 +01:00
print '<td class="right" valign="center">' . price ( $loan -> capital - $sumpaid ) . " </td> " ;
2015-03-29 11:39:55 +02:00
2021-02-26 18:20:21 +01:00
print '<td class="right">' ;
if ( $sumpaid < $loan -> capital ) {
2020-10-31 18:51:30 +01:00
print $langs -> trans ( " LoanCapital " ) . ': <input type="text" size="8" name="amount_capital" value="' . ( GETPOSTISSET ( 'amount_capital' ) ? GETPOST ( 'amount_capital' ) : $amount_capital ) . '">' ;
2021-02-26 18:20:21 +01:00
} else {
2015-03-29 11:39:55 +02:00
print '-' ;
2014-09-29 20:37:51 +02:00
}
2021-02-26 18:20:21 +01:00
print '<br>' ;
if ( $sumpaid < $loan -> capital ) {
2020-10-31 14:32:18 +01:00
print $langs -> trans ( " Insurance " ) . ': <input type="text" size="8" name="amount_insurance" value="' . ( GETPOSTISSET ( 'amount_insurance' ) ? GETPOST ( 'amount_insurance' ) : $amount_insurance ) . '">' ;
2021-02-26 18:20:21 +01:00
} else {
2015-03-29 11:39:55 +02:00
print '-' ;
}
2021-02-26 18:20:21 +01:00
print '<br>' ;
if ( $sumpaid < $loan -> capital ) {
2020-10-31 14:32:18 +01:00
print $langs -> trans ( " Interest " ) . ': <input type="text" size="8" name="amount_interest" value="' . ( GETPOSTISSET ( 'amount_interest' ) ? GETPOST ( 'amount_interest' ) : $amount_interest ) . '" ' . ( ! empty ( $line ) ? 'disabled title="' . $langs -> trans ( 'CantModifyInterestIfScheduleIsUsed' ) . '"' : '' ) . '>' ;
2021-02-26 18:20:21 +01:00
} else {
2015-03-29 11:39:55 +02:00
print '-' ;
}
2021-02-26 18:20:21 +01:00
print " </td> " ;
2014-09-29 20:37:51 +02:00
2021-02-26 18:20:21 +01:00
print " </tr> \n " ;
2015-03-29 11:39:55 +02:00
2021-02-26 18:20:21 +01:00
print '</table>' ;
2014-09-29 20:37:51 +02:00
2021-08-20 14:41:30 +02:00
print $form -> buttonsSaveCancel ();
2014-09-29 20:37:51 +02:00
2021-02-26 18:20:21 +01:00
print " </form> \n " ;
2014-09-29 20:37:51 +02:00
}
llxFooter ();
2015-12-11 19:37:12 +01:00
$db -> close ();