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.
'/bom/class/bom.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/bom/lib/bom.lib.php';
43$langs->loadLangs(array(
'admin',
'errors',
'mrp',
'other'));
49$action =
GETPOST(
'action',
'aZ09');
50$value =
GETPOST(
'value',
'alpha');
51$modulepart =
GETPOST(
'modulepart',
'aZ09');
53$label =
GETPOST(
'label',
'alpha');
54$scandir =
GETPOST(
'scan_dir',
'alpha');
63include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
65if ($action ==
'updateMask') {
66 $maskconstbom =
GETPOST(
'maskconstBom',
'aZ09');
67 $maskbom =
GETPOST(
'maskBom',
'alpha');
71 if ($maskconstbom && preg_match(
'/_MASK$/', $maskconstbom)) {
84} elseif ($action ==
'specimen') {
85 $modele =
GETPOST(
'module',
'alpha');
88 $bom->initAsSpecimen();
93 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
94 foreach ($dirmodels as $reldir) {
95 $file =
dol_buildpath($reldir.
"core/modules/bom/doc/pdf_".$modele.
".modules.php", 0);
96 if (file_exists($file)) {
97 $classname =
"pdf_".$modele;
102 if ($classname !==
'') {
105 $module =
new $classname($db);
106 '@phan-var-force ModelePDFBom $module';
108 if ($module->write_file($bom, $langs) > 0) {
109 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=bom&file=SPECIMEN.pdf");
117 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
119} elseif ($action ==
'set') {
122} elseif ($action ==
'del') {
125 if (
$conf->global->BOM_ADDON_PDF ==
"$value") {
129} elseif ($action ==
'setdoc') {
134 $conf->global->BOM_ADDON_PDF = $value;
142} elseif ($action ==
'setmod') {
147} elseif ($action ==
'set_BOM_DRAFT_WATERMARK') {
148 $draft =
GETPOST(
"BOM_DRAFT_WATERMARK");
160} elseif ($action ==
'set_BOM_FREE_TEXT') {
161 $freetext =
GETPOST(
"BOM_FREE_TEXT",
'restricthtml');
181$form =
new Form($db);
183$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
185llxHeader(
"", $langs->trans(
"BOMsSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-bom');
187$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
188print
load_fiche_titre($langs->trans(
"BOMsSetup"), $linkback,
'title_setup');
200print
'<div class="div-table-responsive-no-min">';
201print
'<table class="noborder centpercent">';
202print
'<tr class="liste_titre">';
203print
'<td>'.$langs->trans(
"Name").
'</td>';
204print
'<td>'.$langs->trans(
"Description").
'</td>';
205print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
206print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
207print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
212foreach ($dirmodels as $reldir) {
216 $handle = opendir($dir);
217 if (is_resource($handle)) {
218 while (($file = readdir($handle)) !==
false) {
219 if (substr($file, 0, 8) ==
'mod_bom_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
220 $file = substr($file, 0,
dol_strlen($file) - 4);
223 require_once $dir.$file.
'.php';
225 $module =
new $classname($db);
227 '@phan-var-force ModeleNumRefBoms $module';
230 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
233 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
237 if ($module->isEnabled()) {
238 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
239 print $module->info($langs);
243 print
'<td class="nowrap">';
244 $tmp = $module->getExample();
245 if (preg_match(
'/^Error/', $tmp)) {
246 $langs->load(
"errors");
247 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
248 } elseif ($tmp ==
'NotConfigured') {
249 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
255 print
'<td class="center">';
256 if (
$conf->global->BOM_ADDON == $file) {
257 print
img_picto($langs->trans(
"Activated"),
'switch_on');
259 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
260 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
266 $bom->initAsSpecimen();
270 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
272 $nextval = $module->getNextValue($mysoc, $bom);
273 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
274 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
276 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
277 $nextval = $langs->trans($nextval);
279 $htmltooltip .= $nextval.
'<br>';
281 $htmltooltip .= $langs->trans($module->error).
'<br>';
285 print
'<td class="center">';
286 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
311$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
312$sql .=
" WHERE type = '".$db->escape($type).
"'";
313$sql .=
" AND entity = ".$conf->entity;
314$resql = $db->query($sql);
317 $num_rows = $db->num_rows($resql);
318 while ($i < $num_rows) {
319 $array = $db->fetch_array($resql);
320 if (is_array($array)) {
321 array_push($def, $array[0]);
330print
'<div class="div-table-responsive-no-min">';
331print
'<table class="noborder centpercent">';
332print
'<tr class="liste_titre">';
333print
'<td>'.$langs->trans(
"Name").
'</td>';
334print
'<td>'.$langs->trans(
"Description").
'</td>';
335print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
336print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
337print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
338print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
343foreach ($dirmodels as $reldir) {
344 foreach (array(
'',
'/doc') as $valdir) {
345 $realpath = $reldir.
"core/modules/bom".$valdir;
349 $handle = opendir($dir);
350 if (is_resource($handle)) {
352 while (($file = readdir($handle)) !==
false) {
358 foreach ($filelist as $file) {
359 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
360 if (file_exists($dir.
'/'.$file)) {
361 $name = substr($file, 4,
dol_strlen($file) - 16);
362 $classname = substr($file, 0,
dol_strlen($file) - 12);
364 require_once $dir.
'/'.$file;
365 $module =
new $classname($db);
366 '@phan-var-force ModelePDFBom $module';
368 $modulequalified = 1;
369 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
370 $modulequalified = 0;
372 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
373 $modulequalified = 0;
376 if ($modulequalified) {
377 print
'<tr class="oddeven"><td width="100">';
378 print(empty($module->name) ? $name : $module->
name);
380 if (method_exists($module,
'info')) {
381 print $module->info($langs);
383 print $module->description;
388 if (in_array($name, $def)) {
389 print
'<td class="center">'.
"\n";
390 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
391 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
395 print
'<td class="center">'.
"\n";
396 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>';
401 print
'<td class="center">';
402 if (
$conf->global->BOM_ADDON_PDF == $name) {
403 print
img_picto($langs->trans(
"Default"),
'on');
405 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>';
410 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
411 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
412 if ($module->type ==
'pdf') {
413 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
415 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
417 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
418 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
419 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftBOMs").
': '.
yn($module->option_draft_watermark, 1, 1);
422 print
'<td class="center">';
423 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
427 print
'<td class="center">';
428 if ($module->type ==
'pdf') {
429 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
431 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
455print
'<div class="div-table-responsive-no-min">';
456print
'<table class="noborder centpercent">';
457print
'<tr class="liste_titre">';
458print
'<td>'.$langs->trans(
"Parameter").
'</td>';
459print
'<td class="center" width="60">'.$langs->trans(
"Value").
'</td>';
460print
"<td> </td>\n";
464$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
465$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
466foreach ($substitutionarray as $key => $val) {
467 $htmltext .= $key.
'<br>';
471print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
472print
'<input type="hidden" name="token" value="'.newToken().
'">';
473print
'<input type="hidden" name="action" value="set_BOM_FREE_TEXT">';
474print
'<tr class="oddeven"><td colspan="2">';
475print $form->textwithpicto($langs->trans(
"FreeLegalTextOnBOMs"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
476$variablename =
'BOM_FREE_TEXT';
478 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
480 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
482 print $doleditor->Create();
484print
'</td><td class="right">';
485print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
491print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
492print
'<input type="hidden" name="token" value="'.newToken().
'">';
493print
'<input type="hidden" name="action" value="set_BOM_DRAFT_WATERMARK">';
494print
'<tr class="oddeven"><td>';
495print $form->textwithpicto($langs->trans(
"WatermarkOnDraftBOMs"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
497print
'<input class="flat minwidth200" type="text" name="BOM_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'BOM_DRAFT_WATERMARK')).
'">';
498print
'</td><td class="right">';
499print
'<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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
bomAdminPrepareHead()
Prepare admin pages 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)
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_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'.
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...
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.