dolibarr  9.0.0
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 <http://www.gnu.org/licenses/>.
19  * or see http://www.gnu.org/
20  */
21 
27 require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
28 
29 
35 {
39  public $error='';
40 
41  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
49  static function liste_modeles($db,$maxfilenamelength=0)
50  {
51  // phpcs:enable
52  global $conf;
53 
54  $type='company';
55  $liste=array();
56 
57  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
58  $liste = getListOfModels($db,$type,$maxfilenamelength);
59 
60  return $liste;
61  }
62 }
63 
68 abstract class ModeleThirdPartyCode
69 {
73  public $error='';
74 
80  function info($langs)
81  {
82  $langs->load("bills");
83  return $langs->trans("NoDescription");
84  }
85 
91  function getNom($langs)
92  {
93  return $this->nom;
94  }
95 
96 
102  function getExample($langs)
103  {
104  $langs->load("bills");
105  return $langs->trans("NoExample");
106  }
107 
113  function canBeActivated()
114  {
115  return true;
116  }
117 
125  function getNextValue($objsoc=0,$type=-1)
126  {
127  global $langs;
128  return $langs->trans("Function_getNextValue_InModuleNotWorking");
129  }
130 
131 
136  function getVersion()
137  {
138  global $langs;
139  $langs->load("admin");
140 
141  if ($this->version == 'development') return $langs->trans("VersionDevelopment");
142  if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
143  if ($this->version == 'dolibarr') return DOL_VERSION;
144  if ($this->version) return $this->version;
145  return $langs->trans("NotAvailable");
146  }
147 
148  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
156  static function liste_modeles($db,$maxfilenamelength=0)
157  {
158  // phpcs:enable
159  $liste=array();
160  $sql ="";
161 
162  $resql = $db->query($sql);
163  if ($resql)
164  {
165  $num = $db->num_rows($resql);
166  $i = 0;
167  while ($i < $num)
168  {
169  $row = $db->fetch_row($resql);
170  $liste[$row[0]]=$row[1];
171  $i++;
172  }
173  }
174  else
175  {
176  return -1;
177  }
178  return $liste;
179  }
180 
189  function getToolTip($langs,$soc,$type)
190  {
191  global $conf;
192 
193  $langs->load("admin");
194 
195  $s='';
196  if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
197  if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
198  if ($type == 0) $s.=$langs->trans("CustomerCodeDesc").'<br>';
199  if ($type == 1) $s.=$langs->trans("SupplierCodeDesc").'<br>';
200  if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
201  $s.='<br>';
202  $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
203  if ($type == 0)
204  {
205  $s.=$langs->trans("RequiredIfCustomer").': ';
206  if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
207  $s.=yn(!$this->code_null,1,2);
208  if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
209  $s.='<br>';
210  }
211  if ($type == 1)
212  {
213  $s.=$langs->trans("RequiredIfSupplier").': ';
214  if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
215  $s.=yn(!$this->code_null,1,2);
216  if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
217  $s.='<br>';
218  }
219  if ($type == -1)
220  {
221  $s.=$langs->trans("Required").': ';
222  if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
223  $s.=yn(!$this->code_null,1,2);
224  if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
225  $s.='<br>';
226  }
227  $s.=$langs->trans("CanBeModifiedIfOk").': ';
228  $s.=yn($this->code_modifiable,1,2);
229  $s.='<br>';
230  $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
231  $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>';
232  $s.='<br>';
233  if ($type == 0 || $type == -1)
234  {
235  $nextval=$this->getNextValue($soc,0);
236  if (empty($nextval)) $nextval=$langs->trans("Undefined");
237  $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
238  }
239  if ($type == 1 || $type == -1)
240  {
241  $nextval=$this->getNextValue($soc,1);
242  if (empty($nextval)) $nextval=$langs->trans("Undefined");
243  $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
244  }
245  return $s;
246  }
247 
248  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
255  {
256  // phpcs:enable
257  return 0;
258  }
259 }
260 
261 
266 abstract class ModeleAccountancyCode
267 {
271  public $error='';
272 
273 
279  function info($langs)
280  {
281  $langs->load("bills");
282  return $langs->trans("NoDescription");
283  }
284 
292  function getExample($langs,$objsoc=0,$type=-1)
293  {
294  $langs->load("bills");
295  return $langs->trans("NoExample");
296  }
297 
303  function canBeActivated()
304  {
305  return true;
306  }
307 
312  function getVersion()
313  {
314  global $langs;
315  $langs->load("admin");
316 
317  if ($this->version == 'development') return $langs->trans("VersionDevelopment");
318  if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
319  if ($this->version == 'dolibarr') return DOL_VERSION;
320  if ($this->version) return $this->version;
321  return $langs->trans("NotAvailable");
322  }
323 
332  function getToolTip($langs,$soc,$type)
333  {
334  global $conf,$db;
335 
336  $langs->load("admin");
337 
338  $s='';
339  if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->nom.'</b><br>';
340  if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
341  //$s.='<br>';
342  //$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
343  $s.='<br>';
344  if ($type == 0 || $type == -1)
345  {
346  $result=$this->get_code($db,$soc,'customer');
347  $nextval=$this->code;
348  if (empty($nextval)) $nextval=$langs->trans("Undefined");
349  $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
350  }
351  if ($type == 1 || $type == -1)
352  {
353  $result=$this->get_code($db,$soc,'supplier');
354  $nextval=$this->code;
355  if (empty($nextval)) $nextval=$langs->trans("Undefined");
356  $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
357  }
358  return $s;
359  }
360 
361  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
370  function get_code($db, $societe, $type='')
371  {
372  // phpcs:enable
373  global $langs;
374 
375  return $langs->trans("NotAvailable");
376  }
377 }
378 
379 
380 
381 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
397 function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
398 {
399  // phpcs:enable
400  dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
401 
402  return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
403 }
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->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) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
getToolTip($langs, $soc, $type)
Return description of module parameters.
getExample($langs)
Renvoi un exemple de numerotation.
getNom($langs)
Renvoi nom 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.
canBeActivated()
Test si les numeros deja en vigueur dans la base ne provoquent pas de de conflits qui empechera cette...
Parent class for third parties code generators.
Parent class for third parties accountancy code generators.
Parent class for third parties models of doc generators.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
Class to manage third parties objects (customers, suppliers, prospects...)
get_code($db, $societe, $type='')
Set accountancy account code for a third party into this->code.
getToolTip($langs, $soc, $type)
Return description of module parameters.
if(! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'] s nom
Definition: list.php:573
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.
info($langs)
Return description of module.
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()
Test si les numeros deja en vigueur dans la base ne provoquent pas de de conflits qui empechera cette...