dolibarr 21.0.0-alpha
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 // 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 $r = 0;
81
82 $this->rights[$r][0] = 301; // id de la permission
83 $this->rights[$r][1] = 'Generate PDF sheets of barcodes'; // libelle de la permission
84 $this->rights[$r][2] = 'r'; // type de la permission (deprecated)
85 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
86 $this->rights[$r][4] = 'read';
87 $r++;
88
89 $this->rights[$r][0] = 304; // id de la permission
90 $this->rights[$r][1] = 'Read barcodes'; // libelle de la permission
91 $this->rights[$r][2] = 'r'; // type de la permission (deprecated)
92 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
93 $this->rights[$r][4] = 'lire_advance';
94 $r++;
95
96 $this->rights[$r][0] = 305; // id de la permission
97 $this->rights[$r][1] = 'Create/modify barcodes'; // libelle de la permission
98 $this->rights[$r][2] = 'w'; // type de la permission (deprecated)
99 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
100 $this->rights[$r][4] = 'creer_advance';
101 $r++;
102
103 // Main menu entries
104 $r = 0;
105
106 // A menu entry for the Tools top menu
107 $this->menu[$r] = array(
108 '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
109 'mainmenu'=>'tools',
110 'leftmenu'=>'barcodeprint',
111 'type'=>'left', // This is a Left menu entry
112 'titre'=>'BarCodePrintsheet',
113 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
114 'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint',
115 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
116 'position'=>200,
117 '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.
118 'perms'=>'$user->hasRight("barcode", "read")',
119 'target'=>'',
120 'user'=>0, // 0=Menu for internal users, 1=external users, 2=both
121 );
122 $r++;
123
124 // A menu entry for the left menu
125 $this->menu[$r] = array(
126 '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
127 'type'=>'left', // This is a Left menu entry
128 'titre'=>'MassBarcodeInit',
129 'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=admintools',
130 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
131 'position'=>300,
132 '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.
133 'perms'=>'$user->admin',
134 'target'=>'',
135 'user'=>0, // 0=Menu for internal users, 1=external users, 2=both
136 );
137 $r++;
138 }
139
140
149 public function init($options = '')
150 {
151 // Permissions
152 $this->remove($options);
153
154 $sql = array(
155 array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)", 'ignoreerror'=>1),
156 array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1),
157 array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1),
158 array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)", 'ignoreerror'=>1),
159 array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)", 'ignoreerror'=>1),
160 array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)", 'ignoreerror'=>1),
161 array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)", 'ignoreerror'=>1),
162 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)
163 );
164
165 return $this->_init($sql, $options);
166 }
167}
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)
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:142