dolibarr 24.0.0-beta
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
29include_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 // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
67 // Example: $this->const=array(1 => array('MYMODULE_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
68 // 2 => array('MYMODULE_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
69 $this->const = array(
70 0 => array('BARCODE_USE_ON_PRODUCT', 'chaine', '1', 'Constant to activate barcode for products', 0)
71 );
72
73 // Boxes
74 $this->boxes = array();
75
76 // Permissions
77 $this->rights = array();
78 $this->rights_class = 'barcode';
79 $r = 0;
80
81 $this->rights[$r][0] = 301; // id de la permission
82 $this->rights[$r][1] = 'Generate PDF sheets of barcodes'; // libelle de la permission
83 $this->rights[$r][2] = 'r'; // type de la permission (deprecated)
84 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
85 $this->rights[$r][4] = 'read';
86 $r++;
87
88 $this->rights[$r][0] = 304; // id de la permission
89 $this->rights[$r][1] = 'Read barcodes'; // libelle de la permission
90 $this->rights[$r][2] = 'r'; // type de la permission (deprecated)
91 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
92 $this->rights[$r][4] = 'lire_advance';
93 $r++;
94
95 $this->rights[$r][0] = 305; // id de la permission
96 $this->rights[$r][1] = 'Create/modify barcodes'; // libelle de la permission
97 $this->rights[$r][2] = 'w'; // type de la permission (deprecated)
98 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
99 $this->rights[$r][4] = 'creer_advance';
100 $r++;
101
102 // Main menu entries
103 $r = 0;
104
105 // A menu entry for the Tools top menu
106 $this->menu[$r] = array(
107 '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
108 'mainmenu'=>'tools',
109 'leftmenu'=>'barcodeprint',
110 'type'=>'left', // This is a Left menu entry
111 'titre'=>'BarCodePrintsheet',
112 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
113 'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint',
114 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
115 'position'=>200,
116 '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.
117 'perms'=>'$user->hasRight("barcode", "read")',
118 'target'=>'',
119 'user'=>0, // 0=Menu for internal users, 1=external users, 2=both
120 );
121 $r++;
122
123 // A menu entry for the left menu
124 $this->menu[$r] = array(
125 '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
126 'type'=>'left', // This is a Left menu entry
127 'titre'=>'MassBarcodeInit',
128 'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=admintools',
129 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
130 'position'=>300,
131 '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.
132 'perms'=>'$user->admin',
133 'target'=>'',
134 'user'=>0, // 0=Menu for internal users, 1=external users, 2=both
135 );
136 $r++;
137 }
138
139
148 public function init($options = '')
149 {
150 // Permissions
151 $this->remove($options);
152
153 $sql = array(
154 array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)", 'ignoreerror'=>1),
155 array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1),
156 array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1),
157 array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)", 'ignoreerror'=>1),
158 array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)", 'ignoreerror'=>1),
159 array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)", 'ignoreerror'=>1),
160 array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)", 'ignoreerror'=>1),
161 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)
162 );
163
164 return $this->_init($sql, $options);
165 }
166}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
Class to describe Barcode.
init($options='')
Function called when module is enabled.
__construct($db)
Constructor.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133