dolibarr  13.0.2
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 
30 abstract class CommonObjectLine extends CommonObject
31 {
36  public $id;
37 
44  public $rowid;
45 
50  public $fk_unit;
51 
52 
58  public function __construct($db)
59  {
60  $this->db = $db;
61  }
62 
70  public function getLabelOfUnit($type = 'long')
71  {
72  global $langs;
73 
74  if (!$this->fk_unit) {
75  return '';
76  }
77 
78  $langs->load('products');
79 
80  $label_type = 'label';
81 
82  $label_type = 'label';
83  if ($type == 'short') $label_type = 'short_label';
84  elseif ($type == 'code') $label_type = 'code';
85 
86  $sql = 'select '.$label_type.', code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit;
87  $resql = $this->db->query($sql);
88  if ($resql && $this->db->num_rows($resql) > 0) {
89  $res = $this->db->fetch_array($resql);
90  if ($label_type == 'code') $label = 'unit'.$res['code'];
91  else $label = $res[$label_type];
92  $this->db->free($resql);
93  return $label;
94  } else {
95  $this->error = $this->db->error().' sql='.$sql;
96  dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR);
97  return -1;
98  }
99  }
100  // Currently we need function at end of file CommonObject for all object lines. Should find a way to avoid duplicate code.
101 
102  // For the moment we use the extends on CommonObject until PHP min is 5.4 so use Traits.
103 }
__construct($db)
Constructor.
getLabelOfUnit($type= 'long')
Returns the label, shot_label or code found in units dictionary from -&gt;fk_unit.
$conf db
API class for accounts.
Definition: inc.php:54
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)