dolibarr 20.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 * 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
33abstract class ModeleBarCode
34{
38 public $error = '';
39
40
46 public function isEnabled()
47 {
48 return true;
49 }
50
61 public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0)
62 {
63 return -1; // Error by default, this method must be implemented by the driver
64 }
65}
66
67
72{
73 // variables inherited from CommonNumRefGenerator
74 public $code_null;
75
76
84 public function getNextValue($objcommon = null, $type = '')
85 {
86 global $langs;
87 return $langs->trans("Function_getNextValue_InModuleNotWorking");
88 }
89
98 public function getToolTip($langs, $soc, $type)
99 {
100 $langs->loadLangs(array("admin", "companies"));
101
102 $s = '';
103 $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>';
104 $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
105 if ($type != -1) {
106 $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getName($langs).'</b><br>';
107 }
108 $s .= '<br>';
109 $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
110 if ($type == 0) {
111 $s .= $langs->trans("RequiredIfProduct").': ';
112 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
113 $s .= '<strike>';
114 }
115 $s .= yn(!$this->code_null, 1, 2);
116 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
117 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
118 }
119 $s .= '<br>';
120 }
121 if ($type == 1) {
122 $s .= $langs->trans("RequiredIfService").': ';
123 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
124 $s .= '<strike>';
125 }
126 $s .= yn(!$this->code_null, 1, 2);
127 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
128 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
129 }
130 $s .= '<br>';
131 }
132 if ($type == -1) {
133 $s .= $langs->trans("Required").': ';
134 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
135 $s .= '<strike>';
136 }
137 $s .= yn(!$this->code_null, 1, 2);
138 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
139 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
140 }
141 $s .= '<br>';
142 }
143 /*$s.=$langs->trans("CanBeModifiedIfOk").': ';
144 $s.=yn($this->code_modifiable,1,2);
145 $s.='<br>';
146 $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
147 */
148 $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
149 $s .= '<br>';
150
151 $nextval = $this->getNextValue($soc, '');
152 if (empty($nextval)) {
153 $nextval = $langs->trans("Undefined");
154 }
155 $s .= $langs->trans("NextValue").': <b>'.$nextval.'</b><br>';
156
157 return $s;
158 }
159}
Parent class for number ref generators.
getVersion()
Returns version of numbering module.
getName($langs)
Return model name.
Parent class for barcode document generators (image)
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)
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:140