dolibarr 21.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-2024 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
24require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
25
26
30class Loan extends CommonObject
31{
35 public $element = 'loan';
36
37 public $table = 'loan';
38
42 public $table_element = 'loan';
43
47 public $picto = 'money-bill-alt';
48
52 public $rowid;
53
54 public $datestart;
55 public $dateend;
56
60 public $label;
61
62 public $capital;
63 public $nbterm;
64 public $rate;
65 public $paid;
66 public $account_capital;
67 public $account_insurance;
68 public $account_interest;
69 public $accountancy_account_capital;
70 public $accountancy_account_insurance;
71 public $accountancy_account_interest;
72
73 public $insurance_amount;
74
78 public $fk_bank;
79
83 public $fk_user_creat;
84
88 public $fk_user_modif;
89
93 public $fk_project;
94
98 public $totalpaid;
99
100 const STATUS_UNPAID = 0;
101 const STATUS_PAID = 1;
102 const STATUS_STARTED = 2;
103
104
110 public function __construct($db)
111 {
112 $this->db = $db;
113 }
114
121 public function fetch($id)
122 {
123 $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note_private, l.note_public, l.insurance_amount,";
124 $sql .= " l.paid, l.fk_bank, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest, l.fk_projet as fk_project";
125 $sql .= " FROM ".MAIN_DB_PREFIX."loan as l";
126 $sql .= " WHERE l.rowid = ".((int) $id);
127
128 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
129 $resql = $this->db->query($sql);
130 if ($resql) {
131 if ($this->db->num_rows($resql)) {
132 $obj = $this->db->fetch_object($resql);
133
134 $this->id = $obj->rowid;
135 $this->ref = $obj->rowid;
136 $this->datestart = $this->db->jdate($obj->datestart);
137 $this->dateend = $this->db->jdate($obj->dateend);
138 $this->label = $obj->label;
139 $this->capital = $obj->capital;
140 $this->nbterm = $obj->nbterm;
141 $this->rate = $obj->rate;
142 $this->note_private = $obj->note_private;
143 $this->note_public = $obj->note_public;
144 $this->insurance_amount = $obj->insurance_amount;
145 $this->paid = $obj->paid;
146 $this->fk_bank = $obj->fk_bank;
147
148 $this->account_capital = $obj->accountancy_account_capital;
149 $this->account_insurance = $obj->accountancy_account_insurance;
150 $this->account_interest = $obj->accountancy_account_interest;
151 $this->fk_project = $obj->fk_project;
152
153 $this->db->free($resql);
154 return 1;
155 } else {
156 $this->db->free($resql);
157 return 0;
158 }
159 } else {
160 $this->error = $this->db->lasterror();
161 return -1;
162 }
163 }
164
165
172 public function create($user)
173 {
174 global $conf, $langs;
175
176 $error = 0;
177
178 $now = dol_now();
179
180 // clean parameters
181 $newcapital = price2num($this->capital, 'MT');
182 if (empty($this->insurance_amount)) {
183 $this->insurance_amount = 0;
184 }
185 $newinsuranceamount = price2num($this->insurance_amount, 'MT');
186 if (isset($this->note_private)) {
187 $this->note_private = trim($this->note_private);
188 }
189 if (isset($this->note_public)) {
190 $this->note_public = trim($this->note_public);
191 }
192 if (isset($this->account_capital)) {
193 $this->account_capital = trim($this->account_capital);
194 }
195 if (isset($this->account_insurance)) {
196 $this->account_insurance = trim($this->account_insurance);
197 }
198 if (isset($this->account_interest)) {
199 $this->account_interest = trim($this->account_interest);
200 }
201 if (isset($this->fk_bank)) {
202 $this->fk_bank = (int) $this->fk_bank;
203 }
204 if (isset($this->fk_user_creat)) {
205 $this->fk_user_creat = (int) $this->fk_user_creat;
206 }
207 if (isset($this->fk_user_modif)) {
208 $this->fk_user_modif = (int) $this->fk_user_modif;
209 }
210 if (isset($this->fk_project)) {
211 $this->fk_project = (int) $this->fk_project;
212 }
213
214 // Check parameters
215 if (!($newcapital > 0) || empty($this->datestart) || empty($this->dateend)) {
216 $this->error = "ErrorBadParameter";
217 return -2;
218 }
219 if (isModEnabled('accounting') && empty($this->account_capital)) {
220 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyCapitalCode"));
221 return -2;
222 }
223 if (isModEnabled('accounting') && empty($this->account_insurance)) {
224 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInsuranceCode"));
225 return -2;
226 }
227 if (isModEnabled('accounting') && empty($this->account_interest)) {
228 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInterestCode"));
229 return -2;
230 }
231
232 $this->db->begin();
233
234 $sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note_private, note_public,";
235 $sql .= " accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity,";
236 $sql .= " datec, fk_projet, fk_user_author, insurance_amount)";
237 $sql .= " VALUES ('".$this->db->escape($this->label)."',";
238 $sql .= " '".$this->db->escape($this->fk_bank)."',";
239 $sql .= " '".price2num($newcapital)."',";
240 $sql .= " '".$this->db->idate($this->datestart)."',";
241 $sql .= " '".$this->db->idate($this->dateend)."',";
242 $sql .= " '".$this->db->escape($this->nbterm)."',";
243 $sql .= " '".$this->db->escape($this->rate)."',";
244 $sql .= " '".$this->db->escape($this->note_private)."',";
245 $sql .= " '".$this->db->escape($this->note_public)."',";
246 $sql .= " '".$this->db->escape($this->account_capital)."',";
247 $sql .= " '".$this->db->escape($this->account_insurance)."',";
248 $sql .= " '".$this->db->escape($this->account_interest)."',";
249 $sql .= " ".$conf->entity.",";
250 $sql .= " '".$this->db->idate($now)."',";
251 $sql .= " ".(empty($this->fk_project) ? 'NULL' : $this->fk_project).",";
252 $sql .= " ".$user->id.",";
253 $sql .= " '".price2num($newinsuranceamount)."'";
254 $sql .= ")";
255
256 dol_syslog(get_class($this)."::create", LOG_DEBUG);
257 $resql = $this->db->query($sql);
258 if ($resql) {
259 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."loan");
260
261 //dol_syslog("Loans::create this->id=".$this->id);
262 $this->db->commit();
263 return $this->id;
264 } else {
265 $this->error = $this->db->error();
266 $this->db->rollback();
267 return -1;
268 }
269 }
270
271
278 public function delete($user)
279 {
280 $error = 0;
281
282 $this->db->begin();
283
284 // Get bank transaction lines for this loan
285 include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
286 $account = new Account($this->db);
287 $lines_url = $account->get_url('', $this->id, 'loan');
288
289 // Delete bank urls
290 foreach ($lines_url as $line_url) {
291 if (!$error) {
292 $accountline = new AccountLine($this->db);
293 $accountline->fetch($line_url['fk_bank']);
294 $result = $accountline->delete_urls($user);
295 if ($result < 0) {
296 $error++;
297 }
298 }
299 }
300
301 // Delete payments
302 if (!$error) {
303 $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan where fk_loan=".((int) $this->id);
304 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
305 $resql = $this->db->query($sql);
306 if (!$resql) {
307 $error++;
308 $this->error = $this->db->lasterror();
309 }
310 }
311
312 if (!$error) {
313 $sql = "DELETE FROM ".MAIN_DB_PREFIX."loan where rowid=".((int) $this->id);
314 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
315 $resql = $this->db->query($sql);
316 if (!$resql) {
317 $error++;
318 $this->error = $this->db->lasterror();
319 }
320 }
321
322 if (!$error) {
323 $this->db->commit();
324 return 1;
325 } else {
326 $this->db->rollback();
327 return -1;
328 }
329 }
330
331
338 public function update($user)
339 {
340 $this->db->begin();
341
342 if (!is_numeric($this->nbterm)) {
343 $this->error = 'BadValueForParameterForNbTerm';
344 return -1;
345 }
346
347 $sql = "UPDATE ".MAIN_DB_PREFIX."loan";
348 $sql .= " SET label='".$this->db->escape($this->label)."',";
349 $sql .= " capital='".price2num($this->db->escape($this->capital))."',";
350 $sql .= " datestart='".$this->db->idate($this->datestart)."',";
351 $sql .= " dateend='".$this->db->idate($this->dateend)."',";
352 $sql .= " nbterm=".((float) $this->nbterm).",";
353 $sql .= " rate=".((float) $this->rate).",";
354 $sql .= " accountancy_account_capital = '".$this->db->escape($this->account_capital)."',";
355 $sql .= " accountancy_account_insurance = '".$this->db->escape($this->account_insurance)."',";
356 $sql .= " accountancy_account_interest = '".$this->db->escape($this->account_interest)."',";
357 $sql .= " fk_projet=".(empty($this->fk_project) ? 'NULL' : ((int) $this->fk_project)).",";
358 $sql .= " fk_user_modif = ".$user->id.",";
359 $sql .= " insurance_amount = '".price2num($this->db->escape($this->insurance_amount))."'";
360 $sql .= " WHERE rowid=".((int) $this->id);
361
362 dol_syslog(get_class($this)."::update", LOG_DEBUG);
363 $resql = $this->db->query($sql);
364 if ($resql) {
365 $this->db->commit();
366 return 1;
367 } else {
368 $this->error = $this->db->error();
369 $this->db->rollback();
370 return -1;
371 }
372 }
373
380 public function setPaid($user)
381 {
382 $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
383 $sql .= " paid = ".$this::STATUS_PAID;
384 $sql .= " WHERE rowid = ".((int) $this->id);
385
386 $return = $this->db->query($sql);
387
388 if ($return) {
389 $this->paid = $this::STATUS_PAID;
390 return 1;
391 } else {
392 $this->error = $this->db->lasterror();
393 return -1;
394 }
395 }
396
397 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
406 public function set_started($user)
407 {
408 // phpcs:enable
409 dol_syslog(get_class($this)."::set_started is deprecated, use setStarted instead", LOG_NOTICE);
410 return $this->setStarted($user);
411 }
412
419 public function setStarted($user)
420 {
421 $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
422 $sql .= " paid = ".$this::STATUS_STARTED;
423 $sql .= " WHERE rowid = ".((int) $this->id);
424
425 $return = $this->db->query($sql);
426
427 if ($return) {
428 $this->paid = $this::STATUS_STARTED;
429 return 1;
430 } else {
431 $this->error = $this->db->lasterror();
432 return -1;
433 }
434 }
435
442 public function setUnpaid($user)
443 {
444 $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
445 $sql .= " paid = ".$this::STATUS_UNPAID;
446 $sql .= " WHERE rowid = ".((int) $this->id);
447
448 $return = $this->db->query($sql);
449
450 if ($return) {
451 $this->paid = $this::STATUS_UNPAID;
452 return 1;
453 } else {
454 $this->error = $this->db->lasterror();
455 return -1;
456 }
457 }
458
466 public function getLibStatut($mode = 0, $alreadypaid = -1)
467 {
468 return $this->LibStatut($this->paid, $mode, $alreadypaid);
469 }
470
471 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
480 public function LibStatut($status, $mode = 0, $alreadypaid = -1)
481 {
482 // phpcs:enable
483 global $langs;
484
485 // Load translation files required by the page
486 $langs->loadLangs(array("customers", "bills"));
487
488 unset($this->labelStatus); // Force to reset the array of status label, because label can change depending on parameters
489 // Always true because of 'unset':
490 // if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
491 global $langs;
492 $this->labelStatus = array();
493 $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('Unpaid');
494 $this->labelStatus[self::STATUS_PAID] = $langs->transnoentitiesnoconv('Paid');
495 $this->labelStatus[self::STATUS_STARTED] = $langs->transnoentitiesnoconv("BillStatusStarted");
496 if ($status == 0 && $alreadypaid > 0) {
497 $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
498 }
499 $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('Unpaid');
500 $this->labelStatusShort[self::STATUS_PAID] = $langs->transnoentitiesnoconv('Paid');
501 $this->labelStatusShort[self::STATUS_STARTED] = $langs->transnoentitiesnoconv("BillStatusStarted");
502 if ($status == 0 && $alreadypaid > 0) {
503 $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
504 }
505 // } // End of empty(labelStatus,labelStatusShort)
506
507 $statusType = 'status1';
508 if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) {
509 $statusType = 'status3';
510 }
511 if ($status == 1) {
512 $statusType = 'status6';
513 }
514
515 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
516 }
517
518
530 public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
531 {
532 global $conf, $langs, $hookmanager;
533
534 $result = '';
535
536 $label = '<u>'.$langs->trans("ShowLoan").'</u>';
537 if (!empty($this->ref)) {
538 $label .= '<br><strong>'.$langs->trans('Ref').':</strong> '.$this->ref;
539 }
540 if (!empty($this->label)) {
541 $label .= '<br><strong>'.$langs->trans('Label').':</strong> '.$this->label;
542 }
543
544 $url = DOL_URL_ROOT.'/loan/card.php?id='.$this->id;
545
546 if ($option != 'nolink') {
547 // Add param to save lastsearch_values or not
548 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
549 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
550 $add_save_lastsearch_values = 1;
551 }
552 if ($add_save_lastsearch_values) {
553 $url .= '&save_lastsearch_values=1';
554 }
555 }
556
557 $linkclose = '';
558 if (empty($notooltip)) {
559 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
560 $label = $langs->trans("ShowMyObject");
561 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
562 }
563 $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
564 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
565 } else {
566 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
567 }
568
569 $linkstart = '<a href="'.$url.'"';
570 $linkstart .= $linkclose.'>';
571 $linkend = '</a>';
572
573 $result .= $linkstart;
574 if ($withpicto) {
575 $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);
576 }
577 if ($withpicto != 2) {
578 $result .= ($maxlen ? dol_trunc($this->ref, $maxlen) : $this->ref);
579 }
580 $result .= $linkend;
581
582 global $action;
583 $hookmanager->initHooks(array($this->element . 'dao'));
584 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
585 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
586 if ($reshook > 0) {
587 $result = $hookmanager->resPrint;
588 } else {
589 $result .= $hookmanager->resPrint;
590 }
591 return $result;
592 }
593
601 public function initAsSpecimen()
602 {
603 global $user, $langs, $conf;
604
605 $now = dol_now();
606
607 // Initialise parameters
608 $this->id = 0;
609 $this->fk_bank = 1;
610 $this->label = 'SPECIMEN';
611 $this->specimen = 1;
612 $this->account_capital = 16;
613 $this->account_insurance = 616;
614 $this->account_interest = 518;
615 $this->datestart = $now;
616 $this->dateend = $now + (3600 * 24 * 365);
617 $this->note_public = 'SPECIMEN';
618 $this->capital = 20000;
619 $this->nbterm = 48;
620 $this->rate = 4.3;
621
622 return 1;
623 }
624
630 public function getSumPayment()
631 {
632 $table = 'payment_loan';
633 $field = 'fk_loan';
634
635 $sql = 'SELECT sum(amount_capital) as amount';
636 $sql .= ' FROM '.MAIN_DB_PREFIX.$table;
637 $sql .= " WHERE ".$field." = ".((int) $this->id);
638
639 dol_syslog(get_class($this)."::getSumPayment", LOG_DEBUG);
640 $resql = $this->db->query($sql);
641 if ($resql) {
642 $amount = 0;
643
644 $obj = $this->db->fetch_object($resql);
645 if ($obj) {
646 $amount = $obj->amount ? $obj->amount : 0;
647 }
648
649 $this->db->free($resql);
650 return $amount;
651 } else {
652 $this->error = $this->db->lasterror();
653 return -1;
654 }
655 }
656
663 public function info($id)
664 {
665 $sql = 'SELECT l.rowid, l.datec, l.fk_user_author, l.fk_user_modif,';
666 $sql .= ' l.tms as datem';
667 $sql .= ' WHERE l.rowid = '.((int) $id);
668
669 dol_syslog(get_class($this).'::info', LOG_DEBUG);
670 $result = $this->db->query($sql);
671
672 if ($result) {
673 if ($this->db->num_rows($result)) {
674 $obj = $this->db->fetch_object($result);
675
676 $this->id = $obj->rowid;
677
678 $this->user_creation_id = $obj->fk_user_author;
679 $this->user_modification_id = $obj->fk_user_modif;
680 $this->date_creation = $this->db->jdate($obj->datec);
681 $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
682
683 $this->db->free($result);
684 return 1;
685 } else {
686 $this->db->free($result);
687 return 0;
688 }
689 } else {
690 $this->error = $this->db->lasterror();
691 return -1;
692 }
693 }
694
702 public function getKanbanView($option = '', $arraydata = null)
703 {
704 global $langs;
705
706 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
707
708 $return = '<div class="box-flex-item box-flex-grow-zero">';
709 $return .= '<div class="info-box info-box-sm">';
710 $return .= '<span class="info-box-icon bg-infobox-action">';
711 $return .= img_picto('', $this->picto);
712 $return .= '</span>';
713 $return .= '<div class="info-box-content">';
714 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'</span>';
715 if ($selected >= 0) {
716 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
717 }
718 if (property_exists($this, 'capital')) {
719 $return .= ' | <span class="opacitymedium">'.$langs->trans("Amount").'</span> : <span class="info-box-label amount">'.price($this->capital).'</span>';
720 }
721 if (property_exists($this, 'datestart')) {
722 $return .= '<br><span class="opacitymedium">'.$langs->trans("DateStart").'</span> : <span class="info-box-label">'.dol_print_date($this->db->jdate($this->datestart), 'day').'</span>';
723 }
724 if (property_exists($this, 'dateend')) {
725 $return .= '<br><span class="opacitymedium">'.$langs->trans("DateEnd").'</span> : <span class="info-box-label">'.dol_print_date($this->db->jdate($this->dateend), 'day').'</span>';
726 }
727
728 if (method_exists($this, 'LibStatut')) {
729 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3, $this->alreadypaid).'</div>';
730 }
731 $return .= '</div>';
732 $return .= '</div>';
733 $return .= '</div>';
734 return $return;
735 }
736}
$object ref
Definition info.php:79
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 clicable 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 clicable 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)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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 '.
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_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
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 dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.