dolibarr  18.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  *
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 
109 
110 
116  public function __construct($db)
117  {
118  $this->db = $db;
119  }
120 
128  public function getLabelOfUnit($type = 'long')
129  {
130  global $langs;
131 
132  if (empty($this->fk_unit)) {
133  return '';
134  }
135 
136  $langs->load('products');
137 
138  $label_type = 'label';
139 
140  $label_type = 'label';
141  if ($type == 'short') {
142  $label_type = 'short_label';
143  } elseif ($type == 'code') {
144  $label_type = 'code';
145  }
146 
147  $sql = "SELECT ".$label_type.", code from ".$this->db->prefix()."c_units where rowid = ".((int) $this->fk_unit);
148 
149  $resql = $this->db->query($sql);
150  if ($resql && $this->db->num_rows($resql) > 0) {
151  $res = $this->db->fetch_array($resql);
152  if ($label_type == 'code') {
153  $label = 'unit'.$res['code'];
154  } else {
155  $label = $res[$label_type];
156  }
157  $this->db->free($resql);
158  return $label;
159  } else {
160  $this->error = $this->db->lasterror();
161  dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR);
162  return -1;
163  }
164  }
165 
177  public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
178  {
179  return 0;
180  }
181 }
db
$conf db
API class for accounts.
Definition: inc.php:41
CommonObjectLine\fetchAll
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.
Definition: commonobjectline.class.php:177
$sql
if(isModEnabled('facture') &&!empty($user->rights->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') &&!empty($user->rights->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:745
CommonObjectLine
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Definition: commonobjectline.class.php:32
CommonObject
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Definition: commonobject.class.php:45
CommonObjectLine\getLabelOfUnit
getLabelOfUnit($type='long')
Returns the label, short_label or code found in units dictionary from ->fk_unit.
Definition: commonobjectline.class.php:128
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1639
CommonObjectLine\__construct
__construct($db)
Constructor.
Definition: commonobjectline.class.php:116