dolibarr  13.0.2
paiementfourn.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
5  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
7  * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
8  * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
9  * Copyright (C) 2018 Frédéric France <frederic.francenetlogic.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <https://www.gnu.org/licenses/>.
23  */
24 
30 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
33 
37 class PaiementFourn extends Paiement
38 {
42  public $element = 'payment_supplier';
43 
47  public $table_element = 'paiementfourn';
48 
52  public $picto = 'payment';
53 
54  public $statut; //Status of payment. 0 = unvalidated; 1 = validated
55  // fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...)
56  // fk_paiement dans llx_paiement_facture est le rowid du paiement
57 
62  public $type_label;
63 
68  public $type_code;
69 
70 
71 
77  public function __construct($db)
78  {
79  $this->db = $db;
80  }
81 
90  public function fetch($id, $ref = '', $fk_bank = '')
91  {
92  $error = 0;
93 
94  $sql = 'SELECT p.rowid, p.ref, p.entity, p.datep as dp, p.amount, p.statut, p.fk_bank, p.multicurrency_amount,';
95  $sql .= ' c.code as payment_code, c.libelle as payment_type,';
96  $sql .= ' p.num_paiement as num_payment, p.note, b.fk_account';
97  $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p';
98  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
99  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
100  $sql .= ' WHERE p.entity IN ('.getEntity('facture_fourn').')';
101  if ($id > 0)
102  $sql .= ' AND p.rowid = '.$id;
103  elseif ($ref)
104  $sql .= ' AND p.rowid = '.$ref;
105  elseif ($fk_bank)
106  $sql .= ' AND p.fk_bank = '.$fk_bank;
107  //print $sql;
108 
109  $resql = $this->db->query($sql);
110  if ($resql)
111  {
112  $num = $this->db->num_rows($resql);
113  if ($num > 0)
114  {
115  $obj = $this->db->fetch_object($resql);
116 
117  $this->id = $obj->rowid;
118  $this->ref = $obj->ref;
119  $this->entity = $obj->entity;
120  $this->date = $this->db->jdate($obj->dp);
121  $this->datepaye = $this->db->jdate($obj->dp);
122  $this->num_payment = $obj->num_payment;
123  $this->numero = $obj->num_payment;
124  $this->bank_account = $obj->fk_account;
125  $this->fk_account = $obj->fk_account;
126  $this->bank_line = $obj->fk_bank;
127  $this->montant = $obj->amount; // deprecated
128  $this->amount = $obj->amount;
129  $this->multicurrency_amount = $obj->multicurrency_amount;
130  $this->note = $obj->note;
131  $this->note_private = $obj->note;
132  $this->type_code = $obj->payment_code;
133  $this->type_label = $obj->payment_type;
134  $this->statut = $obj->statut;
135 
136  $error = 1;
137  } else {
138  $error = -2; // TODO Use 0 instead
139  }
140  $this->db->free($resql);
141  } else {
142  dol_print_error($this->db);
143  $error = -1;
144  }
145  return $error;
146  }
147 
156  public function create($user, $closepaidinvoices = 0, $thirdparty = null)
157  {
158  global $langs, $conf;
159 
160  $error = 0;
161  $way = $this->getWay();
162 
163  // Clean parameters
164  $totalamount = 0;
165  $totalamount_converted = 0;
166 
167  dol_syslog(get_class($this)."::create", LOG_DEBUG);
168 
169  if ($way == 'dolibarr')
170  {
171  $amounts = &$this->amounts;
172  $amounts_to_update = &$this->multicurrency_amounts;
173  } else {
174  $amounts = &$this->multicurrency_amounts;
175  $amounts_to_update = &$this->amounts;
176  }
177 
178  foreach ($amounts as $key => $value)
179  {
180  $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value ? $value : 0, $way, 'facture_fourn');
181  $totalamount_converted += $value_converted;
182  $amounts_to_update[$key] = price2num($value_converted, 'MT');
183 
184  $newvalue = price2num($value, 'MT');
185  $amounts[$key] = $newvalue;
186  $totalamount += $newvalue;
187  }
188  $totalamount = price2num($totalamount);
189  $totalamount_converted = price2num($totalamount_converted);
190 
191  $this->db->begin();
192 
193  if ($totalamount <> 0) // On accepte les montants negatifs
194  {
195  $ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : '');
196  $now = dol_now();
197 
198  if ($way == 'dolibarr')
199  {
200  $total = $totalamount;
201  $mtotal = $totalamount_converted; // Maybe use price2num with MT for the converted value
202  } else {
203  $total = $totalamount_converted; // Maybe use price2num with MT for the converted value
204  $mtotal = $totalamount;
205  }
206 
207  $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn (';
208  $sql .= 'ref, entity, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)';
209  $sql .= " VALUES ('".$this->db->escape($ref)."', ".$conf->entity.", '".$this->db->idate($now)."',";
210  $sql .= " '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_private)."', ".$user->id.", 0)";
211 
212  $resql = $this->db->query($sql);
213  if ($resql)
214  {
215  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'paiementfourn');
216 
217  // Insere tableau des montants / factures
218  foreach ($this->amounts as $key => $amount)
219  {
220  $facid = $key;
221  if (is_numeric($amount) && $amount <> 0)
222  {
223  $amount = price2num($amount);
224  $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn (fk_facturefourn, fk_paiementfourn, amount, multicurrency_amount)';
225  $sql .= ' VALUES ('.$facid.','.$this->id.',\''.$amount.'\', \''.$this->multicurrency_amounts[$key].'\')';
226  $resql = $this->db->query($sql);
227  if ($resql)
228  {
229  $invoice = new FactureFournisseur($this->db);
230  $invoice->fetch($facid);
231 
232  // If we want to closed paid invoices
233  if ($closepaidinvoices)
234  {
235  $paiement = $invoice->getSommePaiement();
236  //$creditnotes=$invoice->getSumCreditNotesUsed();
237  $creditnotes = 0;
238  //$deposits=$invoice->getSumDepositsUsed();
239  $deposits = 0;
240  $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
241  $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
242  if ($remaintopay == 0)
243  {
244  $result = $invoice->set_paid($user, '', '');
245  } else dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing.");
246  }
247 
248  // Regenerate documents of invoices
249  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
250  {
251  $newlang = '';
252  $outputlangs = $langs;
253  if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
254  if (!empty($newlang)) {
255  $outputlangs = new Translate("", $conf);
256  $outputlangs->setDefaultLang($newlang);
257  }
258  $ret = $invoice->fetch($facid); // Reload to get new records
259  $result = $invoice->generateDocument($invoice->model_pdf, $outputlangs);
260  if ($result < 0) {
261  setEventMessages($invoice->error, $invoice->errors, 'errors');
262  $error++;
263  }
264  }
265  } else {
266  $this->error = $this->db->lasterror();
267  $error++;
268  }
269  } else {
270  dol_syslog(get_class($this).'::Create Amount line '.$key.' not a number. We discard it.');
271  }
272  }
273 
274  if (!$error)
275  {
276  // Call trigger
277  $result = $this->call_trigger('PAYMENT_SUPPLIER_CREATE', $user);
278  if ($result < 0) $error++;
279  // End call triggers
280  }
281  } else {
282  $this->error = $this->db->lasterror();
283  $error++;
284  }
285  } else {
286  $this->error = "ErrorTotalIsNull";
287  dol_syslog('PaiementFourn::Create Error '.$this->error, LOG_ERR);
288  $error++;
289  }
290 
291  if ($totalamount <> 0 && $error == 0) // On accepte les montants negatifs
292  {
293  $this->amount = $total;
294  $this->total = $total;
295  $this->multicurrency_amount = $mtotal;
296  $this->db->commit();
297  dol_syslog('PaiementFourn::Create Ok Total = '.$this->total);
298  return $this->id;
299  } else {
300  $this->db->rollback();
301  return -1;
302  }
303  }
304 
305 
314  public function delete($notrigger = 0)
315  {
316  global $conf, $user, $langs;
317 
318  $bank_line_id = $this->bank_line;
319 
320  $this->db->begin();
321 
322  // Verifier si paiement porte pas sur une facture a l'etat payee
323  // Si c'est le cas, on refuse la suppression
324  $billsarray = $this->getBillsArray('paye=1');
325  if (is_array($billsarray))
326  {
327  if (count($billsarray))
328  {
329  $this->error = "ErrorCantDeletePaymentSharedWithPayedInvoice";
330  $this->db->rollback();
331  return -1;
332  }
333  } else {
334  $this->db->rollback();
335  return -2;
336  }
337 
338  // Verifier si paiement ne porte pas sur ecriture bancaire rapprochee
339  // Si c'est le cas, on refuse le delete
340  if ($bank_line_id)
341  {
342  $accline = new AccountLine($this->db);
343  $accline->fetch($bank_line_id);
344  if ($accline->rappro)
345  {
346  $this->error = "ErrorCantDeletePaymentReconciliated";
347  $this->db->rollback();
348  return -3;
349  }
350  }
351 
352  // Efface la ligne de paiement (dans paiement_facture et paiement)
353  $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn';
354  $sql .= ' WHERE fk_paiementfourn = '.$this->id;
355  $resql = $this->db->query($sql);
356  if ($resql)
357  {
358  $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiementfourn';
359  $sql .= ' WHERE rowid = '.$this->id;
360  $result = $this->db->query($sql);
361  if (!$result)
362  {
363  $this->error = $this->db->error();
364  $this->db->rollback();
365  return -3;
366  }
367 
368  // Supprimer l'ecriture bancaire si paiement lie a ecriture
369  if ($bank_line_id)
370  {
371  $accline = new AccountLine($this->db);
372  $result = $accline->fetch($bank_line_id);
373  if ($result > 0) // If result = 0, record not found, we don't try to delete
374  {
375  $result = $accline->delete($user);
376  }
377  if ($result < 0)
378  {
379  $this->error = $accline->error;
380  $this->db->rollback();
381  return -4;
382  }
383  }
384 
385  if (!$notrigger)
386  {
387  // Appel des triggers
388  $result = $this->call_trigger('PAYMENT_SUPPLIER_DELETE', $user);
389  if ($result < 0)
390  {
391  $this->db->rollback();
392  return -1;
393  }
394  // Fin appel triggers
395  }
396 
397  $this->db->commit();
398  return 1;
399  } else {
400  $this->error = $this->db->error;
401  $this->db->rollback();
402  return -5;
403  }
404  }
405 
412  public function info($id)
413  {
414  $sql = 'SELECT c.rowid, datec, fk_user_author as fk_user_creat, tms';
415  $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as c';
416  $sql .= ' WHERE c.rowid = '.$id;
417 
418  $resql = $this->db->query($sql);
419  if ($resql)
420  {
421  $num = $this->db->num_rows($resql);
422  if ($num)
423  {
424  $obj = $this->db->fetch_object($resql);
425  $this->id = $obj->rowid;
426 
427  if ($obj->fk_user_creat)
428  {
429  $cuser = new User($this->db);
430  $cuser->fetch($obj->fk_user_creat);
431  $this->user_creation = $cuser;
432  }
433  if ($obj->fk_user_modif)
434  {
435  $muser = new User($this->db);
436  $muser->fetch($obj->fk_user_modif);
437  $this->user_modification = $muser;
438  }
439  $this->date_creation = $this->db->jdate($obj->datec);
440  $this->date_modification = $this->db->jdate($obj->tms);
441  }
442  $this->db->free($resql);
443  } else {
444  dol_print_error($this->db);
445  }
446  }
447 
454  public function getBillsArray($filter = '')
455  {
456  $sql = 'SELECT fk_facturefourn';
457  $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'facture_fourn as f';
458  $sql .= ' WHERE pf.fk_facturefourn = f.rowid AND fk_paiementfourn = '.$this->id;
459  if ($filter) $sql .= ' AND '.$filter;
460 
461  dol_syslog(get_class($this).'::getBillsArray', LOG_DEBUG);
462  $resql = $this->db->query($sql);
463  if ($resql)
464  {
465  $i = 0;
466  $num = $this->db->num_rows($resql);
467  $billsarray = array();
468 
469  while ($i < $num)
470  {
471  $obj = $this->db->fetch_object($resql);
472  $billsarray[$i] = $obj->fk_facturefourn;
473  $i++;
474  }
475 
476  return $billsarray;
477  } else {
478  $this->error = $this->db->error();
479  dol_syslog(get_class($this).'::getBillsArray Error '.$this->error);
480  return -1;
481  }
482  }
483 
490  public function getLibStatut($mode = 0)
491  {
492  return $this->LibStatut($this->statut, $mode);
493  }
494 
495  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
503  public function LibStatut($status, $mode = 0)
504  {
505  // phpcs:enable
506  global $langs;
507 
508  $langs->load('compta');
509  /*if ($mode == 0)
510  {
511  if ($status == 0) return $langs->trans('ToValidate');
512  if ($status == 1) return $langs->trans('Validated');
513  }
514  if ($mode == 1)
515  {
516  if ($status == 0) return $langs->trans('ToValidate');
517  if ($status == 1) return $langs->trans('Validated');
518  }
519  if ($mode == 2)
520  {
521  if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
522  if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
523  }
524  if ($mode == 3)
525  {
526  if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
527  if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
528  }
529  if ($mode == 4)
530  {
531  if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
532  if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
533  }
534  if ($mode == 5)
535  {
536  if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
537  if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
538  }
539  if ($mode == 6)
540  {
541  if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
542  if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
543  }*/
544  return '';
545  }
546 
547 
557  public function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0)
558  {
559  global $langs;
560 
561  $result = '';
562 
563  $text = $this->ref; // Sometimes ref contains label
564  $reg = array();
565  if (preg_match('/^\((.*)\)$/i', $text, $reg)) {
566  // Label generique car entre parentheses. On l'affiche en le traduisant
567  if ($reg[1] == 'paiement') $reg[1] = 'Payment';
568  $text = $langs->trans($reg[1]);
569  }
570 
571  $label = '<u>'.$langs->trans("Payment").'</u><br>';
572  $label .= '<strong>'.$langs->trans("Ref").':</strong> '.$text;
573  if ($this->datepaye ? $this->datepaye : $this->date) $label .= '<br><strong>'.$langs->trans("Date").':</strong> '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour');
574 
575  $linkstart = '<a href="'.DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
576  $linkend = '</a>';
577 
578  $result .= $linkstart;
579  if ($withpicto) $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);
580  if ($withpicto != 2) $result .= $this->ref;
581  $result .= $linkend;
582 
583  return $result;
584  }
585 
594  public function initAsSpecimen($option = '')
595  {
596  global $user, $langs, $conf;
597 
598  $now = dol_now();
599  $arraynow = dol_getdate($now);
600  $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']);
601 
602  // Initialize parameters
603  $this->id = 0;
604  $this->ref = 'SPECIMEN';
605  $this->specimen = 1;
606  $this->facid = 1;
607  $this->socid = 1;
608  $this->datepaye = $nownotime;
609  }
610 
619  public function getNextNumRef($soc, $mode = 'next')
620  {
621  global $conf, $db, $langs;
622  $langs->load("bills");
623 
624  // Clean parameters (if not defined or using deprecated value)
625  if (empty($conf->global->SUPPLIER_PAYMENT_ADDON)) $conf->global->SUPPLIER_PAYMENT_ADDON = 'mod_supplier_payment_bronan';
626  elseif ($conf->global->SUPPLIER_PAYMENT_ADDON == 'brodator') $conf->global->SUPPLIER_PAYMENT_ADDON = 'mod_supplier_payment_brodator';
627  elseif ($conf->global->SUPPLIER_PAYMENT_ADDON == 'bronan') $conf->global->SUPPLIER_PAYMENT_ADDON = 'mod_supplier_payment_bronan';
628 
629  if (!empty($conf->global->SUPPLIER_PAYMENT_ADDON))
630  {
631  $mybool = false;
632 
633  $file = $conf->global->SUPPLIER_PAYMENT_ADDON.".php";
634  $classname = $conf->global->SUPPLIER_PAYMENT_ADDON;
635 
636  // Include file with class
637  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
638 
639  foreach ($dirmodels as $reldir) {
640  $dir = dol_buildpath($reldir."core/modules/supplier_payment/");
641 
642  // Load file with numbering class (if found)
643  if (is_file($dir.$file) && is_readable($dir.$file))
644  {
645  $mybool |= include_once $dir.$file;
646  }
647  }
648 
649  // For compatibility
650  if ($mybool === false) {
651  $file = $conf->global->SUPPLIER_PAYMENT_ADDON.".php";
652  $classname = "mod_supplier_payment_".$conf->global->SUPPLIER_PAYMENT_ADDON;
653  $classname = preg_replace('/\-.*$/', '', $classname);
654  // Include file with class
655  foreach ($conf->file->dol_document_root as $dirroot) {
656  $dir = $dirroot."/core/modules/supplier_payment/";
657 
658  // Load file with numbering class (if found)
659  if (is_file($dir.$file) && is_readable($dir.$file)) {
660  $mybool |= include_once $dir.$file;
661  }
662  }
663  }
664 
665  if ($mybool === false) {
666  dol_print_error('', "Failed to include file ".$file);
667  return '';
668  }
669 
670  $obj = new $classname();
671  $numref = "";
672  $numref = $obj->getNextValue($soc, $this);
673 
678  if ($mode != 'last' && !$numref) {
679  dol_print_error($db, "SupplierPayment::getNextNumRef ".$obj->error);
680  return "";
681  }
682 
683  return $numref;
684  } else {
685  $langs->load("errors");
686  print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Supplier"));
687  return "";
688  }
689  }
690 
702  public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
703  {
704  global $conf, $user, $langs;
705 
706  $langs->load("suppliers");
707 
708  // Set the model on the model name to use
709  if (empty($modele))
710  {
711  if (!empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF))
712  {
713  $modele = $conf->global->SUPPLIER_PAYMENT_ADDON_PDF;
714  } else {
715  $modele = ''; // No default value. For supplier invoice, we allow to disable all PDF generation
716  }
717  }
718 
719  if (empty($modele))
720  {
721  return 0;
722  } else {
723  $modelpath = "core/modules/supplier_payment/doc/";
724 
725  return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
726  }
727  }
728 
729 
730 
736  public function getWay()
737  {
738  global $conf;
739 
740  $way = 'dolibarr';
741  if (!empty($conf->multicurrency->enabled))
742  {
743  foreach ($this->multicurrency_amounts as $value)
744  {
745  if (!empty($value)) // one value found then payment is in invoice currency
746  {
747  $way = 'customer';
748  break;
749  }
750  }
751  }
752 
753  return $way;
754  }
755 
756 
757  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
764  public function fetch_thirdparty($force_thirdparty_id = 0)
765  {
766  // phpcs:enable
767  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
768 
769  if (empty($force_thirdparty_id))
770  {
771  $billsarray = $this->getBillsArray(); // From payment, the fk_soc isn't available, we should load the first supplier invoice to get him
772  if (!empty($billsarray))
773  {
774  $supplier_invoice = new FactureFournisseur($this->db);
775  if ($supplier_invoice->fetch($billsarray[0]) > 0)
776  {
777  $force_thirdparty_id = $supplier_invoice->fk_soc;
778  }
779  }
780  }
781 
782  return parent::fetch_thirdparty($force_thirdparty_id);
783  }
784 }
LibStatut($status, $mode=0)
Renvoi le libelle d&#39;un statut donne.
initAsSpecimen($option= '')
Initialise an instance with random values.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
getWay()
get the right way of payment
if(!empty($arrayfields['u.datec']['checked'])) print_liste_field_titre("DateCreationShort"u if(!empty($arrayfields['u.tms']['checked'])) print_liste_field_titre("DateModificationShort"u if(!empty($arrayfields['u.statut']['checked'])) print_liste_field_titre("Status"u statut
Definition: list.php:632
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Definition: user.class.php:44
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
Class to manage bank transaction lines.
Class to manage suppliers invoices.
__construct($db)
Constructor.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
$conf db
API class for accounts.
Definition: inc.php:54
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage payments of customer invoices.
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
getNomUrl($withpicto=0, $option= '', $mode= 'withlistofinvoices', $notooltip=0)
Return clicable name (with picto eventually)
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
getLibStatut($mode=0)
Retourne le libelle du statut d&#39;une facture (brouillon, validee, abandonnee, payee) ...
getBillsArray($filter= '')
Return list of supplier invoices the payment point to.
fetch_thirdparty($force_thirdparty_id=0)
Load the third party of object, from id into this-&gt;thirdparty.
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
call_trigger($triggerName, $user)
Call trigger based on this instance.
info($id)
Information on object.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getNextNumRef($soc, $mode= 'next')
Return next reference of supplier invoice not already used (or last reference) according to numbering...
fetch($id, $ref= '', $fk_bank= '')
Load payment object.
Class to manage payments for supplier invoices.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template model.
create($user, $closepaidinvoices=0, $thirdparty=null)
Create payment in database.
if(!empty($search_group)) natural_search(array("g.nom"g note
Definition: list.php:122
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...