dolibarr  9.0.0
modules_product.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 
22 
29  require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
30 
34 abstract class ModelePDFProduct extends CommonDocGenerator
35 {
39  public $error='';
40 
41 
42  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
50  static function liste_modeles($db,$maxfilenamelength=0)
51  {
52  // phpcs:enable
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 {
69  public $error='';
70 
76  function info($langs)
77  {
78  $langs->load("bills");
79  return $langs->trans("NoDescription");
80  }
81 
87  function getNom($langs)
88  {
89  return empty($this->name)?$this->nom:$this->name;
90  }
91 
92 
98  function getExample($langs)
99  {
100  $langs->load("bills");
101  return $langs->trans("NoExample");
102  }
103 
109  function canBeActivated()
110  {
111  return true;
112  }
113 
121  function getNextValue($objproduct=0,$type=-1)
122  {
123  global $langs;
124  return $langs->trans("Function_getNextValue_InModuleNotWorking");
125  }
126 
127 
132  function getVersion()
133  {
134  global $langs;
135  $langs->load("admin");
136 
137  if ($this->version == 'development') return $langs->trans("VersionDevelopment");
138  if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
139  if ($this->version == 'dolibarr') return DOL_VERSION;
140  if ($this->version) return $this->version;
141  return $langs->trans("NotAvailable");
142  }
143 
144  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
152  static function liste_modeles($db,$maxfilenamelength=0)
153  {
154  // phpcs:enable
155  $liste=array();
156  $sql ="";
157 
158  $resql = $db->query($sql);
159  if ($resql)
160  {
161  $num = $db->num_rows($resql);
162  $i = 0;
163  while ($i < $num)
164  {
165  $row = $db->fetch_row($resql);
166  $liste[$row[0]]=$row[1];
167  $i++;
168  }
169  }
170  else
171  {
172  return -1;
173  }
174  return $liste;
175  }
176 
185  function getToolTip($langs,$product,$type)
186  {
187  global $conf;
188 
189  $langs->load("admin");
190 
191  $s='';
192  if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
193  if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
194  if ($type == 0) $s.=$langs->trans("ProductCodeDesc").'<br>';
195  if ($type == 1) $s.=$langs->trans("ServiceCodeDesc").'<br>';
196  if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
197  $s.='<br>';
198  $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
199  if ($type == 0)
200  {
201  $s.=$langs->trans("RequiredIfProduct").': ';
202  if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
203  $s.=yn(!$this->code_null,1,2);
204  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")).')';
205  $s.='<br>';
206  }
207  elseif ($type == 1)
208  {
209  $s.=$langs->trans("RequiredIfService").': ';
210  if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
211  $s.=yn(!$this->code_null,1,2);
212  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")).')';
213  $s.='<br>';
214  }
215  elseif ($type == -1)
216  {
217  $s.=$langs->trans("Required").': ';
218  if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
219  $s.=yn(!$this->code_null,1,2);
220  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")).')';
221  $s.='<br>';
222  }
223  $s.=$langs->trans("CanBeModifiedIfOk").': ';
224  $s.=yn($this->code_modifiable,1,2);
225  $s.='<br>';
226  $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
227  $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>';
228  $s.='<br>';
229  if ($type == 0 || $type == -1)
230  {
231  $nextval=$this->getNextValue($product,0);
232  if (empty($nextval)) $nextval=$langs->trans("Undefined");
233  $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Product").')':'').': <b>'.$nextval.'</b><br>';
234  }
235  if ($type == 1 || $type == -1)
236  {
237  $nextval=$this->getNextValue($product,1);
238  if (empty($nextval)) $nextval=$langs->trans("Undefined");
239  $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Service").')':'').': <b>'.$nextval.'</b>';
240  }
241  return $s;
242  }
243 
244  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
251  {
252  // phpcs:enable
253  return 0;
254  }
255 }
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
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...
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:103
if(! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'] s nom
Definition: list.php:573
static liste_modeles($db, $maxfilenamelength=0)
Renvoi la liste des modeles de numérotation.
Parent class for product code generators.
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.