dolibarr  9.0.0
discount.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
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 <http://www.gnu.org/licenses/>.
17  */
18 
30 {
34  public $db;
35 
39  public $error;
40 
44  public $errors=array();
45 
49  public $id;
50 
54  public $fk_soc;
55 
56  public $discount_type; // 0 => customer discount, 1 => supplier discount
57  public $amount_ht; //
58  public $amount_tva; //
59  public $amount_ttc; //
60  public $tva_tx; // Vat rate
61 
65  public $fk_user;
66 
70  public $description;
71 
72  public $datec; // Date creation
73 
77  public $fk_facture_line;
78 
82  public $fk_facture;
83 
87  public $fk_facture_source;
88 
89  public $ref_facture_source; // Ref credit note having caused the discount
90 
91  public $ref_invoice_supplier_source;
92 
98  function __construct($db)
99  {
100  $this->db = $db;
101  }
102 
103 
112  function fetch($rowid, $fk_facture_source=0, $fk_invoice_supplier_source=0)
113  {
114  global $conf;
115 
116  // Check parameters
117  if (! $rowid && ! $fk_facture_source && ! $fk_invoice_supplier_source)
118  {
119  $this->error='ErrorBadParameters';
120  return -1;
121  }
122 
123  $sql = "SELECT sr.rowid, sr.fk_soc, sr.discount_type,";
124  $sql.= " sr.fk_user,";
125  $sql.= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx,";
126  $sql.= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,";
127  $sql.= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.fk_invoice_supplier_line, sr.fk_invoice_supplier, sr.fk_invoice_supplier_source, sr.description,";
128  $sql.= " sr.datec,";
129  $sql.= " f.facnumber as ref_facture_source, fsup.facnumber as ref_invoice_supplier_source";
130  $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr";
131  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid";
132  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid";
133  $sql.= " WHERE sr.entity = " . $conf->entity;
134  if ($rowid) $sql.= " AND sr.rowid=".$rowid;
135  if ($fk_facture_source) $sql.= " AND sr.fk_facture_source=".$fk_facture_source;
136  if ($fk_invoice_supplier_source) $sql.= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source;
137 
138  dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
139  $resql = $this->db->query($sql);
140  if ($resql)
141  {
142  if ($this->db->num_rows($resql))
143  {
144  $obj = $this->db->fetch_object($resql);
145 
146  $this->id = $obj->rowid;
147  $this->fk_soc = $obj->fk_soc;
148  $this->discount_type = $obj->discount_type;
149 
150  $this->amount_ht = $obj->amount_ht;
151  $this->amount_tva = $obj->amount_tva;
152  $this->amount_ttc = $obj->amount_ttc;
153 
154  $this->multicurrency_amount_ht = $this->multicurrency_subprice = $obj->multicurrency_amount_ht;
155  $this->multicurrency_amount_tva = $obj->multicurrency_amount_tva;
156  $this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc;
157 
158  $this->tva_tx = $obj->tva_tx;
159  $this->fk_user = $obj->fk_user;
160  $this->fk_facture_line = $obj->fk_facture_line;
161  $this->fk_facture = $obj->fk_facture;
162  $this->fk_facture_source = $obj->fk_facture_source; // Id avoir source
163  $this->ref_facture_source = $obj->ref_facture_source; // Ref avoir source
164  $this->fk_invoice_supplier_line = $obj->fk_invoice_supplier_line;
165  $this->fk_invoice_supplier = $obj->fk_invoice_supplier;
166  $this->fk_invoice_supplier_source = $obj->fk_invoice_supplier_source; // Id avoir source
167  $this->ref_invoice_supplier_source = $obj->ref_invoice_supplier_source; // Ref avoir source
168  $this->description = $obj->description;
169  $this->datec = $this->db->jdate($obj->datec);
170 
171  $this->db->free($resql);
172  return 1;
173  }
174  else
175  {
176  $this->db->free($resql);
177  return 0;
178  }
179  }
180  else
181  {
182  $this->error=$this->db->error();
183  return -1;
184  }
185  }
186 
187 
194  function create($user)
195  {
196  global $conf, $langs;
197 
198  // Clean parameters
199  $this->amount_ht=price2num($this->amount_ht);
200  $this->amount_tva=price2num($this->amount_tva);
201  $this->amount_ttc=price2num($this->amount_ttc);
202 
203  $this->tva_tx=price2num($this->tva_tx);
204 
205  $this->multicurrency_amount_ht=price2num($this->multicurrency_amount_ht);
206  $this->multicurrency_amount_tva=price2num($this->multicurrency_amount_tva);
207  $this->multicurrency_amount_ttc=price2num($this->multicurrency_amount_ttc);
208 
209  if (empty($this->multicurrency_amount_ht)) $this->multicurrency_amount_ht=0;
210  if (empty($this->multicurrency_amount_tva)) $this->multicurrency_amount_tva=0;
211  if (empty($this->multicurrency_amount_ttc)) $this->multicurrency_amount_ttc=0;
212 
213  // Check parameters
214  if (empty($this->description))
215  {
216  $this->error='BadValueForPropertyDescription';
217  dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
218  return -1;
219  }
220 
221  // Insert request
222  $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except";
223  $sql.= " (entity, datec, fk_soc, discount_type, fk_user, description,";
224  $sql.= " amount_ht, amount_tva, amount_ttc, tva_tx,";
225  $sql.= " multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc,";
226  $sql.= " fk_facture_source, fk_invoice_supplier_source";
227  $sql.= ")";
228  $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($this->datec!=''?$this->datec:dol_now())."', ".$this->fk_soc.", ".(empty($this->discount_type)?0:intval($this->discount_type)).", ".$user->id.", '".$this->db->escape($this->description)."',";
229  $sql.= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.",";
230  $sql.= " ".$this->multicurrency_amount_ht.", ".$this->multicurrency_amount_tva.", ".$this->multicurrency_amount_ttc.", ";
231  $sql.= " ".($this->fk_facture_source ? "'".$this->db->escape($this->fk_facture_source)."'":"null").",";
232  $sql.= " ".($this->fk_invoice_supplier_source ? "'".$this->db->escape($this->fk_invoice_supplier_source)."'":"null");
233  $sql.= ")";
234 
235  dol_syslog(get_class($this)."::create", LOG_DEBUG);
236  $resql=$this->db->query($sql);
237  if ($resql)
238  {
239  $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except");
240  return $this->id;
241  }
242  else
243  {
244  $this->error=$this->db->lasterror().' - sql='.$sql;
245  return -1;
246  }
247  }
248 
249 
256  function delete($user)
257  {
258  global $conf, $langs;
259 
260  // Check if we can remove the discount
261  if ($this->fk_facture_source)
262  {
263  $sql="SELECT COUNT(rowid) as nb";
264  $sql.=" FROM ".MAIN_DB_PREFIX."societe_remise_except";
265  $sql.=" WHERE (fk_facture_line IS NOT NULL"; // Not used as absolute simple discount
266  $sql.=" OR fk_facture IS NOT NULL)"; // Not used as credit note and not used as deposit
267  $sql.=" AND fk_facture_source = ".$this->fk_facture_source;
268  //$sql.=" AND rowid != ".$this->id;
269 
270  dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG);
271  $resql=$this->db->query($sql);
272  if ($resql)
273  {
274  $obj = $this->db->fetch_object($resql);
275  if ($obj->nb > 0)
276  {
277  $this->error='ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved';
278  return -2;
279  }
280  }
281  else
282  {
283  dol_print_error($this->db);
284  return -1;
285  }
286  }
287 
288  // Check if we can remove the discount
289  if ($this->fk_invoice_supplier_source)
290  {
291  $sql="SELECT COUNT(rowid) as nb";
292  $sql.=" FROM ".MAIN_DB_PREFIX."societe_remise_except";
293  $sql.=" WHERE (fk_invoice_supplier_line IS NOT NULL"; // Not used as absolute simple discount
294  $sql.=" OR fk_invoice_supplier IS NOT NULL)"; // Not used as credit note and not used as deposit
295  $sql.=" AND fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source;
296  //$sql.=" AND rowid != ".$this->id;
297 
298  dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG);
299  $resql=$this->db->query($sql);
300  if ($resql)
301  {
302  $obj = $this->db->fetch_object($resql);
303  if ($obj->nb > 0)
304  {
305  $this->error='ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved';
306  return -2;
307  }
308  }
309  else
310  {
311  dol_print_error($this->db);
312  return -1;
313  }
314  }
315 
316  $this->db->begin();
317 
318  // Delete but only if not used
319  $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except ";
320  if ($this->fk_facture_source) $sql.= " WHERE fk_facture_source = ".$this->fk_facture_source; // Delete all lines of same serie
321  elseif ($this->fk_invoice_supplier_source) $sql.= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; // Delete all lines of same serie
322  else $sql.= " WHERE rowid = ".$this->id; // Delete only line
323  $sql.= " AND (fk_facture_line IS NULL"; // Not used as absolute simple discount
324  $sql.= " AND fk_facture IS NULL)"; // Not used as credit note and not used as deposit
325  $sql.= " AND (fk_invoice_supplier_line IS NULL"; // Not used as absolute simple discount
326  $sql.= " AND fk_invoice_supplier IS NULL)"; // Not used as credit note and not used as deposit
327 
328  dol_syslog(get_class($this)."::delete Delete discount", LOG_DEBUG);
329  $result=$this->db->query($sql);
330  if ($result)
331  {
332  // If source of discount was a credit note or deposit, we change source statut.
333  if ($this->fk_facture_source)
334  {
335  $sql = "UPDATE ".MAIN_DB_PREFIX."facture";
336  $sql.=" set paye=0, fk_statut=1";
337  $sql.=" WHERE (type = 2 or type = 3) AND rowid=".$this->fk_facture_source;
338 
339  dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG);
340  $result=$this->db->query($sql);
341  if ($result)
342  {
343  $this->db->commit();
344  return 1;
345  }
346  else
347  {
348  $this->error=$this->db->lasterror();
349  $this->db->rollback();
350  return -1;
351  }
352  }
353  elseif($this->fk_invoice_supplier_source) {
354 
355  $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn";
356  $sql.=" set paye=0, fk_statut=1";
357  $sql.=" WHERE (type = 2 or type = 3) AND rowid=".$this->fk_invoice_supplier_source;
358 
359  dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG);
360  $result=$this->db->query($sql);
361  if ($result)
362  {
363  $this->db->commit();
364  return 1;
365  }
366  else
367  {
368  $this->error=$this->db->lasterror();
369  $this->db->rollback();
370  return -1;
371  }
372  }
373  else
374  {
375  $this->db->commit();
376  return 1;
377  }
378  }
379  else
380  {
381  $this->error=$this->db->lasterror();
382  $this->db->rollback();
383  return -1;
384  }
385  }
386 
387 
388 
389  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
399  function link_to_invoice($rowidline,$rowidinvoice)
400  {
401  // phpcs:enable
402  // Check parameters
403  if (! $rowidline && ! $rowidinvoice)
404  {
405  $this->error='ErrorBadParameters';
406  return -1;
407  }
408  if ($rowidline && $rowidinvoice)
409  {
410  $this->error='ErrorBadParameters';
411  return -2;
412  }
413 
414  $sql ="UPDATE ".MAIN_DB_PREFIX."societe_remise_except";
415  if(! empty($this->discount_type)) {
416  if ($rowidline) $sql.=" SET fk_invoice_supplier_line = ".$rowidline;
417  if ($rowidinvoice) $sql.=" SET fk_invoice_supplier = ".$rowidinvoice;
418  } else {
419  if ($rowidline) $sql.=" SET fk_facture_line = ".$rowidline;
420  if ($rowidinvoice) $sql.=" SET fk_facture = ".$rowidinvoice;
421  }
422  $sql.=" WHERE rowid = ".$this->id;
423 
424  dol_syslog(get_class($this)."::link_to_invoice", LOG_DEBUG);
425  $resql = $this->db->query($sql);
426  if ($resql)
427  {
428  if(! empty($this->discount_type)) {
429  $this->fk_invoice_supplier_line=$rowidline;
430  $this->fk_invoice_supplier=$rowidinvoice;
431  } else {
432  $this->fk_facture_line=$rowidline;
433  $this->fk_facture=$rowidinvoice;
434  }
435  return 1;
436  }
437  else
438  {
439  $this->error=$this->db->error();
440  return -3;
441  }
442  }
443 
444 
445  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
452  function unlink_invoice()
453  {
454  // phpcs:enable
455  $sql ="UPDATE ".MAIN_DB_PREFIX."societe_remise_except";
456  if(! empty($this->discount_type)) {
457  $sql.=" SET fk_invoice_supplier_line = NULL, fk_invoice_supplier = NULL";
458  } else {
459  $sql.=" SET fk_facture_line = NULL, fk_facture = NULL";
460  }
461  $sql.=" WHERE rowid = ".$this->id;
462 
463  dol_syslog(get_class($this)."::unlink_invoice", LOG_DEBUG);
464  $resql = $this->db->query($sql);
465  if ($resql)
466  {
467  return 1;
468  }
469  else
470  {
471  $this->error=$this->db->error();
472  return -3;
473  }
474  }
475 
476 
487  function getAvailableDiscounts($company='', $user='',$filter='', $maxvalue=0, $discount_type=0)
488  {
489  global $conf;
490 
491  $sql = "SELECT SUM(rc.amount_ttc) as amount";
492  //$sql = "SELECT rc.amount_ttc as amount";
493  $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
494  $sql.= " WHERE rc.entity = " . $conf->entity;
495  $sql.= " AND rc.discount_type=".intval($discount_type);
496  if (! empty($discount_type)) {
497  $sql.= " AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)"; // Available from supplier
498  } else {
499  $sql.= " AND (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available to customer
500  }
501  if (is_object($company)) $sql.= " AND rc.fk_soc = ".$company->id;
502  if (is_object($user)) $sql.= " AND rc.fk_user = ".$user->id;
503  if ($filter) $sql.=' AND ('.$filter.')';
504  if ($maxvalue) $sql.=' AND rc.amount_ttc <= '.price2num($maxvalue);
505 
506  dol_syslog(get_class($this)."::getAvailableDiscounts", LOG_DEBUG);
507  $resql=$this->db->query($sql);
508  if ($resql)
509  {
510  $obj = $this->db->fetch_object($resql);
511  //while ($obj)
512  //{
513  //print 'zz'.$obj->amount;
514  //$obj = $this->db->fetch_object($resql);
515  //}
516  return $obj->amount;
517  }
518  return -1;
519  }
520 
521 
530  function getSumDepositsUsed($invoice, $multicurrency=0)
531  {
532  dol_syslog(get_class($this)."::getSumDepositsUsed", LOG_DEBUG);
533 
534  if ($invoice->element == 'facture' || $invoice->element == 'invoice')
535  {
536  $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
537  $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
538  $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id;
539  $sql.= ' AND f.type = 3';
540  }
541  else if ($invoice->element == 'invoice_supplier')
542  {
543  $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
544  $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
545  $sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id;
546  $sql.= ' AND f.type = 3';
547  }
548  else
549  {
550  $this->error=get_class($this)."::getSumDepositsUsed was called with a bad object as a first parameter";
551  dol_print_error($this->error);
552  return -1;
553  }
554 
555  $resql=$this->db->query($sql);
556  if ($resql)
557  {
558  $obj = $this->db->fetch_object($resql);
559  if ($multicurrency) return $obj->multicurrency_amount;
560  else return $obj->amount;
561  }
562  else
563  {
564  $this->error = $this->db->lasterror();
565  return -1;
566  }
567  }
568 
576  function getSumCreditNotesUsed($invoice, $multicurrency=0)
577  {
578  dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG);
579 
580  if ($invoice->element == 'facture' || $invoice->element == 'invoice')
581  {
582  $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
583  $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
584  $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id;
585  $sql.= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess received
586  }
587  else if ($invoice->element == 'invoice_supplier')
588  {
589  $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
590  $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
591  $sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id;
592  $sql.= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess paid
593  }
594  else
595  {
596  $this->error=get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter";
597  dol_print_error($this->error);
598  return -1;
599  }
600 
601  $resql=$this->db->query($sql);
602  if ($resql)
603  {
604  $obj = $this->db->fetch_object($resql);
605  if ($multicurrency) return $obj->multicurrency_amount;
606  else return $obj->amount;
607  }
608  else
609  {
610  $this->error = $this->db->lasterror();
611  return -1;
612  }
613  }
614 
622  function getNomUrl($withpicto,$option='invoice')
623  {
624  global $langs;
625 
626  $result='';
627 
628  if ($option == 'invoice') {
629  $facid=! empty($this->discount_type)?$this->fk_invoice_supplier_source:$this->fk_facture_source;
630  $link=! empty($this->discount_type)?'/fourn/facture/card.php':'/compta/facture/card.php';
631  $label=$langs->trans("ShowDiscount").': '.$this->ref_facture_source;
632  $link = '<a href="'.DOL_URL_ROOT.$link.'?facid='.$facid.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
633  $linkend='</a>';
634  $ref=! empty($this->discount_type)?$this->ref_invoice_supplier_source:$this->ref_facture_source;
635  $picto='bill';
636  }
637  if ($option == 'discount') {
638  $label=$langs->trans("Discount");
639  $link = '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$this->fk_soc.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
640  $linkend='</a>';
641  $ref=$langs->trans("Discount");
642  $picto='generic';
643  }
644 
645 
646  if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
647  if ($withpicto && $withpicto != 2) $result.=' ';
648  $result.=$link.$ref.$linkend;
649  return $result;
650  }
651 
652 
660  function initAsSpecimen()
661  {
662  global $user,$langs,$conf;
663 
664  $this->fk_soc = 1;
665  $this->amount_ht = 10;
666  $this->amount_tva = 1.96;
667  $this->amount_ttc = 11.96;
668  $this->tva_tx = 19.6;
669  $this->description = 'Specimen discount';
670  }
671 }
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->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) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
getSumCreditNotesUsed($invoice, $multicurrency=0)
Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment...
getSumDepositsUsed($invoice, $multicurrency=0)
Return amount (with tax) of all deposits invoices used by invoice as a payment.
</td >< td class="liste_titre" align="right"></td ></tr >< tr class="liste_titre">< input type="checkbox" onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< tr class="oddeven">< td >< input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td >< td >< input type="checkbox" class="check" name="choose'.$i.'"></td >< td class="nowrap"></td >< td >< input type="hidden" name="desc' . $i . '" value="' . dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:573
initAsSpecimen()
Initialise an instance with random values.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
fetch($rowid, $fk_facture_source=0, $fk_invoice_supplier_source=0)
Load object from database into memory.
getNomUrl($withpicto, $option='invoice')
Return clickable ref of object (with picto or not)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
dol_now($mode='gmt')
Return date for now.
create($user)
Create a discount into database.
getAvailableDiscounts($company='', $user='', $filter='', $maxvalue=0, $discount_type=0)
Return amount (with tax) of discounts currently available for a company, user or other criteria...
link_to_invoice($rowidline, $rowidinvoice)
Link the discount to a particular invoice line or a particular invoice.
Class to manage absolute discounts.
__construct($db)
Constructor.
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
unlink_invoice()
Link the discount to a particular invoice line or a particular invoice.