dolibarr  13.0.2
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 <https://www.gnu.org/licenses/>.
19  * or see https://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.ScopeNotCamelCaps
50  public 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 
67 abstract class ModeleProductCode
68 {
72  public $error = '';
73 
79  public function info($langs)
80  {
81  $langs->load("bills");
82  return $langs->trans("NoDescription");
83  }
84 
90  public function getNom($langs)
91  {
92  return empty($this->name) ? $this->nom : $this->name;
93  }
94 
95 
101  public function getExample($langs)
102  {
103  return $langs->trans("NoExample");
104  }
105 
112  public function canBeActivated()
113  {
114  return true;
115  }
116 
124  public function getNextValue($objproduct = 0, $type = -1)
125  {
126  global $langs;
127  return $langs->trans("Function_getNextValue_InModuleNotWorking");
128  }
129 
130 
135  public function getVersion()
136  {
137  global $langs;
138  $langs->load("admin");
139 
140  if ($this->version == 'development') {
141  return $langs->trans("VersionDevelopment");
142  }
143  if ($this->version == 'experimental') {
144  return $langs->trans("VersionExperimental");
145  }
146  if ($this->version == 'dolibarr') {
147  return DOL_VERSION;
148  }
149  if ($this->version) {
150  return $this->version;
151  }
152  return $langs->trans("NotAvailable");
153  }
154 
155  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
163  public static function liste_modeles($db, $maxfilenamelength = 0)
164  {
165  // phpcs:enable
166  $liste = array();
167  $sql = "";
168 
169  $resql = $db->query($sql);
170  if ($resql) {
171  $num = $db->num_rows($resql);
172  $i = 0;
173  while ($i < $num) {
174  $row = $db->fetch_row($resql);
175  $liste[$row[0]] = $row[1];
176  $i++;
177  }
178  } else {
179  return -1;
180  }
181  return $liste;
182  }
183 
192  public function getToolTip($langs, $product, $type)
193  {
194  global $conf;
195 
196  $langs->load("admin");
197  $strikestart = '';
198  $strikeend = '';
199  if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) {
200  $strikestart = '<strike>';
201  $strikeend = '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
202  }
203  $s = '';
204  if ($type == -1) {
205  $s .= $langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
206  $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
207  } elseif ($type == 0) {
208  $s .= $langs->trans("ProductCodeDesc").'<br>';
209  } elseif ($type == 1) {
210  $s .= $langs->trans("ServiceCodeDesc").'<br>';
211  }
212  if ($type != -1) {
213  $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
214  }
215  $s .= '<br>';
216  $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
217  if ($type == 0) {
218  $s .= $langs->trans("RequiredIfProduct").': '.$strikestart;
219  $s .= yn(!$this->code_null, 1, 2).$strikeend;
220  $s .= '<br>';
221  } elseif ($type == 1) {
222  $s .= $langs->trans("RequiredIfService").': '.$strikestart;
223  $s .= yn(!$this->code_null, 1, 2).$strikeend;
224  $s .= '<br>';
225  } elseif ($type == -1) {
226  $s .= $langs->trans("Required").': '.$strikestart;
227  $s .= yn(!$this->code_null, 1, 2).$strikeend;
228  $s .= '<br>';
229  }
230  $s .= $langs->trans("CanBeModifiedIfOk").': ';
231  $s .= yn($this->code_modifiable, 1, 2);
232  $s .= '<br>';
233  $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
234  $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
235  $s .= '<br>';
236  if ($type == 0 || $type == -1) {
237  $nextval = $this->getNextValue($product, 0);
238  if (empty($nextval)) {
239  $nextval = $langs->trans("Undefined");
240  }
241  $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Product").')' : '').': <b>'.$nextval.'</b><br>';
242  }
243  if ($type == 1 || $type == -1) {
244  $nextval = $this->getNextValue($product, 1);
245  if (empty($nextval)) {
246  $nextval = $langs->trans("Undefined");
247  }
248  $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Service").')' : '').': <b>'.$nextval.'</b>';
249  }
250  return $s;
251  }
252 
253  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
259  public function verif_prefixIsUsed()
260  {
261  // phpcs:enable
262  return 0;
263  }
264 }
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)
Return an example of numbering.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
if(!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'] s nom
Definition: list.php:560
static liste_modeles($db, $maxfilenamelength=0)
Renvoi la liste des modeles de numérotation.
Class template for classes of numbering product.
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
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.