dolibarr  7.0.0-beta
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 <http://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 
60  public function getLabelOfUnit($type='long')
61  {
62  global $langs;
63 
64  if (!$this->fk_unit) {
65  return '';
66  }
67 
68  $langs->load('products');
69 
70  $label_type = 'label';
71 
72  if ($type == 'short')
73  {
74  $label_type = 'short_label';
75  }
76 
77  $sql = 'select '.$label_type.' from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit;
78  $resql = $this->db->query($sql);
79  if($resql && $this->db->num_rows($resql) > 0)
80  {
81  $res = $this->db->fetch_array($resql);
82  $label = $res[$label_type];
83  $this->db->free($resql);
84  return $label;
85  }
86  else
87  {
88  $this->error=$this->db->error().' sql='.$sql;
89  dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR);
90  return -1;
91  }
92  }
93  // Currently we need function at end of file CommonObject for all object lines. Should find a way to avoid duplicate code.
94 
95  // For the moment we use the extends on CommonObject until PHP min is 5.4 so use Traits.
96 }
97 
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='')
Write log message into outputs.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->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)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
getLabelOfUnit($type='long')
Returns the translation key from units dictionary.