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)) {
82 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
84 setEventMessages($langs->trans(
"Error"),
null,
'errors');
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 !==
'') {
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");
118 setEventMessages($langs->trans(
"ErrorModuleNotFound"),
null,
'errors');
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');
171 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
173 setEventMessages($langs->trans(
"Error"),
null,
'errors');
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="'.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) {
224 require_once $dir.$file.
'.php';
228 '@phan-var-force ModeleNumRefBoms $module';
240 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
245 print
'<td class="nowrap">';
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');
311printDocumentModelList($type,
'bom',
'BOM_ADDON_PDF', $langs->trans(
"BOMsModelModule"), array(
312 'MultiLanguage' =>
'option_multilang',
313 'WatermarkOnDraftBOMs' =>
'option_draft_watermark',
323print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" spellcheck="false">';
324print
'<input type="hidden" name="token" value="'.newToken().
'">';
325print
'<input type="hidden" name="action" value="updateother">';
327print
'<div class="div-table-responsive-no-min">';
328print
'<table class="noborder centpercent">';
329print
'<tr class="liste_titre">';
330print
'<td>'.$langs->trans(
"Parameter").
'</td>';
331print
'<td class="center"></td>';
335 print
'<tr class="oddeven"><td>';
336 print $langs->trans(
"BOM_SUB_BOM");
338 if (
$conf->use_javascript_ajax) {
339 print ajax_constantonoff(
'BOM_SUB_BOM');
342 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_BOM_SUB_BOM&token='.
newToken().
'">'.img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
344 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=del_BOM_SUB_BOM&token='.
newToken().
'">'.img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
348 print
"</td></tr>\n";
352print
'<tr class="oddeven">';
353print
'<td>'.$langs->trans(
"UseSearchToSelectBom").
'</td>';
354if (!
$conf->use_javascript_ajax) {
356 print
'<td class="nowrap right">';
357 print $langs->trans(
"NotAvailableWhenAjaxDisabled");
362 0 => array(
'label' => $langs->trans(
"No")),
363 1 => array(
'label' => $langs->trans(
"Yes").
' ('.$langs->trans(
"NumberOfKeyToSearch", 1).
')',
'labelhtml' => $langs->trans(
"Yes").
' <span class="opacitymedium small">('.$langs->trans(
"NumberOfKeyToSearch", 1).
')</span>'),
364 2 => array(
'label' => $langs->trans(
"Yes").
' ('.$langs->trans(
"NumberOfKeyToSearch", 2).
')',
'labelhtml' => $langs->trans(
"Yes").
' <span class="opacitymedium small">('.$langs->trans(
"NumberOfKeyToSearch", 2).
')</span>'),
365 3 => array(
'label' => $langs->trans(
"Yes").
' ('.$langs->trans(
"NumberOfKeyToSearch", 3).
')',
'labelhtml' => $langs->trans(
"Yes").
' <span class="opacitymedium small">('.$langs->trans(
"NumberOfKeyToSearch", 3).
')</span>'),
367 print $form->selectarray(
"activate_BOM_USE_SEARCH_TO_SELECT", $arrval,
getDolGlobalString(
"BOM_USE_SEARCH_TO_SELECT")).
'</td>';
373$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
374$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
375foreach ($substitutionarray as $key => $val) {
376 $htmltext .= $key.
'<br>';
380print
'<tr class="oddeven"><td colspan="2">';
381print $form->textwithpicto($langs->trans(
"FreeLegalTextOnBOMs"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
382$variablename =
'BOM_FREE_TEXT';
384 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
386 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
388 print $doleditor->Create();
394print
'<tr class="oddeven"><td>';
395print $form->textwithpicto($langs->trans(
"WatermarkOnDraftBOMs"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
397print
'<input class="flat minwidth200" type="text" name="BOM_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'BOM_DRAFT_WATERMARK')).
'">';
403print $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.
if(! $sortfield) if(! $sortorder) $module
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.