28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/bom/lib/bom.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
45$langs->loadLangs(array(
'admin',
'errors',
'mrp',
'other'));
51$action =
GETPOST(
'action',
'aZ09');
52$value =
GETPOST(
'value',
'alpha');
53$modulepart =
GETPOST(
'modulepart',
'aZ09');
55$label =
GETPOST(
'label',
'alpha');
56$scandir =
GETPOST(
'scan_dir',
'alpha');
65include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
67if ($action ==
'updateMask') {
68 $maskconstbom =
GETPOST(
'maskconstBom',
'aZ09');
69 $maskbom =
GETPOST(
'maskBom',
'alpha');
73 if ($maskconstbom && preg_match(
'/_MASK$/', $maskconstbom)) {
86} elseif ($action ==
'specimen') {
87 $modele =
GETPOST(
'module',
'alpha');
90 $bom->initAsSpecimen();
95 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
96 foreach ($dirmodels as $reldir) {
97 $file =
dol_buildpath($reldir.
"core/modules/bom/doc/pdf_".$modele.
".modules.php", 0);
98 if (file_exists($file)) {
99 $classname =
"pdf_".$modele;
104 if ($classname !==
'') {
107 $module =
new $classname(
$db);
108 '@phan-var-force ModelePDFBom $module';
110 if ($module->write_file($bom, $langs) > 0) {
111 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=bom&file=SPECIMEN.pdf");
119 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
121} elseif ($action ==
'set') {
124} elseif ($action ==
'del') {
131} elseif ($action ==
'setdoc') {
136 $conf->global->BOM_ADDON_PDF = $value;
144} elseif ($action ==
'setmod') {
149} elseif ($action ==
'updateother') {
150 $draft =
GETPOST(
"BOM_DRAFT_WATERMARK");
156 $bomsearch =
GETPOST(
'activate_BOM_USE_SEARCH_TO_SELECT',
'alpha');
162 $freetext =
GETPOST(
"BOM_FREE_TEXT",
'restricthtml');
183$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
185llxHeader(
"", $langs->trans(
"BOMsSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-bom');
187$linkback =
'<a href="'.dolBuildUrl(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>';
189print
load_fiche_titre($langs->trans(
"BOMsSetup"), $linkback,
'title_setup');
201print
'<div class="div-table-responsive-no-min">';
202print
'<table class="noborder centpercent">';
203print
'<tr class="liste_titre">';
204print
'<td>'.$langs->trans(
"Name").
'</td>';
205print
'<td>'.$langs->trans(
"Description").
'</td>';
206print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
207print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
208print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
213foreach ($dirmodels as $reldir) {
217 $handle = opendir($dir);
218 if (is_resource($handle)) {
219 while (($file = readdir($handle)) !==
false) {
220 if (substr($file, 0, 8) ==
'mod_bom_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
221 $file = substr($file, 0,
dol_strlen($file) - 4);
224 require_once $dir.$file.
'.php';
226 $module =
new $classname(
$db);
228 '@phan-var-force ModeleNumRefBoms $module';
232 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
235 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
239 if ($module->isEnabled()) {
240 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
241 print $module->info($langs);
245 print
'<td class="nowrap">';
246 $tmp = $module->getExample();
247 if (preg_match(
'/^Error/', $tmp)) {
248 $langs->load(
"errors");
249 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
250 } elseif ($tmp ==
'NotConfigured') {
251 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
257 print
'<td class="center">';
259 print
img_picto($langs->trans(
"Activated"),
'switch_on');
261 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.newToken().
'&value='.urlencode($file).
'">';
262 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
268 $bom->initAsSpecimen();
271 $tmpprod->initAsSpecimen();
275 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
277 $nextval = $module->getNextValue($tmpprod, $bom);
278 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
279 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
281 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
282 $nextval = $langs->trans($nextval);
284 $htmltooltip .= $nextval.
'<br>';
286 $htmltooltip .= $langs->trans($module->error).
'<br>';
290 print
'<td class="center">';
291 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
316$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
317$sql .=
" WHERE type = '".$db->escape($type).
"'";
318$sql .=
" AND entity = ".((int)
$conf->entity);
319$resql =
$db->query($sql);
322 $num_rows =
$db->num_rows($resql);
323 while ($i < $num_rows) {
324 $array =
$db->fetch_array($resql);
325 if (is_array($array)) {
326 array_push($def, $array[0]);
335print
'<div class="div-table-responsive-no-min">';
336print
'<table class="noborder centpercent">';
337print
'<tr class="liste_titre">';
338print
'<td>'.$langs->trans(
"Name").
'</td>';
339print
'<td>'.$langs->trans(
"Description").
'</td>';
340print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
341print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
342print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
343print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
348foreach ($dirmodels as $reldir) {
349 foreach (array(
'',
'/doc') as $valdir) {
350 $realpath = $reldir.
"core/modules/bom".$valdir;
354 $handle = opendir($dir);
355 if (is_resource($handle)) {
357 while (($file = readdir($handle)) !==
false) {
363 foreach ($filelist as $file) {
364 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
365 if (file_exists($dir.
'/'.$file)) {
366 $name = substr($file, 4,
dol_strlen($file) - 16);
367 $classname = substr($file, 0,
dol_strlen($file) - 12);
369 require_once $dir.
'/'.$file;
370 $module =
new $classname(
$db);
371 '@phan-var-force ModelePDFBom $module';
374 $modulequalified = 1;
375 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
376 $modulequalified = 0;
378 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
379 $modulequalified = 0;
382 if ($modulequalified) {
383 print
'<tr class="oddeven"><td width="100">';
384 print(empty($module->name) ? $name : $module->
name);
386 if (method_exists($module,
'info')) {
387 print $module->info($langs);
389 print $module->description;
394 if (in_array($name, $def)) {
395 print
'<td class="center">'.
"\n";
396 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'">';
397 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
401 print
'<td class="center">'.
"\n";
402 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>';
407 print
'<td class="center">';
409 print
img_picto($langs->trans(
"Default"),
'on');
411 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>';
416 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
417 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
418 if ($module->type ==
'pdf') {
419 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
421 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
423 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
424 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
425 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftBOMs").
': '.
yn($module->option_draft_watermark, 1, 1);
428 print
'<td class="center">';
429 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
433 print
'<td class="center">';
434 if ($module->type ==
'pdf') {
435 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
437 print
img_object($langs->transnoentitiesnoconv(
"PreviewNotAvailable"),
'generic');
461print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
462print
'<input type="hidden" name="token" value="'.newToken().
'">';
463print
'<input type="hidden" name="action" value="updateother">';
465print
'<div class="div-table-responsive-no-min">';
466print
'<table class="noborder centpercent">';
467print
'<tr class="liste_titre">';
468print
'<td>'.$langs->trans(
"Parameter").
'</td>';
469print
'<td class="center"></td>';
473 print
'<tr class="oddeven"><td>';
474 print $langs->trans(
"BOM_SUB_BOM");
476 if (
$conf->use_javascript_ajax) {
477 print ajax_constantonoff(
'BOM_SUB_BOM');
480 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_BOM_SUB_BOM&token='.newToken().
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
482 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=del_BOM_SUB_BOM&token='.newToken().
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
486 print
"</td></tr>\n";
490print
'<tr class="oddeven">';
491print
'<td>'.$langs->trans(
"UseSearchToSelectBom").
'</td>';
492if (!
$conf->use_javascript_ajax) {
494 print
'<td class="nowrap right">';
495 print $langs->trans(
"NotAvailableWhenAjaxDisabled");
499 $arrval = array(
'0' => $langs->trans(
"No"),
500 '1' => $langs->trans(
"Yes").
' ('.$langs->trans(
"NumberOfKeyToSearch", 1).
')',
501 '2' => $langs->trans(
"Yes").
' ('.$langs->trans(
"NumberOfKeyToSearch", 2).
')',
502 '3' => $langs->trans(
"Yes").
' ('.$langs->trans(
"NumberOfKeyToSearch", 3).
')',
504 print $form->selectarray(
"activate_BOM_USE_SEARCH_TO_SELECT", $arrval,
getDolGlobalString(
"BOM_USE_SEARCH_TO_SELECT")).
'</td>';
510$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
511$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
512foreach ($substitutionarray as $key => $val) {
513 $htmltext .= $key.
'<br>';
517print
'<tr class="oddeven"><td colspan="2">';
518print $form->textwithpicto($langs->trans(
"FreeLegalTextOnBOMs"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
519$variablename =
'BOM_FREE_TEXT';
521 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
523 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
525 print $doleditor->Create();
531print
'<tr class="oddeven"><td>';
532print $form->textwithpicto($langs->trans(
"WatermarkOnDraftBOMs"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
534print
'<input class="flat minwidth200" type="text" name="BOM_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'BOM_DRAFT_WATERMARK')).
'">';
540print $form->buttonsSaveCancel(
"Save",
'');
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.
bomAdminPrepareHead()
Prepare admin pages header.
Class to manage a WYSIWYG editor.
Class to manage products or services.
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.
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.
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.