dolibarr 25.0.0-alpha
schedule.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Franck Moreau <franck.moreau@theobald.com>
3 * Copyright (C) 2018-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
4 * Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
5 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
6 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2026 Lenin Rivas <lenin.rivas777@gmail.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
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';
44if (isModEnabled('project')) {
45 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
46}
47
48$loanid = GETPOSTINT('loanid');
49$action = GETPOST('action', 'aZ09');
50
51// Security check
52$socid = 0;
53if (GETPOSTISSET('socid')) {
54 $socid = GETPOSTINT('socid');
55}
56if ($user->socid) {
57 $socid = $user->socid;
58}
59if (!$user->hasRight('loan', 'calc')) {
61}
62
63// Load translation files required by the page
64$langs->loadLangs(array("compta", "bills", "loan"));
65
66$object = new Loan($db);
67$object->fetch($loanid);
68
69$echeances = new LoanSchedule($db);
70$echeances->fetchAll($object->id);
71
72if ($object->paid > 0 && count($echeances->lines) == 0) {
73 $pay_without_schedule = 1;
74} else {
75 $pay_without_schedule = 0;
76}
77
78$permissiontoadd = $user->hasRight('loan', 'write');
79
80
81/*
82 * Actions
83 */
84
85if ($action == 'createecheancier' && empty($pay_without_schedule) && $permissiontoadd) {
86 $result = -1;
87 $db->begin();
88 $i = 1;
89 while ($i < $object->nbterm + 1) {
90 $date = GETPOSTINT('hi_date'.$i);
91 $mens = price2num(GETPOST('mens'.$i));
92 if (GETPOSTISSET('interets'.$i)) {
93 $int = price2num(GETPOST('interets'.$i));
94 } else {
95 $int = price2num(GETPOST('hi_interets'.$i));
96 }
97 $insurance = price2num(GETPOST('hi_insurance'.$i));
98 if (GETPOSTISSET('amort'.$i)) {
99 $amort = price2num(GETPOST('amort'.$i));
100 } else {
101 $amort = (float) $mens - (float) $int;
102 }
103
104 $new_echeance = new LoanSchedule($db);
105
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);
118 if ($result < 0) {
119 setEventMessages($new_echeance->error, $new_echeance->errors, 'errors');
120 $db->rollback();
121 $echeances->lines = [];
122 break;
123 }
124 $echeances->lines[] = $new_echeance;
125 $i++;
126 }
127 if ($result > 0) {
128 $db->commit();
129 }
130}
131
132if ($action == 'updateecheancier' && empty($pay_without_schedule) && $permissiontoadd) {
133 $result = -1;
134 $db->begin();
135 $i = 1;
136 while ($i < $object->nbterm + 1) {
137 $mens = price2num(GETPOST('mens'.$i));
138 if (GETPOSTISSET('interets'.$i)) {
139 $int = price2num(GETPOST('interets'.$i));
140 } else {
141 $int = price2num(GETPOST('hi_interets'.$i));
142 }
143 $id = GETPOSTINT('hi_rowid'.$i);
144 $insurance = price2num(GETPOST('hi_insurance'.$i));
145 if (GETPOSTISSET('amort'.$i)) {
146 $amort = price2num(GETPOST('amort'.$i));
147 } else {
148 $amort = (float) $mens - (float) $int;
149 }
150
151 $new_echeance = new LoanSchedule($db);
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);
159 if ($result < 0) {
160 setEventMessages(null, $new_echeance->errors, 'errors');
161 $db->rollback();
162 $echeances->fetchAll($object->id);
163 break;
164 }
165
166 $echeances->lines[$i - 1] = $new_echeance;
167 $i++;
168 }
169 if ($result > 0) {
170 $db->commit();
171 }
172}
173
174
175/*
176 * View
177 */
178
179$form = new Form($db);
180$formproject = new FormProjets($db);
181
182$title = $langs->trans("Loan").' - '.$langs->trans("FinancialCommitment");
183$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
184
185llxHeader("", $title, $help_url, '', 0, 0, '', '', '', 'mod-loan page-card_schedule');
186
187$head = loan_prepare_head($object);
188print dol_get_fiche_head($head, 'FinancialCommitment', $langs->trans("Loan"), -1, 'money-bill-alt');
189
190$linkback = '<a href="'.DOL_URL_ROOT.'/loan/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
191
192$morehtmlref = '<div class="refidno">';
193// Ref loan
194$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1);
195$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1);
196// Project
197if (isModEnabled('project')) {
198 $langs->loadLangs(array("projects"));
199 $morehtmlref .= '<br>'.$langs->trans('Project').' : ';
200 if ($user->hasRight('loan', 'write')) {
201 if ($action != 'classify') {
202 //$morehtmlref .= '<a class="editfielda" href="'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
203 if ($action == 'classify') {
204 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
205 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
206 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
207 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
208 $morehtmlref .= $formproject->select_projects(-1, (string) $object->fk_project, 'projectid', 16, 0, 1, 0, 1, 0, 0, '', 1);
209 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
210 $morehtmlref .= '</form>';
211 } else {
212 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, -1, (string) $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
213 }
214 }
215 } else {
216 if (!empty($object->fk_project)) {
217 $proj = new Project($db);
218 $proj->fetch($object->fk_project);
219 $morehtmlref .= ' : '.$proj->getNomUrl(1);
220 if ($proj->title) {
221 $morehtmlref .= ' - '.$proj->title;
222 }
223 } else {
224 $morehtmlref .= '';
225 }
226 }
227}
228$morehtmlref .= '</div>';
229
230$morehtmlstatus = '';
231
232dol_banner_tab($object, 'loanid', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus);
233
234?>
235<script type="text/javascript">
236$(document).ready(function() {
237 var timeout = null;
238 var delay = 750; // 0.75 seconds
239
240 function updateTotals() {
241 var totInsu = 0;
242 var totInt = 0;
243 var totAmort = 0;
244 var totMens = 0;
245
246 $('[name^="hi_insurance"]').each(function() {
247 totInsu += (price2numjs($(this).val()) || 0);
248 });
249 $('[name^="hi_interets"]').each(function() {
250 totInt += (price2numjs($(this).val()) || 0);
251 });
252 $('[id^="hi_amort"]').each(function() {
253 totAmort += (price2numjs($(this).val()) || 0);
254 });
255 $('[id^="hi_mens"]').each(function() {
256 totMens += (price2numjs($(this).val()) || 0);
257 });
258
259 $('#total_insurance').text(pricejs(totInsu, 'MT', '<?php echo $conf->currency; ?>'));
260 $('#total_interest').text(pricejs(totInt, 'MT', '<?php echo $conf->currency; ?>'));
261 $('#total_amort').text(pricejs(totAmort, 'MT', '<?php echo $conf->currency; ?>'));
262 $('#total_mens').text(pricejs(totMens, 'MT', '<?php echo $conf->currency; ?>'));
263 }
264
265 $('[name^="mens"]').on('keyup change', function() {
266 clearTimeout(timeout);
267 var $this = $(this);
268 timeout = setTimeout(() => {
269 var echeance = $this.attr('ech');
270 var mens = $this.val();
271 var amort = $('#amort' + echeance).val();
272 var interet = $('#interets' + echeance).val();
273 calculateMens(echeance, mens, amort, 'mens', 0, interet);
274 }, delay);
275 });
276
277 $('[name^="amort"]').on('keyup change', function() {
278 clearTimeout(timeout);
279 var $this = $(this);
280 timeout = setTimeout(() => {
281 var echeance = $this.attr('ech');
282 var amort = $this.val();
283 var mens = $('#mens' + echeance).val();
284 var interet = $('#interets' + echeance).val();
285 calculateMens(echeance, mens, amort, 'amort', 0, interet);
286 }, delay);
287 });
288
289 $('[name^="interets"]').on('keyup change', function() {
290 clearTimeout(timeout);
291 var $this = $(this);
292 timeout = setTimeout(() => {
293 var echeance = $this.attr('ech');
294 var interet = $this.val();
295 var amort = $('#amort' + echeance).val();
296 var mens = $('#mens' + echeance).val();
297 calculateMens(echeance, mens, amort, 'interet', 0, interet);
298 }, delay);
299 });
300
301 $('#btn_apply_grace_period').on('click', function(e) {
302 e.preventDefault();
303 var months = parseInt($('#grace_period_months').val(), 10);
304 if (isNaN(months) || months < 1) return;
305 var nbterm = <?php echo (int) $object->nbterm; ?>;
306 if (months >= nbterm) months = nbterm - 1;
307
308 calculateMens(1, 0, 0, 'amort', months, 0);
309 });
310
311 function calculateMens(echeance, mens, amort, source, grace_period, interet) {
312 var idcap = echeance - 1;
313 idcap = '#hi_capital' + idcap;
314 var capital = price2numjs($(idcap).val());
315 console.log("calculateMens echeance=" + echeance + " idcap=" + idcap + " capital=" + capital + " source=" + source + " grace=" + grace_period);
316
317 $.ajax({
318 method: "GET",
319 dataType: 'json',
320 url: 'calcmens.php',
321 data: {
322 echeance: echeance,
323 mens: price2numjs(mens),
324 amort: price2numjs(amort),
325 interet: price2numjs(interet),
326 source: source,
327 grace_period: grace_period,
328 capital: capital,
329 rate: <?php echo $object->rate / 100; ?>,
330 nbterm: <?php echo $object->nbterm; ?>,
331 token: '<?php echo currentToken(); ?>'
332 },
333 success: function(data) {
334 $.each(data, function(index, element) {
335 $('#hi_capital' + index).val(element.cap_rest);
336 $('#capital' + index).text(element.cap_rest_str);
337
338 if ($('#interets' + index).is('input')) {
339 $('#interets' + index).val(element.interet);
340 } else {
341 $('#interets' + index).text(element.interet_str);
342 }
343 $('#hi_interets' + index).val(element.interet);
344
345 if ($('#amort' + index).is('input')) {
346 $('#amort' + index).val(element.amort);
347 } else {
348 $('#amort' + index).text(element.amort);
349 }
350 $('#hi_amort' + index).val(element.amort_num);
351
352 if ($('#mens' + index).is('input')) {
353 $('#mens' + index).val(element.mens);
354 } else {
355 $('#mens' + index).text(element.mens);
356 }
357 $('#hi_mens' + index).val(element.mens_num);
358 });
359 updateTotals();
360 }
361 });
362 }
363
364 updateTotals();
365});
366</script>
367<?php
368
369if ($pay_without_schedule == 1) {
370 print '<div class="warning">'.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'</div>'."\n";
371}
372
373print '<form name="createecheancier" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
374print '<input type="hidden" name="token" value="'.newToken().'">';
375print '<input type="hidden" name="loanid" value="'.$loanid.'">';
376if (count($echeances->lines) > 0) {
377 print '<input type="hidden" name="action" value="updateecheancier">';
378} else {
379 print '<input type="hidden" name="action" value="createecheancier">';
380}
381
382if (empty($pay_without_schedule) && $permissiontoadd) {
383 print '<div class="marginbottomonly inline-block valignmiddle">';
384 print '<span class="opacitymedium">'.$langs->trans("GracePeriodMonths").': </span>';
385 print '<input type="number" id="grace_period_months" min="1" max="'.max(1, $object->nbterm - 1).'" value="1" class="width50 right"> ';
386 print '<input type="button" id="btn_apply_grace_period" class="button valignmiddle" value="'.$langs->trans("Apply").'">';
387 print '</div>';
388 print '<br><br>';
389}
390
391print '<div class="div-table-responsive-no-min">';
392print '<table class="border centpercent">';
393
394$colspan = 7;
395if (count($echeances->lines) > 0) {
396 $colspan++;
397}
398
399print '<tr class="liste_titre">';
400print '<th class="center">'.$langs->trans("Term").'</th>';
401print '<th class="center">'.$langs->trans("Date").'</th>';
402print '<th class="center">'.$langs->trans("Insurance").'</th>';
403print '<th class="center">'.$langs->trans("InterestAmount").'</th>';
404print '<th class="center">'.$langs->trans("CapitalAmortization").'</th>';
405print '<th class="center">'.$langs->trans("Amount").'</th>';
406print '<th class="center">'.$langs->trans("CapitalRemain");
407print '<br>('.price($object->capital, 0, '', 1, -1, -1, $conf->currency).')';
408print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">';
409print '</th>';
410if (count($echeances->lines) > 0) {
411 print '<th class="center">'.$langs->trans('DoPayment').'</th>';
412}
413print '</tr>'."\n";
414
415$cap_rest = 0.0;
416$total_insurance = 0.0;
417$total_interest = 0.0;
418$total_amort = 0.0;
419$total_mens = 0.0;
420
421if ($object->nbterm > 0 && count($echeances->lines) == 0) {
422 $i = 1;
423 $capital = $object->capital;
424 $cap_rest = (float) $capital;
425 $insurance = (float) $object->insurance_amount / $object->nbterm;
426 $insurance = price2num($insurance, 'MT');
427 $regulInsurance = price2num((float) $object->insurance_amount - ((float) $insurance * $object->nbterm));
428
429 while ($i < $object->nbterm + 1) {
430 $mens = price2num($echeances->calcMonthlyPayments($capital, $object->rate / 100, $object->nbterm - $i + 1), 'MT');
431 $int = ($capital * ($object->rate / 12)) / 100;
432 $int = price2num($int, 'MT');
433 $amort = price2num((float) $mens - (float) $int, 'MT');
434 $insu = ((float) $insurance + (($i == 1) ? (float) $regulInsurance : 0));
435 $cap_rest = (float) price2num((float) $capital - (float) $amort, 'MT');
436
437 // Adjust rounding difference on last term
438 if ($i == $object->nbterm && abs($cap_rest) <= 0.05 && $capital > 0) {
439 $amort = $capital;
440 $cap_rest = 0.0;
441 $mens = price2num((float) $amort + (float) $int, 'MT');
442 }
443
444 $total_insurance += $insu;
445 $total_interest += $int;
446 $total_amort += $amort;
447 $total_mens += $mens;
448
449 print '<tr>';
450 print '<td class="center" id="n'.$i.'">'.$i.'</td>';
451 print '<td class="center" id ="date'.$i.'"><input type="hidden" name="hi_date'.$i.'" id ="hi_date'.$i.'" value="'.dol_time_plus_duree($object->datestart, $i - 1, 'm').'">'.dol_print_date(dol_time_plus_duree($object->datestart, $i - 1, 'm'), 'day').'</td>';
452 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.'">';
453 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>';
454 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>';
455 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>';
456 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.'">';
457 print '</tr>'."\n";
458 $i++;
459 $capital = $cap_rest;
460 }
461} elseif (count($echeances->lines) > 0) {
462 $i = 1;
463 $capital = $object->capital;
464 $cap_rest = (float) $capital;
465 $insurance = (float) $object->insurance_amount / $object->nbterm;
466 $insurance = price2num($insurance, 'MT');
467 $regulInsurance = price2num((float) $object->insurance_amount - ((float) $insurance * $object->nbterm));
468 $printed = false;
469
470 foreach ($echeances->lines as $line) {
471 $mens = $line->amount_capital + $line->amount_interest;
472 $int = $line->amount_interest;
473 $amort = $line->amount_capital;
474 $insu = ((float) $insurance + (($i == 1) ? (float) $regulInsurance : 0));
475 $cap_rest = price2num($capital - $amort, 'MT');
476
477 $total_insurance += $insu;
478 $total_interest += $int;
479 $total_amort += $amort;
480 $total_mens += $mens;
481
482 print '<tr>';
483 print '<td class="center" id="n'.$i.'"><input type="hidden" name="hi_rowid'.$i.'" id ="hi_rowid'.$i.'" value="'.$line->id.'">'.$i.'</td>';
484 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>';
485 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.'">';
486
487 if (empty($line->fk_bank)) {
488 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>';
489 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>';
490 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>';
491 } else {
492 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.'">';
493 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.'">';
494 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.'">';
495 }
496
497 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.'">';
498 print '<td class="center">';
499 if (!empty($line->fk_bank)) {
500 print $langs->trans('Paid');
501 if (!empty($line->fk_payment_loan)) {
502 print '&nbsp;<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>';
503 }
504 } elseif (!$printed) {
505 print '<a class="butAction smallpaddingimp" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&action=create">'.$langs->trans('DoPayment').'</a>';
506 $printed = true;
507 }
508 print '</td>';
509 print '</tr>'."\n";
510 $i++;
511 $capital = $cap_rest;
512 }
513}
514
515print '<tr class="liste_total">';
516print '<td class="center">'.$langs->trans("Total").'</td>';
517print '<td></td>';
518print '<td class="center amount" id="total_insurance">'.price($total_insurance, 0, '', 1, -1, -1, $conf->currency).'</td>';
519print '<td class="center amount" id="total_interest">'.price($total_interest, 0, '', 1, -1, -1, $conf->currency).'</td>';
520print '<td class="center amount" id="total_amort">'.price($total_amort, 0, '', 1, -1, -1, $conf->currency).'</td>';
521print '<td class="center amount" id="total_mens">'.price($total_mens, 0, '', 1, -1, -1, $conf->currency).'</td>';
522print '<td class="center amount" id="total_capital">'.price(0, 0, '', 1, -1, -1, $conf->currency).'</td>';
523if (count($echeances->lines) > 0) {
524 print '<td></td>';
525}
526print '</tr>'."\n";
527
528print '</table>';
529print '</div>';
530
531print '<br>';
532
533if (count($echeances->lines) == 0) {
534 $label = $langs->trans("Create");
535} else {
536 $label = $langs->trans("Save");
537}
538print '<div class="center"><input type="submit" class="button button-add" value="'.$label.'" '.(($pay_without_schedule == 1) ? 'disabled title="'.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'"' : '').'title=""></div>';
539print '</form>';
540
541// End of page
542llxFooter();
543$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition propal.php:280
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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.
Definition wrapper.php:73
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
Loan.
Class to manage Schedule of loans.
Class to manage projects.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:126
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_now($mode='gmt')
Return date for now.
price2num($amount, $rounding='', $option=0)
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.
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.
Definition html.lib.php:540
loan_prepare_head($object)
Prepare array with list of tabs.
Definition loan.lib.php:34
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.