dolibarr 21.0.0-alpha
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 * or see https://www.gnu.org/
22 */
23
24
31require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
33
34
39{
40 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
48 public static function liste_modeles($dbs, $maxfilenamelength = 0)
49 {
50 // phpcs:enable
51 $type = 'product';
52 $list = array();
53
54 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
55 $list = getListOfModels($dbs, $type, $maxfilenamelength);
56 return $list;
57 }
58}
59
64{
72 public function getNextValue($objproduct = '', $type = -1)
73 {
74 global $langs;
75 return $langs->trans("Function_getNextValue_InModuleNotWorking");
76 }
77
78 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
86 public static function liste_modeles($dbs, $maxfilenamelength = 0)
87 {
88 // phpcs:enable
89 $list = array();
90 $sql = "";
91
92 $resql = $dbs->query($sql);
93 if ($resql) {
94 $num = $dbs->num_rows($resql);
95 $i = 0;
96 while ($i < $num) {
97 $row = $dbs->fetch_row($resql);
98 $list[$row[0]] = $row[1];
99 $i++;
100 }
101 } else {
102 return -1;
103 }
104 return $list;
105 }
106
115 public function getToolTip($langs, $product, $type)
116 {
117 global $conf;
118
119 $langs->loadLangs(array("admin", "companies"));
120
121 $strikestart = '';
122 $strikeend = '';
123 if (getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
124 $strikestart = '<strike>';
125 $strikeend = '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
126 }
127 $s = '';
128 if ($type == -1) {
129 $s .= $langs->trans("Name").': <b>'.$this->getName($langs).'</b><br>';
130 $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
131 } elseif ($type == 0) {
132 $s .= $langs->trans("ProductCodeDesc").'<br>';
133 } elseif ($type == 1) {
134 $s .= $langs->trans("ServiceCodeDesc").'<br>';
135 }
136 if ($type != -1) {
137 $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getName($langs).'</b><br>';
138 }
139 $s .= '<br>';
140 $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
141 if ($type == 0) {
142 $s .= $langs->trans("RequiredIfProduct").': '.$strikestart;
143 $s .= yn(!$this->code_null, 1, 2).$strikeend;
144 $s .= '<br>';
145 } elseif ($type == 1) {
146 $s .= $langs->trans("RequiredIfService").': '.$strikestart;
147 $s .= yn(!$this->code_null, 1, 2).$strikeend;
148 $s .= '<br>';
149 } elseif ($type == -1) {
150 $s .= $langs->trans("Required").': '.$strikestart;
151 $s .= yn(!$this->code_null, 1, 2).$strikeend;
152 $s .= '<br>';
153 }
154 $s .= $langs->trans("CanBeModifiedIfOk").': ';
155 $s .= yn($this->code_modifiable, 1, 2);
156 $s .= '<br>';
157 $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
158 $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
159 $s .= '<br>';
160 if ($type == 0 || $type == -1) {
161 $nextval = $this->getNextValue($product, 0);
162 if (empty($nextval)) {
163 $nextval = $langs->trans("Undefined");
164 }
165 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Product").')' : '').': <b>'.$nextval.'</b><br>';
166 }
167 if ($type == 1 || $type == -1) {
168 $nextval = $this->getNextValue($product, 1);
169 if (empty($nextval)) {
170 $nextval = $langs->trans("Undefined");
171 }
172 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Service").')' : '').': <b>'.$nextval.'</b>';
173 }
174 return $s;
175 }
176
177 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
183 public function verif_prefixIsUsed()
184 {
185 // phpcs:enable
186 return 0;
187 }
188}
Parent class for documents (PDF, ODT, ...) generators.
Parent class for number ref generators.
getVersion()
Returns version of numbering module.
getName($langs)
Return model name.
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.
getNextValue($objproduct='', $type=-1)
Return next value available.
verif_prefixIsUsed()
Check if mask/numbering use prefix.
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.