2005-07-08 16:46:57 +02:00
< ? php
/* Copyright ( C ) 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2008-09-02 11:55:31 +02:00
* Copyright ( C ) 2005 - 2008 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2009 Regis Houssin < regis . houssin @ inodbox . com >
2015-08-07 12:45:27 +02:00
* Copyright ( C ) 2015 Juanjo Menent < jmenent @ 2 byte . es >
2005-07-08 16:46:57 +02:00
*
* 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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2005-07-08 16:46:57 +02:00
* ( 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 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2005-07-08 16:46:57 +02:00
*/
/**
2009-07-30 00:52:08 +02:00
* \defgroup barcode Module barcode
2008-10-28 21:37:30 +01:00
* \brief Module pour gerer les codes barres
2011-10-24 14:11:49 +02:00
* \file htdocs / core / modules / modBarcode . class . php
2021-03-20 13:55:43 +01:00
* \ingroup barcode , product
* \brief Description and activation file for the module barcode
2008-10-01 21:10:17 +02:00
*/
2005-07-08 16:46:57 +02:00
2020-04-10 10:59:32 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2005-07-08 16:46:57 +02:00
/**
2014-03-16 17:37:54 +01:00
* Class to describe Barcode
2008-10-01 21:10:17 +02:00
*/
2005-07-08 16:46:57 +02:00
class modBarcode extends DolibarrModules
{
2008-10-01 21:10:17 +02:00
/**
2011-09-26 16:22:35 +02:00
* Constructor . Define names , constants , directories , boxes , permissions
*
2012-01-04 21:23:50 +01:00
* @ param DoliDB $db Database handler
2008-10-01 21:10:17 +02:00
*/
2019-02-25 20:35:59 +01:00
public function __construct ( $db )
2008-10-01 21:10:17 +02:00
{
2012-01-04 21:23:50 +01:00
$this -> db = $db ;
$this -> numero = 55 ;
2008-10-01 21:10:17 +02:00
$this -> family = " technic " ;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
2019-01-27 11:55:16 +01:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
2008-10-01 21:10:17 +02:00
$this -> description = " Gestion des codes barres " ;
2017-08-22 18:34:58 +02:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this -> version = 'dolibarr' ;
2008-10-06 09:39:52 +02:00
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
2020-04-10 10:59:32 +02:00
$this -> picto = 'barcode' ;
2008-10-01 21:10:17 +02:00
2009-04-28 15:04:35 +02:00
// Data directories to create when module is enabled
2009-05-04 13:40:00 +02:00
$this -> dirs = array ( " /barcode/temp " );
2009-04-28 15:04:35 +02:00
2015-09-07 15:29:51 +02:00
// Dependencies
2020-04-10 10:59:32 +02:00
$this -> depends = array (); // May be used for product or service or third party module
2008-10-01 21:10:17 +02:00
$this -> requiredby = array ();
// Config pages
2011-08-16 12:11:00 +02:00
$this -> config_page_url = array ( " barcode.php " );
2008-10-01 21:10:17 +02:00
2010-04-18 18:08:53 +02:00
// Constants
// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
2015-05-03 11:51:54 +02:00
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
2015-05-03 10:07:04 +02:00
$this -> const = array ();
2015-05-03 11:51:54 +02:00
//$this->const[0] = array('BARCODE_LABEL_LEFT_TEXT','chaine','%BARCODE%','Print barcode on left side of label',1);
//$this->const[1] = array('BARCODE_LABEL_RIGHT_TEXT','chaine','%LOGO%','Print Company logo on right side',1);
//$this->const[2] = array('BARCODE_LABEL_HEADER_TEXT','chaine','My header','Print header text on label',1);
//$this->const[3] = array('BARCODE_LABEL_FOOTER_TEXT','chaine','My footer','Print footer text on label',1);
2008-10-01 21:10:17 +02:00
// Boxes
$this -> boxes = array ();
// Permissions
$this -> rights = array ();
$this -> rights_class = 'barcode' ;
2022-09-08 14:58:00 +02:00
$r = 0 ;
2008-10-01 21:10:17 +02:00
2022-09-08 14:58:00 +02:00
$this -> rights [ $r ][ 0 ] = 301 ; // id de la permission
$this -> rights [ $r ][ 1 ] = 'Generate PDF sheets of barcodes' ; // libelle de la permission
2024-01-13 19:48:20 +01:00
$this -> rights [ $r ][ 2 ] = 'r' ; // type de la permission (deprecated)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par default
2022-09-08 14:58:00 +02:00
$this -> rights [ $r ][ 4 ] = 'read' ;
$r ++ ;
2008-10-01 21:10:17 +02:00
2022-09-08 14:58:00 +02:00
$this -> rights [ $r ][ 0 ] = 304 ; // id de la permission
$this -> rights [ $r ][ 1 ] = 'Read barcodes' ; // libelle de la permission
2024-01-13 19:48:20 +01:00
$this -> rights [ $r ][ 2 ] = 'r' ; // type de la permission (deprecated)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par default
2022-09-08 14:58:00 +02:00
$this -> rights [ $r ][ 4 ] = 'lire_advance' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 305 ; // id de la permission
$this -> rights [ $r ][ 1 ] = 'Create/modify barcodes' ; // libelle de la permission
2024-01-13 19:48:20 +01:00
$this -> rights [ $r ][ 2 ] = 'w' ; // type de la permission (deprecated)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par default
2022-09-08 14:58:00 +02:00
$this -> rights [ $r ][ 4 ] = 'creer_advance' ;
$r ++ ;
2008-10-01 21:10:17 +02:00
2020-10-31 14:32:18 +01:00
// Main menu entries
$r = 0 ;
2021-07-16 14:05:42 +02:00
2022-03-03 01:17:44 +01:00
// A menu entry for the Tools top menu
2021-02-07 22:15:20 +01:00
$this -> menu [ $r ] = array (
'fk_menu' => 'fk_mainmenu=tools' , // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'mainmenu' => 'tools' ,
'leftmenu' => 'barcodeprint' ,
'type' => 'left' , // This is a Left menu entry
'titre' => 'BarCodePrintsheet' ,
'prefix' => img_picto ( '' , $this -> picto , 'class="paddingright pictofixedwidth"' ),
'url' => '/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint' ,
'langs' => 'products' , // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position' => 200 ,
2022-09-08 14:58:00 +02:00
'enabled' => 'isModEnabled("barcode")' , // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms' => '$user->hasRight("barcode", "read")' ,
2021-02-07 22:15:20 +01:00
'target' => '' ,
2021-07-16 14:05:42 +02:00
'user' => 0 , // 0=Menu for internal users, 1=external users, 2=both
2021-02-07 22:15:20 +01:00
);
2014-02-18 20:49:22 +01:00
$r ++ ;
2022-03-03 01:17:44 +01:00
// A menu entry for the left menu
2021-02-07 22:15:20 +01:00
$this -> menu [ $r ] = array (
'fk_menu' => 'fk_mainmenu=home,fk_leftmenu=admintools' , // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type' => 'left' , // This is a Left menu entry
'titre' => 'MassBarcodeInit' ,
'url' => '/barcode/codeinit.php?mainmenu=home&leftmenu=admintools' ,
'langs' => 'products' , // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position' => 300 ,
2022-09-08 14:58:00 +02:00
'enabled' => 'isModEnabled("barcode") && preg_match(\'/^(admintools|all)/\',$leftmenu)' , // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms' => '$user->admin' ,
2021-02-07 22:15:20 +01:00
'target' => '' ,
'user' => 0 , // 0=Menu for internal users, 1=external users, 2=both
);
2014-02-18 20:49:22 +01:00
$r ++ ;
2008-10-01 21:10:17 +02:00
}
2020-10-31 14:32:18 +01: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 .
*
* @ param string $options Options when enabling module ( '' , 'noboxes' )
2012-03-03 17:37:45 +01:00
* @ return int 1 if OK , 0 if KO
2008-10-01 21:10:17 +02:00
*/
2019-02-26 21:13:07 +01:00
public function init ( $options = '' )
2008-10-01 21:10:17 +02:00
{
// Permissions
2012-03-03 17:37:45 +01:00
$this -> remove ( $options );
2008-10-01 21:10:17 +02:00
2012-08-22 17:33:09 +02:00
$sql = array (
2021-02-07 22:15:20 +01:00
array ( 'sql' => " INSERT INTO " . MAIN_DB_PREFIX . " c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__) " , 'ignoreerror' => 1 ),
array ( 'sql' => " INSERT INTO " . MAIN_DB_PREFIX . " c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__) " , 'ignoreerror' => 1 ),
array ( 'sql' => " INSERT INTO " . MAIN_DB_PREFIX . " c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__) " , 'ignoreerror' => 1 ),
array ( 'sql' => " INSERT INTO " . MAIN_DB_PREFIX . " c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__) " , 'ignoreerror' => 1 ),
array ( 'sql' => " INSERT INTO " . MAIN_DB_PREFIX . " c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__) " , 'ignoreerror' => 1 ),
array ( 'sql' => " INSERT INTO " . MAIN_DB_PREFIX . " c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__) " , 'ignoreerror' => 1 ),
array ( 'sql' => " INSERT INTO " . MAIN_DB_PREFIX . " c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__) " , 'ignoreerror' => 1 ),
array ( 'sql' => " INSERT INTO " . MAIN_DB_PREFIX . " c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__) " , 'ignoreerror' => 1 )
2012-08-22 17:33:09 +02:00
);
return $this -> _init ( $sql , $options );
2008-10-01 21:10:17 +02:00
}
2005-07-08 16:46:57 +02:00
}