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($dbs, $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($dbs, $type, $maxfilenamelength);
54
55 return $list;
56 }
57}
58
63{
69 abstract public function __construct($db);
70
71
79 public function getNextValue($objsoc = '', $type = -1)
80 {
81 global $langs;
82 return $langs->trans("Function_getNextValue_InModuleNotWorking");
83 }
84
85
86 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
94 public static function liste_modeles($dbs, $maxfilenamelength = 0)
95 {
96 // phpcs:enable
97 $list = array();
98 $sql = "";
99
100 $resql = $dbs->query($sql);
101 if ($resql) {
102 $num = $dbs->num_rows($resql);
103 $i = 0;
104 while ($i < $num) {
105 $row = $dbs->fetch_row($resql);
106 $list[$row[0]] = $row[1];
107 $i++;
108 }
109 } else {
110 return -1;
111 }
112 return $list;
113 }
114
115
124 public function getToolTip($langs, $soc, $type)
125 {
126 global $conf;
127
128 $langs->loadLangs(array("admin", "companies"));
129
130 $strikestart = '';
131 $strikeend = '';
132 if (getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
133 $strikestart = '<strike>';
134 $strikeend = '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
135 }
136
137 $s = '';
138 if ($type == -1) {
139 $s .= $langs->trans("Name").': <b>'.$this->getName($langs).'</b><br>';
140 } elseif ($type == 0) {
141 $s .= $langs->trans("CustomerCodeDesc").'<br>';
142 } elseif ($type == 1) {
143 $s .= $langs->trans("SupplierCodeDesc").'<br>';
144 }
145 if ($type != -1) {
146 $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getName($langs).'</b><br>';
147 }
148 $s .= '<br>';
149 $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
150 if ($type == 0) {
151 $s .= $langs->trans("RequiredIfCustomer").': '.$strikestart;
152 $s .= yn(!$this->code_null, 1, 2).$strikeend;
153 $s .= '<br>';
154 } elseif ($type == 1) {
155 $s .= $langs->trans("RequiredIfSupplier").': '.$strikestart;
156 $s .= yn(!$this->code_null, 1, 2).$strikeend;
157 $s .= '<br>';
158 } elseif ($type == -1) {
159 $s .= $langs->trans("Required").': '.$strikestart;
160 $s .= yn(!$this->code_null, 1, 2).$strikeend;
161 $s .= '<br>';
162 }
163 $s .= $langs->trans("CanBeModifiedIfOk").': ';
164 $s .= yn($this->code_modifiable, 1, 2);
165 $s .= '<br>';
166 $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
167 $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
168 $s .= '<br>';
169 if ($type == 0 || $type == -1) {
170 $nextval = $this->getNextValue($soc, 0);
171 if (empty($nextval)) {
172 $nextval = $langs->trans("Undefined");
173 }
174 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
175 }
176 if ($type == 1 || $type == -1) {
177 $nextval = $this->getNextValue($soc, 1);
178 if (empty($nextval)) {
179 $nextval = $langs->trans("Undefined");
180 }
181 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
182 }
183 return $s;
184 }
185
186 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
192 public function verif_prefixIsUsed()
193 {
194 // phpcs:enable
195 return 0;
196 }
197}
198
199
204{
208 public $code;
209
218 public function getToolTip($langs, $soc, $type)
219 {
220 global $db;
221
222 $langs->load("admin");
223
224 $s = '';
225 if ($type == -1) {
226 $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>';
227 $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
228 }
229 //$s.='<br>';
230 //$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
231 $s .= '<br>';
232 if ($type == 0 || $type == -1) {
233 $result = $this->get_code($db, $soc, 'customer');
234 $nextval = $this->code;
235 if (empty($nextval)) {
236 $nextval = $langs->trans("Undefined");
237 }
238 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
239 }
240 if ($type == 1 || $type == -1) {
241 $result = $this->get_code($db, $soc, 'supplier');
242 $nextval = $this->code;
243 if (empty($nextval)) {
244 $nextval = $langs->trans("Undefined");
245 }
246 $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
247 }
248 return $s;
249 }
250
251 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
260 public function get_code($db, $societe, $type = '')
261 {
262 // phpcs:enable
263 global $langs;
264
265 dol_syslog(get_class($this)."::get_code".$langs->trans("NotAvailable"), LOG_ERR);
266 return -1;
267 }
268}
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.
__construct($db)
Constructor.
getNextValue($objsoc='', $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.
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:142