dolibarr  19.0.0-dev
paymentsocialcontribution.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.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 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
27 require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
28 
29 
34 {
38  public $element = 'paiementcharge';
39 
43  public $table_element = 'paiementcharge';
44 
48  public $picto = 'payment';
49 
53  public $label;
54 
58  public $fk_charge;
59 
60  public $datec = '';
61  public $tms = '';
62  public $datep = '';
63 
68  public $total;
69 
70  public $amount; // Total amount of payment
71  public $amounts = array(); // Array of amounts
72 
76  public $fk_typepaiement;
77 
82  public $num_paiement;
83 
87  public $num_payment;
88 
92  public $fk_bank;
93 
97  public $fk_user_creat;
98 
102  public $fk_user_modif;
103 
107  public $chid;
108 
112  public $datepaye;
113 
117  public $paiementtype;
118 
119 
125  public function __construct(DoliDB $db)
126  {
127  $this->db = $db;
128  }
129 
138  public function create($user, $closepaidcontrib = 0)
139  {
140  global $conf, $langs;
141 
142  $error = 0;
143 
144  $now = dol_now();
145 
146  dol_syslog(get_class($this)."::create", LOG_DEBUG);
147 
148  // Validate parametres
149  if (!$this->datepaye) {
150  $this->error = 'ErrorBadValueForParameterCreatePaymentSocialContrib';
151  return -1;
152  }
153 
154  // Clean parameters
155  if (isset($this->fk_charge)) {
156  $this->fk_charge = (int) $this->fk_charge;
157  }
158  if (isset($this->amount)) {
159  $this->amount = trim($this->amount);
160  }
161  if (isset($this->fk_typepaiement)) {
162  $this->fk_typepaiement = (int) $this->fk_typepaiement;
163  }
164  if (isset($this->num_payment)) {
165  $this->num_payment = trim($this->num_payment);
166  }
167  if (isset($this->note_private)) {
168  $this->note_private = trim($this->note_private);
169  }
170  if (isset($this->fk_bank)) {
171  $this->fk_bank = (int) $this->fk_bank;
172  }
173  if (isset($this->fk_user_creat)) {
174  $this->fk_user_creat = (int) $this->fk_user_creat;
175  }
176  if (isset($this->fk_user_modif)) {
177  $this->fk_user_modif = (int) $this->fk_user_modif;
178  }
179 
180  $totalamount = 0;
181  foreach ($this->amounts as $key => $value) { // How payment is dispatch
182  $newvalue = price2num($value, 'MT');
183  $this->amounts[$key] = $newvalue;
184  $totalamount += $newvalue;
185  }
186  $totalamount = price2num($totalamount);
187 
188  // Check parameters
189  if ($totalamount == 0) {
190  return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null
191  }
192 
193 
194  $this->db->begin();
195 
196  if ($totalamount != 0) {
197  $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementcharge (fk_charge, datec, datep, amount,";
198  $sql .= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)";
199  $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',";
200  $sql .= " '".$this->db->idate($this->datepaye)."',";
201  $sql .= " ".((float) $totalamount).",";
202  $sql .= " ".((int) $this->paiementtype).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.",";
203  $sql .= " 0)";
204 
205  $resql = $this->db->query($sql);
206  if ($resql) {
207  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementcharge");
208 
209  // Insere tableau des montants / factures
210  foreach ($this->amounts as $key => $amount) {
211  $contribid = $key;
212  if (is_numeric($amount) && $amount <> 0) {
213  $amount = price2num($amount);
214 
215  // If we want to closed paid invoices
216  if ($closepaidcontrib) {
217  $contrib = new ChargeSociales($this->db);
218  $contrib->fetch($contribid);
219  $paiement = $contrib->getSommePaiement();
220  //$creditnotes=$contrib->getSumCreditNotesUsed();
221  $creditnotes = 0;
222  //$deposits=$contrib->getSumDepositsUsed();
223  $deposits = 0;
224  $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
225  $remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT');
226  if ($remaintopay == 0) {
227  $result = $contrib->setPaid($user);
228  } else {
229  dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing.");
230  }
231  }
232  }
233  }
234  } else {
235  $error++;
236  }
237  }
238 
239  $result = $this->call_trigger('PAYMENTSOCIALCONTRIBUTION_CREATE', $user);
240  if ($result < 0) {
241  $error++;
242  }
243 
244  if ($totalamount != 0 && !$error) {
245  $this->amount = $totalamount;
246  $this->total = $totalamount; // deprecated
247  $this->db->commit();
248  return $this->id;
249  } else {
250  $this->error = $this->db->error();
251  $this->db->rollback();
252  return -1;
253  }
254  }
255 
262  public function fetch($id)
263  {
264  global $langs;
265  $sql = "SELECT";
266  $sql .= " t.rowid,";
267  $sql .= " t.fk_charge,";
268  $sql .= " t.datec,";
269  $sql .= " t.tms,";
270  $sql .= " t.datep,";
271  $sql .= " t.amount,";
272  $sql .= " t.fk_typepaiement,";
273  $sql .= " t.num_paiement as num_payment,";
274  $sql .= " t.note,";
275  $sql .= " t.fk_bank,";
276  $sql .= " t.fk_user_creat,";
277  $sql .= " t.fk_user_modif,";
278  $sql .= " pt.code as type_code, pt.libelle as type_label,";
279  $sql .= ' b.fk_account';
280  $sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as t LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepaiement = pt.id";
281  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
282  $sql .= " WHERE t.rowid = ".((int) $id);
283  // TODO link on entity of tax;
284 
285  dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
286  $resql = $this->db->query($sql);
287  if ($resql) {
288  if ($this->db->num_rows($resql)) {
289  $obj = $this->db->fetch_object($resql);
290 
291  $this->id = $obj->rowid;
292  $this->ref = $obj->rowid;
293 
294  $this->fk_charge = $obj->fk_charge;
295  $this->datec = $this->db->jdate($obj->datec);
296  $this->tms = $this->db->jdate($obj->tms);
297  $this->datep = $this->db->jdate($obj->datep);
298  $this->amount = $obj->amount;
299  $this->fk_typepaiement = $obj->fk_typepaiement;
300  $this->num_payment = $obj->num_payment;
301  $this->note_private = $obj->note;
302  $this->fk_bank = $obj->fk_bank;
303  $this->fk_user_creat = $obj->fk_user_creat;
304  $this->fk_user_modif = $obj->fk_user_modif;
305 
306  $this->type_code = $obj->type_code;
307  $this->type_label = $obj->type_label;
308 
309  $this->bank_account = $obj->fk_account;
310  $this->bank_line = $obj->fk_bank;
311  }
312  $this->db->free($resql);
313 
314  return 1;
315  } else {
316  $this->error = "Error ".$this->db->lasterror();
317  return -1;
318  }
319  }
320 
321 
329  public function update($user = null, $notrigger = 0)
330  {
331  global $conf, $langs;
332  $error = 0;
333 
334  // Clean parameters
335 
336  if (isset($this->fk_charge)) {
337  $this->fk_charge = (int) $this->fk_charge;
338  }
339  if (isset($this->amount)) {
340  $this->amount = trim($this->amount);
341  }
342  if (isset($this->fk_typepaiement)) {
343  $this->fk_typepaiement = (int) $this->fk_typepaiement;
344  }
345  if (isset($this->num_payment)) {
346  $this->num_payment = trim($this->num_payment);
347  }
348  if (isset($this->note_private)) {
349  $this->note_private = trim($this->note_private);
350  }
351  if (isset($this->fk_bank)) {
352  $this->fk_bank = (int) $this->fk_bank;
353  }
354  if (isset($this->fk_user_creat)) {
355  $this->fk_user_creat = (int) $this->fk_user_creat;
356  }
357  if (isset($this->fk_user_modif)) {
358  $this->fk_user_modif = (int) $this->fk_user_modif;
359  }
360 
361 
362 
363  // Check parameters
364  // Put here code to add control on parameters values
365 
366  // Update request
367  $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET";
368  $sql .= " fk_charge=".(isset($this->fk_charge) ? ((int) $this->fk_charge) : "null").",";
369  $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
370  $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
371  $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').",";
372  $sql .= " amount=".(isset($this->amount) ? price2num($this->amount) : "null").",";
373  $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? ((int) $this->fk_typepaiement) : "null").",";
374  $sql .= " num_paiement=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").",";
375  $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").",";
376  $sql .= " fk_bank=".(isset($this->fk_bank) ? ((int) $this->fk_bank) : "null").",";
377  $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? ((int) $this->fk_user_creat) : "null").",";
378  $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? ((int) $this->fk_user_modif) : "null");
379  $sql .= " WHERE rowid=".((int) $this->id);
380 
381  $this->db->begin();
382 
383  dol_syslog(get_class($this)."::update", LOG_DEBUG);
384  $resql = $this->db->query($sql);
385  if (!$resql) {
386  $error++;
387  $this->errors[] = "Error ".$this->db->lasterror();
388  }
389 
390  // Commit or rollback
391  if ($error) {
392  foreach ($this->errors as $errmsg) {
393  dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
394  $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
395  }
396  $this->db->rollback();
397  return -1 * $error;
398  } else {
399  $this->db->commit();
400  return 1;
401  }
402  }
403 
404 
412  public function delete($user, $notrigger = 0)
413  {
414  global $conf, $langs;
415  $error = 0;
416 
417  dol_syslog(get_class($this)."::delete");
418 
419  $this->db->begin();
420 
421  if ($this->bank_line > 0) {
422  $accline = new AccountLine($this->db);
423  $accline->fetch($this->bank_line);
424  $result = $accline->delete();
425  if ($result < 0) {
426  $this->errors[] = $accline->error;
427  $error++;
428  }
429  }
430 
431  if (!$error) {
432  $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge";
433  $sql .= " WHERE rowid=".((int) $this->id);
434 
435  dol_syslog(get_class($this)."::delete", LOG_DEBUG);
436  $resql = $this->db->query($sql);
437  if (!$resql) {
438  $error++;
439  $this->errors[] = "Error ".$this->db->lasterror();
440  }
441  }
442 
443  // Commit or rollback
444  if ($error) {
445  foreach ($this->errors as $errmsg) {
446  dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
447  $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
448  }
449  $this->db->rollback();
450  return -1 * $error;
451  } else {
452  $this->db->commit();
453  return 1;
454  }
455  }
456 
457 
458 
466  public function createFromClone(User $user, $fromid)
467  {
468  $error = 0;
469 
470  $object = new PaymentSocialContribution($this->db);
471 
472  $this->db->begin();
473 
474  // Load source object
475  $object->fetch($fromid);
476  $object->id = 0;
477  $object->statut = 0;
478 
479  // Clear fields
480  // ...
481 
482  // Create clone
483  $object->context['createfromclone'] = 'createfromclone';
484  $result = $object->create($user);
485 
486  // Other options
487  if ($result < 0) {
488  $this->error = $object->error;
489  $error++;
490  }
491 
492  unset($object->context['createfromclone']);
493 
494  // End
495  if (!$error) {
496  $this->db->commit();
497  return $object->id;
498  } else {
499  $this->db->rollback();
500  return -1;
501  }
502  }
503 
504 
512  public function initAsSpecimen()
513  {
514  $this->id = 0;
515 
516  $this->fk_charge = '';
517  $this->datec = '';
518  $this->tms = '';
519  $this->datep = '';
520  $this->amount = '';
521  $this->fk_typepaiement = '';
522  $this->num_payment = '';
523  $this->note_private = '';
524  $this->note_public = '';
525  $this->fk_bank = '';
526  $this->fk_user_creat = '';
527  $this->fk_user_modif = '';
528  }
529 
530 
543  public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
544  {
545  global $conf, $langs;
546 
547  // Clean data
548  $this->num_payment = trim($this->num_payment);
549 
550  $error = 0;
551 
552  if (isModEnabled("banque")) {
553  include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
554 
555  $acc = new Account($this->db);
556  $acc->fetch($accountid);
557 
559  if ($mode == 'payment_sc') {
560  $total = -$total;
561  }
562 
563  // Insert payment into llx_bank
564  $bank_line_id = $acc->addline(
565  $this->datepaye,
566  $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example")
567  $label,
568  $total,
569  $this->num_payment,
570  '',
571  $user,
572  $emetteur_nom,
573  $emetteur_banque
574  );
575 
576  // Mise a jour fk_bank dans llx_paiement.
577  // On connait ainsi le paiement qui a genere l'ecriture bancaire
578  if ($bank_line_id > 0) {
579  $result = $this->update_fk_bank($bank_line_id);
580  if ($result <= 0) {
581  $error++;
582  dol_print_error($this->db);
583  }
584 
585  // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction
586  $url = '';
587  if ($mode == 'payment_sc') {
588  $url = DOL_URL_ROOT.'/compta/payment_sc/card.php?id=';
589  }
590  if ($url) {
591  $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
592  if ($result <= 0) {
593  $error++;
594  dol_print_error($this->db);
595  }
596  }
597 
598  // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
599  $linkaddedforthirdparty = array();
600  foreach ($this->amounts as $key => $value) {
601  if ($mode == 'payment_sc') {
602  $socialcontrib = new ChargeSociales($this->db);
603  $socialcontrib->fetch($key);
604  $result = $acc->add_url_line($bank_line_id, $socialcontrib->id, DOL_URL_ROOT.'/compta/charges.php?id=', $socialcontrib->type_label.(($socialcontrib->lib && $socialcontrib->lib != $socialcontrib->type_label) ? ' ('.$socialcontrib->lib.')' : ''), 'sc');
605  if ($result <= 0) {
606  dol_print_error($this->db);
607  }
608 
609  if ($socialcontrib->fk_user) {
610  $fuser = new User($this->db);
611  $fuser->fetch($socialcontrib->fk_user);
612 
613  // Add link 'user' in bank_url between operation and bank transaction
614  $result = $acc->add_url_line(
615  $bank_line_id,
616  $socialcontrib->fk_user,
617  DOL_URL_ROOT.'/user/card.php?id=',
618  $fuser->getFullName($langs),
619  'user'
620  );
621 
622  if ($result <= 0) {
623  $this->error = $acc->error;
624  $error++;
625  }
626  }
627  }
628  }
629  } else {
630  $this->error = $acc->error;
631  $error++;
632  }
633  }
634 
635  if (!$error) {
636  return 1;
637  } else {
638  return -1;
639  }
640  }
641 
642 
643  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
650  public function update_fk_bank($id_bank)
651  {
652  // phpcs:enable
653  $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".((int) $this->id);
654 
655  dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
656  $result = $this->db->query($sql);
657  if ($result) {
658  return 1;
659  } else {
660  $this->error = $this->db->error();
661  return 0;
662  }
663  }
664 
665 
672  public function getLibStatut($mode = 0)
673  {
674  return $this->LibStatut($this->statut, $mode);
675  }
676 
677  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
685  public function LibStatut($status, $mode = 0)
686  {
687  // phpcs:enable
688  global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
689 
690  $langs->load('compta');
691  /*if ($mode == 0)
692  {
693  if ($status == 0) return $langs->trans('ToValidate');
694  if ($status == 1) return $langs->trans('Validated');
695  }
696  if ($mode == 1)
697  {
698  if ($status == 0) return $langs->trans('ToValidate');
699  if ($status == 1) return $langs->trans('Validated');
700  }
701  if ($mode == 2)
702  {
703  if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
704  if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
705  }
706  if ($mode == 3)
707  {
708  if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
709  if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
710  }
711  if ($mode == 4)
712  {
713  if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
714  if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
715  }
716  if ($mode == 5)
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  if ($mode == 6)
722  {
723  if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
724  if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
725  }*/
726  return '';
727  }
728 
736  public function getNomUrl($withpicto = 0, $maxlen = 0)
737  {
738  global $langs;
739 
740  $result = '';
741 
742  if (empty($this->ref)) {
743  $this->ref = $this->label;
744  }
745 
746  $label = img_picto('', $this->picto).' <u>'.$langs->trans("SocialContributionPayment").'</u>';
747  $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
748  if (!empty($this->label)) {
749  $labeltoshow = $this->label;
750  $reg = array();
751  if (preg_match('/^\‍((.*)\‍)$/i', $this->label, $reg)) {
752  // Label generique car entre parentheses. On l'affiche en le traduisant
753  if ($reg[1] == 'paiement') {
754  $reg[1] = 'Payment';
755  }
756  $labeltoshow = $langs->trans($reg[1]);
757  }
758  $label .= '<br><b>'.$langs->trans('Label').':</b> '.$labeltoshow;
759  }
760  if ($this->datep) {
761  $label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->datep, 'day');
762  }
763 
764  if (!empty($this->id)) {
765  $link = '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
766  $linkend = '</a>';
767 
768  if ($withpicto) {
769  $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' ');
770  }
771  if ($withpicto && $withpicto != 2) {
772  $result .= ' ';
773  }
774  if ($withpicto != 2) {
775  $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend;
776  }
777  }
778 
779  return $result;
780  }
781 
782 
788  public function getVentilExportCompta()
789  {
790  $alreadydispatched = 0;
791 
792  $type = 'bank';
793 
794  $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->bank_line);
795  $resql = $this->db->query($sql);
796  if ($resql) {
797  $obj = $this->db->fetch_object($resql);
798  if ($obj) {
799  $alreadydispatched = $obj->nb;
800  }
801  } else {
802  $this->error = $this->db->lasterror();
803  return -1;
804  }
805 
806  if ($alreadydispatched) {
807  return 1;
808  }
809  return 0;
810  }
811 }
$object ref
Definition: info.php:78
Class to manage bank accounts.
Class to manage bank transaction lines.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
Parent class of all other business classes (invoices, contracts, proposals, orders,...
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage Dolibarr database access.
Class to manage payments of social contributions.
getLibStatut($mode=0)
Return the label of the status.
fetch($id)
Load object in memory from database.
getNomUrl($withpicto=0, $maxlen=0)
Return clicable name (with picto eventually)
getVentilExportCompta()
Return if object was dispatched into bookkeeping.
create($user, $closepaidcontrib=0)
Create payment of social contribution into 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.
LibStatut($status, $mode=0)
Return the label of a given status.
update($user=null, $notrigger=0)
Update database.
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
update_fk_bank($id_bank)
Mise a jour du lien entre le paiement de charge et la ligne dans llx_bank generee.
initAsSpecimen()
Initialise an instance with random values.
Class to manage Dolibarr users.
Definition: user.class.php:48
if(isModEnabled('facture') && $user->hasRight('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
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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...