dolibarr  18.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-2023 Frédéric France <frederic.france@netlogic.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 
24 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
25 
26 
30 class 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 
76  public $date_creation;
77 
81  public $date_modification;
82 
86  public $date_validation;
87 
88  public $insurance_amount;
89 
93  public $fk_bank;
94 
98  public $fk_user_creat;
99 
103  public $fk_user_modif;
104 
108  public $fk_project;
109 
113  public $totalpaid;
114 
115  const STATUS_UNPAID = 0;
116  const STATUS_PAID = 1;
117  const STATUS_STARTED = 2;
118 
119 
125  public function __construct($db)
126  {
127  $this->db = $db;
128  }
129 
136  public function fetch($id)
137  {
138  $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,";
139  $sql .= " l.paid, l.fk_bank, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest, l.fk_projet as fk_project";
140  $sql .= " FROM ".MAIN_DB_PREFIX."loan as l";
141  $sql .= " WHERE l.rowid = ".((int) $id);
142 
143  dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
144  $resql = $this->db->query($sql);
145  if ($resql) {
146  if ($this->db->num_rows($resql)) {
147  $obj = $this->db->fetch_object($resql);
148 
149  $this->id = $obj->rowid;
150  $this->ref = $obj->rowid;
151  $this->datestart = $this->db->jdate($obj->datestart);
152  $this->dateend = $this->db->jdate($obj->dateend);
153  $this->label = $obj->label;
154  $this->capital = $obj->capital;
155  $this->nbterm = $obj->nbterm;
156  $this->rate = $obj->rate;
157  $this->note_private = $obj->note_private;
158  $this->note_public = $obj->note_public;
159  $this->insurance_amount = $obj->insurance_amount;
160  $this->paid = $obj->paid;
161  $this->fk_bank = $obj->fk_bank;
162 
163  $this->account_capital = $obj->accountancy_account_capital;
164  $this->account_insurance = $obj->accountancy_account_insurance;
165  $this->account_interest = $obj->accountancy_account_interest;
166  $this->fk_project = $obj->fk_project;
167 
168  $this->db->free($resql);
169  return 1;
170  } else {
171  $this->db->free($resql);
172  return 0;
173  }
174  } else {
175  $this->error = $this->db->lasterror();
176  return -1;
177  }
178  }
179 
180 
187  public function create($user)
188  {
189  global $conf, $langs;
190 
191  $error = 0;
192 
193  $now = dol_now();
194 
195  // clean parameters
196  $newcapital = price2num($this->capital, 'MT');
197  if (empty($this->insurance_amount)) {
198  $this->insurance_amount = 0;
199  }
200  $newinsuranceamount = price2num($this->insurance_amount, 'MT');
201  if (isset($this->note_private)) {
202  $this->note_private = trim($this->note_private);
203  }
204  if (isset($this->note_public)) {
205  $this->note_public = trim($this->note_public);
206  }
207  if (isset($this->account_capital)) {
208  $this->account_capital = trim($this->account_capital);
209  }
210  if (isset($this->account_insurance)) {
211  $this->account_insurance = trim($this->account_insurance);
212  }
213  if (isset($this->account_interest)) {
214  $this->account_interest = trim($this->account_interest);
215  }
216  if (isset($this->fk_bank)) {
217  $this->fk_bank = (int) $this->fk_bank;
218  }
219  if (isset($this->fk_user_creat)) {
220  $this->fk_user_creat = (int) $this->fk_user_creat;
221  }
222  if (isset($this->fk_user_modif)) {
223  $this->fk_user_modif = (int) $this->fk_user_modif;
224  }
225  if (isset($this->fk_project)) {
226  $this->fk_project = (int) $this->fk_project;
227  }
228 
229  // Check parameters
230  if (!($newcapital > 0) || empty($this->datestart) || empty($this->dateend)) {
231  $this->error = "ErrorBadParameter";
232  return -2;
233  }
234  if (isModEnabled('accounting') && empty($this->account_capital)) {
235  $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyCapitalCode"));
236  return -2;
237  }
238  if (isModEnabled('accounting') && empty($this->account_insurance)) {
239  $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInsuranceCode"));
240  return -2;
241  }
242  if (isModEnabled('accounting') && empty($this->account_interest)) {
243  $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInterestCode"));
244  return -2;
245  }
246 
247  $this->db->begin();
248 
249  $sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note_private, note_public,";
250  $sql .= " accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity,";
251  $sql .= " datec, fk_projet, fk_user_author, insurance_amount)";
252  $sql .= " VALUES ('".$this->db->escape($this->label)."',";
253  $sql .= " '".$this->db->escape($this->fk_bank)."',";
254  $sql .= " '".price2num($newcapital)."',";
255  $sql .= " '".$this->db->idate($this->datestart)."',";
256  $sql .= " '".$this->db->idate($this->dateend)."',";
257  $sql .= " '".$this->db->escape($this->nbterm)."',";
258  $sql .= " '".$this->db->escape($this->rate)."',";
259  $sql .= " '".$this->db->escape($this->note_private)."',";
260  $sql .= " '".$this->db->escape($this->note_public)."',";
261  $sql .= " '".$this->db->escape($this->account_capital)."',";
262  $sql .= " '".$this->db->escape($this->account_insurance)."',";
263  $sql .= " '".$this->db->escape($this->account_interest)."',";
264  $sql .= " ".$conf->entity.",";
265  $sql .= " '".$this->db->idate($now)."',";
266  $sql .= " ".(empty($this->fk_project) ? 'NULL' : $this->fk_project).",";
267  $sql .= " ".$user->id.",";
268  $sql .= " '".price2num($newinsuranceamount)."'";
269  $sql .= ")";
270 
271  dol_syslog(get_class($this)."::create", LOG_DEBUG);
272  $resql = $this->db->query($sql);
273  if ($resql) {
274  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."loan");
275 
276  //dol_syslog("Loans::create this->id=".$this->id);
277  $this->db->commit();
278  return $this->id;
279  } else {
280  $this->error = $this->db->error();
281  $this->db->rollback();
282  return -1;
283  }
284  }
285 
286 
293  public function delete($user)
294  {
295  $error = 0;
296 
297  $this->db->begin();
298 
299  // Get bank transaction lines for this loan
300  include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
301  $account = new Account($this->db);
302  $lines_url = $account->get_url('', $this->id, 'loan');
303 
304  // Delete bank urls
305  foreach ($lines_url as $line_url) {
306  if (!$error) {
307  $accountline = new AccountLine($this->db);
308  $accountline->fetch($line_url['fk_bank']);
309  $result = $accountline->delete_urls($user);
310  if ($result < 0) {
311  $error++;
312  }
313  }
314  }
315 
316  // Delete payments
317  if (!$error) {
318  $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan where fk_loan=".((int) $this->id);
319  dol_syslog(get_class($this)."::delete", LOG_DEBUG);
320  $resql = $this->db->query($sql);
321  if (!$resql) {
322  $error++;
323  $this->error = $this->db->lasterror();
324  }
325  }
326 
327  if (!$error) {
328  $sql = "DELETE FROM ".MAIN_DB_PREFIX."loan where rowid=".((int) $this->id);
329  dol_syslog(get_class($this)."::delete", LOG_DEBUG);
330  $resql = $this->db->query($sql);
331  if (!$resql) {
332  $error++;
333  $this->error = $this->db->lasterror();
334  }
335  }
336 
337  if (!$error) {
338  $this->db->commit();
339  return 1;
340  } else {
341  $this->db->rollback();
342  return -1;
343  }
344  }
345 
346 
353  public function update($user)
354  {
355  $this->db->begin();
356 
357  if (!is_numeric($this->nbterm)) {
358  $this->error = 'BadValueForParameterForNbTerm';
359  return -1;
360  }
361 
362  $sql = "UPDATE ".MAIN_DB_PREFIX."loan";
363  $sql .= " SET label='".$this->db->escape($this->label)."',";
364  $sql .= " capital='".price2num($this->db->escape($this->capital))."',";
365  $sql .= " datestart='".$this->db->idate($this->datestart)."',";
366  $sql .= " dateend='".$this->db->idate($this->dateend)."',";
367  $sql .= " nbterm=".((float) $this->nbterm).",";
368  $sql .= " rate=".((float) $this->rate).",";
369  $sql .= " accountancy_account_capital = '".$this->db->escape($this->account_capital)."',";
370  $sql .= " accountancy_account_insurance = '".$this->db->escape($this->account_insurance)."',";
371  $sql .= " accountancy_account_interest = '".$this->db->escape($this->account_interest)."',";
372  $sql .= " fk_projet=".(empty($this->fk_project) ? 'NULL' : ((int) $this->fk_project)).",";
373  $sql .= " fk_user_modif = ".$user->id.",";
374  $sql .= " insurance_amount = '".price2num($this->db->escape($this->insurance_amount))."'";
375  $sql .= " WHERE rowid=".((int) $this->id);
376 
377  dol_syslog(get_class($this)."::update", LOG_DEBUG);
378  $resql = $this->db->query($sql);
379  if ($resql) {
380  $this->db->commit();
381  return 1;
382  } else {
383  $this->error = $this->db->error();
384  $this->db->rollback();
385  return -1;
386  }
387  }
388 
389  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
398  public function set_paid($user)
399  {
400  // phpcs:enable
401  dol_syslog(get_class($this)."::set_paid is deprecated, use setPaid instead", LOG_NOTICE);
402  return $this->setPaid($user);
403  }
404 
411  public function setPaid($user)
412  {
413  $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
414  $sql .= " paid = ".$this::STATUS_PAID;
415  $sql .= " WHERE rowid = ".((int) $this->id);
416  $return = $this->db->query($sql);
417  if ($return) {
418  return 1;
419  } else {
420  $this->error = $this->db->lasterror();
421  return -1;
422  }
423  }
424 
425  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
434  public function set_started($user)
435  {
436  // phpcs:enable
437  dol_syslog(get_class($this)."::set_started is deprecated, use setStarted instead", LOG_NOTICE);
438  return $this->setStarted($user);
439  }
440 
447  public function setStarted($user)
448  {
449  $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
450  $sql .= " paid = ".$this::STATUS_STARTED;
451  $sql .= " WHERE rowid = ".((int) $this->id);
452  $return = $this->db->query($sql);
453  if ($return) {
454  return 1;
455  } else {
456  $this->error = $this->db->lasterror();
457  return -1;
458  }
459  }
460 
461  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
469  public function set_unpaid($user)
470  {
471  // phpcs:enable
472  dol_syslog(get_class($this)."::set_unpaid is deprecated, use setUnpaid instead", LOG_NOTICE);
473  return $this->setUnpaid($user);
474  }
475 
482  public function setUnpaid($user)
483  {
484  $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
485  $sql .= " paid = ".$this::STATUS_UNPAID;
486  $sql .= " WHERE rowid = ".((int) $this->id);
487  $return = $this->db->query($sql);
488  if ($return) {
489  return 1;
490  } else {
491  $this->error = $this->db->lasterror();
492  return -1;
493  }
494  }
495 
503  public function getLibStatut($mode = 0, $alreadypaid = -1)
504  {
505  return $this->LibStatut($this->paid, $mode, $alreadypaid);
506  }
507 
508  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
517  public function LibStatut($status, $mode = 0, $alreadypaid = -1)
518  {
519  // phpcs:enable
520  global $langs;
521 
522  // Load translation files required by the page
523  $langs->loadLangs(array("customers", "bills"));
524 
525  unset($this->labelStatus); // Force to reset the array of status label, because label can change depending on parameters
526  if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
527  global $langs;
528  $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('Unpaid');
529  $this->labelStatus[self::STATUS_PAID] = $langs->transnoentitiesnoconv('Paid');
530  $this->labelStatus[self::STATUS_STARTED] = $langs->transnoentitiesnoconv("BillStatusStarted");
531  if ($status == 0 && $alreadypaid > 0) {
532  $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
533  }
534  $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('Unpaid');
535  $this->labelStatusShort[self::STATUS_PAID] = $langs->transnoentitiesnoconv('Enabled');
536  $this->labelStatusShort[self::STATUS_STARTED] = $langs->transnoentitiesnoconv("BillStatusStarted");
537  if ($status == 0 && $alreadypaid > 0) {
538  $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
539  }
540  }
541 
542  $statusType = 'status1';
543  if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) {
544  $statusType = 'status3';
545  }
546  if ($status == 1) {
547  $statusType = 'status6';
548  }
549 
550  return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
551  }
552 
553 
565  public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
566  {
567  global $conf, $langs, $hookmanager;
568 
569  $result = '';
570 
571  $label = '<u>'.$langs->trans("ShowLoan").'</u>';
572  if (!empty($this->ref)) {
573  $label .= '<br><strong>'.$langs->trans('Ref').':</strong> '.$this->ref;
574  }
575  if (!empty($this->label)) {
576  $label .= '<br><strong>'.$langs->trans('Label').':</strong> '.$this->label;
577  }
578 
579  $url = DOL_URL_ROOT.'/loan/card.php?id='.$this->id;
580 
581  if ($option != 'nolink') {
582  // Add param to save lastsearch_values or not
583  $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
584  if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
585  $add_save_lastsearch_values = 1;
586  }
587  if ($add_save_lastsearch_values) {
588  $url .= '&save_lastsearch_values=1';
589  }
590  }
591 
592  $linkclose = '';
593  if (empty($notooltip)) {
594  if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
595  $label = $langs->trans("ShowMyObject");
596  $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
597  }
598  $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
599  $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
600  } else {
601  $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
602  }
603 
604  $linkstart = '<a href="'.$url.'"';
605  $linkstart .= $linkclose.'>';
606  $linkend = '</a>';
607 
608  $result .= $linkstart;
609  if ($withpicto) {
610  $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);
611  }
612  if ($withpicto != 2) {
613  $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref);
614  }
615  $result .= $linkend;
616 
617  global $action;
618  $hookmanager->initHooks(array($this->element . 'dao'));
619  $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
620  $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
621  if ($reshook > 0) {
622  $result = $hookmanager->resPrint;
623  } else {
624  $result .= $hookmanager->resPrint;
625  }
626  return $result;
627  }
628 
636  public function initAsSpecimen()
637  {
638  global $user, $langs, $conf;
639 
640  $now = dol_now();
641 
642  // Initialise parameters
643  $this->id = 0;
644  $this->fk_bank = 1;
645  $this->label = 'SPECIMEN';
646  $this->specimen = 1;
647  $this->account_capital = 16;
648  $this->account_insurance = 616;
649  $this->account_interest = 518;
650  $this->datestart = $now;
651  $this->dateend = $now + (3600 * 24 * 365);
652  $this->note_public = 'SPECIMEN';
653  $this->capital = 20000;
654  $this->nbterm = 48;
655  $this->rate = 4.3;
656  }
657 
663  public function getSumPayment()
664  {
665  $table = 'payment_loan';
666  $field = 'fk_loan';
667 
668  $sql = 'SELECT sum(amount_capital) as amount';
669  $sql .= ' FROM '.MAIN_DB_PREFIX.$table;
670  $sql .= " WHERE ".$field." = ".((int) $this->id);
671 
672  dol_syslog(get_class($this)."::getSumPayment", LOG_DEBUG);
673  $resql = $this->db->query($sql);
674  if ($resql) {
675  $amount = 0;
676 
677  $obj = $this->db->fetch_object($resql);
678  if ($obj) {
679  $amount = $obj->amount ? $obj->amount : 0;
680  }
681 
682  $this->db->free($resql);
683  return $amount;
684  } else {
685  $this->error = $this->db->lasterror();
686  return -1;
687  }
688  }
689 
696  public function info($id)
697  {
698  $sql = 'SELECT l.rowid, l.datec, l.fk_user_author, l.fk_user_modif,';
699  $sql .= ' l.tms as datem';
700  $sql .= ' WHERE l.rowid = '.((int) $id);
701 
702  dol_syslog(get_class($this).'::info', LOG_DEBUG);
703  $result = $this->db->query($sql);
704 
705  if ($result) {
706  if ($this->db->num_rows($result)) {
707  $obj = $this->db->fetch_object($result);
708  $this->id = $obj->rowid;
709 
710  $this->user_creation_id = $obj->fk_user_author;
711  $this->user_modification_id = $obj->fk_user_modif;
712  $this->date_creation = $this->db->jdate($obj->datec);
713  $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
714 
715  $this->db->free($result);
716  return 1;
717  } else {
718  $this->db->free($result);
719  return 0;
720  }
721  } else {
722  $this->error = $this->db->lasterror();
723  return -1;
724  }
725  }
726 
734  public function getKanbanView($option = '', $arraydata = null)
735  {
736  global $langs;
737 
738  $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
739 
740  $return = '<div class="box-flex-item box-flex-grow-zero">';
741  $return .= '<div class="info-box info-box-sm">';
742  $return .= '<span class="info-box-icon bg-infobox-action">';
743  $return .= img_picto('', $this->picto);
744  $return .= '</span>';
745  $return .= '<div class="info-box-content">';
746  $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'</span>';
747  $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
748  if (property_exists($this, 'capital')) {
749  $return .= ' | <span class="opacitymedium">'.$langs->trans("Amount").'</span> : <span class="info-box-label amount">'.price($this->capital).'</span>';
750  }
751  if (property_exists($this, 'datestart')) {
752  $return .= '<br><span class="opacitymedium">'.$langs->trans("DateStart").'</span> : <span class="info-box-label">'.dol_print_date($this->db->jdate($this->datestart), 'day').'</span>';
753  }
754  if (property_exists($this, 'dateend')) {
755  $return .= '<br><span class="opacitymedium">'.$langs->trans("DateEnd").'</span> : <span class="info-box-label">'.dol_print_date($this->db->jdate($this->dateend), 'day').'</span>';
756  }
757 
758  if (method_exists($this, 'LibStatut')) {
759  $return .= '<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3, $this->alreadypaid).'</div>';
760  }
761  $return .= '</div>';
762  $return .= '</div>';
763  $return .= '</div>';
764  return $return;
765  }
766 }
Loan\setStarted
setStarted($user)
Tag loan as payment started.
Definition: loan.class.php:447
dol_trunc
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.
Definition: functions.lib.php:4049
Loan\getNomUrl
getNomUrl($withpicto=0, $maxlen=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return clicable name (with eventually the picto)
Definition: loan.class.php:565
Loan\__construct
__construct($db)
Constructor.
Definition: loan.class.php:125
CommonObject
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Definition: commonobject.class.php:45
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5943
Loan
Loan.
Definition: loan.class.php:30
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2665
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:4125
Loan\getKanbanView
getKanbanView($option='', $arraydata=null)
Return clicable link of object (with eventually picto)
Definition: loan.class.php:734
Loan\getLibStatut
getLibStatut($mode=0, $alreadypaid=-1)
Return label of loan status (unpaid, paid)
Definition: loan.class.php:503
Loan\initAsSpecimen
initAsSpecimen()
Initialise an instance with random values.
Definition: loan.class.php:636
Loan\set_started
set_started($user)
Tag loan as payment started.
Definition: loan.class.php:434
$sql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
Loan\getSumPayment
getSumPayment()
Return amount of payments already done.
Definition: loan.class.php:663
Loan\setUnpaid
setUnpaid($user)
Tag loan as payment as unpaid.
Definition: loan.class.php:482
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1732
Loan\info
info($id)
Information on record.
Definition: loan.class.php:696
Loan\create
create($user)
Create a loan into database.
Definition: loan.class.php:187
Loan\set_unpaid
set_unpaid($user)
Tag loan as payment as unpaid.
Definition: loan.class.php:469
Loan\setPaid
setPaid($user)
Tag loan as paid completely.
Definition: loan.class.php:411
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:207
ref
$object ref
Definition: info.php:78
dolGetStatus
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
Definition: functions.lib.php:10932
Loan\set_paid
set_paid($user)
Tag loan as paid completely.
Definition: loan.class.php:398
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4462
Loan\update
update($user)
Update loan.
Definition: loan.class.php:353
AccountLine
Class to manage bank transaction lines.
Definition: account.class.php:1881
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:3046
price
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.
Definition: functions.lib.php:5817
Account
Class to manage bank accounts.
Definition: account.class.php:40
Loan\fetch
fetch($id)
Load object in memory from database.
Definition: loan.class.php:136
Loan\LibStatut
LibStatut($status, $mode=0, $alreadypaid=-1)
Return label for given status.
Definition: loan.class.php:517