dolibarr 24.0.0-beta
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-2025 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
43 public $table = 'loan';
44
48 public $table_element = 'loan';
49
53 public $picto = 'money-bill-alt';
54
58 public $rowid;
59
63 public $datestart;
64
68 public $dateend;
69
73 public $label;
74
78 public $capital;
79
83 public $nbterm;
84
88 public $rate;
89
93 public $paid;
94
98 public $account_capital;
99
103 public $account_insurance;
104
108 public $account_interest;
109
113 public $accountancy_account_capital;
114
118 public $accountancy_account_insurance;
119
123 public $accountancy_account_interest;
124
128 public $insurance_amount;
129
133 public $fk_bank;
134
138 public $fk_user_creat;
139
143 public $fk_user_modif;
144
148 public $totalpaid;
149
153 const STATUS_UNPAID = 0;
154
158 const STATUS_PAID = 1;
159
163 const STATUS_STARTED = 2;
164
165
171 public function __construct($db)
172 {
173 $this->db = $db;
174 }
175
182 public function fetch($id)
183 {
184 $sql = "SELECT l.rowid, l.entity, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note_private, l.note_public, l.insurance_amount,";
185 $sql .= " l.paid, l.fk_bank, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest, l.fk_projet as fk_project";
186 $sql .= " FROM ".MAIN_DB_PREFIX."loan as l";
187 $sql .= " WHERE l.rowid = ".((int) $id);
188
189 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
190 $resql = $this->db->query($sql);
191 if ($resql) {
192 if ($this->db->num_rows($resql)) {
193 $obj = $this->db->fetch_object($resql);
194
195 $this->id = $obj->rowid;
196 $this->entity = $obj->entity;
197 $this->ref = $obj->rowid;
198 $this->datestart = $this->db->jdate($obj->datestart);
199 $this->dateend = $this->db->jdate($obj->dateend);
200 $this->label = $obj->label;
201 $this->capital = $obj->capital;
202 $this->nbterm = $obj->nbterm;
203 $this->rate = $obj->rate;
204 $this->note_private = $obj->note_private;
205 $this->note_public = $obj->note_public;
206 $this->insurance_amount = $obj->insurance_amount;
207 $this->paid = $obj->paid;
208 $this->fk_bank = $obj->fk_bank;
209
210 $this->account_capital = $obj->accountancy_account_capital;
211 $this->account_insurance = $obj->accountancy_account_insurance;
212 $this->account_interest = $obj->accountancy_account_interest;
213 $this->fk_project = $obj->fk_project;
214
215 $this->db->free($resql);
216 return 1;
217 } else {
218 $this->db->free($resql);
219 return 0;
220 }
221 } else {
222 $this->error = $this->db->lasterror();
223 return -1;
224 }
225 }
226
227
234 public function create($user)
235 {
236 global $conf, $langs;
237
238 $error = 0;
239
240 $now = dol_now();
241
242 // clean parameters
243 $newcapital = price2num($this->capital, 'MT');
244 if (empty($this->insurance_amount)) {
245 $this->insurance_amount = 0;
246 }
247 $newinsuranceamount = price2num($this->insurance_amount, 'MT');
248 if (isset($this->note_private)) {
249 $this->note_private = trim($this->note_private);
250 }
251 if (isset($this->note_public)) {
252 $this->note_public = trim($this->note_public);
253 }
254 if (isset($this->account_capital)) {
255 $this->account_capital = trim($this->account_capital);
256 }
257 if (isset($this->account_insurance)) {
258 $this->account_insurance = trim($this->account_insurance);
259 }
260 if (isset($this->account_interest)) {
261 $this->account_interest = trim($this->account_interest);
262 }
263 if (isset($this->fk_bank)) {
264 $this->fk_bank = (int) $this->fk_bank;
265 }
266 if (isset($this->fk_user_creat)) {
267 $this->fk_user_creat = (int) $this->fk_user_creat;
268 }
269 if (isset($this->fk_user_modif)) {
270 $this->fk_user_modif = (int) $this->fk_user_modif;
271 }
272 if (isset($this->fk_project)) {
273 $this->fk_project = (int) $this->fk_project;
274 }
275
276 // Check parameters
277 if (!($newcapital > 0) || empty($this->datestart) || empty($this->dateend)) {
278 $this->error = "ErrorBadParameter";
279 return -2;
280 }
281 if (isModEnabled('accounting') && empty($this->account_capital)) {
282 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyCapitalCode"));
283 return -2;
284 }
285 if (isModEnabled('accounting') && empty($this->account_insurance)) {
286 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInsuranceCode"));
287 return -2;
288 }
289 if (isModEnabled('accounting') && empty($this->account_interest)) {
290 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInterestCode"));
291 return -2;
292 }
293
294 $this->db->begin();
295
296 $sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note_private, note_public,";
297 $sql .= " accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity,";
298 $sql .= " datec, fk_projet, fk_user_author, insurance_amount)";
299 $sql .= " VALUES ('".$this->db->escape($this->label)."',";
300 $sql .= " '".$this->db->escape((string) $this->fk_bank)."',";
301 $sql .= " '".price2num($newcapital)."',";
302 $sql .= " '".$this->db->idate($this->datestart)."',";
303 $sql .= " '".$this->db->idate($this->dateend)."',";
304 $sql .= " '".$this->db->escape((string) $this->nbterm)."',";
305 $sql .= " '".$this->db->escape((string) $this->rate)."',";
306 $sql .= " '".$this->db->escape($this->note_private)."',";
307 $sql .= " '".$this->db->escape($this->note_public)."',";
308 $sql .= " '".$this->db->escape($this->account_capital)."',";
309 $sql .= " '".$this->db->escape($this->account_insurance)."',";
310 $sql .= " '".$this->db->escape($this->account_interest)."',";
311 $sql .= " ".((int) $conf->entity).",";
312 $sql .= " '".$this->db->idate($now)."',";
313 $sql .= " ".(empty($this->fk_project) ? 'NULL' : $this->fk_project).",";
314 $sql .= " ".((int) $user->id).",";
315 $sql .= " '".price2num($newinsuranceamount)."'";
316 $sql .= ")";
317
318 dol_syslog(get_class($this)."::create", LOG_DEBUG);
319 $resql = $this->db->query($sql);
320 if ($resql) {
321 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."loan");
322
323 //dol_syslog("Loans::create this->id=".$this->id);
324 $this->db->commit();
325 return $this->id;
326 } else {
327 $this->error = $this->db->error();
328 $this->db->rollback();
329 return -1;
330 }
331 }
332
333
340 public function delete($user)
341 {
342 $error = 0;
343
344 $this->db->begin();
345
346 // Get bank transaction lines for this loan
347 include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
348 $account = new Account($this->db);
349 $lines_url = $account->get_url(0, $this->id, 'loan');
350
351 // Delete bank urls
352 foreach ($lines_url as $line_url) {
353 if (!$error) {
354 $accountline = new AccountLine($this->db);
355 $accountline->fetch($line_url['fk_bank']);
356 $result = $accountline->delete_urls($user);
357 if ($result < 0) {
358 $this->errors = array_merge($this->errors, [$accountline->error], $accountline->errors);
359 $error++;
360 }
361 }
362 }
363
364 // Delete payments
365 if (!$error) {
366 $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan where fk_loan=".((int) $this->id);
367 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
368 $resql = $this->db->query($sql);
369 if (!$resql) {
370 $error++;
371 $this->error = $this->db->lasterror();
372 }
373 }
374
375 if (!$error) {
376 $sql = "DELETE FROM ".MAIN_DB_PREFIX."loan where rowid=".((int) $this->id);
377 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
378 $resql = $this->db->query($sql);
379 if (!$resql) {
380 $error++;
381 $this->error = $this->db->lasterror();
382 }
383 }
384
385 if (!$error) {
386 $this->db->commit();
387 return 1;
388 } else {
389 $this->db->rollback();
390 return -1;
391 }
392 }
393
394
401 public function update($user)
402 {
403 $this->db->begin();
404
405 if (!is_numeric($this->nbterm)) {
406 $this->error = 'BadValueForParameterForNbTerm';
407 return -1;
408 }
409
410 $sql = "UPDATE ".MAIN_DB_PREFIX."loan";
411 $sql .= " SET label='".$this->db->escape($this->label)."',";
412 $sql .= " capital='".$this->db->escape(price2num($this->capital))."',";
413 $sql .= " datestart='".$this->db->idate($this->datestart)."',";
414 $sql .= " dateend='".$this->db->idate($this->dateend)."',";
415 $sql .= " nbterm=".((float) $this->nbterm).",";
416 $sql .= " rate=".((float) $this->rate).",";
417 $sql .= " accountancy_account_capital = '".$this->db->escape($this->account_capital)."',";
418 $sql .= " accountancy_account_insurance = '".$this->db->escape($this->account_insurance)."',";
419 $sql .= " accountancy_account_interest = '".$this->db->escape($this->account_interest)."',";
420 $sql .= " fk_projet=".(empty($this->fk_project) ? 'NULL' : ((int) $this->fk_project)).",";
421 $sql .= " fk_user_modif = ".((int) $user->id).",";
422 $sql .= " insurance_amount = '".price2num($this->db->escape((string) $this->insurance_amount))."'";
423 $sql .= " WHERE rowid=".((int) $this->id);
424
425 dol_syslog(get_class($this)."::update", LOG_DEBUG);
426 $resql = $this->db->query($sql);
427 if ($resql) {
428 $this->db->commit();
429 return 1;
430 } else {
431 $this->error = $this->db->error();
432 $this->db->rollback();
433 return -1;
434 }
435 }
436
443 public function setPaid($user)
444 {
445 $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
446 $sql .= " paid = ".((int) $this::STATUS_PAID);
447 $sql .= " WHERE rowid = ".((int) $this->id);
448
449 $return = $this->db->query($sql);
450
451 if ($return) {
452 $this->paid = $this::STATUS_PAID;
453 return 1;
454 } else {
455 $this->error = $this->db->lasterror();
456 return -1;
457 }
458 }
459
460 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
469 public function set_started($user)
470 {
471 // phpcs:enable
472 dol_syslog(get_class($this)."::set_started is deprecated, use setStarted instead", LOG_NOTICE);
473 return $this->setStarted($user);
474 }
475
482 public function setStarted($user)
483 {
484 $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
485 $sql .= " paid = ".((int) $this::STATUS_STARTED);
486 $sql .= " WHERE rowid = ".((int) $this->id);
487
488 $return = $this->db->query($sql);
489
490 if ($return) {
491 $this->paid = $this::STATUS_STARTED;
492 return 1;
493 } else {
494 $this->error = $this->db->lasterror();
495 return -1;
496 }
497 }
498
505 public function setUnpaid($user)
506 {
507 $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
508 $sql .= " paid = ".((int) $this::STATUS_UNPAID);
509 $sql .= " WHERE rowid = ".((int) $this->id);
510
511 $return = $this->db->query($sql);
512
513 if ($return) {
514 $this->paid = $this::STATUS_UNPAID;
515 return 1;
516 } else {
517 $this->error = $this->db->lasterror();
518 return -1;
519 }
520 }
521
529 public function getLibStatut($mode = 0, $alreadypaid = -1)
530 {
531 return $this->LibStatut($this->paid, $mode, $alreadypaid);
532 }
533
534 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
543 public function LibStatut($status, $mode = 0, $alreadypaid = -1)
544 {
545 // phpcs:enable
546 global $langs;
547
548 // Load translation files required by the page
549 $langs->loadLangs(array("customers", "bills"));
550
551 unset($this->labelStatus); // Force to reset the array of status label, because label can change depending on parameters
552 // Always true because of 'unset':
553 // if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
554 global $langs;
555 $this->labelStatus = array();
556 $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('Unpaid');
557 $this->labelStatus[self::STATUS_PAID] = $langs->transnoentitiesnoconv('Paid');
558 $this->labelStatus[self::STATUS_STARTED] = $langs->transnoentitiesnoconv("BillStatusStarted");
559 if ($status == 0 && $alreadypaid > 0) {
560 $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
561 }
562 $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('Unpaid');
563 $this->labelStatusShort[self::STATUS_PAID] = $langs->transnoentitiesnoconv('Paid');
564 $this->labelStatusShort[self::STATUS_STARTED] = $langs->transnoentitiesnoconv("BillStatusStarted");
565 if ($status == 0 && $alreadypaid > 0) {
566 $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
567 }
568 // } // End of empty(labelStatus,labelStatusShort)
569
570 $statusType = 'status1';
571 if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) {
572 $statusType = 'status3';
573 }
574 if ($status == 1) {
575 $statusType = 'status6';
576 }
577
578 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
579 }
580
581
593 public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
594 {
595 global $conf, $langs, $hookmanager;
596
597 $result = '';
598
599 $label = '<u>'.$langs->trans("ShowLoan").'</u>';
600 if (!empty($this->ref)) {
601 $label .= '<br><strong>'.$langs->trans('Ref').':</strong> '.$this->ref;
602 }
603 if (!empty($this->label)) {
604 $label .= '<br><strong>'.$langs->trans('Label').':</strong> '.$this->label;
605 }
606 if (isDolTms($this->datestart)) {
607 $label .= '<br><strong>'.$langs->trans("DateStart").':</strong> '.dol_print_date($this->datestart, 'day');
608 }
609 if (isDolTms($this->dateend)) {
610 $label .= '<br><strong>'.$langs->trans("DateEnd").':</strong> '.dol_print_date($this->dateend, 'day');
611 }
612
613 $baseurl = DOL_URL_ROOT.'/loan/card.php';
614 $query = ['id' => $this->id];
615 if ($option != 'nolink') {
616 // Add param to save lastsearch_values or not
617 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
618 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
619 $add_save_lastsearch_values = 1;
620 }
621 if ($add_save_lastsearch_values) {
622 $query += ['save_lastsearch_values' => 1];
623 }
624 }
625 $url = dolBuildUrl($baseurl, $query);
626
627 $linkclose = '';
628 if (empty($notooltip)) {
629 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
630 $label = $langs->trans("ShowLoan");
631 $linkclose .= ' alt="'.dolPrintHTMLForAttribute($label).'"';
632 }
633 $linkclose .= ' title="'.dolPrintHTMLForAttribute($label).'"';
634 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
635 } else {
636 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
637 }
638
639 $linkstart = '<a href="'.$url.'"';
640 $linkstart .= $linkclose.'>';
641 $linkend = '</a>';
642
643 $result .= $linkstart;
644 if ($withpicto) {
645 $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);
646 }
647 if ($withpicto != 2) {
648 $result .= ($maxlen ? dol_trunc($this->ref, $maxlen) : $this->ref);
649 }
650 $result .= $linkend;
651
652 global $action;
653 $hookmanager->initHooks(array($this->element . 'dao'));
654 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
655 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
656 if ($reshook > 0) {
657 $result = $hookmanager->resPrint;
658 } else {
659 $result .= $hookmanager->resPrint;
660 }
661 return $result;
662 }
663
671 public function initAsSpecimen()
672 {
673 $now = dol_now();
674
675 // Initialise parameters
676 $this->id = 0;
677 $this->fk_bank = 1;
678 $this->label = 'SPECIMEN';
679 $this->specimen = 1;
680 $this->account_capital = '16';
681 $this->account_insurance = '616';
682 $this->account_interest = '518';
683 $this->datestart = $now;
684 $this->dateend = $now + (3600 * 24 * 365);
685 $this->note_public = 'SPECIMEN';
686 $this->capital = 20000.80;
687 $this->nbterm = 48;
688 $this->rate = 4.3;
689
690 return 1;
691 }
692
698 public function getSumPayment()
699 {
700 $sql = "SELECT sum(amount_capital) as amount";
701 $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan";
702 $sql .= " WHERE fk_loan = ".((int) $this->id);
703
704 dol_syslog(get_class($this)."::getSumPayment", LOG_DEBUG);
705
706 $resql = $this->db->query($sql);
707 if ($resql) {
708 $amount = 0;
709
710 $obj = $this->db->fetch_object($resql);
711 if ($obj) {
712 $amount = $obj->amount ? $obj->amount : 0;
713 }
714
715 $this->db->free($resql);
716 return $amount;
717 } else {
718 $this->error = $this->db->lasterror();
719 return -1;
720 }
721 }
722
729 public function info($id)
730 {
731 $sql = 'SELECT l.rowid, l.datec, l.fk_user_author, l.fk_user_modif,';
732 $sql .= ' l.tms as datem';
733 $sql .= ' WHERE l.rowid = '.((int) $id);
734
735 dol_syslog(get_class($this).'::info', LOG_DEBUG);
736 $result = $this->db->query($sql);
737
738 if ($result) {
739 if ($this->db->num_rows($result)) {
740 $obj = $this->db->fetch_object($result);
741
742 $this->id = $obj->rowid;
743
744 $this->user_creation_id = $obj->fk_user_author;
745 $this->user_modification_id = $obj->fk_user_modif;
746 $this->date_creation = $this->db->jdate($obj->datec);
747 $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
748
749 $this->db->free($result);
750 return 1;
751 } else {
752 $this->db->free($result);
753 return 0;
754 }
755 } else {
756 $this->error = $this->db->lasterror();
757 return -1;
758 }
759 }
760
768 public function getKanbanView($option = '', $arraydata = null)
769 {
770 global $langs;
771
772 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
773
774 $return = '<div class="box-flex-item box-flex-grow-zero">';
775 $return .= '<div class="info-box info-box-sm">';
776 $return .= '<span class="info-box-icon bg-infobox-action">';
777 $return .= img_picto('', $this->picto);
778 $return .= '</span>';
779 $return .= '<div class="info-box-content">';
780 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.$this->getNomUrl(1).'</span>';
781 if ($selected >= 0) {
782 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
783 }
784 if (!empty($this->capital)) {
785 $return .= ' | <span class="opacitymedium">'.$langs->trans("Amount").'</span> : <span class="info-box-label amount">'.price($this->capital).'</span>';
786 }
787 if (isDolTms($this->datestart)) {
788 $return .= '<br><span class="opacitymedium">'.$langs->trans("DateStart").'</span> : <span class="info-box-label">'.dol_print_date($this->datestart, 'day').'</span>';
789 }
790 if (isDolTms($this->dateend)) {
791 $return .= '<br><span class="opacitymedium">'.$langs->trans("DateEnd").'</span> : <span class="info-box-label">'.dol_print_date($this->dateend, 'day').'</span>';
792 }
793
794 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3, (float) $this->alreadypaid).'</div>';
795 $return .= '</div>';
796 $return .= '</div>';
797 $return .= '</div>';
798
799 return $return;
800 }
801}
$object ref
Definition info.php:90
Class to manage bank accounts.
Class to manage bank transaction lines.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
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)
update($user)
Update loan.
getSumPayment()
Return amount of payments already done.
create($user)
Create a loan into database.
set_started($user)
Tag loan as payment started.
getLibStatut($mode=0, $alreadypaid=-1)
Return label of loan status (unpaid, paid)
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
price2num($amount, $rounding='', $option=0)
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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.