dolibarr  16.0.5
modBarcode.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
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  */
20 
29 include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30 
35 {
41  public function __construct($db)
42  {
43  $this->db = $db;
44  $this->numero = 55;
45 
46  $this->family = "technic";
47  // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
48  $this->name = preg_replace('/^mod/i', '', get_class($this));
49  $this->description = "Gestion des codes barres";
50  // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
51  $this->version = 'dolibarr';
52  $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
53  $this->picto = 'barcode';
54 
55  // Data directories to create when module is enabled
56  $this->dirs = array("/barcode/temp");
57 
58  // Dependencies
59  $this->depends = array(); // May be used for product or service or third party module
60  $this->requiredby = array();
61 
62  // Config pages
63  $this->config_page_url = array("barcode.php");
64 
65  // Constants
66  // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
67  // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
68  $this->const = array();
69  //$this->const[0] = array('BARCODE_LABEL_LEFT_TEXT','chaine','%BARCODE%','Print barcode on left side of label',1);
70  //$this->const[1] = array('BARCODE_LABEL_RIGHT_TEXT','chaine','%LOGO%','Print Company logo on right side',1);
71  //$this->const[2] = array('BARCODE_LABEL_HEADER_TEXT','chaine','My header','Print header text on label',1);
72  //$this->const[3] = array('BARCODE_LABEL_FOOTER_TEXT','chaine','My footer','Print footer text on label',1);
73 
74  // Boxes
75  $this->boxes = array();
76 
77  // Permissions
78  $this->rights = array();
79  $this->rights_class = 'barcode';
80 
81  $this->rights[1][0] = 301; // id de la permission
82  $this->rights[1][1] = 'Read barcodes'; // libelle de la permission
83  $this->rights[1][2] = 'r'; // type de la permission (deprecie a ce jour)
84  $this->rights[1][3] = 1; // La permission est-elle une permission par defaut
85  $this->rights[1][4] = 'lire_advance';
86 
87  $this->rights[2][0] = 302; // id de la permission
88  $this->rights[2][1] = 'Create/modify barcodes'; // libelle de la permission
89  $this->rights[2][2] = 'w'; // type de la permission (deprecie a ce jour)
90  $this->rights[2][3] = 0; // La permission est-elle une permission par defaut
91  $this->rights[2][4] = 'creer_advance';
92 
93  // Main menu entries
94  $r = 0;
95 
96  // A menu entry for the Tools top menu
97  $this->menu[$r] = array(
98  '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
99  'mainmenu'=>'tools',
100  'leftmenu'=>'barcodeprint',
101  'type'=>'left', // This is a Left menu entry
102  'titre'=>'BarCodePrintsheet',
103  'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
104  'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint',
105  'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
106  'position'=>200,
107  'enabled'=>'$conf->barcode->enabled', // 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.
108  'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
109  'target'=>'',
110  'user'=>0, // 0=Menu for internal users, 1=external users, 2=both
111  );
112  $r++;
113 
114  // A menu entry for the left menu
115  $this->menu[$r] = array(
116  '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
117  'type'=>'left', // This is a Left menu entry
118  'titre'=>'MassBarcodeInit',
119  'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=admintools',
120  'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
121  'position'=>300,
122  'enabled'=>'$conf->barcode->enabled && 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.
123  'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->creer_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
124  'target'=>'',
125  'user'=>0, // 0=Menu for internal users, 1=external users, 2=both
126  );
127  $r++;
128  }
129 
130 
139  public function init($options = '')
140  {
141  // Permissions
142  $this->remove($options);
143 
144  $sql = array(
145  array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)", 'ignoreerror'=>1),
146  array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1),
147  array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1),
148  array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)", 'ignoreerror'=>1),
149  array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)", 'ignoreerror'=>1),
150  array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)", 'ignoreerror'=>1),
151  array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)", 'ignoreerror'=>1),
152  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)
153  );
154 
155  return $this->_init($sql, $options);
156  }
157 }
modBarcode
Class to describe Barcode.
Definition: modBarcode.class.php:34
modBarcode\init
init($options='')
Function called when module is enabled.
Definition: modBarcode.class.php:139
db
$conf db
API class for accounts.
Definition: inc.php:41
description
print *****$script_file(".$version.") pid cd cd cd description as description
Definition: email_expire_services_to_customers.php:83
name
$conf db name
Definition: repair.php:122
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
DolibarrModules\_init
_init($array_sql, $options='')
Enables a module.
Definition: DolibarrModules.class.php:383
DolibarrModules
Class DolibarrModules.
Definition: DolibarrModules.class.php:37
modBarcode\__construct
__construct($db)
Constructor.
Definition: modBarcode.class.php:41