dolibarr 19.0.3
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';
25require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
26
27
31abstract class ModeleBarCode
32{
36 public $error = '';
37
38
44 public function isEnabled()
45 {
46 return true;
47 }
48}
49
50
55{
59 public $code_null;
60
64 public $code_auto;
65
66
74 public function getNextValue($objproduct, $type = '')
75 {
76 global $langs;
77 return $langs->trans("Function_getNextValue_InModuleNotWorking");
78 }
79
88 public function getToolTip($langs, $soc, $type)
89 {
90 global $conf;
91
92 $langs->loadLangs(array("admin", "companies"));
93
94 $s = '';
95 $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>';
96 $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
97 if ($type != -1) {
98 $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
99 }
100 $s .= '<br>';
101 $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
102 if ($type == 0) {
103 $s .= $langs->trans("RequiredIfProduct").': ';
104 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
105 $s .= '<strike>';
106 }
107 $s .= yn(!$this->code_null, 1, 2);
108 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
109 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
110 }
111 $s .= '<br>';
112 }
113 if ($type == 1) {
114 $s .= $langs->trans("RequiredIfService").': ';
115 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
116 $s .= '<strike>';
117 }
118 $s .= yn(!$this->code_null, 1, 2);
119 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
120 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
121 }
122 $s .= '<br>';
123 }
124 if ($type == -1) {
125 $s .= $langs->trans("Required").': ';
126 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
127 $s .= '<strike>';
128 }
129 $s .= yn(!$this->code_null, 1, 2);
130 if (getDolGlobalString('MAIN_BARCODE_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
131 $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
132 }
133 $s .= '<br>';
134 }
135 /*$s.=$langs->trans("CanBeModifiedIfOk").': ';
136 $s.=yn($this->code_modifiable,1,2);
137 $s.='<br>';
138 $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
139 */
140 $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
141 $s .= '<br>';
142
143 $nextval = $this->getNextValue($soc, '');
144 if (empty($nextval)) {
145 $nextval = $langs->trans("Undefined");
146 }
147 $s .= $langs->trans("NextValue").': <b>'.$nextval.'</b><br>';
148
149 return $s;
150 }
151}
Parent class for number ref generators.
getVersion()
Returns version of numbering module.
getNom($langs)
Return model name TODO Replace with getName()
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($objproduct, $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:124