dolibarr 20.0.0
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
34abstract class CommonObjectLine extends CommonObject
35{
39 public $parent_element = '';
40
44 public $fk_parent_attribute = '';
45
50 public $id;
51
58 public $rowid;
59
63 public $picto = 'line';
64
70 public $fk_unit;
71
72 public $date_debut_prevue;
73 public $date_debut_reel;
74 public $date_fin_prevue;
75 public $date_fin_reel;
76
77 public $weight;
78 public $weight_units;
79 public $width;
80 public $width_units;
81 public $height;
82 public $height_units;
83 public $length;
84 public $length_units;
85 public $surface;
86 public $surface_units;
87 public $volume;
88 public $volume_units;
89
90 public $multilangs;
91
95 public $product_type;
96
100 public $fk_product;
101
106 public $desc;
107
114 public $description;
115
119 public $product;
120
124 public $product_ref;
125
129 public $product_label;
130
134 public $product_barcode;
135
139 public $product_desc;
140
144 public $fk_product_type;
145
149 public $qty;
150 public $duree;
151 public $remise_percent;
152
159 public $info_bits;
160
164 public $special_code;
165
170 public $subprice;
171 public $tva_tx;
172
176 public $fk_multicurrency;
177
181 public $multicurrency_code;
182
186 public $multicurrency_subprice;
187
191 public $multicurrency_total_ht;
192
196 public $multicurrency_total_tva;
197
201 public $multicurrency_total_ttc;
202
203
209 public function __construct($db)
210 {
211 $this->db = $db;
212 }
213
221 public function getLabelOfUnit($type = 'long')
222 {
223 global $langs;
224
225 if (empty($this->fk_unit)) {
226 return '';
227 }
228
229 $langs->load('products');
230
231 $label_type = 'label';
232 if ($type == 'short') {
233 $label_type = 'short_label';
234 } elseif ($type == 'code') {
235 $label_type = 'code';
236 }
237
238 $sql = "SELECT ".$label_type.", code from ".$this->db->prefix()."c_units where rowid = ".((int) $this->fk_unit);
239
240 $resql = $this->db->query($sql);
241 if ($resql && $this->db->num_rows($resql) > 0 && $res = $this->db->fetch_array($resql)) {
242 if ($label_type == 'code') {
243 $label = 'unit'.$res['code'];
244 } else {
245 $label = $res[$label_type];
246 }
247 $this->db->free($resql);
248 return $label;
249 } else {
250 $this->error = $this->db->lasterror();
251 dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR);
252 return -1;
253 }
254 }
255
268 public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
269 {
270 return 0;
271 }
272}
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.