dolibarr 19.0.3
modRecruitment.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2018-2019 Nicolas ZABOURI <info@inovea-conseil.com>
4 * Copyright (C) 2019-2021 Frédéric France <frederic.france@netlogic.fr>
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
28include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
29
30
35{
41 public function __construct($db)
42 {
43 global $langs, $conf;
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 = 750;
49 // Key text used to identify module (for permissions, menus, etc...)
50 $this->rights_class = 'recruitment';
51 // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
52 // It is used to group modules by family in module setup page
53 $this->family = "hr";
54 // Module position in the family on 2 digits ('01', '10', '20', ...)
55 $this->module_position = '44';
56 // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
57 //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
58 // Module label (no space allowed), used if translation string 'ModuleRecruitmentName' not found (Recruitment is name of module).
59 $this->name = preg_replace('/^mod/i', '', get_class($this));
60 // Module description, used if translation string 'ModuleRecruitmentDesc' not found (Recruitment is name of module).
61 $this->description = "Manage and follow recruitment campaign for new job positions";
62 // Used only if file README.md and README-LL.md not found.
63 $this->descriptionlong = "Manage and follow recruitment campaign for new job positions";
64 // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
65 $this->version = 'dolibarr';
66 // Url to the file with your last numberversion of this module
67 //$this->url_last_version = 'http://www.example.com/versionmodule.txt';
68
69 // Key used in llx_const table to save module status enabled/disabled (where RECRUITMENT is value of property name of module in uppercase)
70 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
71 // Name of image file used for this module.
72 // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
73 // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
74 $this->picto = 'recruitmentjobposition';
75 // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
76 $this->module_parts = array(
77 // Set this to 1 if module has its own trigger directory (core/triggers)
78 'triggers' => 0,
79 // Set this to 1 if module has its own login method file (core/login)
80 'login' => 0,
81 // Set this to 1 if module has its own substitution function file (core/substitutions)
82 'substitutions' => 0,
83 // Set this to 1 if module has its own menus handler directory (core/menus)
84 'menus' => 0,
85 // Set this to 1 if module overwrite template dir (core/tpl)
86 'tpl' => 0,
87 // Set this to 1 if module has its own barcode directory (core/modules/barcode)
88 'barcode' => 0,
89 // Set this to 1 if module has its own models directory (core/modules/xxx)
90 'models' => 1,
91 // Set this to 1 if module has its own theme directory (theme)
92 'theme' => 0,
93 // Set this to relative path of css file if module has its own css file
94 'css' => array(
95 // '/recruitment/css/recruitment.css.php',
96 ),
97 // Set this to relative path of js file if module must load a js on all pages
98 'js' => array(
99 // '/recruitment/js/recruitment.js.php',
100 ),
101 // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
102 'hooks' => array(
103 // 'data' => array(
104 // 'hookcontext1',
105 // 'hookcontext2',
106 // ),
107 // 'entity' => '0',
108 ),
109 // Set this to 1 if features of module are opened to external users
110 'moduleforexternal' => 0,
111 );
112 // Data directories to create when module is enabled.
113 // Example: this->dirs = array("/recruitment/temp","/recruitment/subdir");
114 $this->dirs = array("/recruitment/temp");
115 // Config pages. Put here list of php page, stored into recruitment/admin directory, to use to setup module.
116 $this->config_page_url = array("setup.php@recruitment");
117 // Dependencies
118 // A condition to hide module
119 $this->hidden = false;
120 // List of module class names as string that must be enabled if this module is enabled. Example: array('always'=>array('modModuleToEnable1','modModuleToEnable2'), 'FR'=>array('modModuleToEnableFR'...))
121 $this->depends = array();
122 $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
123 $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
124 $this->langfiles = array("recruitment");
125 $this->phpmin = array(7, 0); // Minimum version of PHP required by module
126 $this->need_dolibarr_version = array(11, -3); // Minimum version of Dolibarr required by module
127 $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
128 $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
129 //$this->automatic_activation = array('FR'=>'RecruitmentWasAutomaticallyActivatedBecauseOfYourCountryChoice');
130 //$this->always_enabled = true; // If true, can't be disabled
131
132 // Constants
133 // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
134 // Example: $this->const=array(1 => array('RECRUITMENT_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
135 // 2 => array('RECRUITMENT_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
136 // );
137 $r = 0;
138 $this->const[$r][0] = "RECRUITMENT_RECRUITMENTJOBPOSITION_ADDON";
139 $this->const[$r][1] = "chaine";
140 $this->const[$r][2] = "mod_recruitmentjobposition_standard";
141 $this->const[$r][3] = 'Name of manager to generate recruitment job position ref number';
142 $this->const[$r][4] = 0;
143 $r++;
144
145 $this->const[$r][0] = "RECRUITMENT_RECRUITMENTCANDIDATURE_ADDON";
146 $this->const[$r][1] = "chaine";
147 $this->const[$r][2] = "mod_recruitmentcandidature_standard";
148 $this->const[$r][3] = 'Name of manager to generate recruitment candidature ref number';
149 $this->const[$r][4] = 0;
150 $r++;
151
152 // Some keys to add into the overwriting translation tables
153 /*$this->overwrite_translation = array(
154 'en_US:ParentCompany'=>'Parent company or reseller',
155 'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
156 )*/
157
158 if (!isset($conf->recruitment) || !isset($conf->recruitment->enabled)) {
159 $conf->recruitment = new stdClass();
160 $conf->recruitment->enabled = 0;
161 }
162
163 // Array to add new pages in new tabs
164 $this->tabs = array();
165 // Example:
166 // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@recruitment:$user->rights->recruitment->read:/recruitment/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
167 // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@recruitment:$user->rights->othermodule->read:/recruitment/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.
168 // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
169 //
170 // Where objecttype can be
171 // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
172 // 'contact' to add a tab in contact view
173 // 'contract' to add a tab in contract view
174 // 'group' to add a tab in group view
175 // 'intervention' to add a tab in intervention view
176 // 'invoice' to add a tab in customer invoice view
177 // 'invoice_supplier' to add a tab in supplier invoice view
178 // 'member' to add a tab in fundation member view
179 // 'opensurveypoll' to add a tab in opensurvey poll view
180 // 'order' to add a tab in sales order view
181 // 'order_supplier' to add a tab in supplier order view
182 // 'payment' to add a tab in payment view
183 // 'payment_supplier' to add a tab in supplier payment view
184 // 'product' to add a tab in product view
185 // 'propal' to add a tab in propal view
186 // 'project' to add a tab in project view
187 // 'stock' to add a tab in stock view
188 // 'thirdparty' to add a tab in third party view
189 // 'user' to add a tab in user view
190
191 // Dictionaries
192 $this->dictionaries = array();
193
194 // Boxes/Widgets
195 // Add here list of php file(s) stored in recruitment/core/boxes that contains a class to show a widget.
196 $this->boxes = array(
197 // 0 => array(
198 // 'file' => 'recruitmentwidget1.php@recruitment',
199 // 'note' => 'Widget provided by Recruitment',
200 // 'enabledbydefaulton' => 'Home',
201 // ),
202 // ...
203 );
204
205 // Cronjobs (List of cron jobs entries to add when module is enabled)
206 // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
207 $this->cronjobs = array(
208 // 0 => array(
209 // 'label' => 'MyJob label',
210 // 'jobtype' => 'method',
211 // 'class' => '/recruitment/class/recruitmentjobposition.class.php',
212 // 'objectname' => 'RecruitmentJobPosition',
213 // 'method' => 'doScheduledJob',
214 // 'parameters' => '',
215 // 'comment' => 'Comment',
216 // 'frequency' => 2,
217 // 'unitfrequency' => 3600,
218 // 'status' => 0,
219 // 'test' => '$conf->recruitment->enabled',
220 // 'priority' => 50,
221 // ),
222 );
223 // Example: $this->cronjobs=array(
224 // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->recruitment->enabled', 'priority'=>50),
225 // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->recruitment->enabled', 'priority'=>50)
226 // );
227
228 // Permissions provided by this module
229 $this->rights = array();
230 $r = 0;
231 // Add here entries to declare new permissions
232 /* BEGIN MODULEBUILDER PERMISSIONS */
233 $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
234 $this->rights[$r][1] = 'Read job positions to fill and candidatures'; // Permission label
235 $this->rights[$r][4] = 'recruitmentjobposition'; // In php code, permission will be checked by test if ($user->rights->recruitment->level1->level2)
236 $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->recruitment->level1->level2)
237 $r++;
238 $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
239 $this->rights[$r][1] = 'Create/Update job positions to fill and candidatures'; // Permission label
240 $this->rights[$r][4] = 'recruitmentjobposition'; // In php code, permission will be checked by test if ($user->rights->recruitment->level1->level2)
241 $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->recruitment->level1->level2)
242 $r++;
243 $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
244 $this->rights[$r][1] = 'Delete Job positions to fill and candidatures'; // Permission label
245 $this->rights[$r][4] = 'recruitmentjobposition'; // In php code, permission will be checked by test if ($user->rights->recruitment->level1->level2)
246 $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->recruitment->level1->level2)
247 $r++;
248 /* END MODULEBUILDER PERMISSIONS */
249
250 // Main menu entries to add
251 $this->menu = array();
252 $r = 0;
253 // Add here entries to declare new menus
254 /* BEGIN MODULEBUILDER TOPMENU */
255 /* END MODULEBUILDER TOPMENU */
256 /* BEGIN MODULEBUILDER LEFTMENU RECRUITMENTJOBPOSITION */
257 $this->menu[$r++] = array(
258 'fk_menu'=>'fk_mainmenu=hrm', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
259 'type'=>'left', // This is a Top menu entry
260 'titre'=>'Recruitment',
261 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
262 'mainmenu'=>'hrm',
263 'leftmenu'=>'recruitmentjobposition',
264 'url'=>'/recruitment/index.php',
265 'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
266 'position'=>1000 + $r,
267 'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled.
268 'perms'=>'$user->hasRight("recruitment", "recruitmentjobposition", "read")', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
269 'target'=>'',
270 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
271 );
272 $this->menu[$r++] = array(
273 'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
274 'type'=>'left', // This is a Left menu entry
275 'titre'=>'NewPositionToBeFilled',
276 'mainmenu'=>'hrm',
277 'leftmenu'=>'recruitment_recruitmentjobposition_new',
278 'url'=>'/recruitment/recruitmentjobposition_card.php?action=create',
279 'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
280 'position'=>1000 + $r,
281 'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
282 'perms'=>'$user->rights->recruitment->recruitmentjobposition->write', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
283 'target'=>'',
284 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
285 );
286 $this->menu[$r++] = array(
287 'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
288 'type'=>'left', // This is a Left menu entry
289 'titre'=>'ListOfPositionsToBeFilled',
290 'mainmenu'=>'hrm',
291 'leftmenu'=>'recruitment_recruitmentjobposition_list',
292 'url'=>'/recruitment/recruitmentjobposition_list.php',
293 'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
294 'position'=>1000 + $r,
295 'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
296 'perms'=>'$user->hasRight("recruitment", "recruitmentjobposition", "read")', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
297 'target'=>'',
298 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
299 );
300 $this->menu[$r++] = array(
301 'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
302 'type'=>'left', // This is a Left menu entry
303 'titre'=>'NewCandidature',
304 'mainmenu'=>'hrm',
305 'leftmenu'=>'recruitment_recruitmentcandidature_new',
306 'url'=>'/recruitment/recruitmentcandidature_card.php?action=create',
307 'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
308 'position'=>1000 + $r,
309 'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
310 'perms'=>'$user->rights->recruitment->recruitmentjobposition->write', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
311 'target'=>'',
312 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
313 );
314 $this->menu[$r++] = array(
315 'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
316 'type'=>'left', // This is a Left menu entry
317 'titre'=>'ListOfCandidatures',
318 'mainmenu'=>'hrm',
319 'leftmenu'=>'recruitment_recruitmentcandidature_list',
320 'url'=>'/recruitment/recruitmentcandidature_list.php',
321 'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
322 'position'=>1000 + $r,
323 'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
324 'perms'=>'$user->hasRight("recruitment", "recruitmentjobposition", "read")', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
325 'target'=>'',
326 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
327 );
328 /* END MODULEBUILDER LEFTMENU RECRUITMENTJOBPOSITION */
329
330 // Exports profiles provided by this module
331 $r = 1;
332 /* BEGIN MODULEBUILDER EXPORT RECRUITMENTJOBPOSITION */
333 /*
334 $langs->load("recruitment");
335 $this->export_code[$r]=$this->rights_class.'_'.$r;
336 $this->export_label[$r]='RecruitmentJobPositionLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
337 $this->export_icon[$r]='recruitmentjobposition';
338 // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array
339 $keyforclass = 'RecruitmentJobPosition'; $keyforclassfile='/mymobule/class/recruitmentjobposition.class.php'; $keyforelement='recruitmentjobposition';
340 include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
341 //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text';
342 //unset($this->export_fields_array[$r]['t.fieldtoremove']);
343 //$keyforclass = 'RecruitmentJobPositionLine'; $keyforclassfile='/recruitment/class/recruitmentjobposition.class.php'; $keyforelement='recruitmentjobpositionline'; $keyforalias='tl';
344 //include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
345 $keyforselect='recruitmentjobposition'; $keyforaliasextra='extra'; $keyforelement='recruitmentjobposition';
346 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
347 //$keyforselect='recruitmentjobpositionline'; $keyforaliasextra='extraline'; $keyforelement='recruitmentjobpositionline';
348 //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
349 //$this->export_dependencies_array[$r] = array('recruitmentjobpositionline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
350 //$this->export_special_array[$r] = array('t.field'=>'...');
351 //$this->export_examplevalues_array[$r] = array('t.field'=>'Example');
352 //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp');
353 $this->export_sql_start[$r]='SELECT DISTINCT ';
354 $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'recruitmentjobposition as t';
355 //$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'recruitmentjobposition_line as tl ON tl.fk_recruitmentjobposition = t.rowid';
356 $this->export_sql_end[$r] .=' WHERE 1 = 1';
357 $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('recruitmentjobposition').')';
358 $r++; */
359 /* END MODULEBUILDER EXPORT RECRUITMENTJOBPOSITION */
360
361 // Imports profiles provided by this module
362 $r = 1;
363 /* BEGIN MODULEBUILDER IMPORT RECRUITMENTJOBPOSITION */
364 /*
365 $langs->load("recruitment");
366 $this->export_code[$r]=$this->rights_class.'_'.$r;
367 $this->export_label[$r]='RecruitmentJobPositionLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
368 $this->export_icon[$r]='recruitmentjobposition';
369 $keyforclass = 'RecruitmentJobPosition'; $keyforclassfile='/mymobule/class/recruitmentjobposition.class.php'; $keyforelement='recruitmentjobposition';
370 include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
371 $keyforselect='recruitmentjobposition'; $keyforaliasextra='extra'; $keyforelement='recruitmentjobposition';
372 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
373 //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
374 $this->export_sql_start[$r]='SELECT DISTINCT ';
375 $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'recruitmentjobposition as t';
376 $this->export_sql_end[$r] .=' WHERE 1 = 1';
377 $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('recruitmentjobposition').')';
378 $r++; */
379 /* END MODULEBUILDER IMPORT RECRUITMENTJOBPOSITION */
380 }
381
390 public function init($options = '')
391 {
392 global $conf, $langs;
393
394 $result = $this->_load_tables('/install/mysql/', 'recruitment');
395 if ($result < 0) {
396 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')
397 }
398
399 // Create extrafields during init
400 //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
401 //$extrafields = new ExtraFields($this->db);
402 //$result1=$extrafields->addExtraField('recruitment_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'recruitment', '$conf->recruitment->enabled');
403 //$result2=$extrafields->addExtraField('recruitment_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'recruitment', '$conf->recruitment->enabled');
404 //$result3=$extrafields->addExtraField('recruitment_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'recruitment', '$conf->recruitment->enabled');
405 //$result4=$extrafields->addExtraField('recruitment_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'recruitment', '$conf->recruitment->enabled');
406 //$result5=$extrafields->addExtraField('recruitment_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'recruitment', '$conf->recruitment->enabled');
407
408 // Permissions
409 $this->remove($options);
410
411 $sql = array();
412
413 // Document template
414 $moduledir = 'recruitment';
415 $myTmpObjects = array();
416 $myTmpObjects['RecruitmentJobPosition'] = array('includerefgeneration'=>1, 'includedocgeneration'=>1);
417
418 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
419 if ($myTmpObjectKey == 'MyObject') {
420 continue;
421 }
422 if ($myTmpObjectArray['includedocgeneration']) {
423 $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/'.$moduledir.'/template_recruitmentjobposition.odt';
424 $dirodt = DOL_DATA_ROOT.'/doctemplates/'.$moduledir;
425 $dest = $dirodt.'/template_recruitmentjobposition.odt';
426
427 if (file_exists($src) && !file_exists($dest)) {
428 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
429 dol_mkdir($dirodt);
430 $result = dol_copy($src, $dest, 0, 0);
431 if ($result < 0) {
432 $langs->load("errors");
433 $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
434 return 0;
435 }
436 }
437
438 $sql = array_merge($sql, array(
439 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity),
440 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."','".$this->db->escape(strtolower($myTmpObjectKey))."',".((int) $conf->entity).")",
441
442 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity),
443 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")"
444 ));
445 }
446 }
447
448 return $this->_init($sql, $options);
449 }
450
459 public function remove($options = '')
460 {
461 $sql = array();
462 return $this->_remove($sql, $options);
463 }
464}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
_remove($array_sql, $options='')
Disable function.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Description and activation class for module Recruitment.
init($options='')
Function called when module is enabled.
__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.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:124