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 * Copyright (C) 2024 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 $fk_project;
149
153 public $totalpaid;
154
158 const STATUS_UNPAID = 0;
159
163 const STATUS_PAID = 1;
164
168 const STATUS_STARTED = 2;
169
170
176 public function __construct($db)
177 {
178 $this->db = $db;
179 }
180
187 public function fetch($id)
188 {
189 $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,";
190 $sql .= " l.paid, l.fk_bank, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest, l.fk_projet as fk_project";
191 $sql .= " FROM ".MAIN_DB_PREFIX."loan as l";
192 $sql .= " WHERE l.rowid = ".((int) $id);
193
194 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
195 $resql = $this->db->query($sql);
196 if ($resql) {
197 if ($this->db->num_rows($resql)) {
198 $obj = $this->db->fetch_object($resql);
199
200 $this->id = $obj->rowid;
201 $this->ref = $obj->rowid;
202 $this->datestart = $this->db->jdate($obj->datestart);
203 $this->dateend = $this->db->jdate($obj->dateend);
204 $this->label = $obj->label;
205 $this->capital = $obj->capital;
206 $this->nbterm = $obj->nbterm;
207 $this->rate = $obj->rate;
208 $this->note_private = $obj->note_private;
209 $this->note_public = $obj->note_public;
210 $this->insurance_amount = $obj->insurance_amount;
211 $this->paid = $obj->paid;
212 $this->fk_bank = $obj->fk_bank;
213
214 $this->account_capital = $obj->accountancy_account_capital;
215 $this->account_insurance = $obj->accountancy_account_insurance;
216 $this->account_interest = $obj->accountancy_account_interest;
217 $this->fk_project = $obj->fk_project;
218
219 $this->db->free($resql);
220 return 1;
221 } else {
222 $this->db->free($resql);
223 return 0;
224 }
225 } else {
226 $this->error = $this->db->lasterror();
227 return -1;
228 }
229 }
230
231
238 public function create($user)
239 {
240 global $conf, $langs;
241
242 $error = 0;
243
244 $now = dol_now();
245
246 // clean parameters
247 $newcapital = price2num($this->capital, 'MT');
248 if (empty($this->insurance_amount)) {
249 $this->insurance_amount = 0;
250 }
251 $newinsuranceamount = price2num($this->insurance_amount, 'MT');
252 if (isset($this->note_private)) {
253 $this->note_private = trim($this->note_private);
254 }
255 if (isset($this->note_public)) {
256 $this->note_public = trim($this->note_public);
257 }
258 if (isset($this->account_capital)) {
259 $this->account_capital = trim($this->account_capital);
260 }
261 if (isset($this->account_insurance)) {
262 $this->account_insurance = trim($this->account_insurance);
263 }
264 if (isset($this->account_interest)) {
265 $this->account_interest = trim($this->account_interest);
266 }
267 if (isset($this->fk_bank)) {
268 $this->fk_bank = (int) $this->fk_bank;
269 }
270 if (isset($this->fk_user_creat)) {
271 $this->fk_user_creat = (int) $this->fk_user_creat;
272 }
273 if (isset($this->fk_user_modif)) {
274 $this->fk_user_modif = (int) $this->fk_user_modif;
275 }
276 if (isset($this->fk_project)) {
277 $this->fk_project = (int) $this->fk_project;
278 }
279
280 // Check parameters
281 if (!($newcapital > 0) || empty($this->datestart) || empty($this->dateend)) {
282 $this->error = "ErrorBadParameter";
283 return -2;
284 }
285 if (isModEnabled('accounting') && empty($this->account_capital)) {
286 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyCapitalCode"));
287 return -2;
288 }
289 if (isModEnabled('accounting') && empty($this->account_insurance)) {
290 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInsuranceCode"));
291 return -2;
292 }
293 if (isModEnabled('accounting') && empty($this->account_interest)) {
294 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInterestCode"));
295 return -2;
296 }
297
298 $this->db->begin();
299
300 $sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note_private, note_public,";
301 $sql .= " accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity,";
302 $sql .= " datec, fk_projet, fk_user_author, insurance_amount)";
303 $sql .= " VALUES ('".$this->db->escape($this->label)."',";
304 $sql .= " '".$this->db->escape($this->fk_bank)."',";
305 $sql .= " '".price2num($newcapital)."',";
306 $sql .= " '".$this->db->idate($this->datestart)."',";
307 $sql .= " '".$this->db->idate($this->dateend)."',";
308 $sql .= " '".$this->db->escape($this->nbterm)."',";
309 $sql .= " '".$this->db->escape($this->rate)."',";
310 $sql .= " '".$this->db->escape($this->note_private)."',";
311 $sql .= " '".$this->db->escape($this->note_public)."',";
312 $sql .= " '".$this->db->escape($this->account_capital)."',";
313 $sql .= " '".$this->db->escape($this->account_insurance)."',";
314 $sql .= " '".$this->db->escape($this->account_interest)."',";
315 $sql .= " ".((int) $conf->entity).",";
316 $sql .= " '".$this->db->idate($now)."',";
317 $sql .= " ".(empty($this->fk_project) ? 'NULL' : $this->fk_project).",";
318 $sql .= " ".((int) $user->id).",";
319 $sql .= " '".price2num($newinsuranceamount)."'";
320 $sql .= ")";
321
322 dol_syslog(get_class($this)."::create", LOG_DEBUG);
323 $resql = $this->db->query($sql);
324 if ($resql) {
325 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."loan");
326
327 //dol_syslog("Loans::create this->id=".$this->id);
328 $this->db->commit();
329 return $this->id;
330 } else {
331 $this->error = $this->db->error();
332 $this->db->rollback();
333 return -1;
334 }
335 }
336
337
344 public function delete($user)
345 {
346 $error = 0;
347
348 $this->db->begin();
349
350 // Get bank transaction lines for this loan
351 include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
352 $account = new Account($this->db);
353 $lines_url = $account->get_url('', $this->id, 'loan');
354
355 // Delete bank urls
356 foreach ($lines_url as $line_url) {
357 if (!$error) {
358 $accountline = new AccountLine($this->db);
359 $accountline->fetch($line_url['fk_bank']);
360 $result = $accountline->delete_urls($user);
361 if ($result < 0) {
362 $error++;
363 }
364 }
365 }
366
367 // Delete payments
368 if (!$error) {
369 $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan where fk_loan=".((int) $this->id);
370 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
371 $resql = $this->db->query($sql);
372 if (!$resql) {
373 $error++;
374 $this->error = $this->db->lasterror();
375 }
376 }
377
378 if (!$error) {
379 $sql = "DELETE FROM ".MAIN_DB_PREFIX."loan where rowid=".((int) $this->id);
380 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
381 $resql = $this->db->query($sql);
382 if (!$resql) {
383 $error++;
384 $this->error = $this->db->lasterror();
385 }
386 }
387
388 if (!$error) {
389 $this->db->commit();
390 return 1;
391 } else {
392 $this->db->rollback();
393 return -1;
394 }
395 }
396
397
404 public function update($user)
405 {
406 $this->db->begin();
407
408 if (!is_numeric($this->nbterm)) {
409 $this->error = 'BadValueForParameterForNbTerm';
410 return -1;
411 }
412
413 $sql = "UPDATE ".MAIN_DB_PREFIX."loan";
414 $sql .= " SET label='".$this->db->escape($this->label)."',";
415 $sql .= " capital='".price2num($this->db->escape($this->capital))."',";
416 $sql .= " datestart='".$this->db->idate($this->datestart)."',";
417 $sql .= " dateend='".$this->db->idate($this->dateend)."',";
418 $sql .= " nbterm=".((float) $this->nbterm).",";
419 $sql .= " rate=".((float) $this->rate).",";
420 $sql .= " accountancy_account_capital = '".$this->db->escape($this->account_capital)."',";
421 $sql .= " accountancy_account_insurance = '".$this->db->escape($this->account_insurance)."',";
422 $sql .= " accountancy_account_interest = '".$this->db->escape($this->account_interest)."',";
423 $sql .= " fk_projet=".(empty($this->fk_project) ? 'NULL' : ((int) $this->fk_project)).",";
424 $sql .= " fk_user_modif = ".((int) $user->id).",";
425 $sql .= " insurance_amount = '".price2num($this->db->escape($this->insurance_amount))."'";
426 $sql .= " WHERE rowid=".((int) $this->id);
427
428 dol_syslog(get_class($this)."::update", LOG_DEBUG);
429 $resql = $this->db->query($sql);
430 if ($resql) {
431 $this->db->commit();
432 return 1;
433 } else {
434 $this->error = $this->db->error();
435 $this->db->rollback();
436 return -1;
437 }
438 }
439
446 public function setPaid($user)
447 {
448 $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
449 $sql .= " paid = ".((int) $this::STATUS_PAID);
450 $sql .= " WHERE rowid = ".((int) $this->id);
451
452 $return = $this->db->query($sql);
453
454 if ($return) {
455 $this->paid = $this::STATUS_PAID;
456 return 1;
457 } else {
458 $this->error = $this->db->lasterror();
459 return -1;
460 }
461 }
462
463 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
472 public function set_started($user)
473 {
474 // phpcs:enable
475 dol_syslog(get_class($this)."::set_started is deprecated, use setStarted instead", LOG_NOTICE);
476 return $this->setStarted($user);
477 }
478
485 public function setStarted($user)
486 {
487 $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
488 $sql .= " paid = ".((int) $this::STATUS_STARTED);
489 $sql .= " WHERE rowid = ".((int) $this->id);
490
491 $return = $this->db->query($sql);
492
493 if ($return) {
494 $this->paid = $this::STATUS_STARTED;
495 return 1;
496 } else {
497 $this->error = $this->db->lasterror();
498 return -1;
499 }
500 }
501
508 public function setUnpaid($user)
509 {
510 $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
511 $sql .= " paid = ".((int) $this::STATUS_UNPAID);
512 $sql .= " WHERE rowid = ".((int) $this->id);
513
514 $return = $this->db->query($sql);
515
516 if ($return) {
517 $this->paid = $this::STATUS_UNPAID;
518 return 1;
519 } else {
520 $this->error = $this->db->lasterror();
521 return -1;
522 }
523 }
524
532 public function getLibStatut($mode = 0, $alreadypaid = -1)
533 {
534 return $this->LibStatut($this->paid, $mode, $alreadypaid);
535 }
536
537 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
546 public function LibStatut($status, $mode = 0, $alreadypaid = -1)
547 {
548 // phpcs:enable
549 global $langs;
550
551 // Load translation files required by the page
552 $langs->loadLangs(array("customers", "bills"));
553
554 unset($this->labelStatus); // Force to reset the array of status label, because label can change depending on parameters
555 // Always true because of 'unset':
556 // if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
557 global $langs;
558 $this->labelStatus = array();
559 $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('Unpaid');
560 $this->labelStatus[self::STATUS_PAID] = $langs->transnoentitiesnoconv('Paid');
561 $this->labelStatus[self::STATUS_STARTED] = $langs->transnoentitiesnoconv("BillStatusStarted");
562 if ($status == 0 && $alreadypaid > 0) {
563 $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
564 }
565 $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('Unpaid');
566 $this->labelStatusShort[self::STATUS_PAID] = $langs->transnoentitiesnoconv('Paid');
567 $this->labelStatusShort[self::STATUS_STARTED] = $langs->transnoentitiesnoconv("BillStatusStarted");
568 if ($status == 0 && $alreadypaid > 0) {
569 $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
570 }
571 // } // End of empty(labelStatus,labelStatusShort)
572
573 $statusType = 'status1';
574 if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) {
575 $statusType = 'status3';
576 }
577 if ($status == 1) {
578 $statusType = 'status6';
579 }
580
581 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
582 }
583
584
596 public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
597 {
598 global $conf, $langs, $hookmanager;
599
600 $result = '';
601
602 $label = '<u>'.$langs->trans("ShowLoan").'</u>';
603 if (!empty($this->ref)) {
604 $label .= '<br><strong>'.$langs->trans('Ref').':</strong> '.$this->ref;
605 }
606 if (!empty($this->label)) {
607 $label .= '<br><strong>'.$langs->trans('Label').':</strong> '.$this->label;
608 }
609
610 $url = DOL_URL_ROOT.'/loan/card.php?id='.$this->id;
611
612 if ($option != 'nolink') {
613 // Add param to save lastsearch_values or not
614 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
615 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
616 $add_save_lastsearch_values = 1;
617 }
618 if ($add_save_lastsearch_values) {
619 $url .= '&save_lastsearch_values=1';
620 }
621 }
622
623 $linkclose = '';
624 if (empty($notooltip)) {
625 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
626 $label = $langs->trans("ShowMyObject");
627 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
628 }
629 $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
630 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
631 } else {
632 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
633 }
634
635 $linkstart = '<a href="'.$url.'"';
636 $linkstart .= $linkclose.'>';
637 $linkend = '</a>';
638
639 $result .= $linkstart;
640 if ($withpicto) {
641 $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);
642 }
643 if ($withpicto != 2) {
644 $result .= ($maxlen ? dol_trunc($this->ref, $maxlen) : $this->ref);
645 }
646 $result .= $linkend;
647
648 global $action;
649 $hookmanager->initHooks(array($this->element . 'dao'));
650 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
651 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
652 if ($reshook > 0) {
653 $result = $hookmanager->resPrint;
654 } else {
655 $result .= $hookmanager->resPrint;
656 }
657 return $result;
658 }
659
667 public function initAsSpecimen()
668 {
669 $now = dol_now();
670
671 // Initialise parameters
672 $this->id = 0;
673 $this->fk_bank = 1;
674 $this->label = 'SPECIMEN';
675 $this->specimen = 1;
676 $this->account_capital = '16';
677 $this->account_insurance = '616';
678 $this->account_interest = '518';
679 $this->datestart = $now;
680 $this->dateend = $now + (3600 * 24 * 365);
681 $this->note_public = 'SPECIMEN';
682 $this->capital = 20000.80;
683 $this->nbterm = 48;
684 $this->rate = 4.3;
685
686 return 1;
687 }
688
694 public function getSumPayment()
695 {
696 $table = 'payment_loan';
697 $field = 'fk_loan';
698
699 $sql = 'SELECT sum(amount_capital) as amount';
700 $sql .= ' FROM '.MAIN_DB_PREFIX.$table;
701 $sql .= " WHERE ".$field." = ".((int) $this->id);
702
703 dol_syslog(get_class($this)."::getSumPayment", LOG_DEBUG);
704 $resql = $this->db->query($sql);
705 if ($resql) {
706 $amount = 0;
707
708 $obj = $this->db->fetch_object($resql);
709 if ($obj) {
710 $amount = $obj->amount ? $obj->amount : 0;
711 }
712
713 $this->db->free($resql);
714 return $amount;
715 } else {
716 $this->error = $this->db->lasterror();
717 return -1;
718 }
719 }
720
727 public function info($id)
728 {
729 $sql = 'SELECT l.rowid, l.datec, l.fk_user_author, l.fk_user_modif,';
730 $sql .= ' l.tms as datem';
731 $sql .= ' WHERE l.rowid = '.((int) $id);
732
733 dol_syslog(get_class($this).'::info', LOG_DEBUG);
734 $result = $this->db->query($sql);
735
736 if ($result) {
737 if ($this->db->num_rows($result)) {
738 $obj = $this->db->fetch_object($result);
739
740 $this->id = $obj->rowid;
741
742 $this->user_creation_id = $obj->fk_user_author;
743 $this->user_modification_id = $obj->fk_user_modif;
744 $this->date_creation = $this->db->jdate($obj->datec);
745 $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
746
747 $this->db->free($result);
748 return 1;
749 } else {
750 $this->db->free($result);
751 return 0;
752 }
753 } else {
754 $this->error = $this->db->lasterror();
755 return -1;
756 }
757 }
758
766 public function getKanbanView($option = '', $arraydata = null)
767 {
768 global $langs;
769
770 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
771
772 $return = '<div class="box-flex-item box-flex-grow-zero">';
773 $return .= '<div class="info-box info-box-sm">';
774 $return .= '<span class="info-box-icon bg-infobox-action">';
775 $return .= img_picto('', $this->picto);
776 $return .= '</span>';
777 $return .= '<div class="info-box-content">';
778 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'</span>';
779 if ($selected >= 0) {
780 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
781 }
782 if (property_exists($this, 'capital')) {
783 $return .= ' | <span class="opacitymedium">'.$langs->trans("Amount").'</span> : <span class="info-box-label amount">'.price($this->capital).'</span>';
784 }
785 if (property_exists($this, 'datestart')) {
786 $return .= '<br><span class="opacitymedium">'.$langs->trans("DateStart").'</span> : <span class="info-box-label">'.dol_print_date($this->db->jdate($this->datestart), 'day').'</span>';
787 }
788 if (property_exists($this, 'dateend')) {
789 $return .= '<br><span class="opacitymedium">'.$langs->trans("DateEnd").'</span> : <span class="info-box-label">'.dol_print_date($this->db->jdate($this->dateend), 'day').'</span>';
790 }
791
792 if (method_exists($this, 'LibStatut')) {
793 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3, $this->alreadypaid).'</div>';
794 }
795 $return .= '</div>';
796 $return .= '</div>';
797 $return .= '</div>';
798 return $return;
799 }
800}
$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 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)
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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.