dolibarr 18.0.6
modHRM.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2015-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 * or see https://www.gnu.org/
17 */
18
25include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php";
26
27
32{
38 public function __construct($db)
39 {
40 global $langs, $conf;
41
42 $this->db = $db;
43
44 // Id for module (must be unique).
45 // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
46 $this->numero = 4000;
47 // Key text used to identify module (for permissions, menus, etc...)
48 $this->rights_class = 'hrm';
49
50 // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
51 // It is used to group modules in module setup page
52 $this->family = "hr";
53 $this->module_position = '50';
54 // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
55 $this->name = preg_replace('/^mod/i', '', get_class($this));
56 // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
57 $this->description = "HRM";
58 // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
59 $this->version = 'dolibarr';
60 // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
61 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
62 // Name of image file used for this module.
63 // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
64 // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
65 $this->picto = 'hrm';
66
67 // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
68 $this->module_parts = array(
69 // Set this to 1 if module has its own trigger directory (core/triggers)
70 'triggers' => 0,
71 // Set this to 1 if module has its own login method file (core/login)
72 'login' => 0,
73 // Set this to 1 if module has its own substitution function file (core/substitutions)
74 'substitutions' => 0,
75 // Set this to 1 if module has its own menus handler directory (core/menus)
76 'menus' => 0,
77 // Set this to 1 if module overwrite template dir (core/tpl)
78 'tpl' => 0,
79 // Set this to 1 if module has its own barcode directory (core/modules/barcode)
80 'barcode' => 0,
81 // Set this to 1 if module has its own models directory (core/modules/xxx)
82 'models' => 1,
83 // Set this to 1 if module has its own printing directory (core/modules/printing)
84 'printing' => 0,
85 // Set this to 1 if module has its own theme directory (theme)
86 'theme' => 0,
87 // Set this to relative path of css file if module has its own css file
88 'css' => array(),
89 // Set this to relative path of js file if module must load a js on all pages
90 'js' => array(),
91
92 // Set this to 1 if features of module are opened to external users
93 'moduleforexternal' => 0,
94 );
95
96 // Data directories to create when module is enabled.
97 // Example: this->dirs = array("/hrm/temp","/hrm/subdir");
98 $this->dirs = array("/hrm/temp");
99
100 // Config pages. Put here list of php page, stored into hrm/admin directory, to use to setup module.
101 $this->config_page_url = array("hrm.php");
102
103 // Dependencies
104 $this->hidden = false; // A condition to hide module
105 $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
106 $this->requiredby = array(); // List of module ids to disable if this one is disabled
107 $this->conflictwith = array(); // List of module class names as string this module is in conflict with
108 $this->phpmin = array(7, 0); // Minimum version of PHP required by module
109 $this->need_dolibarr_version = array(11, 0); // Minimum version of Dolibarr required by module
110 $this->langfiles = array("hrm");
111
112 // Constants
113 // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
114 // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
115 // 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0)
116 $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities')
117 $r = 0;
118
119
120 if (!isset($conf->hrm) || !isset($conf->hrm->enabled)) {
121 $conf->hrm = new stdClass();
122 $conf->hrm->enabled = 0;
123 }
124
125 // Array to add new pages in new tabs
126 $this->tabs = array();
127 $this->tabs[] = array('data'=>'user:+skill_tab:Skills:hrm:1:/hrm/skill_tab.php?id=__ID__&objecttype=user'); // To add a new tab identified by code tabname1
128 //$this->tabs[] = array('data'=>'job:+tabname1:Poste:mylangfile@hrm:1:/hrm/poste_list.php?fk_job=__ID__'); // To add a new tab identified by code tabname1
129 // Example:
130 // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@hrm:$user->rights->hrm->read:/hrm/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
131 // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@hrm:$user->rights->othermodule->read:/hrm/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
132 // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
133 //
134 // Where objecttype can be
135 // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
136 // 'contact' to add a tab in contact view
137 // 'contract' to add a tab in contract view
138 // 'group' to add a tab in group view
139 // 'intervention' to add a tab in intervention view
140 // 'invoice' to add a tab in customer invoice view
141 // 'invoice_supplier' to add a tab in supplier invoice view
142 // 'member' to add a tab in fundation member view
143 // 'opensurveypoll' to add a tab in opensurvey poll view
144 // 'order' to add a tab in sales order view
145 // 'order_supplier' to add a tab in supplier order view
146 // 'payment' to add a tab in payment view
147 // 'payment_supplier' to add a tab in supplier payment view
148 // 'product' to add a tab in product view
149 // 'propal' to add a tab in propal view
150 // 'project' to add a tab in project view
151 // 'stock' to add a tab in stock view
152 // 'thirdparty' to add a tab in third party view
153 // 'user' to add a tab in user view
154
155
156 // Dictionaries
157 $this->dictionaries = array();
158
159 // Boxes/Widgets
160 // Add here list of php file(s) stored in hrm/core/boxes that contains a class to show a widget.
161 $this->boxes = array(
162 // 0 => array(
163 // 'file' => 'hrmwidget1.php@hrm',
164 // 'note' => 'Widget provided by HrmTest',
165 // 'enabledbydefaulton' => 'Home',
166 // ),
167 // ...
168 );
169
170 // Cronjobs (List of cron jobs entries to add when module is enabled)
171 // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
172 $this->cronjobs = array(
173 // 0 => array(
174 // 'label' => 'MyJob label',
175 // 'jobtype' => 'method',
176 // 'class' => '/hrm/class/poste.class.php',
177 // 'objectname' => 'Poste',
178 // 'method' => 'doScheduledJob',
179 // 'parameters' => '',
180 // 'comment' => 'Comment',
181 // 'frequency' => 2,
182 // 'unitfrequency' => 3600,
183 // 'status' => 0,
184 // 'test' => '$conf->hrm->enabled',
185 // 'priority' => 50,
186 // ),
187 );
188
189
190 // Permissions
191 $this->rights = array(); // Permission array used by this module
192 $r = 0;
193
194 // Skill / Job / Position
195 $this->rights[$r][0] = 4001; // Permission id (must not be already used)
196 $this->rights[$r][1] = 'Read skill/job/position'; // Permission label
197 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
198 $this->rights[$r][4] = 'all';
199 $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->all->read)
200 $r++;
201
202 $this->rights[$r][0] = 4002; // Permission id (must not be already used)
203 $this->rights[$r][1] = 'Create/modify skill/job/position'; // Permission label
204 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
205 $this->rights[$r][4] = 'all';
206 $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->all->write)
207 $r++;
208
209 $this->rights[$r][0] = 4003; // Permission id (must not be already used)
210 $this->rights[$r][1] = 'Delete skill/job/position'; // Permission label
211 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
212 $this->rights[$r][4] = 'all';
213 $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->all->delete)
214 $r++;
215
216 // Evaluation
217 $this->rights[$r][0] = 4021; // Permission id (must not be already used)
218 $this->rights[$r][1] = 'Read evaluations'; // Permission label
219 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
220 $this->rights[$r][4] = 'evaluation';
221 $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->read)
222 $r++;
223
224 $this->rights[$r][0] = 4022; // Permission id (must not be already used)
225 $this->rights[$r][1] = 'Create/modify your evaluation'; // Permission label
226 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
227 $this->rights[$r][4] = 'evaluation';
228 $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->write)
229 $r++;
230
231 $this->rights[$r][0] = 4023; // Permission id (must not be already used)
232 $this->rights[$r][1] = 'Validate evaluation'; // Permission label
233 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
234 $this->rights[$r][4] = 'evaluation_advance';
235 $this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->validate)
236 $r++;
237
238 $this->rights[$r][0] = 4025; // Permission id (must not be already used)
239 $this->rights[$r][1] = 'Delete evaluations'; // Permission label
240 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
241 $this->rights[$r][4] = 'evaluation';
242 $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->delete)
243 $r++;
244
245 // Comparison
246 $this->rights[$r][0] = 4028; // Permission id (must not be already used)
247 $this->rights[$r][1] = 'See comparison menu'; // Permission label
248 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
249 $this->rights[$r][4] = 'compare_advance';
250 $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->compare_advance->read)
251 $r++;
252
253 // Evaluation
254 $this->rights[$r][0] = 4029; // Permission id (must not be already used)
255 $this->rights[$r][1] = 'Read all evaluations'; // Permission label
256 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
257 $this->rights[$r][4] = 'evaluation';
258 $this->rights[$r][5] = 'readall'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->read)
259 $r++;
260
261 // Read employee
262 $this->rights[$r][0] = 4031; // Permission id (must not be already used)
263 $this->rights[$r][1] = 'Read personal/HR information'; // Permission label
264 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
265 $this->rights[$r][4] = 'read_personal_information';
266 $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->read_personal_information->read)
267 $r++;
268
269 // Write employee
270 $this->rights[$r][0] = 4032; // Permission id (must not be already used)
271 $this->rights[$r][1] = 'Write personal/HR information'; // Permission label
272 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
273 $this->rights[$r][4] = 'write_personal_information';
274 $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->write_personal_information->write)
275 $r++;
276 }
277
286 public function init($options = '')
287 {
288 // Permissions
289 $this->remove($options);
290
291 $result = $this->_load_tables('/install/mysql/', 'hrm');
292 if ($result < 0) {
293 return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
294 }
295
296 $sql = array();
297
298 return $this->_init($sql, $options);
299 }
300}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Description and activation class for module HRM.
__construct($db)
Constructor.
init($options='')
Function called when module is enabled.
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.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:123