dolibarr  16.0.5
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 
52  $type = 'company';
53  $list = array();
54 
55  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
56  $list = getListOfModels($dbs, $type, $maxfilenamelength);
57 
58  return $list;
59  }
60 }
61 
65 abstract class ModeleThirdPartyCode
66 {
70  public $error = '';
71 
75  public $errors;
76 
77 
83  public function info($langs)
84  {
85  $langs->load("bills");
86  return $langs->trans("NoDescription");
87  }
88 
94  public function getNom($langs)
95  {
96  return $this->name;
97  }
98 
99 
105  public function getExample($langs)
106  {
107  $langs->load("bills");
108  return $langs->trans("NoExample");
109  }
110 
117  public function canBeActivated()
118  {
119  return true;
120  }
121 
129  public function getNextValue($objsoc = 0, $type = -1)
130  {
131  global $langs;
132  return $langs->trans("Function_getNextValue_InModuleNotWorking");
133  }
134 
135 
141  public function getVersion()
142  {
143  global $langs;
144  $langs->load("admin");
145 
146  if ($this->version == 'development') {
147  return $langs->trans("VersionDevelopment");
148  } elseif ($this->version == 'experimental') {
149  return $langs->trans("VersionExperimental");
150  } elseif ($this->version == 'dolibarr') {
151  return DOL_VERSION;
152  } elseif ($this->version) {
153  return $this->version;
154  } else {
155  return $langs->trans("NotAvailable");
156  }
157  }
158 
159  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
167  public static function liste_modeles($dbs, $maxfilenamelength = 0)
168  {
169  // phpcs:enable
170  $list = array();
171  $sql = "";
172 
173  $resql = $dbs->query($sql);
174  if ($resql) {
175  $num = $dbs->num_rows($resql);
176  $i = 0;
177  while ($i < $num) {
178  $row = $dbs->fetch_row($resql);
179  $list[$row[0]] = $row[1];
180  $i++;
181  }
182  } else {
183  return -1;
184  }
185  return $list;
186  }
187 
196  public function getToolTip($langs, $soc, $type)
197  {
198  global $conf;
199 
200  $langs->loadLangs(array("admin", "companies"));
201 
202  $strikestart = '';
203  $strikeend = '';
204  if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) {
205  $strikestart = '<strike>';
206  $strikeend = '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
207  }
208 
209  $s = '';
210  if ($type == -1) {
211  $s .= $langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
212  } elseif ($type == -1) {
213  $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
214  } elseif ($type == 0) {
215  $s .= $langs->trans("CustomerCodeDesc").'<br>';
216  } elseif ($type == 1) {
217  $s .= $langs->trans("SupplierCodeDesc").'<br>';
218  }
219  if ($type != -1) {
220  $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
221  }
222  $s .= '<br>';
223  $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
224  if ($type == 0) {
225  $s .= $langs->trans("RequiredIfCustomer").': '.$strikestart;
226  $s .= yn(!$this->code_null, 1, 2).$strikeend;
227  $s .= '<br>';
228  } elseif ($type == 1) {
229  $s .= $langs->trans("RequiredIfSupplier").': '.$strikestart;
230  $s .= yn(!$this->code_null, 1, 2).$strikeend;
231  $s .= '<br>';
232  } elseif ($type == -1) {
233  $s .= $langs->trans("Required").': '.$strikestart;
234  $s .= yn(!$this->code_null, 1, 2).$strikeend;
235  $s .= '<br>';
236  }
237  $s .= $langs->trans("CanBeModifiedIfOk").': ';
238  $s .= yn($this->code_modifiable, 1, 2);
239  $s .= '<br>';
240  $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
241  $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
242  $s .= '<br>';
243  if ($type == 0 || $type == -1) {
244  $nextval = $this->getNextValue($soc, 0);
245  if (empty($nextval)) {
246  $nextval = $langs->trans("Undefined");
247  }
248  $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
249  }
250  if ($type == 1 || $type == -1) {
251  $nextval = $this->getNextValue($soc, 1);
252  if (empty($nextval)) {
253  $nextval = $langs->trans("Undefined");
254  }
255  $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
256  }
257  return $s;
258  }
259 
260  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
266  public function verif_prefixIsUsed()
267  {
268  // phpcs:enable
269  return 0;
270  }
271 }
272 
273 
277 abstract class ModeleAccountancyCode
278 {
282  public $error = '';
283 
284 
291  public function info($langs)
292  {
293  $langs->load("bills");
294  return $langs->trans("NoDescription");
295  }
296 
305  public function getExample($langs, $objsoc = 0, $type = -1)
306  {
307  $langs->load("bills");
308  return $langs->trans("NoExample");
309  }
310 
317  public function canBeActivated()
318  {
319  return true;
320  }
321 
327  public function getVersion()
328  {
329  global $langs;
330  $langs->load("admin");
331 
332  if ($this->version == 'development') {
333  return $langs->trans("VersionDevelopment");
334  } elseif ($this->version == 'experimental') {
335  return $langs->trans("VersionExperimental");
336  } elseif ($this->version == 'dolibarr') {
337  return DOL_VERSION;
338  } elseif ($this->version) {
339  return $this->version;
340  } else {
341  return $langs->trans("NotAvailable");
342  }
343  }
344 
353  public function getToolTip($langs, $soc, $type)
354  {
355  global $conf, $db;
356 
357  $langs->load("admin");
358 
359  $s = '';
360  if ($type == -1) {
361  $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>';
362  $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
363  }
364  //$s.='<br>';
365  //$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
366  $s .= '<br>';
367  if ($type == 0 || $type == -1) {
368  $result = $this->get_code($db, $soc, 'customer');
369  $nextval = $this->code;
370  if (empty($nextval)) {
371  $nextval = $langs->trans("Undefined");
372  }
373  $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
374  }
375  if ($type == 1 || $type == -1) {
376  $result = $this->get_code($db, $soc, 'supplier');
377  $nextval = $this->code;
378  if (empty($nextval)) {
379  $nextval = $langs->trans("Undefined");
380  }
381  $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
382  }
383  return $s;
384  }
385 
386  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
395  public function get_code($db, $societe, $type = '')
396  {
397  // phpcs:enable
398  global $langs;
399 
400  return $langs->trans("NotAvailable");
401  }
402 }
ModeleThirdPartyCode\liste_modeles
static liste_modeles($dbs, $maxfilenamelength=0)
Renvoie la liste des modeles de numérotation.
Definition: modules_societe.class.php:167
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6491
ModeleAccountancyCode\getVersion
getVersion()
Return version of module.
Definition: modules_societe.class.php:327
ModeleAccountancyCode\canBeActivated
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
Definition: modules_societe.class.php:317
ModeleThirdPartyCode\getToolTip
getToolTip($langs, $soc, $type)
Return description of module parameters.
Definition: modules_societe.class.php:196
ModeleThirdPartyDoc\liste_modeles
static liste_modeles($dbs, $maxfilenamelength=0)
Return list of active generation modules.
Definition: modules_societe.class.php:48
name
$conf db name
Definition: repair.php:122
ModeleAccountancyCode
Parent class for third parties accountancy code generators.
Definition: modules_societe.class.php:277
ModeleAccountancyCode\get_code
get_code($db, $societe, $type='')
Set accountancy account code for a third party into this->code.
Definition: modules_societe.class.php:395
ModeleThirdPartyCode\getNom
getNom($langs)
Return name of module.
Definition: modules_societe.class.php:94
ModeleThirdPartyCode\info
info($langs)
Renvoi la description par defaut du modele de numerotation.
Definition: modules_societe.class.php:83
ModeleThirdPartyCode\getVersion
getVersion()
Return version of module.
Definition: modules_societe.class.php:141
ModeleThirdPartyCode
Parent class for third parties code generators.
Definition: modules_societe.class.php:65
ModeleThirdPartyCode\verif_prefixIsUsed
verif_prefixIsUsed()
Check if mask/numbering use prefix.
Definition: modules_societe.class.php:266
ModeleThirdPartyCode\canBeActivated
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
Definition: modules_societe.class.php:117
ModeleThirdPartyCode\getExample
getExample($langs)
Return an example of numbering.
Definition: modules_societe.class.php:105
ModeleAccountancyCode\info
info($langs)
Return description of module.
Definition: modules_societe.class.php:291
getListOfModels
getListOfModels($db, $type, $maxfilenamelength=0)
Return list of activated modules usable for document generation.
Definition: functions2.lib.php:1919
ModeleThirdPartyCode\getNextValue
getNextValue($objsoc=0, $type=-1)
Return next value available.
Definition: modules_societe.class.php:129
ModeleAccountancyCode\getExample
getExample($langs, $objsoc=0, $type=-1)
Return an example of result returned by getNextValue.
Definition: modules_societe.class.php:305
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
CommonDocGenerator
Parent class for documents generators.
Definition: commondocgenerator.class.php:36
ModeleAccountancyCode\getToolTip
getToolTip($langs, $soc, $type)
Return description of module parameters.
Definition: modules_societe.class.php:353
ModeleThirdPartyDoc
Parent class for third parties models of doc generators.
Definition: modules_societe.class.php:33