28 if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) {
29 $res = @include $_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
32 $tmp = empty($_SERVER[
'SCRIPT_FILENAME']) ?
'' : $_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
33 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
36 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) {
37 $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
39 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) {
40 $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php";
43 if (!$res && file_exists(
"../../main.inc.php")) {
44 $res = @include
"../../main.inc.php";
46 if (!$res && file_exists(
"../../../main.inc.php")) {
47 $res = @include
"../../../main.inc.php";
50 die(
"Include of main fails");
56 require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
57 require_once DOL_DOCUMENT_ROOT.
'/recruitment/lib/recruitment.lib.php';
58 require_once DOL_DOCUMENT_ROOT.
"/recruitment/class/recruitmentjobposition.class.php";
61 $langs->loadLangs(array(
"admin",
"recruitment"));
69 $action =
GETPOST(
'action',
'aZ09');
70 $backtopage =
GETPOST(
'backtopage',
'alpha');
71 $modulepart =
GETPOST(
'modulepart',
'aZ09');
73 $value =
GETPOST(
'value',
'alpha');
74 $label =
GETPOST(
'label',
'alpha');
75 $scandir =
GETPOST(
'scan_dir',
'alpha');
76 $type =
'recruitmentjobposition';
78 $arrayofparameters = array(
91 if ((
float) DOL_VERSION >= 6) {
92 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
95 if ($action ==
'updateMask') {
96 $maskconst =
GETPOST(
'maskconst',
'alpha');
97 $maskvalue =
GETPOST(
'maskRecruitmentJobPosition',
'alpha');
100 $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
112 } elseif ($action ==
'specimen') {
113 $modele =
GETPOST(
'module',
'alpha');
114 $tmpobjectkey =
GETPOST(
'object');
116 $tmpobject =
new $tmpobjectkey($db);
117 $tmpobject->initAsSpecimen();
120 $file =
''; $classname =
''; $filefound = 0;
121 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
122 foreach ($dirmodels as $reldir) {
123 $file =
dol_buildpath($reldir.
"core/modules/recruitment/doc/pdf_".$modele.
"_".strtolower($tmpobjectkey).
".modules.php", 0);
124 if (file_exists($file)) {
126 $classname =
"pdf_".$modele.
"_".strtolower($tmpobjectkey);
134 $module =
new $classname($db);
136 if ($module->write_file($tmpobject, $langs) > 0) {
137 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=recruitment-".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
145 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
147 } elseif ($action ==
'set') {
150 } elseif ($action ==
'del') {
153 $tmpobjectkey =
GETPOST(
'object');
154 if (!empty($tmpobjectkey)) {
155 $constforval =
'RECRUITMENT_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
156 if ($conf->global->$constforval ==
"$value") {
161 } elseif ($action ==
'setmod') {
163 $tmpobjectkey =
GETPOST(
'object');
164 if (!empty($tmpobjectkey)) {
165 $constforval =
'RECRUITMENT_'.strtoupper($tmpobjectkey).
"_ADDON";
169 } elseif ($action ==
'setdoc') {
171 $tmpobjectkey =
GETPOST(
'object');
172 if (!empty($tmpobjectkey)) {
173 $constforval =
'RECRUITMENT_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
177 $conf->global->$constforval = $value;
186 } elseif ($action ==
'unsetdoc') {
187 $tmpobjectkey =
GETPOST(
'object');
188 if (!empty($tmpobjectkey)) {
189 $constforval =
'RECRUITMENT_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
202 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
204 $page_name =
"RecruitmentSetup";
205 llxHeader(
'', $langs->trans($page_name));
208 $linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
210 print
load_fiche_titre($langs->trans($page_name), $linkback,
'title_setup');
220 if ($action ==
'edit') {
221 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
222 print
'<input type="hidden" name="token" value="'.newToken().
'">';
223 print
'<input type="hidden" name="action" value="update">';
225 print
'<table class="noborder centpercent">';
226 print
'<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
228 foreach ($arrayofparameters as $key => $val) {
229 print
'<tr class="oddeven"><td>';
230 $tooltiphelp = (($langs->trans($key.
'Tooltip') != $key.
'Tooltip') ? $langs->trans($key.
'Tooltip') :
'');
231 print
$form->textwithpicto($langs->trans($key), $tooltiphelp);
232 print
'</td><td><input name="'.$key.
'" class="flat '.(empty($val[
'css']) ?
'minwidth200' : $val[
'css']).
'" value="'.
getDolGlobalString($key).
'"></td></tr>';
236 print
'<br><div class="center">';
237 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
243 if (!empty($arrayofparameters)) {
244 print
'<table class="noborder centpercent">';
245 print
'<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
247 foreach ($arrayofparameters as $key => $val) {
250 print
'<tr class="oddeven"><td>';
251 $tooltiphelp = (($langs->trans($key.
'Tooltip') != $key.
'Tooltip') ? $langs->trans($key.
'Tooltip') :
'');
252 print
$form->textwithpicto($langs->trans($key), $tooltiphelp);
253 print
'</td><td>'.getDolGlobalString($key).
'</td></tr>';
258 print
'<div class="tabsAction">';
259 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
265 $moduledir =
'recruitment';
266 $myTmpObjects = array();
267 $myTmpObjects[
'RecruitmentJobPosition'] = array(
'includerefgeneration'=>1,
'includedocgeneration'=>1);
270 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
271 if ($myTmpObjectArray[
'includerefgeneration']) {
277 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
279 print
'<table class="noborder centpercent">';
280 print
'<tr class="liste_titre">';
281 print
'<td>'.$langs->trans(
"Name").
'</td>';
282 print
'<td>'.$langs->trans(
"Description").
'</td>';
283 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
284 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
285 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
290 foreach ($dirmodels as $reldir) {
294 $handle = opendir($dir);
295 if (is_resource($handle)) {
296 while (($file = readdir($handle)) !==
false) {
297 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
298 $file = substr($file, 0,
dol_strlen($file) - 4);
299 require_once $dir.
'/'.$file.
'.php';
301 $module =
new $file($db);
304 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
307 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
311 if ($module->isEnabled()) {
312 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
314 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
315 print $module->info();
319 print
'<td class="nowrap">';
320 $tmp = $module->getExample();
321 if (preg_match(
'/^Error/', $tmp)) {
322 $langs->load(
"errors");
323 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
324 } elseif ($tmp ==
'NotConfigured') {
325 print $langs->trans($tmp);
331 print
'<td class="center">';
332 $constforvar =
'RECRUITMENT_'.strtoupper($myTmpObjectKey).
'_ADDON';
334 print
img_picto($langs->trans(
"Activated"),
'switch_on');
336 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.urlencode($file).
'">';
337 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
342 $mytmpinstance =
new $myTmpObjectKey($db);
343 $mytmpinstance->initAsSpecimen();
347 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
349 $nextval = $module->getNextValue($mytmpinstance);
350 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
351 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
353 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
354 $nextval = $langs->trans($nextval);
356 $htmltooltip .= $nextval.
'<br>';
358 $htmltooltip .= $langs->trans($module->error).
'<br>';
362 print
'<td class="center">';
363 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
374 print
"</table><br>\n";
377 if ($myTmpObjectArray[
'includedocgeneration']) {
382 $type = strtolower($myTmpObjectKey);
384 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
389 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
390 $sql .=
" WHERE type = '".$db->escape($type).
"'";
391 $sql .=
" AND entity = ".$conf->entity;
392 $resql = $db->query($sql);
395 $num_rows = $db->num_rows(
$resql);
396 while ($i < $num_rows) {
397 $array = $db->fetch_array(
$resql);
398 array_push($def, $array[0]);
406 print
"<table class=\"noborder\" width=\"100%\">\n";
407 print
"<tr class=\"liste_titre\">\n";
408 print
'<td>'.$langs->trans(
"Name").
'</td>';
409 print
'<td>'.$langs->trans(
"Description").
'</td>';
410 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
411 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
412 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
413 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
418 foreach ($dirmodels as $reldir) {
419 foreach (array(
'',
'/doc') as $valdir) {
420 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
424 $handle = opendir($dir);
425 if (is_resource($handle)) {
426 while (($file = readdir($handle)) !==
false) {
432 foreach ($filelist as $file) {
433 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
434 if (file_exists($dir.
'/'.$file)) {
435 $name = substr($file, 4,
dol_strlen($file) - 16);
436 $classname = substr($file, 0,
dol_strlen($file) - 12);
438 require_once $dir.
'/'.$file;
439 $module =
new $classname($db);
441 $modulequalified = 1;
442 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
443 $modulequalified = 0;
445 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
446 $modulequalified = 0;
449 if ($modulequalified) {
450 print
'<tr class="oddeven"><td width="100">';
451 print (empty($module->name) ? $name : $module->name);
453 if (method_exists($module,
'info')) {
454 print $module->info($langs);
456 print $module->description;
461 if (in_array($name, $def)) {
462 print
'<td class="center">'.
"\n";
463 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
464 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
468 print
'<td class="center">'.
"\n";
469 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
474 print
'<td class="center">';
475 $constforvar =
'RECRUITMENT_'.strtoupper($myTmpObjectKey).
'_ADDON_PDF';
479 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=unsetdoc&token='.
newToken().
'&object='.urlencode(strtolower($myTmpObjectKey)).
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type='.urlencode($type).
'" alt="'.$langs->trans(
"Disable").
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
481 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&object='.urlencode(strtolower($myTmpObjectKey)).
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
486 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
487 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
488 if ($module->type ==
'pdf') {
489 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
491 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
493 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
494 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
495 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
497 print
'<td class="center">';
498 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
502 print
'<td class="center">';
503 if ($module->type ==
'pdf') {
504 $newname = preg_replace(
'/_'.preg_quote(strtolower($myTmpObjectKey),
'/').
'/',
'', $name);
505 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.urlencode($newname).
'&object='.urlencode($myTmpObjectKey).
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
507 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
525 if (empty($setupnotempty)) {
526 print
'<br>'.$langs->trans(
"NothingToSetup");