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