dolibarr 21.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 * 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/lib/functions.lib.php';
27require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
28
29
35abstract class ModeleBarCode
36{
40 public $error = '';
41
42
48 public function isEnabled()
49 {
50 return true;
51 }
52
53
60 abstract public function info($langs);
61
62
73 public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0)
74 {
75 return -1; // Error by default, this method must be implemented by the driver
76 }
77
84 abstract public function encodingIsSupported($encoding);
85}
86
87
94{
95 // variables inherited from CommonNumRefGenerator
99 public $code_null;
100
101
109 public function getNextValue($objcommon = null, $type = '')
110 {
111 global $langs;
112 return $langs->trans("Function_getNextValue_InModuleNotWorking");
113 }
114
115
123 abstract public function getExample($langs = null, $object = null);
124
125
134 public function getToolTip($langs, $soc, $type)
135 {
136 $langs->loadLangs(array("admin", "companies"));
137
138 $s = '';
139 $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>';
140 $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
141 if ($type != -1) {
142 $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getName($langs).'</b><br>';
143 }
144 $s .= '<br>';
145 $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
146 if ($type == 0) {
147 $s .= $langs->trans("RequiredIfProduct").': ';
148 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
149 $s .= '<strike>';
150 }
151 $s .= yn($this->code_null ? 0 : 1, 1, 2);
152 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
153 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
154 }
155 $s .= '<br>';
156 }
157 if ($type == 1) {
158 $s .= $langs->trans("RequiredIfService").': ';
159 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
160 $s .= '<strike>';
161 }
162 $s .= yn($this->code_null ? 0 : 1, 1, 2);
163 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
164 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
165 }
166 $s .= '<br>';
167 }
168 if ($type == -1) {
169 $s .= $langs->trans("Required").': ';
170 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
171 $s .= '<strike>';
172 }
173 $s .= yn($this->code_null ? 0 : 1, 1, 2);
174 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
175 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
176 }
177 $s .= '<br>';
178 }
179 /*$s.=$langs->trans("CanBeModifiedIfOk").': ';
180 $s.=yn($this->code_modifiable,1,2);
181 $s.='<br>';
182 $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
183 */
184 $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
185 $s .= '<br>';
186
187 $nextval = $this->getNextValue($soc, '');
188 if (empty($nextval)) {
189 $nextval = $langs->trans("Undefined");
190 }
191 $s .= $langs->trans("NextValue").': <b>'.$nextval.'</b><br>';
192
193 return $s;
194 }
195
196
212 abstract public function verif($db, &$code, $object, $thirdparty_type, $type);
213}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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)
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.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:152