30require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/loan/class/loan.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/loan.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/loan/class/loanschedule.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/loan/class/paymentloan.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
49$action =
GETPOST(
'action',
'aZ09');
57 $socid = $user->socid;
59if (!$user->hasRight(
'loan',
'calc')) {
64$langs->loadLangs(array(
"compta",
"bills",
"loan"));
70$echeances->fetchAll(
$object->id);
72if (
$object->paid > 0 && count($echeances->lines) == 0) {
73 $pay_without_schedule = 1;
75 $pay_without_schedule = 0;
78$permissiontoadd = $user->hasRight(
'loan',
'write');
85if ($action ==
'createecheancier' && empty($pay_without_schedule) && $permissiontoadd) {
89 while ($i < $object->nbterm + 1) {
101 $amort = (float) $mens - (
float) $int;
106 $new_echeance->fk_loan =
$object->id;
107 $new_echeance->datec =
dol_now();
108 $new_echeance->tms =
dol_now();
109 $new_echeance->datep = $date;
110 $new_echeance->amount_capital = $amort;
111 $new_echeance->amount_insurance = $insurance;
112 $new_echeance->amount_interest = $int;
113 $new_echeance->fk_typepayment = 3;
114 $new_echeance->fk_bank = 0;
115 $new_echeance->fk_user_creat = $user->id;
116 $new_echeance->fk_user_modif = $user->id;
117 $result = $new_echeance->create($user);
119 setEventMessages($new_echeance->error, $new_echeance->errors,
'errors');
121 $echeances->lines = [];
124 $echeances->lines[] = $new_echeance;
132if ($action ==
'updateecheancier' && empty($pay_without_schedule) && $permissiontoadd) {
136 while ($i < $object->nbterm + 1) {
148 $amort = (float) $mens - (
float) $int;
152 $new_echeance->fetch(
$id);
153 $new_echeance->tms =
dol_now();
154 $new_echeance->amount_capital = $amort;
155 $new_echeance->amount_insurance = $insurance;
156 $new_echeance->amount_interest = $int;
157 $new_echeance->fk_user_modif = $user->id;
158 $result = $new_echeance->update($user, 0);
160 setEventMessages(
null, $new_echeance->errors,
'errors');
162 $echeances->fetchAll(
$object->id);
166 $echeances->lines[$i - 1] = $new_echeance;
174if ($action ==
'recalculate' && $permissiontoadd) {
176 $keep = (
GETPOST(
'keep',
'aZ09') ===
'payment' ?
'payment' :
'term');
178 $oldrate = (float)
$object->rate;
179 if (
GETPOST(
'newrate') ===
'' || $newrate < 0 || empty($datefrom)) {
180 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"LoanNewRate")),
null,
'errors');
184 if (count($echeances->lines) == 0) {
187 if (
$object->update($user) < 0) {
190 } elseif (
loanRecordChange($db, $user,
$object->id,
'rate', $datefrom, $oldrate, $newrate,
'', 0, 0,
$object->nbterm,
$object->nbterm) < 0) {
192 setEventMessages($db->lasterror(),
null,
'errors');
197 $capital = (float)
$object->capital;
198 foreach ($echeances->lines as $k => $l) {
199 if (empty($l->fk_bank) && $l->datep >= $datefrom) {
203 $capital -= (float) $l->amount_capital;
205 $nbtermold = (float)
$object->nbterm;
209 setEventMessages($langs->trans($res[
'error']),
null,
'errors');
210 } elseif (
loanRecordChange($db, $user,
$object->id,
'rate', (
int) $echeances->lines[$from]->datep, $oldrate, $newrate, $keep, $res[
'payment_old'], $res[
'payment_new'], $nbtermold, $res[
'nbterm_new']) < 0) {
212 setEventMessages($db->lasterror(),
null,
'errors');
219 setEventMessages($langs->trans(
"LoanRecalcDone"),
null);
223 $echeances->fetchAll(
$object->id);
232$form =
new Form($db);
235$title = $langs->trans(
"Loan").
' - '.$langs->trans(
"FinancialCommitment");
236$help_url =
'EN:Module_Loan|FR:Module_Emprunt';
238llxHeader(
"", $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-loan page-card_schedule');
241print
dol_get_fiche_head($head,
'FinancialCommitment', $langs->trans(
"Loan"), -1,
'money-bill-alt');
243$linkback =
'<a href="'.DOL_URL_ROOT.
'/loan/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
245$morehtmlref =
'<div class="refidno">';
247$morehtmlref .= $form->editfieldkey(
"Label",
'label',
$object->label, $object, 0,
'string',
'', 0, 1);
248$morehtmlref .= $form->editfieldval(
"Label",
'label',
$object->label, $object, 0,
'string',
'',
null,
null,
'', 1);
251 $langs->loadLangs(array(
"projects"));
252 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' : ';
253 if ($user->hasRight(
'loan',
'write')) {
254 if ($action !=
'classify') {
256 if ($action ==
'classify') {
258 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
259 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
260 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
261 $morehtmlref .= $formproject->select_projects(-1, (
string)
$object->fk_project,
'projectid', 16, 0, 1, 0, 1, 0, 0,
'', 1);
262 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
263 $morehtmlref .=
'</form>';
265 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, -1, (
string)
$object->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300');
269 if (!empty(
$object->fk_project)) {
271 $proj->fetch((
int)
$object->fk_project);
272 $morehtmlref .=
' : '.$proj->getNomUrl(1);
274 $morehtmlref .=
' - '.$proj->title;
281$morehtmlref .=
'</div>';
285dol_banner_tab($object,
'loanid', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'', $morehtmlstatus);
288<script
type=
"text/javascript">
289$(document).ready(
function() {
293 function updateTotals() {
299 $(
'[name^="hi_insurance"]').each(
function() {
300 totInsu += (price2numjs($(
this).val()) || 0);
302 $(
'[name^="hi_interets"]').each(
function() {
303 totInt += (price2numjs($(
this).val()) || 0);
305 $(
'[id^="hi_amort"]').each(
function() {
306 totAmort += (price2numjs($(
this).val()) || 0);
308 $(
'[id^="hi_mens"]').each(
function() {
309 totMens += (price2numjs($(
this).val()) || 0);
312 $(
'#total_insurance').text(pricejs(totInsu,
'MT',
'<?php echo $conf->currency; ?>'));
313 $(
'#total_interest').text(pricejs(totInt,
'MT',
'<?php echo $conf->currency; ?>'));
314 $(
'#total_amort').text(pricejs(totAmort,
'MT',
'<?php echo $conf->currency; ?>'));
315 $(
'#total_mens').text(pricejs(totMens,
'MT',
'<?php echo $conf->currency; ?>'));
318 $(
'[name^="mens"]').on(
'keyup change',
function() {
319 clearTimeout(timeout);
321 timeout = setTimeout(() => {
322 var echeance = $this.attr(
'ech');
323 var mens = $this.val();
324 var amort = $(
'#amort' + echeance).val();
325 var interet = $(
'#interets' + echeance).val();
326 calculateMens(echeance, mens, amort,
'mens', 0, interet);
330 $(
'[name^="amort"]').on(
'keyup change',
function() {
331 clearTimeout(timeout);
333 timeout = setTimeout(() => {
334 var echeance = $this.attr(
'ech');
335 var amort = $this.val();
336 var mens = $(
'#mens' + echeance).val();
337 var interet = $(
'#interets' + echeance).val();
338 calculateMens(echeance, mens, amort,
'amort', 0, interet);
342 $(
'[name^="interets"]').on(
'keyup change',
function() {
343 clearTimeout(timeout);
345 timeout = setTimeout(() => {
346 var echeance = $this.attr(
'ech');
347 var interet = $this.val();
348 var amort = $(
'#amort' + echeance).val();
349 var mens = $(
'#mens' + echeance).val();
350 calculateMens(echeance, mens, amort,
'interet', 0, interet);
354 $(
'#btn_apply_grace_period').on(
'click',
function(e) {
356 var months = parseInt($(
'#grace_period_months').val(), 10);
357 if (isNaN(months) || months < 1)
return;
358 var nbterm = <?php echo (
int)
$object->nbterm; ?>;
359 if (months >= nbterm) months = nbterm - 1;
361 calculateMens(1, 0, 0,
'amort', months, 0);
364 function calculateMens(echeance, mens, amort, source, grace_period, interet) {
365 var idcap = echeance - 1;
366 idcap =
'#hi_capital' + idcap;
367 var capital = price2numjs($(idcap).val());
368 console.log(
"calculateMens echeance=" + echeance +
" idcap=" + idcap +
" capital=" + capital +
" source=" + source +
" grace=" + grace_period);
376 mens: price2numjs(mens),
377 amort: price2numjs(amort),
378 interet: price2numjs(interet),
380 grace_period: grace_period,
382 rate: <?php echo
$object->rate / 100; ?>,
383 nbterm: <?php echo
$object->nbterm; ?>,
384 frequency: <?php echo (
int)
$object->frequency; ?>,
385 interest_basis: <?php echo (
int)
$object->interest_basis; ?>,
386 datestart: <?php echo (
int)
$object->datestart; ?>,
387 balloon: <?php echo (
float)
$object->balloon_amount; ?>,
388 token:
'<?php echo currentToken(); ?>'
390 success:
function(data) {
391 $.each(data,
function(index, element) {
392 $(
'#hi_capital' + index).val(element.cap_rest);
393 $(
'#capital' + index).text(element.cap_rest_str);
395 if ($(
'#interets' + index).is(
'input')) {
396 $(
'#interets' + index).val(element.interet);
398 $(
'#interets' + index).text(element.interet_str);
400 $(
'#hi_interets' + index).val(element.interet);
402 if ($(
'#amort' + index).is(
'input')) {
403 $(
'#amort' + index).val(element.amort);
405 $(
'#amort' + index).text(element.amort);
407 $(
'#hi_amort' + index).val(element.amort_num);
409 if ($(
'#mens' + index).is(
'input')) {
410 $(
'#mens' + index).val(element.mens);
412 $(
'#mens' + index).text(element.mens);
414 $(
'#hi_mens' + index).val(element.mens_num);
426if ($pay_without_schedule == 1) {
427 print
'<div class="warning">'.$langs->trans(
'CantUseScheduleWithLoanStartedToPaid').
'</div>'.
"\n";
430print
'<form name="createecheancier" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
431print
'<input type="hidden" name="token" value="'.newToken().
'">';
432print
'<input type="hidden" name="loanid" value="'.$loanid.
'">';
433if (count($echeances->lines) > 0) {
434 print
'<input type="hidden" name="action" value="updateecheancier">';
436 print
'<input type="hidden" name="action" value="createecheancier">';
439if (empty($pay_without_schedule) && $permissiontoadd) {
440 print
'<div class="marginbottomonly inline-block valignmiddle">';
441 print
'<span class="opacitymedium">'.$langs->trans((
int)
$object->frequency == 12 ?
"GracePeriodMonths" :
"GracePeriodTerms").
': </span>';
442 print
'<input type="number" id="grace_period_months" min="1" max="'.max(1,
$object->nbterm - 1).
'" value="1" class="width50 right"> ';
443 print
'<input type="button" id="btn_apply_grace_period" class="button valignmiddle" value="'.$langs->trans(
"Apply").
'">';
448print
'<div class="div-table-responsive-no-min">';
449print
'<table class="border centpercent">';
452if (count($echeances->lines) > 0) {
456print
'<tr class="liste_titre">';
457print
'<th class="center">'.$langs->trans(
"Term").
'</th>';
458print
'<th class="center">'.$langs->trans(
"Date").
'</th>';
459print
'<th class="center">'.loanChargeLabel(
$object->charge_type, $langs).
'</th>';
460print
'<th class="center">'.$langs->trans(
"InterestAmount").
'</th>';
461print
'<th class="center">'.$langs->trans(
"CapitalAmortization").
'</th>';
462print
'<th class="center">'.$langs->trans(
"Amount").
'</th>';
463print
'<th class="center">'.$langs->trans(
"CapitalRemain");
464print
'<br>('.price(
$object->capital, 0,
'', 1, -1, -1,
$conf->currency).
')';
465print
'<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.
'">';
467if (count($echeances->lines) > 0) {
468 print
'<th class="center">'.$langs->trans(
'DoPayment').
'</th>';
473$total_insurance = 0.0;
474$total_interest = 0.0;
478if (
$object->nbterm > 0 && count($echeances->lines) == 0) {
481 $cap_rest = (float) $capital;
484 while ($i < $object->nbterm + 1) {
488 $amort =
price2num((
float) $mens - (
float) $int,
'MT');
489 $insu = ((float) $insurance + (($i == 1) ? (float) $regulInsurance : 0));
490 $cap_rest = (float)
price2num((
float) $capital - (float) $amort,
'MT');
495 if ($i ==
$object->nbterm && (
$object->interest_basis || (
float)
$object->balloon_amount > 0 || abs($cap_rest) <= 0.05) && $capital > 0) {
498 $mens =
price2num((
float) $amort + (
float) $int,
'MT');
501 $total_insurance += $insu;
502 $total_interest += $int;
503 $total_amort += $amort;
504 $total_mens += $mens;
507 print
'<td class="center" id="n'.$i.
'">'.$i.
'</td>';
509 print
'<td class="center amount" id="insurance'.$i.
'">'.
price($insu, 0,
'', 1, -1, -1,
$conf->currency).
'</td><input type="hidden" name="hi_insurance'.$i.
'" id ="hi_insurance'.$i.
'" value="'.$insu.
'">';
510 print
'<td class="center"><input class="width75 right" name="interets'.$i.
'" id="interets'.$i.
'" value="'.
price($int).
'" ech="'.$i.
'"><input type="hidden" name="hi_interets'.$i.
'" id="hi_interets'.$i.
'" value="'.$int.
'"></td>';
511 print
'<td class="center"><input class="width75 right" name="amort'.$i.
'" id="amort'.$i.
'" value="'.
price($amort).
'" ech="'.$i.
'"><input type="hidden" name="hi_amort'.$i.
'" id="hi_amort'.$i.
'" value="'.$amort.
'"></td>';
512 print
'<td class="center"><input class="width75 right" name="mens'.$i.
'" id="mens'.$i.
'" value="'.
price($mens).
'" ech="'.$i.
'"><input type="hidden" name="hi_mens'.$i.
'" id="hi_mens'.$i.
'" value="'.$mens.
'"></td>';
513 print
'<td class="center amount" id="capital'.$i.
'">'.
price($cap_rest, 0,
'', 1, -1, -1,
$conf->currency).
'</td><input type="hidden" name="hi_capital'.$i.
'" id ="hi_capital'.$i.
'" value="'.$cap_rest.
'">';
516 $capital = $cap_rest;
518} elseif (count($echeances->lines) > 0) {
521 $cap_rest = (float) $capital;
525 foreach ($echeances->lines as $line) {
526 $mens = $line->amount_capital + $line->amount_interest;
527 $int = $line->amount_interest;
528 $amort = $line->amount_capital;
529 $insu = ((float) $insurance + (($i == 1) ? (float) $regulInsurance : 0));
530 $cap_rest =
price2num($capital - $amort,
'MT');
532 $total_insurance += $insu;
533 $total_interest += $int;
534 $total_amort += $amort;
535 $total_mens += $mens;
538 print
'<td class="center" id="n'.$i.
'"><input type="hidden" name="hi_rowid'.$i.
'" id ="hi_rowid'.$i.
'" value="'.$line->id.
'">'.$i.
'</td>';
539 print
'<td class="center" id ="date'.$i.
'"><input type="hidden" name="hi_date'.$i.
'" id ="hi_date'.$i.
'" value="'.$line->datep.
'">'.
dol_print_date($line->datep,
'day').
'</td>';
540 print
'<td class="center amount" id="insurance'.$i.
'">'.
price($insu, 0,
'', 1, -1, -1,
$conf->currency).
'</td><input type="hidden" name="hi_insurance'.$i.
'" id ="hi_insurance'.$i.
'" value="'.$insu.
'">';
542 if (empty($line->fk_bank)) {
543 print
'<td class="center"><input class="right width75" name="interets'.$i.
'" id="interets'.$i.
'" value="'.
price($int).
'" ech="'.$i.
'"><input type="hidden" name="hi_interets'.$i.
'" id="hi_interets'.$i.
'" value="'.$int.
'"></td>';
544 print
'<td class="center"><input class="right width75" name="amort'.$i.
'" id="amort'.$i.
'" value="'.
price($amort).
'" ech="'.$i.
'"><input type="hidden" name="hi_amort'.$i.
'" id="hi_amort'.$i.
'" value="'.$amort.
'"></td>';
545 print
'<td class="center"><input class="right width75" name="mens'.$i.
'" id="mens'.$i.
'" value="'.
price($mens).
'" ech="'.$i.
'"><input type="hidden" name="hi_mens'.$i.
'" id="hi_mens'.$i.
'" value="'.$mens.
'"></td>';
547 print
'<td class="center amount" id="interets'.$i.
'">'.
price($int, 0,
'', 1, -1, -1,
$conf->currency).
'</td><input type="hidden" name="interets'.$i.
'" id="interets'.$i.
'" value="'.$int.
'"><input type="hidden" name="hi_interets'.$i.
'" id="hi_interets'.$i.
'" value="'.$int.
'">';
548 print
'<td class="center amount" id="amort'.$i.
'">'.
price($amort, 0,
'', 1, -1, -1,
$conf->currency).
'</td><input type="hidden" name="amort'.$i.
'" id ="amort'.$i.
'" value="'.$amort.
'"><input type="hidden" name="hi_amort'.$i.
'" id="hi_amort'.$i.
'" value="'.$amort.
'">';
549 print
'<td class="center amount" id="mens'.$i.
'">'.
price($mens, 0,
'', 1, -1, -1,
$conf->currency).
'</td><input type="hidden" name="mens'.$i.
'" id ="mens'.$i.
'" value="'.$mens.
'"><input type="hidden" name="hi_mens'.$i.
'" id="hi_mens'.$i.
'" value="'.$mens.
'">';
552 print
'<td class="center amount" id="capital'.$i.
'">'.
price($cap_rest, 0,
'', 1, -1, -1,
$conf->currency).
'</td><input type="hidden" name="hi_capital'.$i.
'" id ="hi_capital'.$i.
'" value="'.$cap_rest.
'">';
553 print
'<td class="center">';
554 if (!empty($line->fk_bank)) {
555 print $langs->trans(
'Paid');
556 if (!empty($line->fk_payment_loan)) {
557 print
' <a href="'.DOL_URL_ROOT.
'/loan/payment/card.php?id='.$line->fk_payment_loan.
'">('.img_object($langs->trans(
"Payment"),
"payment").
' '.$line->fk_payment_loan.
')</a>';
559 } elseif (!$printed) {
560 print
'<a class="butAction smallpaddingimp" href="'.DOL_URL_ROOT.
'/loan/payment/payment.php?id='.
$object->id.
'&action=create">'.$langs->trans(
'DoPayment').
'</a>';
566 $capital = $cap_rest;
570print
'<tr class="liste_total">';
571print
'<td class="center">'.$langs->trans(
"Total").
'</td>';
573print
'<td class="center amount" id="total_insurance">'.price($total_insurance, 0,
'', 1, -1, -1,
$conf->currency).
'</td>';
574print
'<td class="center amount" id="total_interest">'.price($total_interest, 0,
'', 1, -1, -1,
$conf->currency).
'</td>';
575print
'<td class="center amount" id="total_amort">'.price($total_amort, 0,
'', 1, -1, -1,
$conf->currency).
'</td>';
576print
'<td class="center amount" id="total_mens">'.price($total_mens, 0,
'', 1, -1, -1,
$conf->currency).
'</td>';
577print
'<td class="center amount" id="total_capital">'.price(0, 0,
'', 1, -1, -1,
$conf->currency).
'</td>';
578if (count($echeances->lines) > 0) {
586if ((
float)
$object->balloon_amount > 0) {
587 print
'<div class="opacitymedium margintoponly">'.$langs->trans(
"LoanBalloonInLastPayment",
price(
$object->balloon_amount, 0,
'', 1, -1, -1,
$conf->currency)).
'</div>';
592if (count($echeances->lines) == 0) {
593 $label = $langs->trans(
"Create");
595 $label = $langs->trans(
"Save");
597print
'<div class="center"><input type="submit" class="button button-add" value="'.$label.
'" '.(($pay_without_schedule == 1) ?
'disabled title="'.$langs->trans(
'CantUseScheduleWithLoanStartedToPaid').
'"' :
'').
'title=""></div>';
601if ($permissiontoadd &&
$object->paid != Loan::STATUS_PAID) {
603 foreach ($echeances->lines as $l) {
604 if (empty($l->fk_bank)) {
605 $firstunpaid = (int) $l->datep;
611 print
'<form name="recalculate" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
612 print
'<input type="hidden" name="token" value="'.newToken().
'">';
613 print
'<input type="hidden" name="loanid" value="'.$loanid.
'">';
614 print
'<input type="hidden" name="action" value="recalculate">';
615 print
'<table class="border centpercent">';
616 print
'<tr><td class="titlefield">'.$langs->trans(
"LoanRecalcFrom").
'</td><td>'.$form->selectDate($firstunpaid ? $firstunpaid :
dol_now(),
'recalcfrom', 0, 0, 0,
'recalculate', 1, 0).
'</td></tr>';
617 print
'<tr><td>'.$langs->trans(
"LoanNewRate").
'</td><td><input name="newrate" size="5" value="'.
dol_escape_htmltag((
string)
$object->rate).
'"> %</td></tr>';
618 if (count($echeances->lines) > 0) {
619 print
'<tr><td>'.$langs->trans(
"LoanRecalcKeep").
'</td><td>'.$form->selectarray(
'keep', array(
'term' => $langs->trans(
"LoanRecalcKeepTerm"),
'payment' => $langs->trans(
"LoanRecalcKeepPayment")),
'term').
'</td></tr>';
622 print
'<div class="opacitymedium margintoponly">'.$langs->trans(count($echeances->lines) > 0 ?
"LoanRecalcHelp" :
"LoanRecalcHelpNoSchedule").
'</div>';
623 print
'<div class="center"><input type="submit" class="button" value="'.$langs->trans(
"LoanRecalculateButton").
'"></div>';
629if (count($changes)) {
632 print
'<div class="div-table-responsive-no-min">';
633 print
'<table class="noborder centpercent">';
634 print
'<tr class="liste_titre"><th>'.$langs->trans(
"Date").
'</th><th>'.$langs->trans(
"LoanChangeReason").
'</th><th>'.$langs->trans(
"LoanChangeFrom").
'</th>';
635 print
'<th class="right">'.$langs->trans(
"Rate").
'</th><th>'.$langs->trans(
"LoanRecalcKeep").
'</th><th class="right">'.$langs->trans(
"Amount").
'</th><th class="right">'.$langs->trans(
"Nbterms").
'</th><th>'.$langs->trans(
"User").
'</th></tr>';
636 foreach ($changes as
$c) {
638 $u->fetch((
int)
$c->fk_user_author);
639 print
'<tr class="oddeven">';
640 print
'<td class="nowraponall">'.dol_print_date(
$c->datec,
'dayhour').
'</td>';
641 print
'<td>'.$langs->trans(
$c->reason ==
'payment' ?
'LoanChangeReasonPayment' :
'LoanChangeReasonRate');
642 if (!empty(
$c->fk_payment_loan)) {
643 print
' <a href="'.DOL_URL_ROOT.
'/loan/payment/card.php?id='.((int)
$c->fk_payment_loan).
'">'.img_object($langs->trans(
"Payment"),
"payment").
' '.((int)
$c->fk_payment_loan).
'</a>';
646 print
'<td class="nowraponall">'.dol_print_date(
$c->date_change,
'day').
'</td>';
647 print
'<td class="right nowraponall">'.price(
$c->rate_old).
'% → '.
price(
$c->rate_new).
'%</td>';
648 print
'<td>'.($c->keep_mode ==
'payment' ? $langs->trans(
"LoanRecalcKeepPayment") : (
$c->keep_mode ==
'term' ? $langs->trans(
"LoanRecalcKeepTerm") :
'')).
'</td>';
649 print
'<td class="right nowraponall">'.($c->keep_mode ?
price(
$c->payment_old, 0, $langs, 1, -1, -1,
$conf->currency).
' → '.
price(
$c->payment_new, 0, $langs, 1, -1, -1,
$conf->currency) :
'').
'</td>';
650 print
'<td class="right nowraponall">'.((float)
$c->nbterm_old != (
float)
$c->nbterm_new ? ((float)
$c->nbterm_old).
' → '.((float)
$c->nbterm_new) : ((float)
$c->nbterm_new)).
'</td>';
651 print
'<td>'.($u->id > 0 ? $u->getNomUrl(-1) :
'').
'</td>';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage Schedule of loans.
Class to manage projects.
Class to manage Dolibarr users.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
loanFetchChanges($db, $loanid)
History of the changes of a loan, most recent first.
loan_prepare_head($object)
Prepare array with list of tabs.
loanChargePerPayment($amount, $per_payment, $nbterm)
Charge of each payment of a loan.
loanRecordChange($db, $user, $loanid, $reason, $datechange, $rate_old, $rate_new, $keep, $payment_old, $payment_new, $nbterm_old, $nbterm_new, $fk_payment=0)
Record a change of a loan (rate change, or a payment that differs from the schedule) in its history.
loanRecalculateSchedule($db, $user, $loan, $lines, $from, $capital, $rate, $keep, $payment=0.0)
Recalculate the unpaid payments of a loan schedule, from one payment to the end, after a rate change ...
loanPeriodRate($rate, $frequency=12, $interest_basis=0, $days=0)
Interest rate of one period of a loan.
loanTermDate($datestart, $index, $frequency=12)
Date of a payment of a loan.
loanPeriodDays($datestart, $term, $frequency=12)
Number of days of the period that ends with a payment (used by the daily interest basis).
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.