dolibarr  19.0.0-dev
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 
27 require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
28 
29 
34 {
38  public $error = '';
39 
40  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
48  public static function liste_modeles($dbs, $maxfilenamelength = 0)
49  {
50  // phpcs:enable
51  $type = 'company';
52  $list = array();
53 
54  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
55  $list = getListOfModels($dbs, $type, $maxfilenamelength);
56 
57  return $list;
58  }
59 }
60 
64 abstract class ModeleThirdPartyCode
65 {
69  public $error = '';
70 
74  public $errors;
75 
76 
82  public function info($langs)
83  {
84  $langs->load("bills");
85  return $langs->trans("NoDescription");
86  }
87 
93  public function getNom($langs)
94  {
95  return $this->name;
96  }
97 
98 
104  public function getExample($langs)
105  {
106  $langs->load("bills");
107  return $langs->trans("NoExample");
108  }
109 
116  public function canBeActivated()
117  {
118  return true;
119  }
120 
128  public function getNextValue($objsoc = 0, $type = -1)
129  {
130  global $langs;
131  return $langs->trans("Function_getNextValue_InModuleNotWorking");
132  }
133 
134 
140  public function getVersion()
141  {
142  global $langs;
143  $langs->load("admin");
144 
145  if ($this->version == 'development') {
146  return $langs->trans("VersionDevelopment");
147  } elseif ($this->version == 'experimental') {
148  return $langs->trans("VersionExperimental");
149  } elseif ($this->version == 'dolibarr') {
150  return DOL_VERSION;
151  } elseif ($this->version) {
152  return $this->version;
153  } else {
154  return $langs->trans("NotAvailable");
155  }
156  }
157 
158  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
166  public static function liste_modeles($dbs, $maxfilenamelength = 0)
167  {
168  // phpcs:enable
169  $list = array();
170  $sql = "";
171 
172  $resql = $dbs->query($sql);
173  if ($resql) {
174  $num = $dbs->num_rows($resql);
175  $i = 0;
176  while ($i < $num) {
177  $row = $dbs->fetch_row($resql);
178  $list[$row[0]] = $row[1];
179  $i++;
180  }
181  } else {
182  return -1;
183  }
184  return $list;
185  }
186 
195  public function getToolTip($langs, $soc, $type)
196  {
197  global $conf;
198 
199  $langs->loadLangs(array("admin", "companies"));
200 
201  $strikestart = '';
202  $strikeend = '';
203  if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) {
204  $strikestart = '<strike>';
205  $strikeend = '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
206  }
207 
208  $s = '';
209  if ($type == -1) {
210  $s .= $langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
211  } elseif ($type == -1) {
212  $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
213  } elseif ($type == 0) {
214  $s .= $langs->trans("CustomerCodeDesc").'<br>';
215  } elseif ($type == 1) {
216  $s .= $langs->trans("SupplierCodeDesc").'<br>';
217  }
218  if ($type != -1) {
219  $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
220  }
221  $s .= '<br>';
222  $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
223  if ($type == 0) {
224  $s .= $langs->trans("RequiredIfCustomer").': '.$strikestart;
225  $s .= yn(!$this->code_null, 1, 2).$strikeend;
226  $s .= '<br>';
227  } elseif ($type == 1) {
228  $s .= $langs->trans("RequiredIfSupplier").': '.$strikestart;
229  $s .= yn(!$this->code_null, 1, 2).$strikeend;
230  $s .= '<br>';
231  } elseif ($type == -1) {
232  $s .= $langs->trans("Required").': '.$strikestart;
233  $s .= yn(!$this->code_null, 1, 2).$strikeend;
234  $s .= '<br>';
235  }
236  $s .= $langs->trans("CanBeModifiedIfOk").': ';
237  $s .= yn($this->code_modifiable, 1, 2);
238  $s .= '<br>';
239  $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
240  $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
241  $s .= '<br>';
242  if ($type == 0 || $type == -1) {
243  $nextval = $this->getNextValue($soc, 0);
244  if (empty($nextval)) {
245  $nextval = $langs->trans("Undefined");
246  }
247  $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
248  }
249  if ($type == 1 || $type == -1) {
250  $nextval = $this->getNextValue($soc, 1);
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
265  public function verif_prefixIsUsed()
266  {
267  // phpcs:enable
268  return 0;
269  }
270 }
271 
272 
276 abstract class ModeleAccountancyCode
277 {
281  public $error = '';
282 
283 
290  public function info($langs)
291  {
292  $langs->load("bills");
293  return $langs->trans("NoDescription");
294  }
295 
304  public function getExample($langs, $objsoc = 0, $type = -1)
305  {
306  $langs->load("bills");
307  return $langs->trans("NoExample");
308  }
309 
316  public function canBeActivated()
317  {
318  return true;
319  }
320 
326  public function getVersion()
327  {
328  global $langs;
329  $langs->load("admin");
330 
331  if ($this->version == 'development') {
332  return $langs->trans("VersionDevelopment");
333  } elseif ($this->version == 'experimental') {
334  return $langs->trans("VersionExperimental");
335  } elseif ($this->version == 'dolibarr') {
336  return DOL_VERSION;
337  } elseif ($this->version) {
338  return $this->version;
339  } else {
340  return $langs->trans("NotAvailable");
341  }
342  }
343 
352  public function getToolTip($langs, $soc, $type)
353  {
354  global $conf, $db;
355 
356  $langs->load("admin");
357 
358  $s = '';
359  if ($type == -1) {
360  $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>';
361  $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
362  }
363  //$s.='<br>';
364  //$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
365  $s .= '<br>';
366  if ($type == 0 || $type == -1) {
367  $result = $this->get_code($db, $soc, 'customer');
368  $nextval = $this->code;
369  if (empty($nextval)) {
370  $nextval = $langs->trans("Undefined");
371  }
372  $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
373  }
374  if ($type == 1 || $type == -1) {
375  $result = $this->get_code($db, $soc, 'supplier');
376  $nextval = $this->code;
377  if (empty($nextval)) {
378  $nextval = $langs->trans("Undefined");
379  }
380  $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
381  }
382  return $s;
383  }
384 
385  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
394  public function get_code($db, $societe, $type = '')
395  {
396  // phpcs:enable
397  global $langs;
398 
399  return $langs->trans("NotAvailable");
400  }
401 }
Parent class for documents generators.
Parent class for third parties accountancy code generators.
getVersion()
Return version of module.
getExample($langs, $objsoc=0, $type=-1)
Return an example of result returned by getNextValue.
info($langs)
Return description of module.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
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.
info($langs)
Returns the default description of the numbering pattern.
getExample($langs)
Return an example of numbering.
getNextValue($objsoc=0, $type=-1)
Return next value available.
static liste_modeles($dbs, $maxfilenamelength=0)
Renvoie la liste des modeles de numérotation.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
getVersion()
Return version of module.
getToolTip($langs, $soc, $type)
Return description of module parameters.
getNom($langs)
Return name of module.
Parent class for third parties models of doc generators.
static liste_modeles($dbs, $maxfilenamelength=0)
Return list of active generation modules.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
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.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:123