dolibarr  20.0.0-alpha
modules_barcode.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4  * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  * or see https://www.gnu.org/
19  */
20 
26 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
28 
29 
33 abstract class ModeleBarCode
34 {
38  public $error = '';
39 
40 
46  public function isEnabled()
47  {
48  return true;
49  }
50 }
51 
52 
57 {
58  // variables inherited from CommonNumRefGenerator
59  public $code_null;
60 
61 
69  public function getNextValue($objcommon = null, $type = '')
70  {
71  global $langs;
72  return $langs->trans("Function_getNextValue_InModuleNotWorking");
73  }
74 
83  public function getToolTip($langs, $soc, $type)
84  {
85  global $conf;
86 
87  $langs->loadLangs(array("admin", "companies"));
88 
89  $s = '';
90  $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>';
91  $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
92  if ($type != -1) {
93  $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getName($langs).'</b><br>';
94  }
95  $s .= '<br>';
96  $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
97  if ($type == 0) {
98  $s .= $langs->trans("RequiredIfProduct").': ';
99  if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
100  $s .= '<strike>';
101  }
102  $s .= yn(!$this->code_null, 1, 2);
103  if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
104  $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
105  }
106  $s .= '<br>';
107  }
108  if ($type == 1) {
109  $s .= $langs->trans("RequiredIfService").': ';
110  if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
111  $s .= '<strike>';
112  }
113  $s .= yn(!$this->code_null, 1, 2);
114  if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
115  $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
116  }
117  $s .= '<br>';
118  }
119  if ($type == -1) {
120  $s .= $langs->trans("Required").': ';
121  if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
122  $s .= '<strike>';
123  }
124  $s .= yn(!$this->code_null, 1, 2);
125  if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
126  $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
127  }
128  $s .= '<br>';
129  }
130  /*$s.=$langs->trans("CanBeModifiedIfOk").': ';
131  $s.=yn($this->code_modifiable,1,2);
132  $s.='<br>';
133  $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
134  */
135  $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
136  $s .= '<br>';
137 
138  $nextval = $this->getNextValue($soc, '');
139  if (empty($nextval)) {
140  $nextval = $langs->trans("Undefined");
141  }
142  $s .= $langs->trans("NextValue").': <b>'.$nextval.'</b><br>';
143 
144  return $s;
145  }
146 }
Parent class for number ref generators.
getVersion()
Returns version of numbering module.
getName($langs)
Return model name.
Parent class for barcode document models.
isEnabled()
Return if a model can be used or not.
Parent class for barcode numbering models.
getToolTip($langs, $soc, $type)
Return description of module parameters.
getNextValue($objcommon=null, $type='')
Return next value available.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:125