dolibarr  20.0.0-alpha
commonobjectline.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
4  * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5  * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
34 abstract class CommonObjectLine extends CommonObject
35 {
40  public $id;
41 
48  public $rowid;
49 
53  public $picto = 'line';
54 
60  public $fk_unit;
61 
62  public $date_debut_prevue;
63  public $date_debut_reel;
64  public $date_fin_prevue;
65  public $date_fin_reel;
66 
67  public $weight;
68  public $weight_units;
69  public $width;
70  public $width_units;
71  public $height;
72  public $height_units;
73  public $length;
74  public $length_units;
75  public $surface;
76  public $surface_units;
77  public $volume;
78  public $volume_units;
79 
80  public $multilangs;
81 
85  public $product_type;
86 
90  public $fk_product;
91 
96  public $desc;
97 
104  public $description;
105 
109  public $product;
110 
114  public $product_ref;
115 
119  public $product_label;
120 
124  public $product_barcode;
125 
129  public $product_desc;
130 
134  public $fk_product_type;
135 
136  public $qty;
137  public $duree;
138  public $remise_percent;
139 
143  public $info_bits;
144 
148  public $special_code;
149  public $subprice;
150  public $tva_tx;
151 
155  public $fk_multicurrency;
156 
160  public $multicurrency_code;
161 
165  public $multicurrency_subprice;
166 
170  public $multicurrency_total_ht;
171 
175  public $multicurrency_total_tva;
176 
180  public $multicurrency_total_ttc;
181 
182 
188  public function __construct($db)
189  {
190  $this->db = $db;
191  }
192 
200  public function getLabelOfUnit($type = 'long')
201  {
202  global $langs;
203 
204  if (empty($this->fk_unit)) {
205  return '';
206  }
207 
208  $langs->load('products');
209 
210  $label_type = 'label';
211  if ($type == 'short') {
212  $label_type = 'short_label';
213  } elseif ($type == 'code') {
214  $label_type = 'code';
215  }
216 
217  $sql = "SELECT ".$label_type.", code from ".$this->db->prefix()."c_units where rowid = ".((int) $this->fk_unit);
218 
219  $resql = $this->db->query($sql);
220  if ($resql && $this->db->num_rows($resql) > 0 && $res = $this->db->fetch_array($resql)) {
221  if ($label_type == 'code') {
222  $label = 'unit'.$res['code'];
223  } else {
224  $label = $res[$label_type];
225  }
226  $this->db->free($resql);
227  return $label;
228  } else {
229  $this->error = $this->db->lasterror();
230  dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR);
231  return -1;
232  }
233  }
234 
247  public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
248  {
249  return 0;
250  }
251 }
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Empty function to prevent errors on call of this function.
getLabelOfUnit($type='long')
Returns the label, short_label or code found in units dictionary from ->fk_unit.
__construct($db)
Constructor.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('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') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:744
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.