dolibarr 19.0.4
modules_societe.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
27require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
28require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
29
30
35{
36 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
44 public static function liste_modeles($dbs, $maxfilenamelength = 0)
45 {
46 // phpcs:enable
47 $type = 'company';
48 $list = array();
49
50 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
51 $list = getListOfModels($dbs, $type, $maxfilenamelength);
52
53 return $list;
54 }
55}
56
61{
65 public $code_auto;
66
70 public $code_modifiable;
71
72 public $code_modifiable_invalide; // Modified code if it is invalid
73
77 public $code_null;
78
79
87 public function getNextValue($objsoc = 0, $type = -1)
88 {
89 global $langs;
90 return $langs->trans("Function_getNextValue_InModuleNotWorking");
91 }
92
93 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
101 public static function liste_modeles($dbs, $maxfilenamelength = 0)
102 {
103 // phpcs:enable
104 $list = array();
105 $sql = "";
106
107 $resql = $dbs->query($sql);
108 if ($resql) {
109 $num = $dbs->num_rows($resql);
110 $i = 0;
111 while ($i < $num) {
112 $row = $dbs->fetch_row($resql);
113 $list[$row[0]] = $row[1];
114 $i++;
115 }
116 } else {
117 return -1;
118 }
119 return $list;
120 }
121
130 public function getToolTip($langs, $soc, $type)
131 {
132 global $conf;
133
134 $langs->loadLangs(array("admin", "companies"));
135
136 $strikestart = '';
137 $strikeend = '';
138 if (getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
139 $strikestart = '<strike>';
140 $strikeend = '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
141 }
142
143 $s = '';
144 if ($type == -1) {
145 $s .= $langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
146 } elseif ($type == -1) {
147 $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
148 } elseif ($type == 0) {
149 $s .= $langs->trans("CustomerCodeDesc").'<br>';
150 } elseif ($type == 1) {
151 $s .= $langs->trans("SupplierCodeDesc").'<br>';
152 }
153 if ($type != -1) {
154 $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
155 }
156 $s .= '<br>';
157 $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
158 if ($type == 0) {
159 $s .= $langs->trans("RequiredIfCustomer").': '.$strikestart;
160 $s .= yn(!$this->code_null, 1, 2).$strikeend;
161 $s .= '<br>';
162 } elseif ($type == 1) {
163 $s .= $langs->trans("RequiredIfSupplier").': '.$strikestart;
164 $s .= yn(!$this->code_null, 1, 2).$strikeend;
165 $s .= '<br>';
166 } elseif ($type == -1) {
167 $s .= $langs->trans("Required").': '.$strikestart;
168 $s .= yn(!$this->code_null, 1, 2).$strikeend;
169 $s .= '<br>';
170 }
171 $s .= $langs->trans("CanBeModifiedIfOk").': ';
172 $s .= yn($this->code_modifiable, 1, 2);
173 $s .= '<br>';
174 $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
175 $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
176 $s .= '<br>';
177 if ($type == 0 || $type == -1) {
178 $nextval = $this->getNextValue($soc, 0);
179 if (empty($nextval)) {
180 $nextval = $langs->trans("Undefined");
181 }
182 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
183 }
184 if ($type == 1 || $type == -1) {
185 $nextval = $this->getNextValue($soc, 1);
186 if (empty($nextval)) {
187 $nextval = $langs->trans("Undefined");
188 }
189 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
190 }
191 return $s;
192 }
193
194 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
200 public function verif_prefixIsUsed()
201 {
202 // phpcs:enable
203 return 0;
204 }
205}
206
207
212{
216 public $code;
217
226 public function getToolTip($langs, $soc, $type)
227 {
228 global $db;
229
230 $langs->load("admin");
231
232 $s = '';
233 if ($type == -1) {
234 $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>';
235 $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
236 }
237 //$s.='<br>';
238 //$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
239 $s .= '<br>';
240 if ($type == 0 || $type == -1) {
241 $result = $this->get_code($db, $soc, 'customer');
242 $nextval = $this->code;
243 if (empty($nextval)) {
244 $nextval = $langs->trans("Undefined");
245 }
246 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
247 }
248 if ($type == 1 || $type == -1) {
249 $result = $this->get_code($db, $soc, 'supplier');
250 $nextval = $this->code;
251 if (empty($nextval)) {
252 $nextval = $langs->trans("Undefined");
253 }
254 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
255 }
256 return $s;
257 }
258
259 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
268 public function get_code($db, $societe, $type = '')
269 {
270 // phpcs:enable
271 global $langs;
272
273 return $langs->trans("NotAvailable");
274 }
275}
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 for third parties accountancy code generators.
getToolTip($langs, $soc, $type)
Return description of module parameters.
get_code($db, $societe, $type='')
Set accountancy account code for a third party into this->code.
Parent class for third parties code generators.
verif_prefixIsUsed()
Check if mask/numbering use prefix.
getNextValue($objsoc=0, $type=-1)
Return next value available.
static liste_modeles($dbs, $maxfilenamelength=0)
Renvoie la liste des modeles de numérotation.
getToolTip($langs, $soc, $type)
Return description of module parameters.
Parent class for third parties models of doc generators.
static liste_modeles($dbs, $maxfilenamelength=0)
Return list of active generation modules.
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.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:124