27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/mrp/lib/mrp_mo.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/mrp/lib/mrp.lib.php';
35$langs->loadLangs(array(
'admin',
'errors',
'mrp',
'other'));
41$action =
GETPOST(
'action',
'aZ09');
42$value =
GETPOST(
'value',
'alpha');
43$modulepart =
GETPOST(
'modulepart',
'aZ09');
45$label =
GETPOST(
'label',
'alpha');
46$scandir =
GETPOST(
'scan_dir',
'alpha');
54include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
56if ($action ==
'updateMask') {
57 $maskconstmrp =
GETPOST(
'maskconstMo',
'aZ09');
58 $maskmrp =
GETPOST(
'maskMo',
'alpha');
60 if ($maskconstmrp && preg_match(
'/_MASK$/', $maskconstmrp)) {
61 $res =
dolibarr_set_const($db, $maskconstmrp, $maskmrp,
'chaine', 0,
'', $conf->entity);
73} elseif ($action ==
'specimen') {
74 $modele =
GETPOST(
'module',
'alpha');
77 $mo->initAsSpecimen();
82 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
83 foreach ($dirmodels as $reldir) {
84 $file =
dol_buildpath($reldir.
"core/modules/mrp/doc/pdf_".$modele.
".modules.php", 0);
85 if (file_exists($file)) {
86 $classname =
"pdf_".$modele;
91 if ($classname !==
'') {
94 $module =
new $classname($db);
95 '@phan-var-force CommonDocGenerator $module';
97 if ($module->write_file($mo, $langs) > 0) {
98 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=mrp&file=SPECIMEN.pdf");
106 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
108} elseif ($action ==
'set') {
111} elseif ($action ==
'del') {
114 if ($conf->global->MRP_MO_ADDON_PDF ==
"$value") {
118} elseif ($action ==
'setdoc') {
120 if (
dolibarr_set_const($db,
"MRP_MO_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
123 $conf->global->MRP_MO_ADDON_PDF = $value;
131} elseif ($action ==
'setmod') {
136} elseif ($action ==
'set_MRP_MO_DRAFT_WATERMARK') {
137 $draft =
GETPOST(
"MRP_MO_DRAFT_WATERMARK");
138 $res =
dolibarr_set_const($db,
"MRP_MO_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
149} elseif ($action ==
'set_MRP_MO_FREE_TEXT') {
150 $freetext =
GETPOST(
"MRP_MO_FREE_TEXT",
'restricthtml');
152 $res =
dolibarr_set_const($db,
"MRP_MO_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
170$form =
new Form($db);
172$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
174llxHeader(
"", $langs->trans(
"MrpSetupPage"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-mrp');
176$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
177print
load_fiche_titre($langs->trans(
"MrpSetupPage"), $linkback,
'title_setup');
189print
'<table class="noborder centpercent">';
190print
'<tr class="liste_titre">';
191print
'<td>'.$langs->trans(
"Name").
'</td>';
192print
'<td>'.$langs->trans(
"Description").
'</td>';
193print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
194print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
195print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
200foreach ($dirmodels as $reldir) {
204 $handle = opendir($dir);
205 if (is_resource($handle)) {
206 while (($file = readdir($handle)) !==
false) {
207 if (substr($file, 0, 7) ==
'mod_mo_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
208 $file = substr($file, 0,
dol_strlen($file) - 4);
210 require_once $dir.$file.
'.php';
212 $module =
new $file($db);
215 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
218 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
222 if ($module->isEnabled()) {
223 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
224 print $module->info($langs);
228 print
'<td class="nowrap">';
229 $tmp = $module->getExample();
230 if (preg_match(
'/^Error/', $tmp)) {
231 $langs->load(
"errors");
232 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
233 } elseif ($tmp ==
'NotConfigured') {
234 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
240 print
'<td class="center">';
241 if ($conf->global->MRP_MO_ADDON == $file) {
242 print
img_picto($langs->trans(
"Activated"),
'switch_on');
244 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
245 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
251 $mrp->initAsSpecimen();
255 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
257 $nextval = $module->getNextValue($mysoc, $mrp);
258 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
259 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
261 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
262 $nextval = $langs->trans($nextval);
264 $htmltooltip .= $nextval.
'<br>';
266 $htmltooltip .= $langs->trans($module->error).
'<br>';
270 print
'<td class="center">';
271 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
282print
"</table><br>\n";
294$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
295$sql .=
" WHERE type = '".$db->escape($type).
"'";
296$sql .=
" AND entity = ".$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]);
313print
"<table class=\"noborder\" width=\"100%\">\n";
314print
"<tr class=\"liste_titre\">\n";
315print
'<td>'.$langs->trans(
"Name").
'</td>';
316print
'<td>'.$langs->trans(
"Description").
'</td>';
317print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
318print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
319print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
320print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
325foreach ($dirmodels as $reldir) {
326 foreach (array(
'',
'/doc') as $valdir) {
327 $realpath = $reldir.
"core/modules/mrp".$valdir;
331 $handle = opendir($dir);
332 if (is_resource($handle)) {
334 while (($file = readdir($handle)) !==
false) {
340 foreach ($filelist as $file) {
341 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
342 if (file_exists($dir.
'/'.$file)) {
343 $name = substr($file, 4,
dol_strlen($file) - 16);
344 $classname = substr($file, 0,
dol_strlen($file) - 12);
346 require_once $dir.
'/'.$file;
347 $module =
new $classname($db);
349 $modulequalified = 1;
350 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
351 $modulequalified = 0;
353 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
354 $modulequalified = 0;
357 if ($modulequalified) {
358 print
'<tr class="oddeven"><td width="100">';
359 print(empty($module->name) ? $name : $module->
name);
361 if (method_exists($module,
'info')) {
362 print $module->info($langs);
364 print $module->description;
369 if (in_array($name, $def)) {
370 print
'<td class="center">'.
"\n";
371 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
372 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
376 print
'<td class="center">'.
"\n";
377 print
'<a class="reposition" 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>';
382 print
'<td class="center">';
383 if ($conf->global->MRP_MO_ADDON_PDF == $name) {
384 print
img_picto($langs->trans(
"Default"),
'on');
386 print
'<a class="reposition" 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>';
391 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
392 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
393 if ($module->type ==
'pdf') {
394 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
396 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
398 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
399 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
400 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftMOs").
': '.
yn($module->option_draft_watermark, 1, 1);
403 print
'<td class="center">';
404 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
408 print
'<td class="center">';
409 if ($module->type ==
'pdf') {
410 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
412 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
434print
'<table class="noborder centpercent">';
435print
'<tr class="liste_titre">';
436print
'<td>'.$langs->trans(
"Parameter").
'</td>';
437print
'<td class="center" width="60">'.$langs->trans(
"Value").
'</td>';
438print
"<td> </td>\n";
442$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
443$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
444foreach ($substitutionarray as $key => $val) {
445 $htmltext .= $key.
'<br>';
449print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
450print
'<input type="hidden" name="token" value="'.newToken().
'">';
451print
'<input type="hidden" name="action" value="set_MRP_MO_FREE_TEXT">';
452print
'<tr class="oddeven"><td colspan="2">';
453print $form->textwithpicto($langs->trans(
"FreeLegalTextOnMOs"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
454$variablename =
'MRP_MO_FREE_TEXT';
456 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
458 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
460 print $doleditor->Create();
462print
'</td><td class="right">';
463print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
469print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
470print
'<input type="hidden" name="token" value="'.newToken().
'">';
471print
"<input type=\"hidden\" name=\"action\" value=\"set_MRP_MO_DRAFT_WATERMARK\">";
472print
'<tr class="oddeven"><td>';
473print $form->textwithpicto($langs->trans(
"WatermarkOnDraftMOs"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
475print
'<input class="flat minwidth200" type="text" name="MRP_MO_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'MRP_MO_DRAFT_WATERMARK')).
'">';
476print
'</td><td class="right">';
477print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
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.
Class to manage a WYSIWYG editor.
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_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
mrpAdminPrepareHead()
Prepare admin pages header.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
$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.