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');
75 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
76 $res =
dolibarr_set_const($db, $maskconst, $maskorder,
'chaine', 0,
'', $conf->entity);
88} elseif ($action ==
'specimen') {
89 $modele =
GETPOST(
'module',
'alpha');
91 $nameofclass = ucfirst($tmpobjectkey);
92 $tmpobject =
new $nameofclass($db);
93 $tmpobject->initAsSpecimen();
98 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
99 foreach ($dirmodels as $reldir) {
100 $file =
dol_buildpath($reldir.
"core/modules/workstation/doc/pdf_".$modele.
"_".strtolower($tmpobjectkey).
".modules.php", 0);
101 if (file_exists($file)) {
102 $classname =
"pdf_".$modele;
107 if ($classname !==
'') {
110 $module =
new $classname($db);
111 '@phan-var-force CommonDocGenerator $module';
113 if ($module->write_file($tmpobject, $langs) > 0) {
114 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
122 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
124} elseif ($action ==
'set') {
127} elseif ($action ==
'del') {
130 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
135} elseif ($action ==
'setdoc') {
137 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
141 $conf->global->$constforval = $value;
149} elseif ($action ==
'setmod') {
152 $constforval =
'WORKSTATION_'.strtoupper($tmpobjectkey).
"_ADDON";
162$form =
new Form($db);
165$page_name =
"WorkstationSetup";
167llxHeader(
'', $langs->trans($page_name), $help_url,
'', 0, 0,
'',
'',
'',
'mod-admin page-workstation');
170$linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
176print
dol_get_fiche_head($head,
'settings', $langs->trans($page_name), -1,
"workstation");
182if ($action ==
'edit') {
183 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
184 print
'<input type="hidden" name="token" value="'.newToken().
'">';
185 print
'<input type="hidden" name="action" value="update">';
187 print
'<table class="noborder centpercent">';
188 print
'<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
190 foreach ($arrayofparameters as $key => $val) {
191 print
'<tr class="oddeven"><td>';
192 $tooltiphelp = (($langs->trans($key.
'Tooltip') != $key.
'Tooltip') ? $langs->trans($key.
'Tooltip') :
'');
193 print $form->textwithpicto($langs->trans($key), $tooltiphelp);
194 print
'</td><td><input name="'.$key.
'" class="flat '.(empty($val[
'css']) ?
'minwidth200' : $val[
'css']).
'" value="'.
getDolGlobalString($key).
'"></td></tr>';
198 print
'<br><div class="center">';
199 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
205 if (!empty($arrayofparameters)) {
206 print
'<table class="noborder centpercent">';
207 print
'<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
209 foreach ($arrayofparameters as $key => $val) {
212 print
'<tr class="oddeven"><td>';
213 $tooltiphelp = (($langs->trans($key.
'Tooltip') != $key.
'Tooltip') ? $langs->trans($key.
'Tooltip') :
'');
214 print $form->textwithpicto($langs->trans($key), $tooltiphelp);
215 print
'</td><td>'.getDolGlobalString($key).
'</td></tr>';
220 print
'<div class="tabsAction">';
221 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
229foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
230 if ($myTmpObjectKey ==
'MyObject') {
233 if ($myTmpObjectArray[
'includerefgeneration']) {
239 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
241 print
'<table class="noborder centpercent">';
242 print
'<tr class="liste_titre">';
243 print
'<td>'.$langs->trans(
"Name").
'</td>';
244 print
'<td>'.$langs->trans(
"Description").
'</td>';
245 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
246 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
247 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
252 foreach ($dirmodels as $reldir) {
256 $handle = opendir($dir);
257 if (is_resource($handle)) {
258 while (($file = readdir($handle)) !==
false) {
259 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
260 $file = substr($file, 0,
dol_strlen($file) - 4);
262 require_once $dir.
'/'.$file.
'.php';
264 $module =
new $file($db);
265 '@phan-var-force CommonNumRefGenerator $module';
268 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
271 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
275 if ($module->isEnabled()) {
276 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
278 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
279 print $module->info($langs);
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 $constforvar =
'WORKSTATION_'.strtoupper($myTmpObjectKey).
'_ADDON';
298 print
img_picto($langs->trans(
"Activated"),
'switch_on');
300 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.urlencode($file).
'">';
301 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
306 $nameofclass = ucfirst($myTmpObjectKey);
307 $mytmpinstance =
new $nameofclass($db);
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']) {
347 $type = strtolower($myTmpObjectKey);
349 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
354 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
355 $sql .=
" WHERE type = '".$db->escape($type).
"'";
356 $sql .=
" AND entity = ".$conf->entity;
357 $resql = $db->query($sql);
360 $num_rows = $db->num_rows($resql);
361 while ($i < $num_rows) {
362 $array = $db->fetch_array($resql);
363 if (is_array($array)) {
364 array_push($def, $array[0]);
372 print
"<table class=\"noborder\" width=\"100%\">\n";
373 print
"<tr class=\"liste_titre\">\n";
374 print
'<td>'.$langs->trans(
"Name").
'</td>';
375 print
'<td>'.$langs->trans(
"Description").
'</td>';
376 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
377 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
378 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
379 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
384 foreach ($dirmodels as $reldir) {
385 foreach (array(
'',
'/doc') as $valdir) {
386 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
390 $handle = opendir($dir);
391 if (is_resource($handle)) {
393 while (($file = readdir($handle)) !==
false) {
399 foreach ($filelist as $file) {
400 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
401 if (file_exists($dir.
'/'.$file)) {
402 $name = substr($file, 4,
dol_strlen($file) - 16);
403 $classname = substr($file, 0,
dol_strlen($file) - 12);
405 require_once $dir.
'/'.$file;
406 $module =
new $classname($db);
407 '@phan-var-force CommonDocGenerator $module';
409 $modulequalified = 1;
410 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
411 $modulequalified = 0;
413 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
414 $modulequalified = 0;
417 if ($modulequalified) {
418 print
'<tr class="oddeven"><td width="100">';
419 print(empty($module->name) ? $name : $module->
name);
421 if (method_exists($module,
'info')) {
422 print $module->info($langs);
424 print $module->description;
429 if (in_array($name, $def)) {
430 print
'<td class="center">'.
"\n";
431 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
432 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
436 print
'<td class="center">'.
"\n";
437 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>';
442 print
'<td class="center">';
443 $constforvar =
'WORKSTATION_'.strtoupper($myTmpObjectKey).
'_ADDON';
445 print
img_picto($langs->trans(
"Default"),
'on');
447 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>';
452 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
453 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
454 if ($module->type ==
'pdf') {
455 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
457 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
459 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
460 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
461 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
463 print
'<td class="center">';
464 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
468 print
'<td class="center">';
469 if ($module->type ==
'pdf') {
470 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
472 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($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)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_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'.
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.
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 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.