dolibarr  16.0.5
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 
82  public $desc;
83 
84  public $product; // To store full product object after a fetch_product() on a line
85  public $product_ref; // ref in product table
86  public $product_label; // label in product table
87  public $product_barcode; // barcode in product table
88  public $product_desc; // desc in product table
89  public $fk_product_type; // type in product table
90 
91  public $qty;
92  public $duree;
93  public $remise_percent;
94  public $info_bits;
95  public $special_code;
96 
97 
98 
104  public function __construct($db)
105  {
106  $this->db = $db;
107  }
108 
116  public function getLabelOfUnit($type = 'long')
117  {
118  global $langs;
119 
120  if (empty($this->fk_unit)) {
121  return '';
122  }
123 
124  $langs->load('products');
125 
126  $label_type = 'label';
127 
128  $label_type = 'label';
129  if ($type == 'short') {
130  $label_type = 'short_label';
131  } elseif ($type == 'code') {
132  $label_type = 'code';
133  }
134 
135  $sql = "SELECT ".$label_type.", code from ".$this->db->prefix()."c_units where rowid = ".((int) $this->fk_unit);
136 
137  $resql = $this->db->query($sql);
138  if ($resql && $this->db->num_rows($resql) > 0) {
139  $res = $this->db->fetch_array($resql);
140  if ($label_type == 'code') {
141  $label = 'unit'.$res['code'];
142  } else {
143  $label = $res[$label_type];
144  }
145  $this->db->free($resql);
146  return $label;
147  } else {
148  $this->error = $this->db->lasterror();
149  dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR);
150  return -1;
151  }
152  }
153 
165  public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
166  {
167  return 0;
168  }
169 }
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:165
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:44
CommonObjectLine\getLabelOfUnit
getLabelOfUnit($type='long')
Returns the label, short_label or code found in units dictionary from ->fk_unit.
Definition: commonobjectline.class.php:116
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
CommonObjectLine\__construct
__construct($db)
Constructor.
Definition: commonobjectline.class.php:104
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742