31 require
'../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fichinter.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
38 $langs->loadLangs(array(
'admin',
'errors',
'interventions',
'other'));
44 $action =
GETPOST(
'action',
'aZ09');
45 $value =
GETPOST(
'value',
'alpha');
46 $modulepart =
GETPOST(
'modulepart',
'aZ09');
48 $label =
GETPOST(
'label',
'alpha');
49 $scandir =
GETPOST(
'scan_dir',
'alpha');
57 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
59 if ($action ==
'updateMask') {
60 $maskconst =
GETPOST(
'maskconst',
'alpha');
61 $maskvalue =
GETPOST(
'maskvalue',
'alpha');
63 $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
75 } elseif ($action ==
'specimen') {
76 $modele =
GETPOST(
'module',
'alpha');
79 $inter->initAsSpecimen();
82 $file =
''; $classname =
''; $filefound = 0;
83 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
84 foreach ($dirmodels as $reldir) {
85 $file =
dol_buildpath($reldir.
"core/modules/fichinter/doc/pdf_".$modele.
".modules.php", 0);
86 if (file_exists($file)) {
88 $classname =
"pdf_".$modele;
96 $module =
new $classname($db);
98 if ($module->write_file($inter, $langs) > 0) {
99 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=ficheinter&file=SPECIMEN.pdf");
107 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
109 } elseif ($action ==
'set') {
112 } elseif ($action ==
'del') {
115 if ($conf->global->FICHEINTER_ADDON_PDF ==
"$value") {
119 } elseif ($action ==
'setdoc') {
121 if (
dolibarr_set_const($db,
"FICHEINTER_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
124 $conf->global->FICHEINTER_ADDON_PDF = $value;
132 } elseif ($action ==
'setmod') {
137 } elseif ($action ==
'set_FICHINTER_FREE_TEXT') {
138 $freetext =
GETPOST(
'FICHINTER_FREE_TEXT',
'restricthtml');
139 $res =
dolibarr_set_const($db,
"FICHINTER_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
150 } elseif ($action ==
'set_FICHINTER_DRAFT_WATERMARK') {
151 $draft =
GETPOST(
'FICHINTER_DRAFT_WATERMARK',
'alpha');
152 $res =
dolibarr_set_const($db,
"FICHINTER_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
163 } elseif ($action ==
'set_FICHINTER_PRINT_PRODUCTS') {
164 $val =
GETPOST(
'FICHINTER_PRINT_PRODUCTS',
'alpha');
165 $res =
dolibarr_set_const($db,
"FICHINTER_PRINT_PRODUCTS", ($val ==
'on' ? 1 : 0),
'bool', 0,
'', $conf->entity);
176 } elseif ($action ==
'set_FICHINTER_USE_SERVICE_DURATION') {
177 $val =
GETPOST(
'FICHINTER_USE_SERVICE_DURATION',
'alpha');
178 $res =
dolibarr_set_const($db,
"FICHINTER_USE_SERVICE_DURATION", ($val ==
'on' ? 1 : 0),
'bool', 0,
'', $conf->entity);
189 } elseif ($action ==
'set_FICHINTER_WITHOUT_DURATION') {
190 $val =
GETPOST(
'FICHINTER_WITHOUT_DURATION',
'alpha');
191 $res =
dolibarr_set_const($db,
"FICHINTER_WITHOUT_DURATION", ($val ==
'on' ? 1 : 0),
'bool', 0,
'', $conf->entity);
202 } elseif ($action ==
'set_FICHINTER_DATE_WITHOUT_HOUR') {
203 $val =
GETPOST(
'FICHINTER_DATE_WITHOUT_HOUR',
'alpha');
204 $res =
dolibarr_set_const($db,
"FICHINTER_DATE_WITHOUT_HOUR", ($val ==
'on' ? 1 : 0),
'bool', 0,
'', $conf->entity);
223 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
229 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
230 print
load_fiche_titre($langs->trans(
"InterventionsSetup"), $linkback,
'title_setup');
235 print
dol_get_fiche_head($head,
'ficheinter', $langs->trans(
"Interventions"), -1,
'intervention');
239 print
load_fiche_titre($langs->trans(
"FicheinterNumberingModules"),
'',
'');
241 print
'<div class="div-table-responsive-no-min">';
242 print
'<table class="noborder centpercent">';
243 print
'<tr class="liste_titre">';
244 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
245 print
'<td>'.$langs->trans(
"Description").
'</td>';
246 print
'<td>'.$langs->trans(
"Example").
'</td>';
247 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
248 print
'<td align="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
253 foreach ($dirmodels as $reldir) {
257 $handle = opendir($dir);
258 if (is_resource($handle)) {
259 while (($file = readdir($handle)) !==
false) {
260 if (preg_match(
'/^(mod_.*)\.php$/i', $file, $reg)) {
262 $classname = substr($file, 4);
264 require_once $dir.$file.
'.php';
268 if ($module->isEnabled()) {
270 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
273 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
278 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
279 print $module->info();
283 print
'<td class="nowrap">';
284 $tmp = $module->getExample();
285 if (preg_match(
'/^Error/', $tmp)) {
286 $langs->load(
"errors");
287 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
288 } elseif ($tmp ==
'NotConfigured') {
289 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
295 print
'<td class="center">';
296 if ($conf->global->FICHEINTER_ADDON == $classname) {
297 print
img_picto($langs->trans(
"Activated"),
'switch_on');
299 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($classname).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
304 $ficheinter->initAsSpecimen();
308 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
309 $nextval = $module->getNextValue($mysoc, $ficheinter);
310 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
311 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
313 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
314 $nextval = $langs->trans($nextval);
316 $htmltooltip .= $nextval.
'<br>';
318 $htmltooltip .= $langs->trans($module->error).
'<br>';
321 print
'<td class="center">';
322 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
347 $type =
'ficheinter';
350 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
351 $sql .=
" WHERE type = '".$db->escape($type).
"'";
352 $sql .=
" AND entity = ".$conf->entity;
353 $resql = $db->query($sql);
356 $num_rows = $db->num_rows(
$resql);
357 while ($i < $num_rows) {
358 $array = $db->fetch_array(
$resql);
359 array_push($def, $array[0]);
367 print
'<div class="div-table-responsive-no-min">';
368 print
'<table class="noborder centpercent">';
369 print
'<tr class="liste_titre">';
370 print
'<td>'.$langs->trans(
"Name").
'</td>';
371 print
'<td>'.$langs->trans(
"Description").
'</td>';
372 print
'<td align="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
373 print
'<td align="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
374 print
'<td align="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
375 print
'<td align="center" width="80">'.$langs->trans(
"Preview").
'</td>';
380 foreach ($dirmodels as $reldir) {
381 $realpath = $reldir.
"core/modules/fichinter/doc";
385 $handle = opendir($dir);
386 if (is_resource($handle)) {
387 while (($file = readdir($handle)) !==
false) {
393 foreach ($filelist as $file) {
394 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
395 if (file_exists($dir.
'/'.$file)) {
396 $name = substr($file, 4,
dol_strlen($file) - 16);
397 $classname = substr($file, 0,
dol_strlen($file) - 12);
399 require_once $dir.
'/'.$file;
400 $module =
new $classname($db);
402 $modulequalified = 1;
403 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
404 $modulequalified = 0;
406 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
407 $modulequalified = 0;
410 if ($modulequalified) {
411 print
'<tr class="oddeven"><td width="100">';
412 print (empty($module->name) ? $name : $module->name);
414 if (method_exists($module,
'info')) {
415 print $module->info($langs);
417 print $module->description;
422 if (in_array($name, $def)) {
423 print
"<td align=\"center\">\n";
424 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">';
425 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
429 print
"<td align=\"center\">\n";
430 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>';
435 print
"<td align=\"center\">";
436 if ($conf->global->FICHEINTER_ADDON_PDF ==
"$name") {
437 print
img_picto($langs->trans(
"Default"),
'on');
439 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
444 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
445 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
446 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
447 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
449 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
450 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
451 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
452 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
453 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
454 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
455 print
'<td class="center">';
456 print
$form->textwithpicto(
'', $htmltooltip, -1, 0);
460 print
'<td class="center">';
461 if ($module->type ==
'pdf') {
462 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
464 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
487 print
'<div class="div-table-responsive-no-min">';
488 print
'<table class="noborder centpercent">';
489 print
'<tr class="liste_titre">';
490 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
491 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
492 print
"<td> </td>\n";
496 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
497 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
498 foreach ($substitutionarray as $key => $val) {
499 $htmltext .= $key.
'<br>';
503 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
504 print
'<input type="hidden" name="token" value="'.newToken().
'">';
505 print
'<input type="hidden" name="action" value="set_FICHINTER_FREE_TEXT">';
506 print
'<tr class="oddeven"><td colspan="2">';
507 print
$form->textwithpicto($langs->trans(
"FreeLegalTextOnInterventions"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
508 $variablename =
'FICHINTER_FREE_TEXT';
509 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
510 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
512 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
514 print $doleditor->Create();
516 print
'</td><td class="right">';
517 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
518 print
"</td></tr>\n";
522 print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
523 print
'<input type="hidden" name="token" value="'.newToken().
'">';
524 print
"<input type=\"hidden\" name=\"action\" value=\"set_FICHINTER_DRAFT_WATERMARK\">";
525 print
'<tr class="oddeven"><td>';
526 print
$form->textwithpicto($langs->trans(
"WatermarkOnDraftInterventionCards"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
528 print
'<input class="flat minwidth200" type="text" name="FICHINTER_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'FICHINTER_DRAFT_WATERMARK')).
'">';
529 print
'</td><td class="right">';
530 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
531 print
"</td></tr>\n";
534 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
535 print
'<input type="hidden" name="token" value="'.newToken().
'">';
536 print
'<input type="hidden" name="action" value="set_FICHINTER_PRINT_PRODUCTS">';
537 print
'<tr class="oddeven"><td>';
538 print $langs->trans(
"PrintProductsOnFichinter").
' ('.$langs->trans(
"PrintProductsOnFichinterDetails").
')</td>';
539 print
'<td align="center"><input type="checkbox" name="FICHINTER_PRINT_PRODUCTS" ';
540 if ($conf->global->FICHINTER_PRINT_PRODUCTS) {
544 print
'</td><td class="right">';
545 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
546 print
"</td></tr>\n";
549 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
550 print
'<input type="hidden" name="token" value="'.newToken().
'">';
551 print
'<input type="hidden" name="action" value="set_FICHINTER_USE_SERVICE_DURATION">';
552 print
'<tr class="oddeven">';
554 print $langs->trans(
"UseServicesDurationOnFichinter");
556 print
'<td class="center">';
557 print
'<input type="checkbox" name="FICHINTER_USE_SERVICE_DURATION"'.($conf->global->FICHINTER_USE_SERVICE_DURATION ?
' checked' :
'').
'>';
559 print
'<td class="right">';
560 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
565 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
566 print
'<input type="hidden" name="token" value="'.newToken().
'">';
567 print
'<input type="hidden" name="action" value="set_FICHINTER_WITHOUT_DURATION">';
568 print
'<tr class="oddeven">';
570 print $langs->trans(
"UseDurationOnFichinter");
572 print
'<td class="center">';
573 print
'<input type="checkbox" name="FICHINTER_WITHOUT_DURATION"'.($conf->global->FICHINTER_WITHOUT_DURATION ?
' checked' :
'').
'>';
575 print
'<td class="right">';
576 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
581 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
582 print
'<input type="hidden" name="token" value="'.newToken().
'">';
583 print
'<input type="hidden" name="action" value="set_FICHINTER_DATE_WITHOUT_HOUR">';
584 print
'<tr class="oddeven">';
586 print $langs->trans(
"UseDateWithoutHourOnFichinter");
588 print
'<td class="center">';
589 print
'<input type="checkbox" name="FICHINTER_DATE_WITHOUT_HOUR"'.($conf->global->FICHINTER_DATE_WITHOUT_HOUR ?
' checked' :
'').
'>';
591 print
'<td class="right">';
592 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';