28require
"../main.inc.php";
31require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
32require_once DOL_DOCUMENT_ROOT.
'/workstation/lib/workstation.lib.php';
36$langs->loadLangs(array(
"admin",
"workstation"));
39$action =
GETPOST(
'action',
'aZ09');
40$backtopage =
GETPOST(
'backtopage',
'alpha');
41$modulepart =
GETPOST(
'modulepart',
'aZ09');
43$value =
GETPOST(
'value',
'alpha');
48$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
55$moduledir =
'workstation';
56$myTmpObjects = array();
57$myTmpObjects[
'workstation'] = array(
'label' =>
'Workstation',
'includerefgeneration' => 1,
'includedocgeneration' => 0,
'class' =>
'Workstation');
59$tmpobjectkey =
GETPOST(
'object',
'aZ09');
60if ($tmpobjectkey && !array_key_exists($tmpobjectkey, $myTmpObjects)) {
69include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
71if ($action ==
'updateMask') {
72 $maskconst =
GETPOST(
'maskconstWorkstation',
'aZ09');
73 $maskorder =
GETPOST(
'maskWorkstation',
'alpha');
77 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
78 $res =
dolibarr_set_const($db, $maskconst, $maskorder,
'chaine', 0,
'', $conf->entity);
90} elseif ($action ==
'specimen') {
91 $modele =
GETPOST(
'module',
'alpha');
93 $nameofclass = ucfirst($tmpobjectkey);
94 $tmpobject =
new $nameofclass($db);
95 '@phan-var-force Workstation $tmpobject';
96 $tmpobject->initAsSpecimen();
101 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
102 foreach ($dirmodels as $reldir) {
103 $file =
dol_buildpath($reldir.
"core/modules/workstation/doc/pdf_".$modele.
"_".strtolower($tmpobjectkey).
".modules.php", 0);
104 if (file_exists($file)) {
105 $classname =
"pdf_".$modele;
110 if ($classname !==
'') {
113 $module =
new $classname($db);
114 '@phan-var-force ModelePDFWorkstation $module';
116 if ($module->write_file($tmpobject, $langs) > 0) {
117 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
125 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
127} elseif ($action ==
'set') {
130} elseif ($action ==
'del') {
133 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
138} elseif ($action ==
'setdoc') {
140 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
144 $conf->global->$constforval = $value;
152} elseif ($action ==
'setmod') {
155 $constforval =
'WORKSTATION_'.strtoupper($tmpobjectkey).
"_ADDON";
165$form =
new Form($db);
168$page_name =
"WorkstationSetup";
170llxHeader(
'', $langs->trans($page_name), $help_url,
'', 0, 0,
'',
'',
'',
'mod-admin page-workstation');
173$linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
179print
dol_get_fiche_head($head,
'settings', $langs->trans($page_name), -1,
"workstation");
185if ($action ==
'edit') {
186 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
187 print
'<input type="hidden" name="token" value="'.newToken().
'">';
188 print
'<input type="hidden" name="action" value="update">';
190 print
'<table class="noborder centpercent">';
191 print
'<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
194 foreach ($arrayofparameters as $key => $val) {
195 print
'<tr class="oddeven"><td>';
196 $tooltiphelp = (($langs->trans($key.
'Tooltip') != $key.
'Tooltip') ? $langs->trans($key.
'Tooltip') :
'');
197 print $form->textwithpicto($langs->trans($key), $tooltiphelp);
198 print
'</td><td><input name="'.$key.
'" class="flat '.(empty($val[
'css']) ?
'minwidth200' : $val[
'css']).
'" value="'.
getDolGlobalString($key).
'"></td></tr>';
202 print
'<br><div class="center">';
203 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
209 if (!empty($arrayofparameters)) {
210 print
'<table class="noborder centpercent">';
211 print
'<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
213 foreach ($arrayofparameters as $key => $val) {
216 print
'<tr class="oddeven"><td>';
217 $tooltiphelp = (($langs->trans($key.
'Tooltip') != $key.
'Tooltip') ? $langs->trans($key.
'Tooltip') :
'');
218 print $form->textwithpicto($langs->trans($key), $tooltiphelp);
219 print
'</td><td>'.getDolGlobalString($key).
'</td></tr>';
224 print
'<div class="tabsAction">';
225 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
233foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
234 if ($myTmpObjectArray[
'includerefgeneration']) {
238 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
240 print
'<table class="noborder centpercent">';
241 print
'<tr class="liste_titre">';
242 print
'<td>'.$langs->trans(
"Name").
'</td>';
243 print
'<td>'.$langs->trans(
"Description").
'</td>';
244 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
245 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
246 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
251 foreach ($dirmodels as $reldir) {
255 $handle = opendir($dir);
256 if (is_resource($handle)) {
257 while (($file = readdir($handle)) !==
false) {
258 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
259 $file = substr($file, 0,
dol_strlen($file) - 4);
261 require_once $dir.
'/'.$file.
'.php';
263 $module =
new $file($db);
264 '@phan-var-force ModeleNumRefWorkstation $module';
267 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
270 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
274 if ($module->isEnabled()) {
275 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
277 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
278 print $module->info($langs);
282 print
'<td class="nowrap">';
283 $tmp = $module->getExample();
284 if (preg_match(
'/^Error/', $tmp)) {
285 $langs->load(
"errors");
286 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
287 } elseif ($tmp ==
'NotConfigured') {
288 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
294 print
'<td class="center">';
295 $constforvar =
'WORKSTATION_'.strtoupper($myTmpObjectKey).
'_ADDON';
297 print
img_picto($langs->trans(
"Activated"),
'switch_on');
299 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.urlencode($file).
'">';
300 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
305 $nameofclass = ucfirst($myTmpObjectKey);
306 $mytmpinstance =
new $nameofclass($db);
307 '@phan-var-force Workstation $mytmpinstance';
308 $mytmpinstance->initAsSpecimen();
312 $htmltooltip .= $langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
314 $nextval = $module->getNextValue($mytmpinstance);
315 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
316 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
318 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
319 $nextval = $langs->trans($nextval);
321 $htmltooltip .= $nextval.
'<br>';
323 $htmltooltip .= $langs->trans($module->error).
'<br>';
327 print
'<td class="center">';
328 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
339 print
"</table><br>\n";
342 if ($myTmpObjectArray[
'includedocgeneration']) {
345 $type = strtolower($myTmpObjectKey);
347 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
352 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
353 $sql .=
" WHERE type = '".$db->escape($type).
"'";
354 $sql .=
" AND entity = ".$conf->entity;
355 $resql = $db->query($sql);
358 $num_rows = $db->num_rows($resql);
359 while ($i < $num_rows) {
360 $array = $db->fetch_array($resql);
361 if (is_array($array)) {
362 array_push($def, $array[0]);
370 print
"<table class=\"noborder\" width=\"100%\">\n";
371 print
"<tr class=\"liste_titre\">\n";
372 print
'<td>'.$langs->trans(
"Name").
'</td>';
373 print
'<td>'.$langs->trans(
"Description").
'</td>';
374 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
375 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
376 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
377 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
382 foreach ($dirmodels as $reldir) {
383 foreach (array(
'',
'/doc') as $valdir) {
384 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
388 $handle = opendir($dir);
389 if (is_resource($handle)) {
391 while (($file = readdir($handle)) !==
false) {
397 foreach ($filelist as $file) {
398 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
399 if (file_exists($dir.
'/'.$file)) {
400 $name = substr($file, 4,
dol_strlen($file) - 16);
401 $classname = substr($file, 0,
dol_strlen($file) - 12);
403 require_once $dir.
'/'.$file;
404 $module =
new $classname($db);
405 '@phan-var-force ModelePDFWorkstation $module';
407 $modulequalified = 1;
408 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
409 $modulequalified = 0;
411 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
412 $modulequalified = 0;
415 if ($modulequalified) {
416 print
'<tr class="oddeven"><td width="100">';
417 print(empty($module->name) ? $name : $module->
name);
419 if (method_exists($module,
'info')) {
420 print $module->info($langs);
422 print $module->description;
427 if (in_array($name, $def)) {
428 print
'<td class="center">'.
"\n";
429 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
430 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
434 print
'<td class="center">'.
"\n";
435 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>';
440 print
'<td class="center">';
441 $constforvar =
'WORKSTATION_'.strtoupper($myTmpObjectKey).
'_ADDON';
443 print
img_picto($langs->trans(
"Default"),
'on');
445 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>';
450 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
451 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
452 if ($module->type ==
'pdf') {
453 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
455 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
457 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
458 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
459 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
461 print
'<td class="center">';
462 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
466 print
'<td class="center">';
467 if ($module->type ==
'pdf') {
468 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
470 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_get_fiche_end($notab=0)
Return tab footer of a card.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a 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.