dolibarr 21.0.0-beta
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($db, $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($db, $type, $maxfilenamelength);
56 return $list;
57 }
58
59
60 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
72 abstract public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0);
73}
74
75
80{
88 public function getNextValue($objproduct = '', $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 $langs->loadLangs(array("admin", "companies"));
134
135 $strikestart = '';
136 $strikeend = '';
137 if (getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
138 $strikestart = '<strike>';
139 $strikeend = '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
140 }
141 $s = '';
142 if ($type == -1) {
143 $s .= $langs->trans("Name").': <b>'.$this->getName($langs).'</b><br>';
144 $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
145 } elseif ($type == 0) {
146 $s .= $langs->trans("ProductCodeDesc").'<br>';
147 } elseif ($type == 1) {
148 $s .= $langs->trans("ServiceCodeDesc").'<br>';
149 }
150 if ($type != -1) {
151 $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getName($langs).'</b><br>';
152 }
153 $s .= '<br>';
154 $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
155 if ($type == 0) {
156 $s .= $langs->trans("RequiredIfProduct").': '.$strikestart;
157 $s .= yn($this->code_null ? 0 : 1, 1, 2).$strikeend;
158 $s .= '<br>';
159 } elseif ($type == 1) {
160 $s .= $langs->trans("RequiredIfService").': '.$strikestart;
161 $s .= yn($this->code_null ? 0 : 1, 1, 2).$strikeend;
162 $s .= '<br>';
163 } elseif ($type == -1) {
164 $s .= $langs->trans("Required").': '.$strikestart;
165 $s .= yn($this->code_null ? 0 : 1, 1, 2).$strikeend;
166 $s .= '<br>';
167 }
168 $s .= $langs->trans("CanBeModifiedIfOk").': ';
169 $s .= yn($this->code_modifiable, 1, 2);
170 $s .= '<br>';
171 $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
172 $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
173 $s .= '<br>';
174 if ($type == 0 || $type == -1) {
175 $nextval = $this->getNextValue($product, 0);
176 if (empty($nextval)) {
177 $nextval = $langs->trans("Undefined");
178 }
179 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Product").')' : '').': <b>'.$nextval.'</b><br>';
180 }
181 if ($type == 1 || $type == -1) {
182 $nextval = $this->getNextValue($product, 1);
183 if (empty($nextval)) {
184 $nextval = $langs->trans("Undefined");
185 }
186 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Service").')' : '').': <b>'.$nextval.'</b>';
187 }
188 return $s;
189 }
190
191 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
197 public function verif_prefixIsUsed()
198 {
199 // phpcs:enable
200 return 0;
201 }
202
203
212 public function getExample($langs = null, $objproduct = '', $type = -1)
213 {
214 return '';
215 }
216}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build document.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class template for classes of numbering product.
getExample($langs=null, $objproduct='', $type=-1)
Return an example of result returned by getNextValue.
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, $format=1, $color=0)
Return yes or no in current language.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.