dolibarr  7.0.0-beta
modules_product.class.php
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 
22 
34  require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
35 
39 abstract class ModelePDFProduct extends CommonDocGenerator
40 {
41  var $error='';
42 
43 
51  static function liste_modeles($db,$maxfilenamelength=0)
52  {
53  global $conf;
54 
55  $type='product';
56  $liste=array();
57 
58  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
59  $liste=getListOfModels($db,$type,$maxfilenamelength);
60  return $liste;
61  }
62 }
63 
64 abstract class ModeleProductCode
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 empty($this->name)?$this->nom:$this->name;
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($objproduct=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,$product,$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("ProductCodeDesc").'<br>';
190  if ($type == 1) $s.=$langs->trans("ServiceCodeDesc").'<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("RequiredIfProduct").': ';
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("RequiredIfService").': ';
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($product,0);
227  if (empty($nextval)) $nextval=$langs->trans("Undefined");
228  $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Product").')':'').': <b>'.$nextval.'</b><br>';
229  }
230  if ($type == 1 || $type == -1)
231  {
232  $nextval=$this->getNextValue($product,1);
233  if (empty($nextval)) $nextval=$langs->trans("Undefined");
234  $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Service").')':'').': <b>'.$nextval.'</b>';
235  }
236  return $s;
237  }
238 
245  {
246  return 0;
247  }
248 
249 }
250 
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
getNom($langs)
Renvoi nom module.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
verif_prefixIsUsed()
Check if mask/numbering use prefix.
getExample($langs)
Renvoi un exemple de numerotation.
canBeActivated()
Test si les numeros deja en vigueur dans la base ne provoquent pas de de conflits qui empechera cette...
static liste_modeles($db, $maxfilenamelength=0)
Renvoi la liste des modeles de numérotation.
Parent class for product code generators.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
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 to manage intervention document templates.
Parent class for documents generators.
info($langs)
Renvoi la description par defaut du modele de numerotation.
getListOfModels($db, $type, $maxfilenamelength=0)
Return list of activated modules usable for document generation.
getToolTip($langs, $product, $type)
Return description of module parameters.
getNextValue($objproduct=0, $type=-1)
Return next value available.