dolibarr  16.0.5
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 
44  public $page_largeur;
45 
49  public $page_hauteur;
50 
54  public $format;
55 
59  public $marge_gauche;
60 
64  public $marge_droite;
65 
69  public $marge_haute;
70 
74  public $marge_basse;
75 
76 
77  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
85  public static function liste_modeles($dbs, $maxfilenamelength = 0)
86  {
87  // phpcs:enable
88  $type = 'product';
89  $list = array();
90 
91  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
92  $list = getListOfModels($dbs, $type, $maxfilenamelength);
93  return $list;
94  }
95 }
96 
100 abstract class ModeleProductCode
101 {
105  public $error = '';
106 
112  public function info($langs)
113  {
114  $langs->load("bills");
115  return $langs->trans("NoDescription");
116  }
117 
123  public function getNom($langs)
124  {
125  return empty($this->name) ? $this->nom : $this->name;
126  }
127 
128 
134  public function getExample($langs)
135  {
136  return $langs->trans("NoExample");
137  }
138 
145  public function canBeActivated()
146  {
147  return true;
148  }
149 
157  public function getNextValue($objproduct = 0, $type = -1)
158  {
159  global $langs;
160  return $langs->trans("Function_getNextValue_InModuleNotWorking");
161  }
162 
163 
168  public function getVersion()
169  {
170  global $langs;
171  $langs->load("admin");
172 
173  if ($this->version == 'development') {
174  return $langs->trans("VersionDevelopment");
175  }
176  if ($this->version == 'experimental') {
177  return $langs->trans("VersionExperimental");
178  }
179  if ($this->version == 'dolibarr') {
180  return DOL_VERSION;
181  }
182  if ($this->version) {
183  return $this->version;
184  }
185  return $langs->trans("NotAvailable");
186  }
187 
188  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
196  public static function liste_modeles($dbs, $maxfilenamelength = 0)
197  {
198  // phpcs:enable
199  $list = array();
200  $sql = "";
201 
202  $resql = $dbs->query($sql);
203  if ($resql) {
204  $num = $dbs->num_rows($resql);
205  $i = 0;
206  while ($i < $num) {
207  $row = $dbs->fetch_row($resql);
208  $list[$row[0]] = $row[1];
209  $i++;
210  }
211  } else {
212  return -1;
213  }
214  return $list;
215  }
216 
225  public function getToolTip($langs, $product, $type)
226  {
227  global $conf;
228 
229  $langs->loadLangs(array("admin", "companies"));
230 
231  $strikestart = '';
232  $strikeend = '';
233  if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) {
234  $strikestart = '<strike>';
235  $strikeend = '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
236  }
237  $s = '';
238  if ($type == -1) {
239  $s .= $langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
240  $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
241  } elseif ($type == 0) {
242  $s .= $langs->trans("ProductCodeDesc").'<br>';
243  } elseif ($type == 1) {
244  $s .= $langs->trans("ServiceCodeDesc").'<br>';
245  }
246  if ($type != -1) {
247  $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
248  }
249  $s .= '<br>';
250  $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
251  if ($type == 0) {
252  $s .= $langs->trans("RequiredIfProduct").': '.$strikestart;
253  $s .= yn(!$this->code_null, 1, 2).$strikeend;
254  $s .= '<br>';
255  } elseif ($type == 1) {
256  $s .= $langs->trans("RequiredIfService").': '.$strikestart;
257  $s .= yn(!$this->code_null, 1, 2).$strikeend;
258  $s .= '<br>';
259  } elseif ($type == -1) {
260  $s .= $langs->trans("Required").': '.$strikestart;
261  $s .= yn(!$this->code_null, 1, 2).$strikeend;
262  $s .= '<br>';
263  }
264  $s .= $langs->trans("CanBeModifiedIfOk").': ';
265  $s .= yn($this->code_modifiable, 1, 2);
266  $s .= '<br>';
267  $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
268  $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
269  $s .= '<br>';
270  if ($type == 0 || $type == -1) {
271  $nextval = $this->getNextValue($product, 0);
272  if (empty($nextval)) {
273  $nextval = $langs->trans("Undefined");
274  }
275  $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Product").')' : '').': <b>'.$nextval.'</b><br>';
276  }
277  if ($type == 1 || $type == -1) {
278  $nextval = $this->getNextValue($product, 1);
279  if (empty($nextval)) {
280  $nextval = $langs->trans("Undefined");
281  }
282  $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Service").')' : '').': <b>'.$nextval.'</b>';
283  }
284  return $s;
285  }
286 
287  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
293  public function verif_prefixIsUsed()
294  {
295  // phpcs:enable
296  return 0;
297  }
298 }
ModeleProductCode
Class template for classes of numbering product.
Definition: modules_product.class.php:100
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6491
name
$conf db name
Definition: repair.php:122
ModeleProductCode\getExample
getExample($langs)
Return an example of numbering.
Definition: modules_product.class.php:134
ModeleProductCode\verif_prefixIsUsed
verif_prefixIsUsed()
Check if mask/numbering use prefix.
Definition: modules_product.class.php:293
ModeleProductCode\info
info($langs)
Renvoi la description par defaut du modele de numerotation.
Definition: modules_product.class.php:112
ModeleProductCode\canBeActivated
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
Definition: modules_product.class.php:145
ModeleProductCode\getVersion
getVersion()
Return version of module.
Definition: modules_product.class.php:168
ModeleProductCode\getNom
getNom($langs)
Renvoi nom module.
Definition: modules_product.class.php:123
ModelePDFProduct
Parent class to manage intervention document templates.
Definition: modules_product.class.php:34
getListOfModels
getListOfModels($db, $type, $maxfilenamelength=0)
Return list of activated modules usable for document generation.
Definition: functions2.lib.php:1919
ModeleProductCode\getToolTip
getToolTip($langs, $product, $type)
Return description of module parameters.
Definition: modules_product.class.php:225
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
CommonDocGenerator
Parent class for documents generators.
Definition: commondocgenerator.class.php:36
ModeleProductCode\getNextValue
getNextValue($objproduct=0, $type=-1)
Return next value available.
Definition: modules_product.class.php:157
ModeleProductCode\liste_modeles
static liste_modeles($dbs, $maxfilenamelength=0)
Renvoi la liste des modeles de numérotation.
Definition: modules_product.class.php:196
ModelePDFProduct\liste_modeles
static liste_modeles($dbs, $maxfilenamelength=0)
Return list of active generation modules.
Definition: modules_product.class.php:85