dolibarr  7.0.0-beta
modMargin.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
3  * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
25 include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
26 
27 
32 {
38  function __construct($db)
39  {
40  $this->db = $db;
41 
42  // Id for module (must be unique).
43  // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
44  $this->numero = 59000;
45  // Key text used to identify module (for permissions, menus, etc...)
46  $this->rights_class = 'margins';
47 
48  // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
49  // It is used to group modules in module setup page
50  $this->family = "financial";
51  $this->module_position = 550;
52  // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53  $this->name = preg_replace('/^mod/i','',get_class($this));
54  // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
55  $this->description = "Margin management";
56  // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57  $this->version = 'dolibarr';
58  // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
59  $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60  // Where to store the module in setup page (0=common,1=interface,2=other)
61  $this->special = 2;
62  // Name of png file (without png) used for this module.
63  // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png.
64  $this->picto='margin';
65 
66  // Data directories to create when module is enabled.
67  $this->dirs = array('/margin/temp');
68 
69  // Config pages. Put here list of php page names stored in admmin directory used to setup module.
70  $this->config_page_url = array("margin.php@margin");
71 
72  // Dependencies
73  $this->depends = array("modPropale", "modProduct"); // List of modules id that must be enabled if this module is enabled
74  $this->requiredby = array(); // List of modules id to disable if this one is disabled
75  $this->phpmin = array(5,1); // Minimum version of PHP required by module
76  $this->need_dolibarr_version = array(3,2); // Minimum version of Dolibarr required by module
77  $this->langfiles = array("margins");
78 
79  // Constants
80  // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
81  // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
82  // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
83  // );
84  $this->const = array(0=>array('MARGIN_TYPE','chaine','costprice','Rule for margin calculation by default',0,'current',0)); // List of particular constants to add when module is enabled
85 
86  // New pages on tabs
87  $this->tabs = array(
88  'product:+margin:Margins:margins:$user->rights->margins->liretous:/margin/tabs/productMargins.php?id=__ID__',
89  'thirdparty:+margin:Margins:margins:empty($user->societe_id) && $user->rights->margins->liretous && ($object->client > 0):/margin/tabs/thirdpartyMargins.php?socid=__ID__'
90  );
91 
92 
93  // Boxes
94  $this->boxes = array(); // List of boxes
95  $r=0;
96 
97  // Permissions
98  $this->rights = array(); // Permission array used by this module
99  $r=0;
100 
101  // Main menu entries
102  $this->menu = array(); // List of menus to add
103  $r = 0;
104 
105  // left menu entry
106  $this->menu[$r]=array(
107  'fk_menu'=>'fk_mainmenu=billing', // Put 0 if this is a top menu
108  'type'=>'left', // This is a Top menu entry
109  'titre'=>'Margins',
110  'mainmenu'=>'billing',
111  'leftmenu'=>'margins',
112  'url'=>'/margin/index.php',
113  'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
114  'position'=>100,
115  'enabled'=>'$conf->margin->enabled', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
116  'perms'=>'$user->rights->margins->liretous', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
117  'target'=>'',
118  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
119  $r++;
120 
121  // Permissions
122  $this->rights = array();
123  $r=0;
124 
125  $r++;
126  $this->rights[$r][0] = 59001; // id de la permission
127  $this->rights[$r][1] = 'Visualiser les marges'; // libelle de la permission
128  $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
129  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
130  $this->rights[$r][4] = 'liretous';
131 
132  $r++;
133  $this->rights[$r][0] = 59002; // id de la permission
134  $this->rights[$r][1] = 'Définir les marges'; // libelle de la permission
135  $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
136  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
137  $this->rights[$r][4] = 'creer';
138 
139  $r++;
140  $this->rights[$r][0] = 59003; // id de la permission
141  $this->rights[$r][1] = 'Read every user margin'; // libelle de la permission
142  $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
143  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
144  $this->rights[$r][4] = 'read';
145  $this->rights[$r][5] = 'all';
146  }
147 }
148 
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
Class to describe module Margin.
__construct($db)
Constructor.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104