dolibarr 19.0.3
modules_product.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * or see https://www.gnu.org/
20 */
21
22
29require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
31
32
37{
38 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
46 public static function liste_modeles($dbs, $maxfilenamelength = 0)
47 {
48 // phpcs:enable
49 $type = 'product';
50 $list = array();
51
52 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
53 $list = getListOfModels($dbs, $type, $maxfilenamelength);
54 return $list;
55 }
56}
57
62{
66 public $code_auto;
67
71 public $code_modifiable;
72
73 public $code_modifiable_invalide; // Modified code if it is invalid
74
78 public $code_null;
79
80
88 public function getNextValue($objproduct = 0, $type = -1)
89 {
90 global $langs;
91 return $langs->trans("Function_getNextValue_InModuleNotWorking");
92 }
93
94 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
102 public static function liste_modeles($dbs, $maxfilenamelength = 0)
103 {
104 // phpcs:enable
105 $list = array();
106 $sql = "";
107
108 $resql = $dbs->query($sql);
109 if ($resql) {
110 $num = $dbs->num_rows($resql);
111 $i = 0;
112 while ($i < $num) {
113 $row = $dbs->fetch_row($resql);
114 $list[$row[0]] = $row[1];
115 $i++;
116 }
117 } else {
118 return -1;
119 }
120 return $list;
121 }
122
131 public function getToolTip($langs, $product, $type)
132 {
133 global $conf;
134
135 $langs->loadLangs(array("admin", "companies"));
136
137 $strikestart = '';
138 $strikeend = '';
139 if (getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
140 $strikestart = '<strike>';
141 $strikeend = '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
142 }
143 $s = '';
144 if ($type == -1) {
145 $s .= $langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
146 $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
147 } elseif ($type == 0) {
148 $s .= $langs->trans("ProductCodeDesc").'<br>';
149 } elseif ($type == 1) {
150 $s .= $langs->trans("ServiceCodeDesc").'<br>';
151 }
152 if ($type != -1) {
153 $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
154 }
155 $s .= '<br>';
156 $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
157 if ($type == 0) {
158 $s .= $langs->trans("RequiredIfProduct").': '.$strikestart;
159 $s .= yn(!$this->code_null, 1, 2).$strikeend;
160 $s .= '<br>';
161 } elseif ($type == 1) {
162 $s .= $langs->trans("RequiredIfService").': '.$strikestart;
163 $s .= yn(!$this->code_null, 1, 2).$strikeend;
164 $s .= '<br>';
165 } elseif ($type == -1) {
166 $s .= $langs->trans("Required").': '.$strikestart;
167 $s .= yn(!$this->code_null, 1, 2).$strikeend;
168 $s .= '<br>';
169 }
170 $s .= $langs->trans("CanBeModifiedIfOk").': ';
171 $s .= yn($this->code_modifiable, 1, 2);
172 $s .= '<br>';
173 $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
174 $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
175 $s .= '<br>';
176 if ($type == 0 || $type == -1) {
177 $nextval = $this->getNextValue($product, 0);
178 if (empty($nextval)) {
179 $nextval = $langs->trans("Undefined");
180 }
181 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Product").')' : '').': <b>'.$nextval.'</b><br>';
182 }
183 if ($type == 1 || $type == -1) {
184 $nextval = $this->getNextValue($product, 1);
185 if (empty($nextval)) {
186 $nextval = $langs->trans("Undefined");
187 }
188 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Service").')' : '').': <b>'.$nextval.'</b>';
189 }
190 return $s;
191 }
192
193 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
199 public function verif_prefixIsUsed()
200 {
201 // phpcs:enable
202 return 0;
203 }
204}
Parent class for documents (PDF, ODT, ...) generators.
Parent class for number ref generators.
getVersion()
Returns version of numbering module.
getNom($langs)
Return model name TODO Replace with getName()
Parent class to manage intervention document templates.
static liste_modeles($dbs, $maxfilenamelength=0)
Return list of active generation modules.
Class template for classes of numbering product.
verif_prefixIsUsed()
Check if mask/numbering use prefix.
getNextValue($objproduct=0, $type=-1)
Return next value available.
getToolTip($langs, $product, $type)
Return description of module parameters.
static liste_modeles($dbs, $maxfilenamelength=0)
Renvoi la liste des modeles de numérotation.
getListOfModels($db, $type, $maxfilenamelength=0)
Return list of activated modules usable for document generation.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.