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