dolibarr 21.0.0-alpha
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 * 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
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($db, $maxfilenamelength = 0)
47 {
48 // phpcs:enable
49 $type = 'company';
50 $list = array();
51
52 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
53 $list = getListOfModels($db, $type, $maxfilenamelength);
54
55 return $list;
56 }
57
58
59 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
71 abstract public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0);
72 // phpcs:enable
73}
74
79{
85 abstract public function __construct($db);
86
87
96 //abstract public function getExample($langs = null, $objsoc = '', $type = -1);
97
98
106 public function getNextValue($objsoc = '', $type = -1)
107 {
108 global $langs;
109 return $langs->trans("Function_getNextValue_InModuleNotWorking");
110 }
111
112
113 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
121 public static function liste_modeles($dbs, $maxfilenamelength = 0)
122 {
123 // phpcs:enable
124 $list = array();
125 $sql = "";
126
127 $resql = $dbs->query($sql);
128 if ($resql) {
129 $num = $dbs->num_rows($resql);
130 $i = 0;
131 while ($i < $num) {
132 $row = $dbs->fetch_row($resql);
133 $list[$row[0]] = $row[1];
134 $i++;
135 }
136 } else {
137 return -1;
138 }
139 return $list;
140 }
141
142
151 public function getToolTip($langs, $soc, $type)
152 {
153 $langs->loadLangs(array("admin", "companies"));
154
155 $strikestart = '';
156 $strikeend = '';
157 if (getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
158 $strikestart = '<strike>';
159 $strikeend = '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
160 }
161
162 $s = '';
163 if ($type == -1) {
164 $s .= $langs->trans("Name").': <b>'.$this->getName($langs).'</b><br>';
165 } elseif ($type == 0) {
166 $s .= $langs->trans("CustomerCodeDesc").'<br>';
167 } elseif ($type == 1) {
168 $s .= $langs->trans("SupplierCodeDesc").'<br>';
169 }
170 if ($type != -1) {
171 $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getName($langs).'</b><br>';
172 }
173 $s .= '<br>';
174 $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
175 if ($type == 0) {
176 $s .= $langs->trans("RequiredIfCustomer").': '.$strikestart;
177 $s .= yn($this->code_null ? 0 : 1, 1, 2).$strikeend;
178 $s .= '<br>';
179 } elseif ($type == 1) {
180 $s .= $langs->trans("RequiredIfSupplier").': '.$strikestart;
181 $s .= yn($this->code_null ? 0 : 1, 1, 2).$strikeend;
182 $s .= '<br>';
183 } elseif ($type == -1) {
184 $s .= $langs->trans("Required").': '.$strikestart;
185 $s .= yn($this->code_null ? 0 : 1, 1, 2).$strikeend;
186 $s .= '<br>';
187 }
188 $s .= $langs->trans("CanBeModifiedIfOk").': ';
189 $s .= yn($this->code_modifiable, 1, 2);
190 $s .= '<br>';
191 $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
192 $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
193 $s .= '<br>';
194 if ($type == 0 || $type == -1) {
195 $nextval = $this->getNextValue($soc, 0);
196 if (empty($nextval)) {
197 $nextval = $langs->trans("Undefined");
198 }
199 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
200 }
201 if ($type == 1 || $type == -1) {
202 $nextval = $this->getNextValue($soc, 1);
203 if (empty($nextval)) {
204 $nextval = $langs->trans("Undefined");
205 }
206 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
207 }
208 return $s;
209 }
210
211 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
217 public function verif_prefixIsUsed()
218 {
219 // phpcs:enable
220 return 0;
221 }
222
238 abstract public function verif($db, &$code, $soc, $type);
239}
240
241
246{
250 public $code;
251
260 public function getToolTip($langs, $soc, $type)
261 {
262 global $db;
263
264 $langs->load("admin");
265
266 $s = '';
267 if ($type == -1) {
268 $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>';
269 $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
270 }
271 //$s.='<br>';
272 //$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
273 $s .= '<br>';
274 if ($type == 0 || $type == -1) {
275 $result = $this->get_code($db, $soc, 'customer');
276 $nextval = $this->code;
277 if (empty($nextval)) {
278 $nextval = $langs->trans("Undefined");
279 }
280 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
281 }
282 if ($type == 1 || $type == -1) {
283 $result = $this->get_code($db, $soc, 'supplier');
284 $nextval = $this->code;
285 if (empty($nextval)) {
286 $nextval = $langs->trans("Undefined");
287 }
288 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
289 }
290 return $s;
291 }
292
293 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
302 public function get_code($db, $societe, $type = '')
303 {
304 // phpcs:enable
305 global $langs;
306
307 dol_syslog(get_class($this)."::get_code".$langs->trans("NotAvailable"), LOG_ERR);
308 return -1;
309 }
310}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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 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.
verif($db, &$code, $soc, $type)
Check validity of code according to its rules.
__construct($db)
Constructor.
getNextValue($objsoc='', $type=-1)
Return an example of result returned by getNextValue.
static liste_modeles($dbs, $maxfilenamelength=0)
Return list of active generation modules.
getToolTip($langs, $soc, $type)
Return description of module parameters.
Parent class for third parties models of doc generators.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build a document on disk using the generic odt module.
static liste_modeles($db, $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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140