dolibarr 19.0.4
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 *
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 <https://www.gnu.org/licenses/>.
17 */
18
32abstract class CommonObjectLine extends CommonObject
33{
38 public $id;
39
46 public $rowid;
47
51 public $picto = 'line';
52
57 public $fk_unit;
58
59 public $date_debut_prevue;
60 public $date_debut_reel;
61 public $date_fin_prevue;
62 public $date_fin_reel;
63
64 public $weight;
65 public $weight_units;
66 public $width;
67 public $width_units;
68 public $height;
69 public $height_units;
70 public $length;
71 public $length_units;
72 public $surface;
73 public $surface_units;
74 public $volume;
75 public $volume_units;
76
77 public $multilangs;
78
79 public $product_type; // type in line
80 public $fk_product; // product id in line (when line is linked to a product)
81
86 public $desc;
87
94 public $description;
95
96 public $product; // To store full product object after a fetch_product() on a line
97 public $product_ref; // ref in product table
98 public $product_label; // label in product table
99 public $product_barcode; // barcode in product table
100 public $product_desc; // desc in product table
101 public $fk_product_type; // type in product table
102
103 public $qty;
104 public $duree;
105 public $remise_percent;
106 public $info_bits;
107 public $special_code;
108 public $subprice;
109 public $tva_tx;
110
114 public $fk_multicurrency;
115
119 public $multicurrency_code;
120
124 public $multicurrency_subprice;
125
129 public $multicurrency_total_ht;
130
134 public $multicurrency_total_tva;
135
139 public $multicurrency_total_ttc;
140
141
147 public function __construct($db)
148 {
149 $this->db = $db;
150 }
151
159 public function getLabelOfUnit($type = 'long')
160 {
161 global $langs;
162
163 if (empty($this->fk_unit)) {
164 return '';
165 }
166
167 $langs->load('products');
168
169 $label_type = 'label';
170
171 $label_type = 'label';
172 if ($type == 'short') {
173 $label_type = 'short_label';
174 } elseif ($type == 'code') {
175 $label_type = 'code';
176 }
177
178 $sql = "SELECT ".$label_type.", code from ".$this->db->prefix()."c_units where rowid = ".((int) $this->fk_unit);
179
180 $resql = $this->db->query($sql);
181 if ($resql && $this->db->num_rows($resql) > 0) {
182 $res = $this->db->fetch_array($resql);
183 if ($label_type == 'code') {
184 $label = 'unit'.$res['code'];
185 } else {
186 $label = $res[$label_type];
187 }
188 $this->db->free($resql);
189 return $label;
190 } else {
191 $this->error = $this->db->lasterror();
192 dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR);
193 return -1;
194 }
195 }
196
208 public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
209 {
210 return 0;
211 }
212}
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, array $filter=array(), $filtermode='AND')
Empty function to prevent errors on call of this function must be overload if usefull.
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.