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