dolibarr 25.0.0-alpha
loan.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
3 * Copyright (C) 2015-2026 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
25require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
26
27
31class Loan extends CommonObject
32{
36 public $element = 'loan';
37
41 public $table_element = 'loan';
42
46 public $picto = 'money-bill-alt';
47
51 public $rowid;
52
56 public $datestart;
57
61 public $dateend;
62
66 public $label;
67
71 public $capital;
72
76 public $nbterm;
77
81 public $rate;
82
86 public $frequency = 12;
87
91 public $interest_basis = 0;
92
96 public $paid;
97
101 public $account_capital;
102
106 public $account_insurance;
107
111 public $account_interest;
112
116 public $accountancy_account_capital;
117
121 public $accountancy_account_insurance;
122
126 public $accountancy_account_interest;
127
131 public $insurance_amount;
132
136 public $balloon_amount = 0;
137
141 public $charge_type = 0;
142
146 public $charge_per_payment = 0;
147
151 public $fk_bank;
152
156 public $fk_user_creat;
157
161 public $fk_user_modif;
162
166 public $totalpaid;
167
171 const STATUS_UNPAID = 0;
172
176 const STATUS_PAID = 1;
177
181 const STATUS_STARTED = 2;
182
183
189 public function __construct($db)
190 {
191 $this->db = $db;
192 }
193
200 public function fetch($id)
201 {
202 $sql = "SELECT l.rowid, l.entity, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.frequency, l.interest_basis, l.note_private, l.note_public, l.insurance_amount, l.balloon_amount, l.charge_type, l.charge_per_payment,";
203 $sql .= " l.paid, l.fk_bank, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest, l.fk_projet as fk_project";
204 $sql .= " FROM ".MAIN_DB_PREFIX."loan as l";
205 $sql .= " WHERE l.rowid = ".((int) $id);
206
207 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
208 $resql = $this->db->query($sql);
209 if ($resql) {
210 if ($this->db->num_rows($resql)) {
211 $obj = $this->db->fetch_object($resql);
212
213 $this->id = $obj->rowid;
214 $this->entity = $obj->entity;
215 $this->ref = $obj->rowid;
216 $this->datestart = $this->db->jdate($obj->datestart);
217 $this->dateend = $this->db->jdate($obj->dateend);
218 $this->label = $obj->label;
219 $this->capital = $obj->capital;
220 $this->nbterm = $obj->nbterm;
221 $this->rate = $obj->rate;
222 $this->frequency = ((int) $obj->frequency > 0 ? (int) $obj->frequency : 12);
223 $this->interest_basis = (int) $obj->interest_basis;
224 $this->note_private = $obj->note_private;
225 $this->note_public = $obj->note_public;
226 $this->insurance_amount = $obj->insurance_amount;
227 $this->balloon_amount = (float) $obj->balloon_amount;
228 $this->charge_type = (int) $obj->charge_type;
229 $this->charge_per_payment = (int) $obj->charge_per_payment;
230 $this->paid = $obj->paid;
231 $this->fk_bank = $obj->fk_bank;
232
233 $this->account_capital = $obj->accountancy_account_capital;
234 $this->account_insurance = $obj->accountancy_account_insurance;
235 $this->account_interest = $obj->accountancy_account_interest;
236 $this->fk_project = $obj->fk_project;
237
238 $this->db->free($resql);
239 return 1;
240 } else {
241 $this->db->free($resql);
242 return 0;
243 }
244 } else {
245 $this->error = $this->db->lasterror();
246 return -1;
247 }
248 }
249
250
258 public function create($user, $notrigger = 0)
259 {
260 global $conf, $langs;
261
262 $error = 0;
263
264 $now = dol_now();
265
266 // clean parameters
267 $newcapital = price2num($this->capital, 'MT');
268 if (empty($this->insurance_amount)) {
269 $this->insurance_amount = 0;
270 }
271 $newinsuranceamount = price2num($this->insurance_amount, 'MT');
272 if (isset($this->note_private)) {
273 $this->note_private = trim($this->note_private);
274 }
275 if (isset($this->note_public)) {
276 $this->note_public = trim($this->note_public);
277 }
278 if (isset($this->account_capital)) {
279 $this->account_capital = trim($this->account_capital);
280 }
281 if (isset($this->account_insurance)) {
282 $this->account_insurance = trim($this->account_insurance);
283 }
284 if (isset($this->account_interest)) {
285 $this->account_interest = trim($this->account_interest);
286 }
287 if (isset($this->fk_bank)) {
288 $this->fk_bank = (int) $this->fk_bank;
289 }
290 if (isset($this->fk_user_creat)) {
291 $this->fk_user_creat = (int) $this->fk_user_creat;
292 }
293 if (isset($this->fk_user_modif)) {
294 $this->fk_user_modif = (int) $this->fk_user_modif;
295 }
296 if (isset($this->fk_project)) {
297 $this->fk_project = (int) $this->fk_project;
298 }
299
300 // Check parameters
301 if (!($newcapital > 0) || empty($this->datestart) || empty($this->dateend)) {
302 $this->error = "ErrorBadParameter";
303 return -2;
304 }
305 if (isModEnabled('accounting') && empty($this->account_capital)) {
306 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyCapitalCode"));
307 return -2;
308 }
309 if (isModEnabled('accounting') && empty($this->account_insurance)) {
310 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInsuranceCode"));
311 return -2;
312 }
313 if (isModEnabled('accounting') && empty($this->account_interest)) {
314 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInterestCode"));
315 return -2;
316 }
317
318 $this->db->begin();
319
320 $sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, frequency, interest_basis, note_private, note_public,";
321 $sql .= " accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity,";
322 $sql .= " datec, fk_projet, fk_user_author, insurance_amount, balloon_amount, charge_type, charge_per_payment)";
323 $sql .= " VALUES ('".$this->db->escape($this->label)."',";
324 $sql .= " '".$this->db->escape((string) $this->fk_bank)."',";
325 $sql .= " '".price2num($newcapital)."',";
326 $sql .= " '".$this->db->idate($this->datestart)."',";
327 $sql .= " '".$this->db->idate($this->dateend)."',";
328 $sql .= " '".$this->db->escape((string) $this->nbterm)."',";
329 $sql .= " '".$this->db->escape((string) $this->rate)."',";
330 $sql .= " ".((int) $this->frequency > 0 ? (int) $this->frequency : 12).",";
331 $sql .= " ".((int) $this->interest_basis ? 1 : 0).",";
332 $sql .= " '".$this->db->escape($this->note_private)."',";
333 $sql .= " '".$this->db->escape($this->note_public)."',";
334 $sql .= " '".$this->db->escape($this->account_capital)."',";
335 $sql .= " '".$this->db->escape($this->account_insurance)."',";
336 $sql .= " '".$this->db->escape($this->account_interest)."',";
337 $sql .= " ".((int) $conf->entity).",";
338 $sql .= " '".$this->db->idate($now)."',";
339 $sql .= " ".(empty($this->fk_project) ? 'NULL' : ((int) $this->fk_project)).",";
340 $sql .= " ".((int) $user->id).",";
341 $sql .= " '".price2num($newinsuranceamount)."',";
342 $sql .= " ".((float) price2num((float) $this->balloon_amount, 'MT')).",";
343 $sql .= " ".((int) $this->charge_type).",";
344 $sql .= " ".((int) $this->charge_per_payment ? 1 : 0);
345 $sql .= ")";
346
347 dol_syslog(get_class($this)."::create", LOG_DEBUG);
348 $resql = $this->db->query($sql);
349 if ($resql) {
350 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."loan");
351
352 if (!$notrigger) {
353 // Call trigger
354 $result = $this->call_trigger('LOAN_CREATE', $user);
355 if ($result < 0) {
356 $error++;
357 }
358 // End call triggers
359 }
360
361 if ($error) {
362 $this->db->rollback();
363 return -1;
364 }
365
366 //dol_syslog("Loans::create this->id=".$this->id);
367 $this->db->commit();
368 return $this->id;
369 } else {
370 $this->error = $this->db->error();
371 $this->db->rollback();
372 return -1;
373 }
374 }
375
376
384 public function delete($user, $notrigger = 0)
385 {
386 $error = 0;
387
388 $this->db->begin();
389
390 // Get bank transaction lines for this loan
391 include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
392 $account = new Account($this->db);
393 $lines_url = $account->get_url(0, $this->id, 'loan');
394
395 // Delete bank urls
396 foreach ($lines_url as $line_url) {
397 if (!$error) {
398 $accountline = new AccountLine($this->db);
399 $accountline->fetch($line_url['fk_bank']);
400 $result = $accountline->delete_urls($user);
401 if ($result < 0) {
402 $this->errors = array_merge($this->errors, [$accountline->error], $accountline->errors);
403 $error++;
404 }
405 }
406 }
407
408 // Delete payments
409 if (!$error) {
410 $sql = "DELETE FROM ".MAIN_DB_PREFIX."loan_change where fk_loan=".((int) $this->id);
411 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
412 if (!$this->db->query($sql)) {
413 $error++;
414 $this->error = $this->db->lasterror();
415 }
416 }
417 if (!$error) {
418 $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan where fk_loan=".((int) $this->id);
419 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
420 $resql = $this->db->query($sql);
421 if (!$resql) {
422 $error++;
423 $this->error = $this->db->lasterror();
424 }
425 }
426
427 if (!$error) {
428 $sql = "DELETE FROM ".MAIN_DB_PREFIX."loan where rowid=".((int) $this->id);
429 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
430 $resql = $this->db->query($sql);
431 if (!$resql) {
432 $error++;
433 $this->error = $this->db->lasterror();
434 }
435 }
436
437 if (!$error && !$notrigger) {
438 // Call trigger
439 $result = $this->call_trigger('LOAN_DELETE', $user);
440 if ($result < 0) {
441 $error++;
442 }
443 // End call triggers
444 }
445
446 if (!$error) {
447 $this->db->commit();
448 return 1;
449 } else {
450 $this->db->rollback();
451 return -1;
452 }
453 }
454
455
463 public function update($user, $notrigger = 0)
464 {
465 $this->db->begin();
466
467 if (!is_numeric($this->nbterm)) {
468 $this->error = 'BadValueForParameterForNbTerm';
469 return -1;
470 }
471
472 $sql = "UPDATE ".MAIN_DB_PREFIX."loan";
473 $sql .= " SET label='".$this->db->escape($this->label)."',";
474 $sql .= " capital='".$this->db->escape(price2num($this->capital))."',";
475 $sql .= " datestart='".$this->db->idate($this->datestart)."',";
476 $sql .= " dateend='".$this->db->idate($this->dateend)."',";
477 $sql .= " nbterm=".((float) $this->nbterm).",";
478 $sql .= " rate=".((float) $this->rate).",";
479 $sql .= " frequency=".((int) $this->frequency > 0 ? (int) $this->frequency : 12).",";
480 $sql .= " interest_basis=".((int) $this->interest_basis ? 1 : 0).",";
481 $sql .= " accountancy_account_capital = '".$this->db->escape($this->account_capital)."',";
482 $sql .= " accountancy_account_insurance = '".$this->db->escape($this->account_insurance)."',";
483 $sql .= " accountancy_account_interest = '".$this->db->escape($this->account_interest)."',";
484 $sql .= " fk_projet=".(empty($this->fk_project) ? 'NULL' : ((int) $this->fk_project)).",";
485 $sql .= " fk_user_modif = ".((int) $user->id).",";
486 $sql .= " insurance_amount = '".price2num($this->db->escape((string) $this->insurance_amount))."',";
487 $sql .= " balloon_amount = ".((float) price2num((float) $this->balloon_amount, 'MT')).",";
488 $sql .= " charge_type = ".((int) $this->charge_type).",";
489 $sql .= " charge_per_payment = ".((int) $this->charge_per_payment ? 1 : 0);
490 $sql .= " WHERE rowid=".((int) $this->id);
491
492 dol_syslog(get_class($this)."::update", LOG_DEBUG);
493 $resql = $this->db->query($sql);
494 if ($resql) {
495 if (!$notrigger) {
496 // Call trigger
497 $result = $this->call_trigger('LOAN_MODIFY', $user);
498 if ($result < 0) {
499 $this->db->rollback();
500 return -1;
501 }
502 // End call triggers
503 }
504
505 $this->db->commit();
506 return 1;
507 } else {
508 $this->error = $this->db->error();
509 $this->db->rollback();
510 return -1;
511 }
512 }
513
520 public function setPaid($user)
521 {
522 $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
523 $sql .= " paid = ".((int) $this::STATUS_PAID);
524 $sql .= " WHERE rowid = ".((int) $this->id);
525
526 $return = $this->db->query($sql);
527
528 if ($return) {
529 $this->paid = $this::STATUS_PAID;
530 return 1;
531 } else {
532 $this->error = $this->db->lasterror();
533 return -1;
534 }
535 }
536
537 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
546 public function set_started($user)
547 {
548 // phpcs:enable
549 dol_syslog(get_class($this)."::set_started is deprecated, use setStarted instead", LOG_NOTICE);
550 return $this->setStarted($user);
551 }
552
559 public function setStarted($user)
560 {
561 $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
562 $sql .= " paid = ".((int) $this::STATUS_STARTED);
563 $sql .= " WHERE rowid = ".((int) $this->id);
564
565 $return = $this->db->query($sql);
566
567 if ($return) {
568 $this->paid = $this::STATUS_STARTED;
569 return 1;
570 } else {
571 $this->error = $this->db->lasterror();
572 return -1;
573 }
574 }
575
582 public function setUnpaid($user)
583 {
584 $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
585 $sql .= " paid = ".((int) $this::STATUS_UNPAID);
586 $sql .= " WHERE rowid = ".((int) $this->id);
587
588 $return = $this->db->query($sql);
589
590 if ($return) {
591 $this->paid = $this::STATUS_UNPAID;
592 return 1;
593 } else {
594 $this->error = $this->db->lasterror();
595 return -1;
596 }
597 }
598
606 public function getLibStatut($mode = 0, $alreadypaid = -1)
607 {
608 return $this->LibStatut($this->paid, $mode, $alreadypaid);
609 }
610
611 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
620 public function LibStatut($status, $mode = 0, $alreadypaid = -1)
621 {
622 // phpcs:enable
623 global $langs;
624
625 // Load translation files required by the page
626 $langs->loadLangs(array("customers", "bills"));
627
628 unset($this->labelStatus); // Force to reset the array of status label, because label can change depending on parameters
629 // Always true because of 'unset':
630 // if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
631 global $langs;
632 $this->labelStatus = array();
633 $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('Unpaid');
634 $this->labelStatus[self::STATUS_PAID] = $langs->transnoentitiesnoconv('Paid');
635 $this->labelStatus[self::STATUS_STARTED] = $langs->transnoentitiesnoconv("BillStatusStarted");
636 if ($status == 0 && $alreadypaid > 0) {
637 $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
638 }
639 $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('Unpaid');
640 $this->labelStatusShort[self::STATUS_PAID] = $langs->transnoentitiesnoconv('Paid');
641 $this->labelStatusShort[self::STATUS_STARTED] = $langs->transnoentitiesnoconv("BillStatusStarted");
642 if ($status == 0 && $alreadypaid > 0) {
643 $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
644 }
645 // } // End of empty(labelStatus,labelStatusShort)
646
647 $statusType = 'status1';
648 if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) {
649 $statusType = 'status3';
650 }
651 if ($status == 1) {
652 $statusType = 'status6';
653 }
654
655 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
656 }
657
658
670 public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
671 {
672 global $conf, $langs, $hookmanager;
673
674 $result = '';
675
676 $label = '<u>'.$langs->trans("ShowLoan").'</u>';
677 if (!empty($this->ref)) {
678 $label .= '<br><strong>'.$langs->trans('Ref').':</strong> '.$this->ref;
679 }
680 if (!empty($this->label)) {
681 $label .= '<br><strong>'.$langs->trans('Label').':</strong> '.$this->label;
682 }
683 if (isDolTms($this->datestart)) {
684 $label .= '<br><strong>'.$langs->trans("DateStart").':</strong> '.dol_print_date($this->datestart, 'day');
685 }
686 if (isDolTms($this->dateend)) {
687 $label .= '<br><strong>'.$langs->trans("DateEnd").':</strong> '.dol_print_date($this->dateend, 'day');
688 }
689
690 $baseurl = DOL_URL_ROOT.'/loan/card.php';
691 $query = ['id' => $this->id];
692 if ($option != 'nolink') {
693 // Add param to save lastsearch_values or not
694 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
695 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
696 $add_save_lastsearch_values = 1;
697 }
698 if ($add_save_lastsearch_values) {
699 $query += ['save_lastsearch_values' => 1];
700 }
701 }
702 $url = dolBuildUrl($baseurl, $query);
703
704 $linkclose = '';
705 if (empty($notooltip)) {
706 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
707 $label = $langs->trans("ShowLoan");
708 $linkclose .= ' alt="'.dolPrintHTMLForAttribute($label).'"';
709 }
710 $linkclose .= ' title="'.dolPrintHTMLForAttribute($label).'"';
711 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
712 } else {
713 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
714 }
715
716 $linkstart = '<a href="'.$url.'"';
717 $linkstart .= $linkclose.'>';
718 $linkend = '</a>';
719
720 $result .= $linkstart;
721 if ($withpicto) {
722 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
723 }
724 if ($withpicto != 2) {
725 $result .= ($maxlen ? dol_trunc($this->ref, $maxlen) : $this->ref);
726 }
727 $result .= $linkend;
728
729 global $action;
730 $hookmanager->initHooks(array($this->element . 'dao'));
731 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
732 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
733 if ($reshook > 0) {
734 $result = $hookmanager->resPrint;
735 } else {
736 $result .= $hookmanager->resPrint;
737 }
738 return $result;
739 }
740
748 public function initAsSpecimen()
749 {
750 $now = dol_now();
751
752 // Initialise parameters
753 $this->id = 0;
754 $this->fk_bank = 1;
755 $this->label = 'SPECIMEN';
756 $this->specimen = 1;
757 $this->account_capital = '16';
758 $this->account_insurance = '616';
759 $this->account_interest = '518';
760 $this->datestart = $now;
761 $this->dateend = $now + (3600 * 24 * 365);
762 $this->note_public = 'SPECIMEN';
763 $this->capital = 20000.80;
764 $this->nbterm = 48;
765 $this->rate = 4.3;
766
767 return 1;
768 }
769
775 public function getSumPayment()
776 {
777 $sql = "SELECT sum(amount_capital) as amount";
778 $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan";
779 $sql .= " WHERE fk_loan = ".((int) $this->id);
780
781 dol_syslog(get_class($this)."::getSumPayment", LOG_DEBUG);
782
783 $resql = $this->db->query($sql);
784 if ($resql) {
785 $amount = 0;
786
787 $obj = $this->db->fetch_object($resql);
788 if ($obj) {
789 $amount = $obj->amount ? $obj->amount : 0;
790 }
791
792 $this->db->free($resql);
793 return $amount;
794 } else {
795 $this->error = $this->db->lasterror();
796 return -1;
797 }
798 }
799
806 public function info($id)
807 {
808 $sql = 'SELECT l.rowid, l.datec, l.fk_user_author, l.fk_user_modif,';
809 $sql .= ' l.tms as datem';
810 $sql .= ' WHERE l.rowid = '.((int) $id);
811
812 dol_syslog(get_class($this).'::info', LOG_DEBUG);
813 $result = $this->db->query($sql);
814
815 if ($result) {
816 if ($this->db->num_rows($result)) {
817 $obj = $this->db->fetch_object($result);
818
819 $this->id = $obj->rowid;
820
821 $this->user_creation_id = $obj->fk_user_author;
822 $this->user_modification_id = $obj->fk_user_modif;
823 $this->date_creation = $this->db->jdate($obj->datec);
824 $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
825
826 $this->db->free($result);
827 return 1;
828 } else {
829 $this->db->free($result);
830 return 0;
831 }
832 } else {
833 $this->error = $this->db->lasterror();
834 return -1;
835 }
836 }
837
845 public function getKanbanView($option = '', $arraydata = null)
846 {
847 global $langs;
848
849 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
850
851 $return = '<div class="box-flex-item box-flex-grow-zero">';
852 $return .= '<div class="info-box info-box-sm">';
853 $return .= '<span class="info-box-icon bg-infobox-action">';
854 $return .= img_picto('', $this->picto);
855 $return .= '</span>';
856 $return .= '<div class="info-box-content">';
857 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.$this->getNomUrl(1).'</span>';
858 if ($selected >= 0) {
859 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
860 }
861 if (!empty($this->capital)) {
862 $return .= ' | <span class="opacitymedium">'.$langs->trans("Amount").'</span> : <span class="info-box-label amount">'.price($this->capital).'</span>';
863 }
864 if (isDolTms($this->datestart)) {
865 $return .= '<br><span class="opacitymedium">'.$langs->trans("DateStart").'</span> : <span class="info-box-label">'.dol_print_date($this->datestart, 'day').'</span>';
866 }
867 if (isDolTms($this->dateend)) {
868 $return .= '<br><span class="opacitymedium">'.$langs->trans("DateEnd").'</span> : <span class="info-box-label">'.dol_print_date($this->dateend, 'day').'</span>';
869 }
870
871 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3, (float) $this->totalpaid).'</div>';
872 $return .= '</div>';
873 $return .= '</div>';
874 $return .= '</div>';
875
876 return $return;
877 }
878}
$object ref
Definition info.php:90
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 bank accounts.
Class to manage bank transaction lines.
Loan.
fetch($id)
Load object in memory from database.
setUnpaid($user)
Tag loan as payment as unpaid.
initAsSpecimen()
Initialise an instance with random values.
setPaid($user)
Tag loan as paid completely.
getKanbanView($option='', $arraydata=null)
Return clickable link of object (with eventually picto)
setStarted($user)
Tag loan as payment started.
info($id)
Information on record.
LibStatut($status, $mode=0, $alreadypaid=-1)
Return label for given status.
__construct($db)
Constructor.
getNomUrl($withpicto=0, $maxlen=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return clickable name (with eventually the picto)
getSumPayment()
Return amount of payments already done.
update($user, $notrigger=0)
Update loan.
set_started($user)
Tag loan as payment started.
create($user, $notrigger=0)
Create a loan into database.
getLibStatut($mode=0, $alreadypaid=-1)
Return label of loan status (unpaid, paid)
dol_now($mode='gmt')
Return date for now.
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
isDolTms($timestamp)
isDolTms check if a timestamp is valid.
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.
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).
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.