dolibarr  x.y.z
paymentsalary.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2011-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
3  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
4  * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
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 
26 // Put here all includes required by your class file
27 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
29 
30 
35 {
39  public $element = 'payment_salary';
40 
44  public $table_element = 'payment_salary';
45 
49  public $picto = 'payment';
50 
54  public $fk_salary;
55 
56  public $datec = '';
57  public $tms = '';
58  public $datep = '';
59 
64  public $total;
65 
66  public $amount; // Total amount of payment
67  public $amounts = array(); // Array of amounts
68 
72  public $fk_typepayment;
73 
78  public $num_paiement;
79 
83  public $num_payment;
84 
88  public $fk_bank;
89 
93  public $fk_user_author;
94 
98  public $fk_user_modif;
99 
103  public $fields = array(
104  'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
105  );
106 
112  public function __construct($db)
113  {
114  $this->db = $db;
115  }
116 
125  public function create($user, $closepaidcontrib = 0)
126  {
127  global $conf, $langs;
128 
129  $error = 0;
130 
131  $now = dol_now();
132 
133  dol_syslog(get_class($this)."::create", LOG_DEBUG);
134 
135  // Validate parametres
136  if (!$this->datepaye) {
137  $this->error = 'ErrorBadValueForParameterCreatePaymentSalary';
138  return -1;
139  }
140 
141  // Clean parameters
142  if (isset($this->fk_salary)) $this->fk_salary = (int) $this->fk_salary;
143  if (isset($this->amount)) $this->amount = trim($this->amount);
144  if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment;
145  if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated
146  if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
147  if (isset($this->note)) $this->note = trim($this->note);
148  if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
149  if (isset($this->fk_user_author)) $this->fk_user_author = (int) $this->fk_user_author;
150  if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
151 
152  $totalamount = 0;
153  foreach ($this->amounts as $key => $value) { // How payment is dispatch
154  $newvalue = price2num($value, 'MT');
155  $this->amounts[$key] = $newvalue;
156  $totalamount += $newvalue;
157  }
158  $totalamount = price2num($totalamount);
159 
160  // Check parameters
161  if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null
162 
163 
164  $this->db->begin();
165 
166  if ($totalamount != 0) {
167  $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (entity, fk_salary, datec, datep, amount,";
168  $sql .= " fk_typepayment, num_payment, note, fk_user_author, fk_bank)";
169  $sql .= " VALUES (".((int) $conf->entity).", ".((int) $this->chid).", '".$this->db->idate($now)."',";
170  $sql .= " '".$this->db->idate($this->datepaye)."',";
171  $sql .= " ".price2num($totalamount).",";
172  $sql .= " ".((int) $this->paiementtype).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".((int) $user->id).",";
173  $sql .= " 0)";
174 
175  $resql = $this->db->query($sql);
176  if ($resql) {
177  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary");
178 
179  // Insere tableau des montants / factures
180  foreach ($this->amounts as $key => $amount) {
181  $contribid = $key;
182  if (is_numeric($amount) && $amount <> 0) {
183  $amount = price2num($amount);
184 
185  // If we want to closed payed invoices
186  if ($closepaidcontrib) {
187  $contrib = new Salary($this->db);
188  $contrib->fetch($contribid);
189  $paiement = $contrib->getSommePaiement();
190  //$creditnotes=$contrib->getSumCreditNotesUsed();
191  $creditnotes = 0;
192  //$deposits=$contrib->getSumDepositsUsed();
193  $deposits = 0;
194  $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
195  $remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT');
196  if ($remaintopay == 0) {
197  $result = $contrib->set_paid($user);
198  } else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing.");
199  }
200  }
201  }
202  } else {
203  $error++;
204  }
205  }
206 
207  $result = $this->call_trigger('PAYMENTSALARY_CREATE', $user);
208  if ($result < 0) $error++;
209 
210  if ($totalamount != 0 && !$error) {
211  $this->amount = $totalamount;
212  $this->total = $totalamount; // deprecated
213  $this->db->commit();
214  return $this->id;
215  } else {
216  $this->error = $this->db->error();
217  $this->db->rollback();
218  return -1;
219  }
220  }
221 
228  public function fetch($id)
229  {
230  global $langs;
231  $sql = "SELECT";
232  $sql .= " t.rowid,";
233  $sql .= " t.fk_salary,";
234  $sql .= " t.datec,";
235  $sql .= " t.tms,";
236  $sql .= " t.datep,";
237  $sql .= " t.amount,";
238  $sql .= " t.fk_typepayment,";
239  $sql .= " t.num_payment as num_payment,";
240  $sql .= " t.note,";
241  $sql .= " t.fk_bank,";
242  $sql .= " t.fk_user_author,";
243  $sql .= " t.fk_user_modif,";
244  $sql .= " pt.code as type_code, pt.libelle as type_label,";
245  $sql .= ' b.fk_account';
246  $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id";
247  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
248  $sql .= " WHERE t.rowid = ".((int) $id);
249  // TODO link on entity of tax;
250 
251  dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
252  $resql = $this->db->query($sql);
253  if ($resql) {
254  if ($this->db->num_rows($resql)) {
255  $obj = $this->db->fetch_object($resql);
256 
257  $this->id = $obj->rowid;
258  $this->ref = $obj->rowid;
259 
260  $this->fk_salary = $obj->fk_salary;
261  $this->datec = $this->db->jdate($obj->datec);
262  $this->tms = $this->db->jdate($obj->tms);
263  $this->datep = $this->db->jdate($obj->datep);
264  $this->amount = $obj->amount;
265  $this->fk_typepayment = $obj->fk_typepayment;
266  $this->num_paiement = $obj->num_payment;
267  $this->num_payment = $obj->num_payment;
268  $this->note = $obj->note;
269  $this->note_private = $obj->note;
270  $this->fk_bank = $obj->fk_bank;
271  $this->fk_user_author = $obj->fk_user_author;
272  $this->fk_user_modif = $obj->fk_user_modif;
273 
274  $this->type_code = $obj->type_code;
275  $this->type_label = $obj->type_label;
276 
277  $this->bank_account = $obj->fk_account;
278  $this->bank_line = $obj->fk_bank;
279  }
280  $this->db->free($resql);
281 
282  return 1;
283  } else {
284  $this->error = "Error ".$this->db->lasterror();
285  return -1;
286  }
287  }
288 
289 
297  public function update($user = null, $notrigger = 0)
298  {
299  global $conf, $langs;
300  $error = 0;
301 
302  // Clean parameters
303 
304  if (isset($this->fk_salary)) $this->fk_salary = (int) $this->fk_salary;
305  if (isset($this->amount)) $this->amount = trim($this->amount);
306  if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment;
307  if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated
308  if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
309  if (isset($this->note)) $this->note = trim($this->note);
310  if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
311  if (isset($this->fk_user_author)) $this->fk_user_author = (int) $this->fk_user_author;
312  if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
313 
314  // Check parameters
315  // Put here code to add control on parameters values
316 
317  // Update request
318  $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET";
319  $sql .= " fk_salary=".(isset($this->fk_salary) ? $this->fk_salary : "null").",";
320  $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
321  $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
322  $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').",";
323  $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").",";
324  $sql .= " fk_typepayment=".(isset($this->fk_typepayment) ? $this->fk_typepayment : "null").",";
325  $sql .= " num_payment=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").",";
326  $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").",";
327  $sql .= " fk_bank=".(isset($this->fk_bank) ? ((int) $this->fk_bank) : "null").",";
328  $sql .= " fk_user_author=".(isset($this->fk_user_author) ? ((int) $this->fk_user_author) : "null").",";
329  $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? ((int) $this->fk_user_modif) : "null");
330  $sql .= " WHERE rowid=".((int) $this->id);
331 
332  $this->db->begin();
333 
334  dol_syslog(get_class($this)."::update", LOG_DEBUG);
335  $resql = $this->db->query($sql);
336  if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
337 
338  // Commit or rollback
339  if ($error) {
340  foreach ($this->errors as $errmsg) {
341  dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
342  $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
343  }
344  $this->db->rollback();
345  return -1 * $error;
346  } else {
347  $this->db->commit();
348  return 1;
349  }
350  }
351 
352 
360  public function delete($user, $notrigger = 0)
361  {
362  global $conf, $langs;
363  $error = 0;
364 
365  dol_syslog(get_class($this)."::delete");
366 
367  $this->db->begin();
368 
369  if ($this->bank_line > 0) {
370  $accline = new AccountLine($this->db);
371  $accline->fetch($this->bank_line);
372  $result = $accline->delete();
373  if ($result < 0) {
374  $this->errors[] = $accline->error;
375  $error++;
376  }
377  }
378 
379  if (!$error) {
380  $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary";
381  $sql .= " WHERE rowid=".((int) $this->id);
382 
383  dol_syslog(get_class($this)."::delete", LOG_DEBUG);
384  $resql = $this->db->query($sql);
385  if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
386  }
387 
388  // Commit or rollback
389  if ($error) {
390  foreach ($this->errors as $errmsg) {
391  dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
392  $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
393  }
394  $this->db->rollback();
395  return -1 * $error;
396  } else {
397  $this->db->commit();
398  return 1;
399  }
400  }
401 
402 
403 
411  public function createFromClone(User $user, $fromid)
412  {
413  $error = 0;
414 
415  $object = new PaymentSalary($this->db);
416 
417  $this->db->begin();
418 
419  // Load source object
420  $object->fetch($fromid);
421  $object->id = 0;
422  $object->statut = 0;
423 
424  // Clear fields
425  // ...
426 
427  // Create clone
428  $object->context['createfromclone'] = 'createfromclone';
429  $result = $object->create($user);
430 
431  // Other options
432  if ($result < 0) {
433  $this->error = $object->error;
434  $error++;
435  }
436 
437  unset($object->context['createfromclone']);
438 
439  // End
440  if (!$error) {
441  $this->db->commit();
442  return $object->id;
443  } else {
444  $this->db->rollback();
445  return -1;
446  }
447  }
448 
449 
457  public function initAsSpecimen()
458  {
459  $this->id = 0;
460 
461  $this->fk_salary = '';
462  $this->datec = '';
463  $this->tms = '';
464  $this->datep = '';
465  $this->amount = '';
466  $this->fk_typepayment = '';
467  $this->num_payment = '';
468  $this->note_private = '';
469  $this->note_public = '';
470  $this->fk_bank = '';
471  $this->fk_user_author = '';
472  $this->fk_user_modif = '';
473  }
474 
475 
488  public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
489  {
490  global $conf, $langs;
491 
492  // Clean data
493  $this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement);
494 
495  $error = 0;
496 
497  if (isModEnabled("banque")) {
498  include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
499 
500  $acc = new Account($this->db);
501  $acc->fetch($accountid);
502 
503  $total = $this->amount;
504 
505  // Insert payment into llx_bank
506  $bank_line_id = $acc->addline(
507  $this->datepaye,
508  $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example")
509  $label,
510  -$total,
511  $this->num_payment,
512  '',
513  $user,
514  $emetteur_nom,
515  $emetteur_banque,
516  '',
517  $this->datev
518  );
519 
520  // Update fk_bank into llx_paiement_salary.
521  // so we know the payment that was used to generated the bank entry.
522  if ($bank_line_id > 0) {
523  $result = $this->update_fk_bank($bank_line_id);
524  if ($result <= 0) {
525  $error++;
526  dol_print_error($this->db);
527  }
528 
529  // Add link 'payment_salary' in bank_url between payment and bank transaction
530  $url = '';
531  if ($mode == 'payment_salary') {
532  $url = DOL_URL_ROOT.'/salaries/payment_salary/card.php?id=';
533  }
534 
535  if ($url) {
536  $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
537  if ($result <= 0) {
538  $error++;
539  dol_print_error($this->db);
540  }
541  }
542 
543  // Add link 'user' in bank_url between user and bank transaction
544  foreach ($this->amounts as $key => $value) {
545  if (!$error) {
546  if ($mode == 'payment_salary') {
547  $salary = new Salary($this->db);
548  $salary->fetch($key);
549  $salary->fetch_user($salary->fk_user);
550 
551  $fuser = $salary->user;
552 
553  if ($fuser->id > 0) {
554  $result = $acc->add_url_line(
555  $bank_line_id,
556  $fuser->id,
557  DOL_URL_ROOT.'/user/card.php?id=',
558  $fuser->getFullName($langs),
559  'user'
560  );
561  }
562  if ($result <= 0) {
563  $this->error = $this->db->lasterror();
564  dol_syslog(get_class($this) . '::addPaymentToBank ' . $this->error);
565  $error++;
566  }
567  }
568  }
569  }
570  } else {
571  $this->error = $acc->error;
572  $error++;
573  }
574  }
575 
576  if (!$error) {
577  return 1;
578  } else {
579  return -1;
580  }
581  }
582 
583 
584  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
591  public function update_fk_bank($id_bank)
592  {
593  // phpcs:enable
594  $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".((int) $this->id);
595 
596  dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
597  $result = $this->db->query($sql);
598  if ($result) {
599  return 1;
600  } else {
601  $this->error = $this->db->error();
602  return 0;
603  }
604  }
605 
613  public function updatePaymentDate($date)
614  {
615  $error = 0;
616 
617  if (!empty($date)) {
618  $this->db->begin();
619 
620  dol_syslog(get_class($this)."::updatePaymentDate with date = ".$date, LOG_DEBUG);
621 
622  $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
623  $sql .= " SET datep = '".$this->db->idate($date)."'";
624  $sql .= " WHERE rowid = ".((int) $this->id);
625 
626  $result = $this->db->query($sql);
627  if (!$result) {
628  $error++;
629  $this->error = 'Error -1 '.$this->db->error();
630  }
631 
632  $type = $this->element;
633 
634  $sql = "UPDATE ".MAIN_DB_PREFIX.'bank';
635  $sql .= " SET dateo = '".$this->db->idate($date)."', datev = '".$this->db->idate($date)."'";
636  $sql .= " WHERE rowid IN (SELECT fk_bank FROM ".MAIN_DB_PREFIX."bank_url WHERE type = '".$this->db->escape($type)."' AND url_id = ".((int) $this->id).")";
637  $sql .= " AND rappro = 0";
638 
639  $result = $this->db->query($sql);
640  if (!$result) {
641  $error++;
642  $this->error = 'Error -1 '.$this->db->error();
643  }
644 
645  if (!$error) {
646  }
647 
648  if (!$error) {
649  $this->datep = $date;
650 
651  $this->db->commit();
652  return 0;
653  } else {
654  $this->db->rollback();
655  return -2;
656  }
657  }
658  return -1; //no date given or already validated
659  }
660 
667  public function getLibStatut($mode = 0)
668  {
669  return $this->LibStatut($this->statut, $mode);
670  }
671 
672  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
680  public function LibStatut($status, $mode = 0)
681  {
682  // phpcs:enable
683  global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
684 
685  $langs->load('compta');
686  /*if ($mode == 0)
687  {
688  if ($status == 0) return $langs->trans('ToValidate');
689  if ($status == 1) return $langs->trans('Validated');
690  }
691  if ($mode == 1)
692  {
693  if ($status == 0) return $langs->trans('ToValidate');
694  if ($status == 1) return $langs->trans('Validated');
695  }
696  if ($mode == 2)
697  {
698  if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
699  if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
700  }
701  if ($mode == 3)
702  {
703  if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
704  if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
705  }
706  if ($mode == 4)
707  {
708  if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
709  if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
710  }
711  if ($mode == 5)
712  {
713  if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
714  if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
715  }
716  if ($mode == 6)
717  {
718  if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
719  if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
720  }*/
721  return '';
722  }
723 
731  public function getNomUrl($withpicto = 0, $maxlen = 0)
732  {
733  global $langs;
734 
735  $result = '';
736 
737  if (empty($this->ref)) $this->ref = $this->lib;
738 
739  $label = img_picto('', $this->picto).' <u>'.$langs->trans("SalaryPayment").'</u>';
740  $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
741  if (!empty($this->label)) {
742  $labeltoshow = $this->label;
743  $reg = array();
744  if (preg_match('/^\‍((.*)\‍)$/i', $this->label, $reg)) {
745  // Label generique car entre parentheses. On l'affiche en le traduisant
746  if ($reg[1] == 'paiement') $reg[1] = 'Payment';
747  $labeltoshow = $langs->trans($reg[1]);
748  }
749  $label .= '<br><b>'.$langs->trans('Label').':</b> '.$labeltoshow;
750  }
751  if ($this->datep) {
752  $label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->datep, 'day');
753  }
754 
755  if (!empty($this->id)) {
756  $link = '<a href="'.DOL_URL_ROOT.'/salaries/payment_salary/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
757  $linkend = '</a>';
758 
759  if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip pictofixedwidth"').$linkend);
760  if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend;
761  }
762 
763  return $result;
764  }
765 }
$object ref
Definition: info.php:78
Class to manage bank accounts.
Class to manage bank transaction lines.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage payments of salaries.
LibStatut($status, $mode=0)
Return the status.
update_fk_bank($id_bank)
Mise a jour du lien entre le paiement de salaire et la ligne dans llx_bank generee.
getNomUrl($withpicto=0, $maxlen=0)
Return clicable name (with picto eventually)
updatePaymentDate($date)
Updates the payment date.
getLibStatut($mode=0)
Return the label of the status.
initAsSpecimen()
Initialise an instance with random values.
create($user, $closepaidcontrib=0)
Create payment of salary into database.
__construct($db)
Constructor.
update($user=null, $notrigger=0)
Update database.
addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
Add record into bank for payment with links between this bank record and invoices of payment.
fetch($id)
Load object in memory from database.
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
Class to manage salary payments.
Class to manage Dolibarr users.
Definition: user.class.php:45
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') &&!empty($user->rights->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)) $resql
Social contributions to pay.
Definition: index.php:745
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.
Definition: inc.php:41