dolibarr  13.0.2
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($db, $maxfilenamelength = 0)
49  {
50  // phpcs:enable
51  global $conf;
52 
53  $type = 'company';
54  $liste = array();
55 
56  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
57  $liste = getListOfModels($db, $type, $maxfilenamelength);
58 
59  return $liste;
60  }
61 }
62 
66 abstract class ModeleThirdPartyCode
67 {
71  public $error = '';
72 
76  public $errors;
77 
78 
84  public function info($langs)
85  {
86  $langs->load("bills");
87  return $langs->trans("NoDescription");
88  }
89 
95  public function getNom($langs)
96  {
97  return $this->name;
98  }
99 
100 
106  public function getExample($langs)
107  {
108  $langs->load("bills");
109  return $langs->trans("NoExample");
110  }
111 
118  public function canBeActivated()
119  {
120  return true;
121  }
122 
130  public function getNextValue($objsoc = 0, $type = -1)
131  {
132  global $langs;
133  return $langs->trans("Function_getNextValue_InModuleNotWorking");
134  }
135 
136 
142  public function getVersion()
143  {
144  global $langs;
145  $langs->load("admin");
146 
147  if ($this->version == 'development') {
148  return $langs->trans("VersionDevelopment");
149  } elseif ($this->version == 'experimental') {
150  return $langs->trans("VersionExperimental");
151  } elseif ($this->version == 'dolibarr') {
152  return DOL_VERSION;
153  } elseif ($this->version) {
154  return $this->version;
155  } else {
156  return $langs->trans("NotAvailable");
157  }
158  }
159 
160  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
168  public static function liste_modeles($db, $maxfilenamelength = 0)
169  {
170  // phpcs:enable
171  $liste = array();
172  $sql = "";
173 
174  $resql = $db->query($sql);
175  if ($resql) {
176  $num = $db->num_rows($resql);
177  $i = 0;
178  while ($i < $num) {
179  $row = $db->fetch_row($resql);
180  $liste[$row[0]] = $row[1];
181  $i++;
182  }
183  } else {
184  return -1;
185  }
186  return $liste;
187  }
188 
197  public function getToolTip($langs, $soc, $type)
198  {
199  global $conf;
200 
201  $langs->load("admin");
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 }
403 
404 
420 function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
421 {
422  dol_syslog(__METHOD__." is deprecated", LOG_WARNING);
423 
424  return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
425 }
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
getToolTip($langs, $soc, $type)
Return description of module parameters.
getExample($langs)
Return an example of numbering.
getNom($langs)
Return name of module.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage Dolibarr database access.
getVersion()
Return version of module.
static liste_modeles($db, $maxfilenamelength=0)
Renvoie la liste des modeles de numérotation.
thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Create a document onto disk according to template module.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
Parent class for third parties code generators.
Parent class for third parties accountancy code generators.
Parent class for third parties models of doc generators.
Class to manage third parties objects (customers, suppliers, prospects...)
getToolTip($langs, $soc, $type)
Return description of module parameters.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
getExample($langs, $objsoc=0, $type=-1)
Return an example of result returned by getNextValue.
getNextValue($objsoc=0, $type=-1)
Return next value available.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
get_code($db, $societe, $type= '')
Set accountancy account code for a third party into this-&gt;code.
info($langs)
Return description of module.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
info($langs)
Renvoi la description par defaut du modele de numerotation.
getVersion()
Return version of module.
Parent class for documents generators.
getListOfModels($db, $type, $maxfilenamelength=0)
Return list of activated modules usable for document generation.
verif_prefixIsUsed()
Check if mask/numbering use prefix.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...