dolibarr  20.0.0-beta
modProductBatch.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2013-2014 Cedric GROSS <c.gross@kreiz-it.fr>
6  * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
29 include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30 
31 
36 {
42  public function __construct($db)
43  {
44  global $langs, $conf;
45 
46  $this->db = $db;
47  $this->numero = 39000;
48 
49  $this->family = "products";
50  $this->module_position = '45';
51 
52  $this->name = preg_replace('/^mod/i', '', get_class($this));
53  $this->description = "Batch number, eat-by and sell-by date management module";
54 
55  $this->rights_class = 'productbatch';
56  // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57  $this->version = 'dolibarr';
58  // Key used in llx_const table to save module status enabled/disabled (where dluo is value of property name of module in uppercase)
59  $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60 
61  $this->picto = 'lot';
62 
63  $this->module_parts = array();
64 
65  // Data directories to create when module is enabled.
66  $this->dirs = array();
67 
68  // Config pages. Put here list of php page, stored into productdluo/admin directory, to use to setup module.
69  $this->config_page_url = array("product_lot.php@product");
70 
71  // Dependencies
72  $this->hidden = false; // A condition to hide module
73  $this->depends = array("modProduct", "modStock", "modExpedition", "modFournisseur"); // List of module class names as string that must be enabled if this module is enabled
74  $this->requiredby = array(); // List of module ids to disable if this one is disabled
75  $this->conflictwith = array(); // List of module class names as string this module is in conflict with
76  $this->phpmin = array(7, 0); // Minimum version of PHP required by module
77  $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module
78  $this->langfiles = array("productbatch");
79 
80  // Constants
81  // Constants
82  $this->const = array();
83  $r = 0;
84 
85  $this->const[$r][0] = "PRODUCTBATCH_LOT_ADDON";
86  $this->const[$r][1] = "chaine";
87  $this->const[$r][2] = "mod_lot_free";
88  $this->const[$r][3] = 'Module to control lot number';
89  $this->const[$r][4] = 0;
90  $r++;
91 
92  $this->const[$r][0] = "PRODUCTBATCH_SN_ADDON";
93  $this->const[$r][1] = "chaine";
94  $this->const[$r][2] = "mod_sn_free";
95  $this->const[$r][3] = 'Module to control serial number';
96  $this->const[$r][4] = 0;
97  $r++;
98 
99  $this->tabs = array();
100 
101  // Dictionaries
102  if (!isset($conf->productbatch->enabled)) {
103  $conf->productbatch = new stdClass();
104  $conf->productbatch->enabled = 0;
105  }
106  $this->dictionaries = array();
107 
108  // Boxes
109  $this->boxes = array(); // List of boxes
110 
111  // Permissions
112  $this->rights = array(); // Permission array used by this module
113  $r = 0;
114 
115 
116  // Menus
117  //-------
118  $this->menu = 1; // This module add menu entries. They are coded into menu manager.
119 
120 
121  // Exports
122  $r = 0;
123  }
124 
133  public function init($options = '')
134  {
135  global $db, $conf;
136 
137  $sql = array();
138 
139  if (!empty($conf->cashdesk->enabled)) {
140  if (!getDolGlobalString('CASHDESK_NO_DECREASE_STOCK')) {
141  include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
142  $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity);
143  }
144  }
145 
146  return $this->_init($sql, $options);
147  }
148 }
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:656
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
Description and activation class for module productdluo.
__construct($db)
Constructor.
init($options='')
Function called when module is enabled.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:745
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:126