dolibarr  7.0.0-beta
modules_barcode.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  * or see http://www.gnu.org/
17  */
18 
24 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
25 
26 
30 abstract class ModeleBarCode
31 {
32  var $error='';
33 
34 
40  function isEnabled()
41  {
42  return true;
43  }
44 
45 }
46 
47 
51 abstract class ModeleNumRefBarCode
52 {
53  var $error='';
54 
60  function info($langs)
61  {
62  $langs->load("bills");
63  return $langs->trans("NoDescription");
64  }
65 
71  function getNom($langs)
72  {
73  return empty($this->name)?$this->nom:$this->name;
74  }
75 
81  function getExample($langs)
82  {
83  $langs->load("bills");
84  return $langs->trans("NoExample");
85  }
86 
94  function getNextValue($objproduct,$type='')
95  {
96  global $langs;
97  return $langs->trans("Function_getNextValue_InModuleNotWorking");
98  }
99 
104  function getVersion()
105  {
106  global $langs;
107  $langs->load("admin");
108 
109  if ($this->version == 'development') return $langs->trans("VersionDevelopment");
110  if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
111  if ($this->version == 'dolibarr') return DOL_VERSION;
112  if ($this->version) return $this->version;
113  return $langs->trans("NotAvailable");
114  }
115 
124  function getToolTip($langs,$soc,$type)
125  {
126  global $conf;
127 
128  $langs->load("admin");
129 
130  $s='';
131  $s.=$langs->trans("Name").': <b>'.$this->name.'</b><br>';
132  $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
133  if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
134  $s.='<br>';
135  $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
136  if ($type == 0)
137  {
138  $s.=$langs->trans("RequiredIfProduct").': ';
139  if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
140  $s.=yn(!$this->code_null,1,2);
141  if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
142  $s.='<br>';
143  }
144  if ($type == 1)
145  {
146  $s.=$langs->trans("RequiredIfService").': ';
147  if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
148  $s.=yn(!$this->code_null,1,2);
149  if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
150  $s.='<br>';
151  }
152  if ($type == -1)
153  {
154  $s.=$langs->trans("Required").': ';
155  if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
156  $s.=yn(!$this->code_null,1,2);
157  if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
158  $s.='<br>';
159  }
160  /*$s.=$langs->trans("CanBeModifiedIfOk").': ';
161  $s.=yn($this->code_modifiable,1,2);
162  $s.='<br>';
163  $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
164  */
165  $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>';
166  $s.='<br>';
167 
168  $nextval=$this->getNextValue($soc,'');
169  if (empty($nextval)) $nextval=$langs->trans("Undefined");
170  $s.=$langs->trans("NextValue").': <b>'.$nextval.'</b><br>';
171 
172  return $s;
173  }
174 
175 }
176 
getToolTip($langs, $soc, $type)
Return description of module parameters.
Parent class for barcode numbering models.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
getNom($langs)
Return model name.
isEnabled()
Return if a model can be used or not.
info($langs)
Return default description of numbering model.
getNextValue($objproduct, $type='')
Return next value available.
getExample($langs)
Return a numbering example.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
getVersion()
Return version of module.
Parent class for barcode document models.