dolibarr  18.0.6
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 
32 abstract 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 
111 
112 
118  public function __construct($db)
119  {
120  $this->db = $db;
121  }
122 
130  public function getLabelOfUnit($type = 'long')
131  {
132  global $langs;
133 
134  if (empty($this->fk_unit)) {
135  return '';
136  }
137 
138  $langs->load('products');
139 
140  $label_type = 'label';
141 
142  $label_type = 'label';
143  if ($type == 'short') {
144  $label_type = 'short_label';
145  } elseif ($type == 'code') {
146  $label_type = 'code';
147  }
148 
149  $sql = "SELECT ".$label_type.", code from ".$this->db->prefix()."c_units where rowid = ".((int) $this->fk_unit);
150 
151  $resql = $this->db->query($sql);
152  if ($resql && $this->db->num_rows($resql) > 0) {
153  $res = $this->db->fetch_array($resql);
154  if ($label_type == 'code') {
155  $label = 'unit'.$res['code'];
156  } else {
157  $label = $res[$label_type];
158  }
159  $this->db->free($resql);
160  return $label;
161  } else {
162  $this->error = $this->db->lasterror();
163  dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR);
164  return -1;
165  }
166  }
167 
179  public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
180  {
181  return 0;
182  }
183 }
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.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->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') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.