35require
'../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
42$langs->loadLangs(array(
'admin',
'errors',
'orders',
'other'));
48$action =
GETPOST(
'action',
'aZ09');
49$value =
GETPOST(
'value',
'alpha');
50$modulepart =
GETPOST(
'modulepart',
'aZ09');
52$label =
GETPOST(
'label',
'alpha');
53$scandir =
GETPOST(
'scan_dir',
'alpha');
61include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
63if ($action ==
'updateMask') {
64 $maskconstorder =
GETPOST(
'maskconstorder',
'aZ09');
65 $maskorder =
GETPOST(
'maskorder',
'alpha');
67 if ($maskconstorder && preg_match(
'/_MASK$/', $maskconstorder)) {
68 $res =
dolibarr_set_const($db, $maskconstorder, $maskorder,
'chaine', 0,
'', $conf->entity);
80} elseif ($action ==
'specimen') {
81 $modele =
GETPOST(
'module',
'alpha');
84 $commande->initAsSpecimen();
87 $file =
''; $classname =
''; $filefound = 0;
88 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
89 foreach ($dirmodels as $reldir) {
90 $file =
dol_buildpath($reldir.
"core/modules/commande/doc/pdf_".$modele.
".modules.php", 0);
91 if (file_exists($file)) {
93 $classname =
"pdf_".$modele;
101 $module =
new $classname($db);
103 if ($module->write_file($commande, $langs) > 0) {
104 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=commande&file=SPECIMEN.pdf");
112 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
114} elseif ($action ==
'set') {
117} elseif ($action ==
'del') {
124} elseif ($action ==
'setdoc') {
126 if (
dolibarr_set_const($db,
"COMMANDE_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
129 $conf->global->COMMANDE_ADDON_PDF = $value;
137} elseif ($action ==
'setmod') {
142} elseif ($action ==
'set_COMMANDE_DRAFT_WATERMARK') {
143 $draft =
GETPOST(
"COMMANDE_DRAFT_WATERMARK");
144 $res =
dolibarr_set_const($db,
"COMMANDE_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
155} elseif ($action ==
'set_ORDER_FREE_TEXT') {
156 $freetext =
GETPOST(
"ORDER_FREE_TEXT",
'restricthtml');
158 $res =
dolibarr_set_const($db,
"ORDER_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
169} elseif ($action ==
'setribchq') {
170 $rib =
GETPOST(
'rib',
'alpha');
171 $chq =
GETPOST(
'chq',
'alpha');
173 $res =
dolibarr_set_const($db,
"FACTURE_RIB_NUMBER", $rib,
'chaine', 0,
'', $conf->entity);
174 $res =
dolibarr_set_const($db,
"FACTURE_CHQ_NUMBER", $chq,
'chaine', 0,
'', $conf->entity);
185} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
198 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
201} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
213 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
251$form =
new Form($db);
253$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
255llxHeader(
"", $langs->trans(
"OrdersSetup"));
257$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
258print
load_fiche_titre($langs->trans(
"OrdersSetup"), $linkback,
'title_setup');
270print
'<div class="div-table-responsive-no-min">';
271print
'<table class="noborder centpercent">';
272print
'<tr class="liste_titre">';
273print
'<td>'.$langs->trans(
"Name").
'</td>';
274print
'<td>'.$langs->trans(
"Description").
'</td>';
275print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
276print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
277print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
282foreach ($dirmodels as $reldir) {
286 $handle = opendir($dir);
287 if (is_resource($handle)) {
288 while (($file = readdir($handle)) !==
false) {
289 if (substr($file, 0, 13) ==
'mod_commande_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
290 $file = substr($file, 0,
dol_strlen($file) - 4);
292 require_once $dir.$file.
'.php';
294 $module =
new $file($db);
297 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
300 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
304 if ($module->isEnabled()) {
305 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
306 print $module->info();
310 print
'<td class="nowrap">';
311 $tmp = $module->getExample();
312 if (preg_match(
'/^Error/', $tmp)) {
313 $langs->load(
"errors");
314 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
315 } elseif ($tmp ==
'NotConfigured') {
316 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
322 print
'<td class="center">';
323 if ($conf->global->COMMANDE_ADDON == $file) {
324 print
img_picto($langs->trans(
"Activated"),
'switch_on');
326 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.newToken().
'&value='.urlencode($file).
'">';
327 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
333 $commande->initAsSpecimen();
337 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
340 $nextval = $module->getNextValue($mysoc, $commande);
341 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
342 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
344 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
345 $nextval = $langs->trans($nextval);
347 $htmltooltip .= $nextval.
'<br>';
349 $htmltooltip .= $langs->trans($module->error).
'<br>';
353 print
'<td class="center">';
354 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
365print
"</table></div><br>\n";
377$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
378$sql .=
" WHERE type = '".$db->escape($type).
"'";
379$sql .=
" AND entity = ".$conf->entity;
380$resql = $db->query($sql);
383 $num_rows = $db->num_rows($resql);
384 while ($i < $num_rows) {
385 $array = $db->fetch_array($resql);
386 array_push($def, $array[0]);
394print
'<div class="div-table-responsive-no-min">';
395print
'<table class="noborder centpercent">'.
"\n";
396print
'<tr class="liste_titre">'.
"\n";
397print
'<td>'.$langs->trans(
"Name").
'</td>';
398print
'<td>'.$langs->trans(
"Description").
'</td>';
399print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
400print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
401print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
402print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
407foreach ($dirmodels as $reldir) {
408 foreach (array(
'',
'/doc') as $valdir) {
409 $realpath = $reldir.
"core/modules/commande".$valdir;
413 $handle = opendir($dir);
414 if (is_resource($handle)) {
415 while (($file = readdir($handle)) !==
false) {
421 foreach ($filelist as $file) {
422 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
423 if (file_exists($dir.
'/'.$file)) {
424 $name = substr($file, 4,
dol_strlen($file) - 16);
425 $classname = substr($file, 0,
dol_strlen($file) - 12);
427 require_once $dir.
'/'.$file;
428 $module =
new $classname($db);
430 $modulequalified = 1;
431 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
432 $modulequalified = 0;
434 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
435 $modulequalified = 0;
438 if ($modulequalified) {
439 print
'<tr class="oddeven"><td width="100">';
440 print (empty($module->name) ? $name : $module->
name);
442 if (method_exists($module,
'info')) {
443 print $module->info($langs);
445 print $module->description;
450 if (in_array($name, $def)) {
451 print
'<td class="center">'.
"\n";
452 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'">';
453 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
457 print
'<td class="center">'.
"\n";
458 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>';
463 print
'<td class="center">';
465 print
img_picto($langs->trans(
"Default"),
'on');
467 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>';
472 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
473 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
474 if ($module->type ==
'pdf') {
475 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
477 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
479 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
480 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
481 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
482 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
483 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
486 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
489 print
'<td class="center">';
490 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
494 print
'<td class="center">';
495 if ($module->type ==
'pdf') {
496 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
498 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
521print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInOrder"),
'',
'');
523print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
524print
'<input type="hidden" name="token" value="'.newToken().
'" />';
526print
'<div class="div-table-responsive-no-min">';
527print
'<table class="noborder centpercent">';
529print
'<tr class="liste_titre">';
531print
'<input type="hidden" name="action" value="setribchq">';
532print $langs->trans(
"PaymentMode").
'</td>';
533print
'<td align="right">';
534if (!isModEnabled(
'facture')) {
535 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
540print
'<tr class="oddeven">';
541print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
543if (!isModEnabled(
'facture')) {
544 if (isModEnabled(
"banque")) {
545 $sql =
"SELECT rowid, label";
546 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
547 $sql .=
" WHERE clos = 0";
548 $sql .=
" AND courant = 1";
549 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
550 $resql = $db->query($sql);
552 $num = $db->num_rows($resql);
555 print
'<select name="rib" class="flat" id="rib">';
556 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
558 $row = $db->fetch_row($resql);
560 print
'<option value="'.$row[0].
'"';
561 print $conf->global->FACTURE_RIB_NUMBER == $row[0] ?
' selected' :
'';
562 print
'>'.$row[1].
'</option>';
568 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
572 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
575 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
579print
'<tr class="oddeven">';
580print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
582if (!isModEnabled(
'facture')) {
583 print
'<select class="flat" name="chq" id="chq">';
584 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
585 print
'<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.($mysoc->name ? $mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
587 $sql =
"SELECT rowid, label";
588 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
589 $sql .=
" WHERE clos = 0";
590 $sql .=
" AND courant = 1";
591 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
593 $resql = $db->query($sql);
595 $num = $db->num_rows($resql);
598 $row = $db->fetch_row($resql);
600 print
'<option value="'.$row[0].
'"';
601 print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ?
' selected' :
'';
602 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
609 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
626print
'<div class="div-table-responsive-no-min">';
627print
'<table class="noborder centpercent">';
628print
'<tr class="liste_titre">';
629print
'<td>'.$langs->trans(
"Parameter").
'</td>';
630print
'<td class="center" width="60">'.$langs->trans(
"Value").
'</td>';
631print
"<td> </td>\n";
635$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
636$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
637foreach ($substitutionarray as $key => $val) {
638 $htmltext .= $key.
'<br>';
642print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
643print
'<input type="hidden" name="token" value="'.newToken().
'">';
644print
'<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
645print
'<tr class="oddeven"><td colspan="2">';
646print $form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
647$variablename =
'ORDER_FREE_TEXT';
648if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
649 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
651 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
653 print $doleditor->Create();
655print
'</td><td class="right">';
656print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
662print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
663print
'<input type="hidden" name="token" value="'.newToken().
'">';
664print
'<input type="hidden" name="action" value="set_COMMANDE_DRAFT_WATERMARK">';
665print
'<tr class="oddeven"><td>';
666print $form->textwithpicto($langs->trans(
"WatermarkOnDraftOrders"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
668print
'<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'COMMANDE_DRAFT_WATERMARK')).
'">';
669print
'</td><td class="right">';
670print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
674print
'<tr class="oddeven">';
675print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
676print
'<td class="center" colspan="2">';
677print ajax_constantonoff(
'ORDER_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
737print
'<div class="div-table-responsive-no-min">';
738print
'<table class="noborder centpercent">';
739print
'<tr class="liste_titre">';
740print
'<td>'.$langs->trans(
"Parameter").
'</td>';
741print
'<td class="center" width="60"></td>';
742print
'<td width="80"> </td>';
745print
'<tr class="oddeven"><td colspan="2">';
746print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
747print
'</td><td class="right">';
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()
Empty header.
Class to manage customers orders.
Class to manage a WYSIWYG editor.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
order_admin_prepare_head()
Return array head with list of tabs to view object informations.
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.