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");
189foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
190 if ($myTmpObjectArray[
'includerefgeneration']) {
194 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
196 print
'<table class="noborder centpercent">';
197 print
'<tr class="liste_titre">';
198 print
'<td>'.$langs->trans(
"Name").
'</td>';
199 print
'<td>'.$langs->trans(
"Description").
'</td>';
200 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
201 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
202 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
207 foreach ($dirmodels as $reldir) {
211 $handle = opendir($dir);
212 if (is_resource($handle)) {
213 while (($file = readdir($handle)) !==
false) {
214 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
215 $file = substr($file, 0,
dol_strlen($file) - 4);
217 require_once $dir.
'/'.$file.
'.php';
219 $module =
new $file($db);
220 '@phan-var-force ModeleNumRefWorkstation $module';
223 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
226 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
230 if ($module->isEnabled()) {
231 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
233 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
234 print $module->info($langs);
238 print
'<td class="nowrap">';
239 $tmp = $module->getExample();
240 if (preg_match(
'/^Error/', $tmp)) {
241 $langs->load(
"errors");
242 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
243 } elseif ($tmp ==
'NotConfigured') {
244 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
250 print
'<td class="center">';
251 $constforvar =
'WORKSTATION_'.strtoupper($myTmpObjectKey).
'_ADDON';
253 print
img_picto($langs->trans(
"Activated"),
'switch_on');
255 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.urlencode($file).
'">';
256 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
261 $nameofclass = ucfirst($myTmpObjectKey);
262 $mytmpinstance =
new $nameofclass($db);
263 '@phan-var-force Workstation $mytmpinstance';
264 $mytmpinstance->initAsSpecimen();
268 $htmltooltip .= $langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
270 $nextval = $module->getNextValue($mytmpinstance);
271 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
272 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
274 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
275 $nextval = $langs->trans($nextval);
277 $htmltooltip .= $nextval.
'<br>';
279 $htmltooltip .= $langs->trans($module->error).
'<br>';
283 print
'<td class="center">';
284 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
295 print
"</table><br>\n";
298 if ($myTmpObjectArray[
'includedocgeneration']) {
301 $type = strtolower($myTmpObjectKey);
303 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
308 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
309 $sql .=
" WHERE type = '".$db->escape($type).
"'";
310 $sql .=
" AND entity = ".$conf->entity;
311 $resql = $db->query($sql);
314 $num_rows = $db->num_rows($resql);
315 while ($i < $num_rows) {
316 $array = $db->fetch_array($resql);
317 if (is_array($array)) {
318 array_push($def, $array[0]);
326 print
"<table class=\"noborder\" width=\"100%\">\n";
327 print
"<tr class=\"liste_titre\">\n";
328 print
'<td>'.$langs->trans(
"Name").
'</td>';
329 print
'<td>'.$langs->trans(
"Description").
'</td>';
330 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
331 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
332 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
333 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
338 foreach ($dirmodels as $reldir) {
339 foreach (array(
'',
'/doc') as $valdir) {
340 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
344 $handle = opendir($dir);
345 if (is_resource($handle)) {
347 while (($file = readdir($handle)) !==
false) {
353 foreach ($filelist as $file) {
354 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
355 if (file_exists($dir.
'/'.$file)) {
356 $name = substr($file, 4,
dol_strlen($file) - 16);
357 $classname = substr($file, 0,
dol_strlen($file) - 12);
359 require_once $dir.
'/'.$file;
360 $module =
new $classname($db);
361 '@phan-var-force ModelePDFWorkstation $module';
363 $modulequalified = 1;
364 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
365 $modulequalified = 0;
367 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
368 $modulequalified = 0;
371 if ($modulequalified) {
372 print
'<tr class="oddeven"><td width="100">';
373 print(empty($module->name) ? $name : $module->
name);
375 if (method_exists($module,
'info')) {
376 print $module->info($langs);
378 print $module->description;
383 if (in_array($name, $def)) {
384 print
'<td class="center">'.
"\n";
385 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
386 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
390 print
'<td class="center">'.
"\n";
391 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>';
396 print
'<td class="center">';
397 $constforvar =
'WORKSTATION_'.strtoupper($myTmpObjectKey).
'_ADDON';
399 print
img_picto($langs->trans(
"Default"),
'on');
401 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>';
406 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
407 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
408 if ($module->type ==
'pdf') {
409 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
411 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
413 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
414 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
415 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
417 print
'<td class="center">';
418 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
422 print
'<td class="center">';
423 if ($module->type ==
'pdf') {
424 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
426 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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
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...
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.