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'));
35 $action =
GETPOST(
'action',
'aZ09');
36 $value =
GETPOST(
'value',
'alpha');
37 $label =
GETPOST(
'label',
'alpha');
38 $scandir =
GETPOST(
'scan_dir',
'alpha');
46 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
48 if ($action ==
'updateMask')
50 $maskconstbom =
GETPOST(
'maskconstBom',
'alpha');
51 $maskbom =
GETPOST(
'maskBom',
'alpha');
53 if ($maskconstbom) $res =
dolibarr_set_const($db, $maskconstbom, $maskbom,
'chaine', 0,
'', $conf->entity);
55 if (!($res > 0)) $error++;
63 } elseif ($action ==
'specimen')
65 $modele =
GETPOST(
'module',
'alpha');
68 $bom->initAsSpecimen();
71 $file =
''; $classname =
''; $filefound = 0;
72 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
73 foreach ($dirmodels as $reldir)
75 $file =
dol_buildpath($reldir.
"core/modules/bom/doc/pdf_".$modele.
".modules.php", 0);
76 if (file_exists($file))
79 $classname =
"pdf_".$modele;
88 $module =
new $classname($db);
90 if ($module->write_file($bom, $langs) > 0)
92 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=bom&file=SPECIMEN.pdf");
100 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
105 elseif ($action ==
'set')
108 } elseif ($action ==
'del')
113 if ($conf->global->BOM_ADDON_PDF ==
"$value")
dolibarr_del_const($db,
'BOM_ADDON_PDF', $conf->entity);
118 elseif ($action ==
'setdoc')
124 $conf->global->BOM_ADDON_PDF = $value;
133 } elseif ($action ==
'setmod')
139 } elseif ($action ==
'set_BOM_DRAFT_WATERMARK')
141 $draft =
GETPOST(
"BOM_DRAFT_WATERMARK");
142 $res =
dolibarr_set_const($db,
"BOM_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
144 if (!($res > 0)) $error++;
152 } elseif ($action ==
'set_BOM_FREE_TEXT')
154 $freetext =
GETPOST(
"BOM_FREE_TEXT",
'restricthtml');
156 $res =
dolibarr_set_const($db,
"BOM_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
158 if (!($res > 0)) $error++;
173 $form =
new Form($db);
175 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
177 llxHeader(
"", $langs->trans(
"BOMsSetup"));
179 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
192 print '<table class="noborder centpercent">';
193 print
'<tr class="liste_titre">';
194 print
'<td>'.$langs->trans(
"Name").
'</td>';
195 print
'<td>'.$langs->trans(
"Description").
'</td>';
196 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
197 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
198 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
203 foreach ($dirmodels as $reldir)
209 $handle = opendir($dir);
210 if (is_resource($handle))
212 while (($file = readdir($handle)) !==
false)
214 if (substr($file, 0, 8) ==
'mod_bom_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php')
216 $file = substr($file, 0,
dol_strlen($file) - 4);
218 require_once $dir.$file.
'.php';
220 $module =
new $file($db);
223 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
224 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
226 if ($module->isEnabled())
228 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
229 print $module->info();
233 print
'<td class="nowrap">';
234 $tmp = $module->getExample();
235 if (preg_match(
'/^Error/', $tmp)) {
236 $langs->load(
"errors");
237 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
238 } elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
242 print '<td class="center">';
243 if ($conf->global->BOM_ADDON == $file)
245 print
img_picto($langs->trans(
"Activated"),
'switch_on');
247 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
248 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
254 $bom->initAsSpecimen();
258 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
260 $nextval = $module->getNextValue($mysoc, $bom);
261 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
262 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
264 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
265 $nextval = $langs->trans($nextval);
266 $htmltooltip .= $nextval.
'<br>';
268 $htmltooltip .= $langs->trans($module->error).
'<br>';
272 print
'<td class="center">';
273 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
284 print
"</table><br>\n";
296 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
297 $sql .=
" WHERE type = '".$db->escape($type).
"'";
298 $sql .=
" AND entity = ".$conf->entity;
299 $resql = $db->query($sql);
303 $num_rows = $db->num_rows(
$resql);
304 while ($i < $num_rows)
306 $array = $db->fetch_array(
$resql);
307 array_push($def, $array[0]);
315 print
"<table class=\"noborder\" width=\"100%\">\n";
316 print
"<tr class=\"liste_titre\">\n";
317 print
'<td>'.$langs->trans(
"Name").
'</td>';
318 print
'<td>'.$langs->trans(
"Description").
'</td>';
319 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
320 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
321 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
322 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
327 foreach ($dirmodels as $reldir)
329 foreach (array(
'',
'/doc') as $valdir)
331 $realpath = $reldir.
"core/modules/bom".$valdir;
336 $handle = opendir($dir);
337 if (is_resource($handle))
339 while (($file = readdir($handle)) !==
false)
346 foreach ($filelist as $file)
348 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file))
350 if (file_exists($dir.
'/'.$file))
352 $name = substr($file, 4,
dol_strlen($file) - 16);
353 $classname = substr($file, 0,
dol_strlen($file) - 12);
355 require_once $dir.
'/'.$file;
356 $module =
new $classname($db);
358 $modulequalified = 1;
359 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
360 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
362 if ($modulequalified)
364 print
'<tr class="oddeven"><td width="100">';
365 print (empty($module->name) ? $name : $module->name);
367 if (method_exists($module,
'info')) print $module->info($langs);
368 else print $module->description;
372 if (in_array($name, $def))
374 print
'<td class="center">'.
"\n";
375 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.$name.
'">';
376 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
380 print
'<td class="center">'.
"\n";
381 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
386 print
'<td class="center">';
387 if ($conf->global->BOM_ADDON_PDF == $name)
389 print
img_picto($langs->trans(
"Default"),
'on');
391 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
396 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
397 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
398 if ($module->type ==
'pdf')
400 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
402 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
404 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
405 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
406 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftBOMs").
': '.
yn($module->option_draft_watermark, 1, 1);
409 print
'<td class="center">';
410 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
414 print
'<td class="center">';
415 if ($module->type ==
'pdf')
417 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
419 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
441 print
'<table class="noborder centpercent">';
442 print
'<tr class="liste_titre">';
443 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
444 print
'<td class="center" width="60">'.$langs->trans(
"Value").
'</td>';
445 print
"<td> </td>\n";
449 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
450 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
451 foreach ($substitutionarray as $key => $val) $htmltext .= $key.
'<br>';
454 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
455 print
'<input type="hidden" name="token" value="'.newToken().
'">';
456 print
'<input type="hidden" name="action" value="set_BOM_FREE_TEXT">';
457 print
'<tr class="oddeven"><td colspan="2">';
458 print $form->textwithpicto($langs->trans(
"FreeLegalTextOnBOMs"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
459 $variablename =
'BOM_FREE_TEXT';
460 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
462 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.$conf->global->$variablename.
'</textarea>';
464 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
465 $doleditor =
new DolEditor($variablename, $conf->global->$variablename,
'', 80,
'dolibarr_notes');
466 print $doleditor->Create();
468 print
'</td><td class="right">';
469 print
'<input type="submit" class="button" value="'.$langs->trans(
"Modify").
'">';
470 print
"</td></tr>\n";
475 print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
476 print
'<input type="hidden" name="token" value="'.newToken().
'">';
477 print
"<input type=\"hidden\" name=\"action\" value=\"set_BOM_DRAFT_WATERMARK\">";
478 print
'<tr class="oddeven"><td>';
479 print $form->textwithpicto($langs->trans(
"WatermarkOnDraftBOMs"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
481 print
'<input class="flat minwidth200" type="text" name="BOM_DRAFT_WATERMARK" value="'.$conf->global->BOM_DRAFT_WATERMARK.
'">';
482 print
'</td><td class="right">';
483 print
'<input type="submit" class="button" value="'.$langs->trans(
"Modify").
'">';
484 print
"</td></tr>\n";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
delDocumentModel($name, $type)
Delete document model used by doc generator.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
bomAdminPrepareHead()
Prepare admin pages header.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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 ...
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print $_SERVER["PHP_SELF"] n
Edit parameters.
Class to manage a WYSIWYG editor.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.