dolibarr  7.0.0-beta
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@capnetworks.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 {
36  var $error='';
37 
45  static function liste_modeles($db,$maxfilenamelength=0)
46  {
47  global $conf;
48 
49  $type='company';
50  $liste=array();
51 
52  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
53  $liste=getListOfModels($db,$type,$maxfilenamelength);
54 
55  return $liste;
56  }
57 
58 }
59 
64 abstract class ModeleThirdPartyCode
65 {
66  var $error='';
67 
73  function info($langs)
74  {
75  $langs->load("bills");
76  return $langs->trans("NoDescription");
77  }
78 
84  function getNom($langs)
85  {
86  return $this->nom;
87  }
88 
89 
95  function getExample($langs)
96  {
97  $langs->load("bills");
98  return $langs->trans("NoExample");
99  }
100 
106  function canBeActivated()
107  {
108  return true;
109  }
110 
118  function getNextValue($objsoc=0,$type=-1)
119  {
120  global $langs;
121  return $langs->trans("Function_getNextValue_InModuleNotWorking");
122  }
123 
124 
129  function getVersion()
130  {
131  global $langs;
132  $langs->load("admin");
133 
134  if ($this->version == 'development') return $langs->trans("VersionDevelopment");
135  if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
136  if ($this->version == 'dolibarr') return DOL_VERSION;
137  if ($this->version) return $this->version;
138  return $langs->trans("NotAvailable");
139  }
140 
148  static function liste_modeles($db,$maxfilenamelength=0)
149  {
150  $liste=array();
151  $sql ="";
152 
153  $resql = $db->query($sql);
154  if ($resql)
155  {
156  $num = $db->num_rows($resql);
157  $i = 0;
158  while ($i < $num)
159  {
160  $row = $db->fetch_row($resql);
161  $liste[$row[0]]=$row[1];
162  $i++;
163  }
164  }
165  else
166  {
167  return -1;
168  }
169  return $liste;
170  }
171 
180  function getToolTip($langs,$soc,$type)
181  {
182  global $conf;
183 
184  $langs->load("admin");
185 
186  $s='';
187  if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
188  if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
189  if ($type == 0) $s.=$langs->trans("CustomerCodeDesc").'<br>';
190  if ($type == 1) $s.=$langs->trans("SupplierCodeDesc").'<br>';
191  if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
192  $s.='<br>';
193  $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
194  if ($type == 0)
195  {
196  $s.=$langs->trans("RequiredIfCustomer").': ';
197  if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
198  $s.=yn(!$this->code_null,1,2);
199  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")).')';
200  $s.='<br>';
201  }
202  if ($type == 1)
203  {
204  $s.=$langs->trans("RequiredIfSupplier").': ';
205  if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
206  $s.=yn(!$this->code_null,1,2);
207  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")).')';
208  $s.='<br>';
209  }
210  if ($type == -1)
211  {
212  $s.=$langs->trans("Required").': ';
213  if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
214  $s.=yn(!$this->code_null,1,2);
215  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")).')';
216  $s.='<br>';
217  }
218  $s.=$langs->trans("CanBeModifiedIfOk").': ';
219  $s.=yn($this->code_modifiable,1,2);
220  $s.='<br>';
221  $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
222  $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>';
223  $s.='<br>';
224  if ($type == 0 || $type == -1)
225  {
226  $nextval=$this->getNextValue($soc,0);
227  if (empty($nextval)) $nextval=$langs->trans("Undefined");
228  $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
229  }
230  if ($type == 1 || $type == -1)
231  {
232  $nextval=$this->getNextValue($soc,1);
233  if (empty($nextval)) $nextval=$langs->trans("Undefined");
234  $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
235  }
236  return $s;
237  }
238 
245  {
246  return 0;
247  }
248 
249 }
250 
251 
256 abstract class ModeleAccountancyCode
257 {
258  var $error='';
259 
260 
266  function info($langs)
267  {
268  $langs->load("bills");
269  return $langs->trans("NoDescription");
270  }
271 
279  function getExample($langs,$objsoc=0,$type=-1)
280  {
281  $langs->load("bills");
282  return $langs->trans("NoExample");
283  }
284 
290  function canBeActivated()
291  {
292  return true;
293  }
294 
299  function getVersion()
300  {
301  global $langs;
302  $langs->load("admin");
303 
304  if ($this->version == 'development') return $langs->trans("VersionDevelopment");
305  if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
306  if ($this->version == 'dolibarr') return DOL_VERSION;
307  if ($this->version) return $this->version;
308  return $langs->trans("NotAvailable");
309  }
310 
319  function getToolTip($langs,$soc,$type)
320  {
321  global $conf,$db;
322 
323  $langs->load("admin");
324 
325  $s='';
326  if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->nom.'</b><br>';
327  if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
328  //$s.='<br>';
329  //$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
330  $s.='<br>';
331  if ($type == 0 || $type == -1)
332  {
333  $result=$this->get_code($db,$soc,'customer');
334  $nextval=$this->code;
335  if (empty($nextval)) $nextval=$langs->trans("Undefined");
336  $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
337  }
338  if ($type == 1 || $type == -1)
339  {
340  $result=$this->get_code($db,$soc,'supplier');
341  $nextval=$this->code;
342  if (empty($nextval)) $nextval=$langs->trans("Undefined");
343  $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
344  }
345  return $s;
346  }
347 
356  function get_code($db, $societe, $type='')
357  {
358  global $langs;
359 
360  return $langs->trans("NotAvailable");
361  }
362 }
363 
364 
365 
381 function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
382 {
383  dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
384 
385  return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
386 }
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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)
Renvoi la liste des modeles de numéroation.
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.
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.
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:1013
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...