dolibarr 18.0.6
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 <https://www.gnu.org/licenses/>.
16 * or see https://www.gnu.org/
17 */
18
24require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
25
26
30abstract class ModeleBarCode
31{
35 public $error = '';
36
37
43 public function isEnabled()
44 {
45 return true;
46 }
47}
48
49
53abstract class ModeleNumRefBarCode
54{
58 public $error = '';
59
65 public function info($langs)
66 {
67 $langs->load("bills");
68 return $langs->trans("NoDescription");
69 }
70
76 public function getNom($langs)
77 {
78 return empty($this->name) ? get_class($this) : $this->name;
79 }
80
86 public function getExample($langs)
87 {
88 $langs->load("bills");
89 return $langs->trans("NoExample");
90 }
91
99 public function getNextValue($objproduct, $type = '')
100 {
101 global $langs;
102 return $langs->trans("Function_getNextValue_InModuleNotWorking");
103 }
104
109 public function getVersion()
110 {
111 global $langs;
112 $langs->load("admin");
113
114 if ($this->version == 'development') {
115 return $langs->trans("VersionDevelopment");
116 }
117 if ($this->version == 'experimental') {
118 return $langs->trans("VersionExperimental");
119 }
120 if ($this->version == 'dolibarr') {
121 return DOL_VERSION;
122 }
123 if ($this->version) {
124 return $this->version;
125 }
126 return $langs->trans("NotAvailable");
127 }
128
137 public function getToolTip($langs, $soc, $type)
138 {
139 global $conf;
140
141 $langs->loadLangs(array("admin", "companies"));
142
143 $s = '';
144 $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>';
145 $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
146 if ($type != -1) {
147 $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
148 }
149 $s .= '<br>';
150 $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
151 if ($type == 0) {
152 $s .= $langs->trans("RequiredIfProduct").': ';
153 if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) {
154 $s .= '<strike>';
155 }
156 $s .= yn(!$this->code_null, 1, 2);
157 if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) {
158 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
159 }
160 $s .= '<br>';
161 }
162 if ($type == 1) {
163 $s .= $langs->trans("RequiredIfService").': ';
164 if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) {
165 $s .= '<strike>';
166 }
167 $s .= yn(!$this->code_null, 1, 2);
168 if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) {
169 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
170 }
171 $s .= '<br>';
172 }
173 if ($type == -1) {
174 $s .= $langs->trans("Required").': ';
175 if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) {
176 $s .= '<strike>';
177 }
178 $s .= yn(!$this->code_null, 1, 2);
179 if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) {
180 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
181 }
182 $s .= '<br>';
183 }
184 /*$s.=$langs->trans("CanBeModifiedIfOk").': ';
185 $s.=yn($this->code_modifiable,1,2);
186 $s.='<br>';
187 $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
188 */
189 $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
190 $s .= '<br>';
191
192 $nextval = $this->getNextValue($soc, '');
193 if (empty($nextval)) {
194 $nextval = $langs->trans("Undefined");
195 }
196 $s .= $langs->trans("NextValue").': <b>'.$nextval.'</b><br>';
197
198 return $s;
199 }
200}
Parent class for barcode document models.
isEnabled()
Return if a model can be used or not.
Parent class for barcode numbering models.
getVersion()
Return version of module.
getExample($langs)
Return a numbering example.
info($langs)
Return default description of numbering model.
getToolTip($langs, $soc, $type)
Return description of module parameters.
getNextValue($objproduct, $type='')
Return next value available.
getNom($langs)
Return model name.
yn($yesno, $case=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:123