28require
"../main.inc.php";
31require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
32require_once DOL_DOCUMENT_ROOT.
'/workstation/lib/workstation.lib.php';
43$langs->loadLangs(array(
"admin",
"workstation"));
46$action =
GETPOST(
'action',
'aZ09');
47$backtopage =
GETPOST(
'backtopage',
'alpha');
48$modulepart =
GETPOST(
'modulepart',
'aZ09');
50$value =
GETPOST(
'value',
'alpha');
55$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
62$moduledir =
'workstation';
63$myTmpObjects = array();
64$myTmpObjects[
'workstation'] = array(
'label' =>
'Workstation',
'includerefgeneration' => 1,
'includedocgeneration' => 0,
'class' =>
'Workstation');
66$tmpobjectkey =
GETPOST(
'object',
'aZ09');
67if ($tmpobjectkey && !array_key_exists($tmpobjectkey, $myTmpObjects)) {
76include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
78if ($action ==
'updateMask') {
79 $maskconst =
GETPOST(
'maskconstWorkstation',
'aZ09');
80 $maskorder =
GETPOST(
'maskWorkstation',
'alpha');
84 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
97} elseif ($action ==
'specimen') {
98 $modele =
GETPOST(
'module',
'alpha');
100 $nameofclass = ucfirst($tmpobjectkey);
101 $tmpobject =
new $nameofclass($db);
102 '@phan-var-force Workstation $tmpobject';
103 $tmpobject->initAsSpecimen();
108 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
109 foreach ($dirmodels as $reldir) {
110 $file =
dol_buildpath($reldir.
"core/modules/workstation/doc/pdf_".$modele.
"_".strtolower($tmpobjectkey).
".modules.php", 0);
111 if (file_exists($file)) {
112 $classname =
"pdf_".$modele;
117 if ($classname !==
'') {
120 $module =
new $classname($db);
121 '@phan-var-force ModelePDFWorkstation $module';
123 if ($module->write_file($tmpobject, $langs) > 0) {
124 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
132 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
134} elseif ($action ==
'set') {
137} elseif ($action ==
'del') {
140 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
145} elseif ($action ==
'setdoc') {
147 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
151 $conf->global->$constforval = $value;
159} elseif ($action ==
'setmod') {
162 $constforval =
'WORKSTATION_'.strtoupper($tmpobjectkey).
"_ADDON";
172$form =
new Form($db);
175$page_name =
"WorkstationSetup";
177llxHeader(
'', $langs->trans($page_name), $help_url,
'', 0, 0,
'',
'',
'',
'mod-admin page-workstation');
180$linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
186print
dol_get_fiche_head($head,
'settings', $langs->trans($page_name), -1,
"workstation");
192if ($action ==
'edit') {
193 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
194 print
'<input type="hidden" name="token" value="'.newToken().
'">';
195 print
'<input type="hidden" name="action" value="update">';
197 print
'<table class="noborder centpercent">';
198 print
'<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
201 foreach ($arrayofparameters as $key => $val) {
202 print
'<tr class="oddeven"><td>';
203 $tooltiphelp = (($langs->trans($key.
'Tooltip') != $key.
'Tooltip') ? $langs->trans($key.
'Tooltip') :
'');
204 print $form->textwithpicto($langs->trans($key), $tooltiphelp);
205 print
'</td><td><input name="'.$key.
'" class="flat '.(empty($val[
'css']) ?
'minwidth200' : $val[
'css']).
'" value="'.
getDolGlobalString($key).
'"></td></tr>';
209 print
'<br><div class="center">';
210 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
216 if (!empty($arrayofparameters)) {
217 print
'<table class="noborder centpercent">';
218 print
'<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
220 foreach ($arrayofparameters as $key => $val) {
223 print
'<tr class="oddeven"><td>';
224 $tooltiphelp = (($langs->trans($key.
'Tooltip') != $key.
'Tooltip') ? $langs->trans($key.
'Tooltip') :
'');
225 print $form->textwithpicto($langs->trans($key), $tooltiphelp);
226 print
'</td><td>'.getDolGlobalString($key).
'</td></tr>';
231 print
'<div class="tabsAction">';
232 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
240foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
241 if ($myTmpObjectArray[
'includerefgeneration']) {
245 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
247 print
'<table class="noborder centpercent">';
248 print
'<tr class="liste_titre">';
249 print
'<td>'.$langs->trans(
"Name").
'</td>';
250 print
'<td>'.$langs->trans(
"Description").
'</td>';
251 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
252 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
253 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
258 foreach ($dirmodels as $reldir) {
262 $handle = opendir($dir);
263 if (is_resource($handle)) {
264 while (($file = readdir($handle)) !==
false) {
265 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
266 $file = substr($file, 0,
dol_strlen($file) - 4);
268 require_once $dir.
'/'.$file.
'.php';
270 $module =
new $file($db);
271 '@phan-var-force ModeleNumRefWorkstation $module';
274 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
277 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
281 if ($module->isEnabled()) {
282 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
284 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
285 print $module->info($langs);
289 print
'<td class="nowrap">';
290 $tmp = $module->getExample();
291 if (preg_match(
'/^Error/', $tmp)) {
292 $langs->load(
"errors");
293 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
294 } elseif ($tmp ==
'NotConfigured') {
295 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
301 print
'<td class="center">';
302 $constforvar =
'WORKSTATION_'.strtoupper($myTmpObjectKey).
'_ADDON';
304 print
img_picto($langs->trans(
"Activated"),
'switch_on');
306 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.urlencode($file).
'">';
307 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
312 $nameofclass = ucfirst($myTmpObjectKey);
313 $mytmpinstance =
new $nameofclass($db);
314 '@phan-var-force Workstation $mytmpinstance';
315 $mytmpinstance->initAsSpecimen();
319 $htmltooltip .= $langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
321 $nextval = $module->getNextValue($mytmpinstance);
322 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
323 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
325 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
326 $nextval = $langs->trans($nextval);
328 $htmltooltip .= $nextval.
'<br>';
330 $htmltooltip .= $langs->trans($module->error).
'<br>';
334 print
'<td class="center">';
335 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
346 print
"</table><br>\n";
349 if ($myTmpObjectArray[
'includedocgeneration']) {
352 $type = strtolower($myTmpObjectKey);
354 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
359 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
360 $sql .=
" WHERE type = '".$db->escape($type).
"'";
361 $sql .=
" AND entity = ".$conf->entity;
362 $resql = $db->query($sql);
365 $num_rows = $db->num_rows($resql);
366 while ($i < $num_rows) {
367 $array = $db->fetch_array($resql);
368 if (is_array($array)) {
369 array_push($def, $array[0]);
377 print
"<table class=\"noborder\" width=\"100%\">\n";
378 print
"<tr class=\"liste_titre\">\n";
379 print
'<td>'.$langs->trans(
"Name").
'</td>';
380 print
'<td>'.$langs->trans(
"Description").
'</td>';
381 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
382 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
383 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
384 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
389 foreach ($dirmodels as $reldir) {
390 foreach (array(
'',
'/doc') as $valdir) {
391 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
395 $handle = opendir($dir);
396 if (is_resource($handle)) {
398 while (($file = readdir($handle)) !==
false) {
404 foreach ($filelist as $file) {
405 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
406 if (file_exists($dir.
'/'.$file)) {
407 $name = substr($file, 4,
dol_strlen($file) - 16);
408 $classname = substr($file, 0,
dol_strlen($file) - 12);
410 require_once $dir.
'/'.$file;
411 $module =
new $classname($db);
412 '@phan-var-force ModelePDFWorkstation $module';
414 $modulequalified = 1;
415 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
416 $modulequalified = 0;
418 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
419 $modulequalified = 0;
422 if ($modulequalified) {
423 print
'<tr class="oddeven"><td width="100">';
424 print(empty($module->name) ? $name : $module->
name);
426 if (method_exists($module,
'info')) {
427 print $module->info($langs);
429 print $module->description;
434 if (in_array($name, $def)) {
435 print
'<td class="center">'.
"\n";
436 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
437 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
441 print
'<td class="center">'.
"\n";
442 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>';
447 print
'<td class="center">';
448 $constforvar =
'WORKSTATION_'.strtoupper($myTmpObjectKey).
'_ADDON';
450 print
img_picto($langs->trans(
"Default"),
'on');
452 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>';
457 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
458 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
459 if ($module->type ==
'pdf') {
460 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
462 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
464 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
465 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
466 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
468 print
'<td class="center">';
469 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
473 print
'<td class="center">';
474 if ($module->type ==
'pdf') {
475 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
477 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
$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.