2014-03-04 17:55:55 +00:00
< ? php
/* Copyright ( C ) 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 12:43:12 +00:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2014-03-04 17:55:55 +00:00
* Copyright ( C ) 2013 - 2014 Cedric GROSS < c . gross @ kreiz - it . fr >
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 19:55:30 +00:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2014-03-04 17:55:55 +00:00
*/
/**
* \defgroup productbatch Module batch number management
* \brief Management module for batch number , eat - by and sell - by date for product
* \file htdocs / core / modules / modProductBatch . class . php
* \ingroup productbatch
2021-03-20 12:55:43 +00:00
* \brief Description and activation file for the module productbatch
2014-03-04 17:55:55 +00:00
*/
2020-04-10 08:59:32 +00:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2014-03-04 17:55:55 +00:00
/**
* Description and activation class for module productdluo
*/
class modProductBatch extends DolibarrModules
{
/**
* Constructor . Define names , constants , directories , boxes , permissions
*
* @ param DoliDB $db Database handler
*/
2019-02-25 19:35:59 +00:00
public function __construct ( $db )
2014-03-04 17:55:55 +00:00
{
2020-10-31 13:32:18 +00:00
global $langs , $conf ;
2014-03-04 17:55:55 +00:00
2020-10-31 13:32:18 +00:00
$this -> db = $db ;
2014-03-05 11:25:31 +00:00
$this -> numero = 39000 ;
2014-03-04 17:55:55 +00:00
$this -> family = " products " ;
2018-10-06 09:57:53 +00:00
$this -> module_position = '45' ;
2018-02-25 09:55:02 +00:00
2019-01-27 10:55:16 +00:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
2014-03-04 17:55:55 +00:00
$this -> description = " Batch number, eat-by and sell-by date management module " ;
2014-12-09 13:03:10 +00:00
$this -> rights_class = 'productbatch' ;
2014-03-04 17:55:55 +00:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
2015-04-08 16:40:10 +00:00
$this -> version = 'dolibarr' ;
2014-03-04 17:55:55 +00:00
// Key used in llx_const table to save module status enabled/disabled (where dluo is value of property name of module in uppercase)
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
2020-04-12 19:36:57 +00:00
$this -> picto = 'lot' ;
2014-03-04 17:55:55 +00:00
$this -> module_parts = array ();
// Data directories to create when module is enabled.
$this -> dirs = array ();
// Config pages. Put here list of php page, stored into productdluo/admin directory, to use to setup module.
2021-03-15 10:42:33 +00:00
$this -> config_page_url = array ( " product_lot.php@product " );
2014-03-04 17:55:55 +00:00
// Dependencies
2020-04-10 08:59:32 +00:00
$this -> hidden = false ; // A condition to hide module
$this -> depends = array ( " modProduct " , " modStock " , " modExpedition " , " modFournisseur " ); // List of module class names as string that must be enabled if this module is enabled
$this -> requiredby = array (); // List of module ids to disable if this one is disabled
$this -> conflictwith = array (); // List of module class names as string this module is in conflict with
2021-02-06 12:48:31 +00:00
$this -> phpmin = array ( 5 , 6 ); // Minimum version of PHP required by module
2020-04-10 08:59:32 +00:00
$this -> need_dolibarr_version = array ( 3 , 0 ); // Minimum version of Dolibarr required by module
2014-03-04 17:55:55 +00:00
$this -> langfiles = array ( " productbatch " );
2021-03-25 10:51:29 +00:00
// Constants
2014-03-04 17:55:55 +00:00
// Constants
$this -> const = array ();
2021-03-25 10:51:29 +00:00
$r = 0 ;
$this -> const [ $r ][ 0 ] = " PRODUCTBATCH_LOT_ADDON " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " mod_lot_free " ;
$this -> const [ $r ][ 3 ] = 'Module to control product codes' ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
$this -> const [ $r ][ 0 ] = " PRODUCTBATCH_SN_ADDON " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " mod_sn_free " ;
$this -> const [ $r ][ 3 ] = 'Module to control product codes' ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2014-03-04 17:55:55 +00:00
2020-10-31 13:32:18 +00:00
$this -> tabs = array ();
2014-03-04 17:55:55 +00:00
2020-10-31 13:32:18 +00:00
// Dictionaries
2021-02-23 21:03:23 +00:00
if ( ! isset ( $conf -> productbatch -> enabled )) {
2020-10-31 13:32:18 +00:00
$conf -> productbatch = new stdClass ();
$conf -> productbatch -> enabled = 0 ;
}
2020-04-10 08:59:32 +00:00
$this -> dictionaries = array ();
2014-03-04 17:55:55 +00:00
2020-10-31 13:32:18 +00:00
// Boxes
$this -> boxes = array (); // List of boxes
2014-03-04 17:55:55 +00:00
// Permissions
2020-04-10 08:59:32 +00:00
$this -> rights = array (); // Permission array used by this module
$r = 0 ;
2014-03-04 17:55:55 +00:00
2018-02-25 09:55:02 +00:00
2016-09-30 11:02:13 +00:00
// Menus
//-------
2020-04-10 08:59:32 +00:00
$this -> menu = 1 ; // This module add menu entries. They are coded into menu manager.
2018-02-25 09:55:02 +00:00
2014-03-04 17:55:55 +00:00
// Exports
2020-04-10 08:59:32 +00:00
$r = 0 ;
2014-03-04 17:55:55 +00:00
}
/**
* Function called when module is enabled .
* The init function add constants , boxes , permissions and menus ( defined in constructor ) into Dolibarr database .
* It also creates data directories
*
2020-10-31 13:32:18 +00:00
* @ param string $options Options when enabling module ( '' , 'noboxes' )
2014-03-04 17:55:55 +00:00
* @ return int 1 if OK , 0 if KO
*/
2019-02-25 21:50:19 +00:00
public function init ( $options = '' )
2014-03-04 17:55:55 +00:00
{
2020-10-31 13:32:18 +00:00
global $db , $conf ;
2015-04-08 16:40:10 +00:00
2014-03-04 17:55:55 +00:00
$sql = array ();
2015-04-08 16:40:10 +00:00
2020-04-10 08:59:32 +00:00
if ( ! empty ( $conf -> cashdesk -> enabled )) {
2020-10-31 13:32:18 +00:00
if ( empty ( $conf -> global -> CASHDESK_NO_DECREASE_STOCK )) {
include_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
$res = dolibarr_set_const ( $db , " CASHDESK_NO_DECREASE_STOCK " , 1 , 'chaine' , 0 , '' , $conf -> entity );
}
2015-02-09 16:19:20 +00:00
}
2015-04-08 16:40:10 +00:00
2014-03-04 17:55:55 +00:00
return $this -> _init ( $sql , $options );
}
}