dolibarr  9.0.0
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 {
35  public $error='';
36 
37 
43  function isEnabled()
44  {
45  return true;
46  }
47 }
48 
49 
53 abstract class ModeleNumRefBarCode
54 {
58  public $error='';
59 
65  function info($langs)
66  {
67  $langs->load("bills");
68  return $langs->trans("NoDescription");
69  }
70 
76  function getNom($langs)
77  {
78  return empty($this->name)?$this->nom:$this->name;
79  }
80 
86  function getExample($langs)
87  {
88  $langs->load("bills");
89  return $langs->trans("NoExample");
90  }
91 
99  function getNextValue($objproduct,$type='')
100  {
101  global $langs;
102  return $langs->trans("Function_getNextValue_InModuleNotWorking");
103  }
104 
109  function getVersion()
110  {
111  global $langs;
112  $langs->load("admin");
113 
114  if ($this->version == 'development') return $langs->trans("VersionDevelopment");
115  if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
116  if ($this->version == 'dolibarr') return DOL_VERSION;
117  if ($this->version) return $this->version;
118  return $langs->trans("NotAvailable");
119  }
120 
129  function getToolTip($langs,$soc,$type)
130  {
131  global $conf;
132 
133  $langs->load("admin");
134 
135  $s='';
136  $s.=$langs->trans("Name").': <b>'.$this->name.'</b><br>';
137  $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
138  if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
139  $s.='<br>';
140  $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
141  if ($type == 0)
142  {
143  $s.=$langs->trans("RequiredIfProduct").': ';
144  if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
145  $s.=yn(!$this->code_null,1,2);
146  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")).')';
147  $s.='<br>';
148  }
149  if ($type == 1)
150  {
151  $s.=$langs->trans("RequiredIfService").': ';
152  if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
153  $s.=yn(!$this->code_null,1,2);
154  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")).')';
155  $s.='<br>';
156  }
157  if ($type == -1)
158  {
159  $s.=$langs->trans("Required").': ';
160  if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
161  $s.=yn(!$this->code_null,1,2);
162  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")).')';
163  $s.='<br>';
164  }
165  /*$s.=$langs->trans("CanBeModifiedIfOk").': ';
166  $s.=yn($this->code_modifiable,1,2);
167  $s.='<br>';
168  $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
169  */
170  $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>';
171  $s.='<br>';
172 
173  $nextval=$this->getNextValue($soc,'');
174  if (empty($nextval)) $nextval=$langs->trans("Undefined");
175  $s.=$langs->trans("NextValue").': <b>'.$nextval.'</b><br>';
176 
177  return $s;
178  }
179 }
180 
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.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:103
isEnabled()
Return if a model can be used or not.
info($langs)
Return default description of numbering model.
if(! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'] s nom
Definition: list.php:573
getNextValue($objproduct, $type='')
Return next value available.
getExample($langs)
Return a numbering example.
getVersion()
Return version of module.
Parent class for barcode document models.