dolibarr  17.0.3
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 <https://www.gnu.org/licenses/>.
17  */
18 
25 include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
26 
27 
32 {
38  public 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 = '55';
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  // Name of png file (without png) used for this module.
61  // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png.
62  $this->picto = 'margin';
63 
64  // Data directories to create when module is enabled.
65  $this->dirs = array('/margin/temp');
66 
67  // Config pages. Put here list of php page names stored in admmin directory used to setup module.
68  $this->config_page_url = array("margin.php@margin");
69 
70  // Dependencies
71  $this->hidden = false; // A condition to hide module
72  $this->depends = array("modPropale", "modProduct"); // List of module class names as string that must be enabled if this module is enabled
73  $this->requiredby = array(); // List of module ids to disable if this one is disabled
74  $this->conflictwith = array(); // List of module class names as string this module is in conflict with
75  $this->phpmin = array(7, 0); // 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->socid) && $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  'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
111  'mainmenu'=>'billing',
112  'leftmenu'=>'margins',
113  'url'=>'/margin/index.php',
114  'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
115  'position'=>100,
116  '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.
117  'perms'=>'$user->rights->margins->liretous', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
118  'target'=>'',
119  'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
120  );
121  $r++;
122 
123  // Permissions
124  $this->rights = array();
125  $r = 0;
126 
127  $r++;
128  $this->rights[$r][0] = 59001; // id de la permission
129  $this->rights[$r][1] = 'Visualiser les marges'; // libelle de la permission
130  $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
131  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
132  $this->rights[$r][4] = 'liretous';
133 
134  $r++;
135  $this->rights[$r][0] = 59002; // id de la permission
136  $this->rights[$r][1] = 'Définir les marges'; // libelle de la permission
137  $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
138  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
139  $this->rights[$r][4] = 'creer';
140 
141  $r++;
142  $this->rights[$r][0] = 59003; // id de la permission
143  $this->rights[$r][1] = 'Read every user margin'; // libelle de la permission
144  $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
145  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
146  $this->rights[$r][4] = 'read';
147  $this->rights[$r][5] = 'all';
148  }
149 }
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
modMargin
Class to describe module Margin.
Definition: modMargin.class.php:31
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:4024
modMargin\__construct
__construct($db)
Constructor.
Definition: modMargin.class.php:38
DolibarrModules
Class DolibarrModules.
Definition: DolibarrModules.class.php:37