26require
"../main.inc.php";
29require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
30require_once DOL_DOCUMENT_ROOT.
'/workstation/lib/workstation.lib.php';
34$langs->loadLangs(array(
"admin",
"workstation"));
37$action =
GETPOST(
'action',
'aZ09');
38$backtopage =
GETPOST(
'backtopage',
'alpha');
39$modulepart =
GETPOST(
'modulepart',
'aZ09');
41$value =
GETPOST(
'value',
'alpha');
46$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
58include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
60if ($action ==
'updateMask') {
61 $maskconst =
GETPOST(
'maskconstWorkstation',
'aZ09');
62 $maskorder =
GETPOST(
'maskWorkstation',
'alpha');
64 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
65 $res =
dolibarr_set_const($db, $maskconst, $maskorder,
'chaine', 0,
'', $conf->entity);
77} elseif ($action ==
'specimen') {
78 $modele =
GETPOST(
'module',
'alpha');
79 $tmpobjectkey =
GETPOST(
'object');
81 $tmpobject =
new $tmpobjectkey($db);
82 $tmpobject->initAsSpecimen();
85 $file =
''; $classname =
''; $filefound = 0;
86 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
87 foreach ($dirmodels as $reldir) {
88 $file =
dol_buildpath($reldir.
"core/modules/workstation/doc/pdf_".$modele.
"_".strtolower($tmpobjectkey).
".modules.php", 0);
89 if (file_exists($file)) {
91 $classname =
"pdf_".$modele;
99 $module =
new $classname($db);
101 if ($module->write_file($tmpobject, $langs) > 0) {
102 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
110 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
112} elseif ($action ==
'set') {
115} elseif ($action ==
'del') {
116 $tmpobjectkey =
GETPOST(
'object');
120 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
121 if ($conf->global->$constforval ==
"$value") {
125} elseif ($action ==
'setdoc') {
127 $tmpobjectkey =
GETPOST(
'object');
128 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
132 $conf->global->$constforval = $value;
140} elseif ($action ==
'setmod') {
143 $tmpobjectkey =
GETPOST(
'object');
144 $constforval =
'WORKSTATION_'.strtoupper($tmpobjectkey).
"_ADDON";
154$form =
new Form($db);
157$page_name =
"WorkstationSetup";
159llxHeader(
'', $langs->trans($page_name), $help_url);
162$linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
168print
dol_get_fiche_head($head,
'settings', $langs->trans($page_name), -1,
"workstation");
174if ($action ==
'edit') {
175 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
176 print
'<input type="hidden" name="token" value="'.newToken().
'">';
177 print
'<input type="hidden" name="action" value="update">';
179 print
'<table class="noborder centpercent">';
180 print
'<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
182 foreach ($arrayofparameters as $key => $val) {
183 print
'<tr class="oddeven"><td>';
184 $tooltiphelp = (($langs->trans($key.
'Tooltip') != $key.
'Tooltip') ? $langs->trans($key.
'Tooltip') :
'');
185 print $form->textwithpicto($langs->trans($key), $tooltiphelp);
186 print
'</td><td><input name="'.$key.
'" class="flat '.(empty($val[
'css']) ?
'minwidth200' : $val[
'css']).
'" value="'.
getDolGlobalString($key).
'"></td></tr>';
190 print
'<br><div class="center">';
191 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
197 if (!empty($arrayofparameters)) {
198 print
'<table class="noborder centpercent">';
199 print
'<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
201 foreach ($arrayofparameters as $key => $val) {
204 print
'<tr class="oddeven"><td>';
205 $tooltiphelp = (($langs->trans($key.
'Tooltip') != $key.
'Tooltip') ? $langs->trans($key.
'Tooltip') :
'');
206 print $form->textwithpicto($langs->trans($key), $tooltiphelp);
207 print
'</td><td>'.getDolGlobalString($key).
'</td></tr>';
212 print
'<div class="tabsAction">';
213 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.newToken().
'">'.$langs->trans(
"Modify").
'</a>';
221$moduledir =
'workstation';
222$myTmpObjects = array();
223$myTmpObjects[
'workstation'] = array(
'includerefgeneration'=>1,
'includedocgeneration'=>0);
226foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
227 if ($myTmpObjectKey ==
'MyObject') {
230 if ($myTmpObjectArray[
'includerefgeneration']) {
236 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
238 print
'<table class="noborder centpercent">';
239 print
'<tr class="liste_titre">';
240 print
'<td>'.$langs->trans(
"Name").
'</td>';
241 print
'<td>'.$langs->trans(
"Description").
'</td>';
242 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
243 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
244 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
249 foreach ($dirmodels as $reldir) {
253 $handle = opendir($dir);
254 if (is_resource($handle)) {
255 while (($file = readdir($handle)) !==
false) {
256 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
257 $file = substr($file, 0,
dol_strlen($file) - 4);
259 require_once $dir.
'/'.$file.
'.php';
261 $module =
new $file($db);
264 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
267 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
271 if ($module->isEnabled()) {
272 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
274 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
275 print $module->info();
279 print
'<td class="nowrap">';
280 $tmp = $module->getExample();
281 if (preg_match(
'/^Error/', $tmp)) {
282 $langs->load(
"errors");
283 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
284 } elseif ($tmp ==
'NotConfigured') {
285 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
291 print
'<td class="center">';
292 $constforvar =
'WORKSTATION_'.strtoupper($myTmpObjectKey).
'_ADDON';
294 print
img_picto($langs->trans(
"Activated"),
'switch_on');
296 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.urlencode($file).
'">';
297 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
302 $nameofclass = ucfirst($myTmpObjectKey);
303 $mytmpinstance =
new $nameofclass($db);
304 $mytmpinstance->initAsSpecimen();
308 $htmltooltip .= $langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
310 $nextval = $module->getNextValue($mytmpinstance);
311 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
312 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
314 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
315 $nextval = $langs->trans($nextval);
317 $htmltooltip .= $nextval.
'<br>';
319 $htmltooltip .= $langs->trans($module->error).
'<br>';
323 print
'<td class="center">';
324 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
335 print
"</table><br>\n";
338 if ($myTmpObjectArray[
'includedocgeneration']) {
343 $type = strtolower($myTmpObjectKey);
345 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
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]);
366 print
"<table class=\"noborder\" width=\"100%\">\n";
367 print
"<tr class=\"liste_titre\">\n";
368 print
'<td>'.$langs->trans(
"Name").
'</td>';
369 print
'<td>'.$langs->trans(
"Description").
'</td>';
370 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
371 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
372 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
373 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
378 foreach ($dirmodels as $reldir) {
379 foreach (array(
'',
'/doc') as $valdir) {
380 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
384 $handle = opendir($dir);
385 if (is_resource($handle)) {
386 while (($file = readdir($handle)) !==
false) {
392 foreach ($filelist as $file) {
393 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
394 if (file_exists($dir.
'/'.$file)) {
395 $name = substr($file, 4,
dol_strlen($file) - 16);
396 $classname = substr($file, 0,
dol_strlen($file) - 12);
398 require_once $dir.
'/'.$file;
399 $module =
new $classname($db);
401 $modulequalified = 1;
402 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
403 $modulequalified = 0;
405 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
406 $modulequalified = 0;
409 if ($modulequalified) {
410 print
'<tr class="oddeven"><td width="100">';
411 print (empty($module->name) ? $name : $module->
name);
413 if (method_exists($module,
'info')) {
414 print $module->info($langs);
416 print $module->description;
421 if (in_array($name, $def)) {
422 print
'<td class="center">'.
"\n";
423 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'">';
424 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
428 print
'<td class="center">'.
"\n";
429 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>';
434 print
'<td class="center">';
435 $constforvar =
'WORKSTATION_'.strtoupper($myTmpObjectKey).
'_ADDON';
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 if ($module->type ==
'pdf') {
447 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
449 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
451 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
452 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
453 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 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.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
464 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
delDocumentModel($name, $type)
Delete document model used by doc generator.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db name
Only used if Module[ID]Name translation string is not found.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
workstationAdminPrepareHead()
Prepare admin pages header.