dolibarr 25.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
26require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
27
28
34abstract class ModeleBarCode
35{
39 public $error = '';
40
41
47 public function isEnabled()
48 {
49 return true;
50 }
51
52
59 abstract public function info($langs);
60
61
72 public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0)
73 {
74 return -1; // Error by default, this method must be implemented by the driver
75 }
76
87 public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0)
88 {
89 return 1;
90 }
91
98 abstract public function encodingIsSupported($encoding);
99}
100
101
108{
109 // variables inherited from CommonNumRefGenerator
113 public $code_null;
114
115
123 public function getNextValue($objcommon = null, $type = '')
124 {
125 global $langs;
126 return $langs->trans("Function_getNextValue_InModuleNotWorking");
127 }
128
129
137 abstract public function getExample($langs = null, $object = null);
138
139
148 public function getToolTip($langs, $soc, $type)
149 {
150 $langs->loadLangs(array("admin", "companies"));
151
152 $s = '';
153 $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>';
154 $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
155 if ($type != -1) {
156 $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getName($langs).'</b><br>';
157 }
158 $s .= '<br>';
159 $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
160 if ($type == 0) {
161 $s .= $langs->trans("RequiredIfProduct").': ';
162 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
163 $s .= '<strike>';
164 }
165 $s .= yn($this->code_null ? 0 : 1, 1, 2);
166 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
167 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
168 }
169 $s .= '<br>';
170 }
171 if ($type == 1) {
172 $s .= $langs->trans("RequiredIfService").': ';
173 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
174 $s .= '<strike>';
175 }
176 $s .= yn($this->code_null ? 0 : 1, 1, 2);
177 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
178 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
179 }
180 $s .= '<br>';
181 }
182 if ($type == -1) {
183 $s .= $langs->trans("Required").': ';
184 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
185 $s .= '<strike>';
186 }
187 $s .= yn($this->code_null ? 0 : 1, 1, 2);
188 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
189 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
190 }
191 $s .= '<br>';
192 }
193 /*$s.=$langs->trans("CanBeModifiedIfOk").': ';
194 $s.=yn($this->code_modifiable,1,2);
195 $s.='<br>';
196 $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
197 */
198 $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
199 $s .= '<br>';
200
201 $nextval = $this->getNextValue($soc, '');
202 if (empty($nextval)) {
203 $nextval = $langs->trans("Undefined");
204 }
205 $s .= $langs->trans("NextValue").': <b>'.$nextval.'</b><br>';
206
207 return $s;
208 }
209
210
226 abstract public function verif($db, &$code, $object, $thirdparty_type, $type);
227}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Parent class for number ref generators.
getVersion()
Returns version of numbering module.
getName($langs)
Return model name.
isEnabled()
Return if a model can be used or not.
writeBarCode($code, $encoding, $readable='Y', $scale=1, $nooutputiferror=0)
Save an image file on disk (with no output)
buildBarCode($code, $encoding, $readable='Y', $scale=1, $nooutputiferror=0)
Return an image file on the fly (no need to write on disk) with the HTTP content-type of image.
info($langs)
Return description.
encodingIsSupported($encoding)
Return true if encoding is supported.
verif($db, &$code, $object, $thirdparty_type, $type)
Check validity of code according to its rules.
getToolTip($langs, $soc, $type)
Return description of module parameters.
getNextValue($objcommon=null, $type='')
Return next value available.
getExample($langs=null, $object=null)
Return an example of result returned by getNextValue.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133