dolibarr  7.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@capnetworks.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 <http://www.gnu.org/licenses/>.
19  */
20 
29 include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
30 
35 {
36 
42  function __construct($db)
43  {
44  $this->db = $db;
45  $this->numero = 55;
46 
47  $this->family = "technic";
48  // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49  $this->name = preg_replace('/^mod/i','',get_class($this));
50  $this->description = "Gestion des codes barres";
51  // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52  $this->version = 'dolibarr';
53  $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54  $this->special = 2;
55  $this->picto='barcode';
56 
57  // Data directories to create when module is enabled
58  $this->dirs = array("/barcode/temp");
59 
60  // Dependencies
61  $this->depends = array(); // May be used for product or service or third party module
62  $this->requiredby = array();
63 
64  // Config pages
65  $this->config_page_url = array("barcode.php");
66 
67  // Constants
68  // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
69  // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
70  $this->const = array();
71  //$this->const[0] = array('BARCODE_LABEL_LEFT_TEXT','chaine','%BARCODE%','Print barcode on left side of label',1);
72  //$this->const[1] = array('BARCODE_LABEL_RIGHT_TEXT','chaine','%LOGO%','Print Company logo on right side',1);
73  //$this->const[2] = array('BARCODE_LABEL_HEADER_TEXT','chaine','My header','Print header text on label',1);
74  //$this->const[3] = array('BARCODE_LABEL_FOOTER_TEXT','chaine','My footer','Print footer text on label',1);
75 
76  // Boxes
77  $this->boxes = array();
78 
79  // Permissions
80  $this->rights = array();
81  $this->rights_class = 'barcode';
82 
83  $this->rights[1][0] = 300; // id de la permission
84  $this->rights[1][1] = 'Read barcodes'; // libelle de la permission
85  $this->rights[1][2] = 'r'; // type de la permission (deprecie a ce jour)
86  $this->rights[1][3] = 1; // La permission est-elle une permission par defaut
87  $this->rights[1][4] = 'lire_advance';
88 
89  $this->rights[2][0] = 301; // id de la permission
90  $this->rights[2][1] = 'Create/modify barcodes'; // libelle de la permission
91  $this->rights[2][2] = 'w'; // type de la permission (deprecie a ce jour)
92  $this->rights[2][3] = 0; // La permission est-elle une permission par defaut
93  $this->rights[2][4] = 'creer_advance';
94 
95  // Main menu entries
96  $r=0;
97  $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
98  'mainmenu'=>'tools',
99  'leftmenu'=>'barcodeprint',
100  'type'=>'left', // This is a Left menu entry
101  'titre'=>'BarCodePrintsheet',
102  'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint',
103  'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
104  'position'=>200,
105  '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.
106  '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
107  'target'=>'',
108  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
109  $r++;
110 
111  $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
112  'type'=>'left', // This is a Left menu entry
113  'titre'=>'MassBarcodeInit',
114  'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=admintools',
115  'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
116  'position'=>300,
117  'enabled'=>'$conf->barcode->enabled && preg_match(\'/^admintools/\',$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.
118  '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
119  'target'=>'',
120  'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
121  $r++;
122  }
123 
124 
133  function init($options='')
134  {
135  // Permissions
136  $this->remove($options);
137 
138  $sql = array(
139  array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)",'ignoreerror'=>1),
140  array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1),
141  array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1),
142  array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)",'ignoreerror'=>1),
143  array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)",'ignoreerror'=>1),
144  array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)",'ignoreerror'=>1),
145  array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)",'ignoreerror'=>1),
146  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)
147  );
148 
149  return $this->_init($sql, $options);
150  }
151 }
__construct($db)
Constructor.
Class DolibarrModules.
</td >< tdclass="liste_titre"align="right"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="'.$i.'"'.$disabled.'></td >< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"></td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:554
init($options='')
Function called when module is enabled.
Class to describe Barcode.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
_init($array_sql, $options='')
Enables a module.