Go to the documentation of this file.
24 require
'../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
27 require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/bom/lib/bom.lib.php';
31 $langs->loadLangs(array(
'admin',
'errors',
'mrp',
'other'));
37 $action =
GETPOST(
'action',
'aZ09');
38 $value =
GETPOST(
'value',
'alpha');
39 $modulepart =
GETPOST(
'modulepart',
'aZ09');
41 $label =
GETPOST(
'label',
'alpha');
42 $scandir =
GETPOST(
'scan_dir',
'alpha');
50 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
52 if ($action ==
'updateMask') {
53 $maskconstbom =
GETPOST(
'maskconstBom',
'alpha');
54 $maskbom =
GETPOST(
'maskBom',
'alpha');
57 $res =
dolibarr_set_const($db, $maskconstbom, $maskbom,
'chaine', 0,
'', $conf->entity);
69 } elseif ($action ==
'specimen') {
70 $modele =
GETPOST(
'module',
'alpha');
73 $bom->initAsSpecimen();
76 $file =
''; $classname =
''; $filefound = 0;
77 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
78 foreach ($dirmodels as $reldir) {
79 $file =
dol_buildpath($reldir.
"core/modules/bom/doc/pdf_".$modele.
".modules.php", 0);
80 if (file_exists($file)) {
82 $classname =
"pdf_".$modele;
90 $module =
new $classname($db);
92 if ($module->write_file($bom, $langs) > 0) {
93 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=bom&file=SPECIMEN.pdf");
101 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
103 } elseif ($action ==
'set') {
106 } elseif ($action ==
'del') {
109 if ($conf->global->BOM_ADDON_PDF ==
"$value") {
113 } elseif ($action ==
'setdoc') {
115 if (
dolibarr_set_const($db,
"BOM_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
118 $conf->global->BOM_ADDON_PDF = $value;
126 } elseif ($action ==
'setmod') {
131 } elseif ($action ==
'set_BOM_DRAFT_WATERMARK') {
132 $draft =
GETPOST(
"BOM_DRAFT_WATERMARK");
133 $res =
dolibarr_set_const($db,
"BOM_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
144 } elseif ($action ==
'set_BOM_FREE_TEXT') {
145 $freetext =
GETPOST(
"BOM_FREE_TEXT",
'restricthtml');
147 $res =
dolibarr_set_const($db,
"BOM_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
167 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
169 llxHeader(
"", $langs->trans(
"BOMsSetup"));
171 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
172 print
load_fiche_titre($langs->trans(
"BOMsSetup"), $linkback,
'title_setup');
184 print
'<div class="div-table-responsive-no-min">';
185 print
'<table class="noborder centpercent">';
186 print
'<tr class="liste_titre">';
187 print
'<td>'.$langs->trans(
"Name").
'</td>';
188 print
'<td>'.$langs->trans(
"Description").
'</td>';
189 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
190 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
191 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
196 foreach ($dirmodels as $reldir) {
200 $handle = opendir($dir);
201 if (is_resource($handle)) {
202 while (($file = readdir($handle)) !==
false) {
203 if (substr($file, 0, 8) ==
'mod_bom_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
204 $file = substr($file, 0,
dol_strlen($file) - 4);
207 require_once $dir.$file.
'.php';
209 $module =
new $classname($db);
212 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
215 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
219 if ($module->isEnabled()) {
220 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
221 print $module->info();
225 print
'<td class="nowrap">';
226 $tmp = $module->getExample();
227 if (preg_match(
'/^Error/', $tmp)) {
228 $langs->load(
"errors");
229 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
230 } elseif ($tmp ==
'NotConfigured') {
231 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
237 print
'<td class="center">';
238 if ($conf->global->BOM_ADDON == $file) {
239 print
img_picto($langs->trans(
"Activated"),
'switch_on');
241 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
242 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
248 $bom->initAsSpecimen();
252 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
254 $nextval = $module->getNextValue($mysoc, $bom);
255 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
256 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
258 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
259 $nextval = $langs->trans($nextval);
261 $htmltooltip .= $nextval.
'<br>';
263 $htmltooltip .= $langs->trans($module->error).
'<br>';
267 print
'<td class="center">';
268 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
293 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
294 $sql .=
" WHERE type = '".$db->escape($type).
"'";
295 $sql .=
" AND entity = ".$conf->entity;
296 $resql = $db->query($sql);
299 $num_rows = $db->num_rows(
$resql);
300 while ($i < $num_rows) {
301 $array = $db->fetch_array(
$resql);
302 array_push($def, $array[0]);
310 print
'<div class="div-table-responsive-no-min">';
311 print
'<table class="noborder centpercent">';
312 print
'<tr class="liste_titre">';
313 print
'<td>'.$langs->trans(
"Name").
'</td>';
314 print
'<td>'.$langs->trans(
"Description").
'</td>';
315 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
316 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
317 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
318 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
323 foreach ($dirmodels as $reldir) {
324 foreach (array(
'',
'/doc') as $valdir) {
325 $realpath = $reldir.
"core/modules/bom".$valdir;
329 $handle = opendir($dir);
330 if (is_resource($handle)) {
331 while (($file = readdir($handle)) !==
false) {
337 foreach ($filelist as $file) {
338 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
339 if (file_exists($dir.
'/'.$file)) {
340 $name = substr($file, 4,
dol_strlen($file) - 16);
341 $classname = substr($file, 0,
dol_strlen($file) - 12);
343 require_once $dir.
'/'.$file;
344 $module =
new $classname($db);
346 $modulequalified = 1;
347 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
348 $modulequalified = 0;
350 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
351 $modulequalified = 0;
354 if ($modulequalified) {
355 print
'<tr class="oddeven"><td width="100">';
356 print (empty($module->name) ? $name : $module->name);
358 if (method_exists($module,
'info')) {
359 print $module->info($langs);
361 print $module->description;
366 if (in_array($name, $def)) {
367 print
'<td class="center">'.
"\n";
368 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
369 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
373 print
'<td class="center">'.
"\n";
374 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>';
379 print
'<td class="center">';
380 if ($conf->global->BOM_ADDON_PDF == $name) {
381 print
img_picto($langs->trans(
"Default"),
'on');
383 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>';
388 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
389 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
390 if ($module->type ==
'pdf') {
391 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
393 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
395 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
396 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
397 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftBOMs").
': '.
yn($module->option_draft_watermark, 1, 1);
400 print
'<td class="center">';
401 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
405 print
'<td class="center">';
406 if ($module->type ==
'pdf') {
407 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
409 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
433 print
'<div class="div-table-responsive-no-min">';
434 print
'<table class="noborder centpercent">';
435 print
'<tr class="liste_titre">';
436 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
437 print
'<td class="center" width="60">'.$langs->trans(
"Value").
'</td>';
438 print
"<td> </td>\n";
442 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
443 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
444 foreach ($substitutionarray as $key => $val) {
445 $htmltext .= $key.
'<br>';
449 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
450 print
'<input type="hidden" name="token" value="'.newToken().
'">';
451 print
'<input type="hidden" name="action" value="set_BOM_FREE_TEXT">';
452 print
'<tr class="oddeven"><td colspan="2">';
453 print
$form->textwithpicto($langs->trans(
"FreeLegalTextOnBOMs"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
454 $variablename =
'BOM_FREE_TEXT';
455 if (empty($conf->global->PDF_ALLOW_HTML_FOR_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();
462 print
'</td><td class="right">';
463 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
464 print
"</td></tr>\n";
469 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
470 print
'<input type="hidden" name="token" value="'.newToken().
'">';
471 print
'<input type="hidden" name="action" value="set_BOM_DRAFT_WATERMARK">';
472 print
'<tr class="oddeven"><td>';
473 print
$form->textwithpicto($langs->trans(
"WatermarkOnDraftBOMs"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
475 print
'<input class="flat minwidth200" type="text" name="BOM_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'BOM_DRAFT_WATERMARK')).
'">';
476 print
'</td><td class="right">';
477 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
478 print
"</td></tr>\n";
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
delDocumentModel($name, $type)
Delete document model used by doc generator.
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='')
Show tabs of a record.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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).
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
bomAdminPrepareHead()
Prepare admin pages header.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage a WYSIWYG editor.