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');
49$label =
GETPOST(
'label',
'alpha');
50$scandir =
GETPOST(
'scan_dir',
'alpha');
52$value =
GETPOST(
'value',
'alpha');
56$dirmodels = array_merge([
'/'], (array) $conf->modules_parts[
'models']);
64$moduledir =
'workstation';
70include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
72if ($action ==
'updateMask') {
73 $maskconst =
GETPOST(
'maskconstWorkstation',
'aZ09');
74 $maskorder =
GETPOST(
'maskWorkstation',
'alpha');
78 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
79 $res =
dolibarr_set_const($db, $maskconst, $maskorder,
'chaine', 0,
'', $conf->entity);
91} elseif ($action ==
'specimen') {
92 $modele =
GETPOST(
'module',
'alpha');
95 $tmpobject->initAsSpecimen();
100 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
101 foreach ($dirmodels as $reldir) {
102 $file =
dol_buildpath($reldir.
"core/modules/workstation/doc/pdf_".$modele.
"_workstation.modules.php", 0);
103 if (file_exists($file)) {
104 $classname =
"pdf_".$modele;
109 if ($classname !==
'') {
112 $module =
new $classname($db);
113 '@phan-var-force ModelePDFWorkstation $module';
116 if ($module->write_file($tmpobject, $langs) > 0) {
117 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=workstation&file=SPECIMEN.pdf");
125 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
127} elseif ($action ==
'set') {
130} elseif ($action ==
'del') {
133 $constforval =
'WORKSTATION_ADDON_PDF';
138} elseif ($action ==
'setdoc') {
140 $constforval =
'WORKSTATION_ADDON_PDF';
144 $conf->global->$constforval = $value;
152} elseif ($action ==
'setmod') {
155 $constforval =
'WORKSTATION_WORKSTATION_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').
'">'.
img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></a>';
179print
dol_get_fiche_head($head,
'settings', $langs->trans($page_name), -1,
"workstation");
184print
load_fiche_titre($langs->trans(
"NumberingModules",
'Workstation'),
'',
'');
186print
'<table class="noborder centpercent">';
187print
'<tr class="liste_titre">';
188print
'<td>'.$langs->trans(
"Name").
'</td>';
189print
'<td>'.$langs->trans(
"Description").
'</td>';
190print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
191print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
192print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
197foreach ($dirmodels as $reldir) {
201 $handle = opendir($dir);
202 if (is_resource($handle)) {
203 while (($file = readdir($handle)) !==
false) {
204 if (strpos($file,
'mod_workstation_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
205 $file = substr($file, 0,
dol_strlen($file) - 4);
207 require_once $dir.
'/'.$file.
'.php';
209 $module =
new $file($db);
210 '@phan-var-force ModeleNumRefWorkstation $module';
214 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
217 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
221 if ($module->isEnabled()) {
224 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
225 print $module->info($langs);
229 print
'<td class="nowrap">';
230 $tmp = $module->getExample();
231 if (preg_match(
'/^Error/', $tmp)) {
232 $langs->load(
"errors");
233 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
234 } elseif ($tmp ==
'NotConfigured') {
235 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
241 print
'<td class="center">';
242 $constforvar =
'WORKSTATION_WORKSTATION_ADDON';
244 print
img_picto($langs->trans(
"Activated"),
'switch_on');
246 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
247 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
253 $mytmpinstance->initAsSpecimen();
257 $htmltooltip .= $langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
259 $nextval = $module->getNextValue($mytmpinstance);
260 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
261 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
263 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
264 $nextval = $langs->trans($nextval);
266 $htmltooltip .= $nextval.
'<br>';
268 $htmltooltip .= $langs->trans($module->error).
'<br>';
272 print
'<td class="center">';
273 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
284print
"</table><br>\n";
289 print
load_fiche_titre($langs->trans(
"DocumentModules",
'Workstation'),
'',
'');
294 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
295 $sql .=
" WHERE type = '".$db->escape($type).
"'";
296 $sql .=
" AND entity = ".((int) $conf->entity);
297 $resql = $db->query($sql);
300 $num_rows = $db->num_rows($resql);
301 while ($i < $num_rows) {
302 $array = $db->fetch_array($resql);
303 if (is_array($array)) {
304 array_push($def, $array[0]);
312 print
"<table class=\"noborder\" width=\"100%\">\n";
313 print
"<tr class=\"liste_titre\">\n";
314 print
'<td>'.$langs->trans(
"Name").
'</td>';
315 print
'<td>'.$langs->trans(
"Description").
'</td>';
316 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
317 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
318 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
319 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
324 foreach ($dirmodels as $reldir) {
325 foreach (array(
'',
'/doc') as $valdir) {
326 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
330 $handle = opendir($dir);
331 if (is_resource($handle)) {
333 while (($file = readdir($handle)) !==
false) {
339 foreach ($filelist as $file) {
340 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
341 if (file_exists($dir.
'/'.$file)) {
342 $name = substr($file, 4,
dol_strlen($file) - 16);
343 $classname = substr($file, 0,
dol_strlen($file) - 12);
345 require_once $dir.
'/'.$file;
346 $module =
new $classname($db);
347 '@phan-var-force ModelePDFWorkstation $module';
350 $modulequalified = 1;
351 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
352 $modulequalified = 0;
354 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
355 $modulequalified = 0;
358 if ($modulequalified) {
359 print
'<tr class="oddeven"><td width="100">';
360 print(empty($module->name) ? $name : $module->
name);
362 if (method_exists($module,
'info')) {
363 print $module->info($langs);
365 print $module->description;
370 if (in_array($name, $def)) {
371 print
'<td class="center">'.
"\n";
372 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
373 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
377 print
'<td class="center">'.
"\n";
378 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>';
383 print
'<td class="center">';
384 $constforvar =
'WORKSTATION_WORKSTATION_ADDON';
386 print
img_picto($langs->trans(
"Default"),
'on');
388 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>';
393 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
394 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
395 if ($module->type ==
'pdf') {
396 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
398 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
400 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
401 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
402 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
404 print
'<td class="center">';
405 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
409 print
'<td class="center">';
410 if ($module->type ==
'pdf') {
411 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
413 print
img_object($langs->transnoentitiesnoconv(
"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.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
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, $allowothertags=array())
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, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.