36require
'../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
43$langs->loadLangs(array(
'admin',
'errors',
'orders',
'other'));
49$action =
GETPOST(
'action',
'aZ09');
50$value =
GETPOST(
'value',
'alpha');
51$modulepart =
GETPOST(
'modulepart',
'aZ09');
53$label =
GETPOST(
'label',
'alpha');
54$scandir =
GETPOST(
'scan_dir',
'alpha');
62include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
64if ($action ==
'updateMask') {
65 $maskconstorder =
GETPOST(
'maskconstorder',
'aZ09');
66 $maskorder =
GETPOST(
'maskorder',
'alpha');
70 if ($maskconstorder && preg_match(
'/_MASK$/', $maskconstorder)) {
71 $res =
dolibarr_set_const($db, $maskconstorder, $maskorder,
'chaine', 0,
'', $conf->entity);
83} elseif ($action ==
'specimen') {
84 $modele =
GETPOST(
'module',
'alpha');
87 $commande->initAsSpecimen();
92 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
93 foreach ($dirmodels as $reldir) {
94 $file =
dol_buildpath($reldir.
"core/modules/commande/doc/pdf_".$modele.
".modules.php", 0);
95 if (file_exists($file)) {
96 $classname =
"pdf_".$modele;
101 if ($classname !==
'') {
104 $module =
new $classname($db);
105 '@phan-var-force ModelePDFCommandes $module';
107 if ($module->write_file($commande, $langs) > 0) {
108 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=commande&file=SPECIMEN.pdf");
116 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
118} elseif ($action ==
'set') {
121} elseif ($action ==
'del') {
128} elseif ($action ==
'setdoc') {
130 if (
dolibarr_set_const($db,
"COMMANDE_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
133 $conf->global->COMMANDE_ADDON_PDF = $value;
141} elseif ($action ==
'setmod') {
146} elseif ($action ==
'set_COMMANDE_DRAFT_WATERMARK') {
147 $draft =
GETPOST(
"COMMANDE_DRAFT_WATERMARK");
148 $res =
dolibarr_set_const($db,
"COMMANDE_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
159} elseif ($action ==
'set_ORDER_FREE_TEXT') {
160 $freetext =
GETPOST(
"ORDER_FREE_TEXT",
'restricthtml');
162 $res =
dolibarr_set_const($db,
"ORDER_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
173} elseif ($action ==
'setribchq') {
174 $rib =
GETPOST(
'rib',
'alpha');
175 $chq =
GETPOST(
'chq',
'alpha');
177 $res =
dolibarr_set_const($db,
"FACTURE_RIB_NUMBER", $rib,
'chaine', 0,
'', $conf->entity);
178 $res =
dolibarr_set_const($db,
"FACTURE_CHQ_NUMBER", $chq,
'chaine', 0,
'', $conf->entity);
189} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
202 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
205} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
217 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
255$form =
new Form($db);
257$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
259llxHeader(
"", $langs->trans(
"OrdersSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-order');
261$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
262print
load_fiche_titre($langs->trans(
"OrdersSetup"), $linkback,
'title_setup');
274print
'<div class="div-table-responsive-no-min">';
275print
'<table class="noborder centpercent">';
276print
'<tr class="liste_titre">';
277print
'<td>'.$langs->trans(
"Name").
'</td>';
278print
'<td>'.$langs->trans(
"Description").
'</td>';
279print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
280print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
281print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
286foreach ($dirmodels as $reldir) {
290 $handle = opendir($dir);
291 if (is_resource($handle)) {
292 while (($file = readdir($handle)) !==
false) {
293 if (substr($file, 0, 13) ==
'mod_commande_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
294 $file = substr($file, 0,
dol_strlen($file) - 4);
296 require_once $dir.$file.
'.php';
298 $module =
new $file($db);
300 '@phan-var-force ModeleNumRefCommandes $module';
303 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
306 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
310 if ($module->isEnabled()) {
311 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
312 print $module->info($langs);
316 print
'<td class="nowrap">';
317 $tmp = $module->getExample();
318 if (preg_match(
'/^Error/', $tmp)) {
319 $langs->load(
"errors");
320 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
321 } elseif ($tmp ==
'NotConfigured') {
322 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
328 print
'<td class="center">';
329 if ($conf->global->COMMANDE_ADDON == $file) {
330 print
img_picto($langs->trans(
"Activated"),
'switch_on');
332 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
333 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
339 $commande->initAsSpecimen();
343 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
346 $nextval = $module->getNextValue($mysoc, $commande);
347 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
348 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
350 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
351 $nextval = $langs->trans($nextval);
353 $htmltooltip .= $nextval.
'<br>';
355 $htmltooltip .= $langs->trans($module->error).
'<br>';
359 print
'<td class="center">';
360 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
371print
"</table></div><br>\n";
383$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
384$sql .=
" WHERE type = '".$db->escape($type).
"'";
385$sql .=
" AND entity = ".$conf->entity;
386$resql = $db->query($sql);
389 $num_rows = $db->num_rows($resql);
390 while ($i < $num_rows) {
391 $array = $db->fetch_array($resql);
392 if (is_array($array)) {
393 array_push($def, $array[0]);
402print
'<div class="div-table-responsive-no-min">';
403print
'<table class="noborder centpercent">'.
"\n";
404print
'<tr class="liste_titre">'.
"\n";
405print
'<td>'.$langs->trans(
"Name").
'</td>';
406print
'<td>'.$langs->trans(
"Description").
'</td>';
407print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
408print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
409print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
410print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
415foreach ($dirmodels as $reldir) {
416 foreach (array(
'',
'/doc') as $valdir) {
417 $realpath = $reldir.
"core/modules/commande".$valdir;
421 $handle = opendir($dir);
422 if (is_resource($handle)) {
424 while (($file = readdir($handle)) !==
false) {
430 foreach ($filelist as $file) {
431 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
432 if (file_exists($dir.
'/'.$file)) {
433 $name = substr($file, 4,
dol_strlen($file) - 16);
434 $classname = substr($file, 0,
dol_strlen($file) - 12);
436 require_once $dir.
'/'.$file;
437 $module =
new $classname($db);
439 '@phan-var-force ModelePDFCommandes $module';
441 $modulequalified = 1;
442 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
443 $modulequalified = 0;
445 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
446 $modulequalified = 0;
449 if ($modulequalified) {
450 print
'<tr class="oddeven"><td width="100">';
451 print(empty($module->name) ? $name : $module->
name);
453 if (method_exists($module,
'info')) {
454 print $module->info($langs);
456 print $module->description;
461 if (in_array($name, $def)) {
462 print
'<td class="center">'.
"\n";
463 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
464 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
468 print
'<td class="center">'.
"\n";
469 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>';
474 print
'<td class="center">';
476 print
img_picto($langs->trans(
"Default"),
'on');
478 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>';
483 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
484 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
485 if ($module->type ==
'pdf') {
486 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
488 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
490 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
491 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
492 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
493 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
494 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
497 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
500 print
'<td class="center">';
501 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
505 print
'<td class="center">';
506 if ($module->type ==
'pdf') {
507 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
509 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
532print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInOrder"),
'',
'');
534print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
535print
'<input type="hidden" name="token" value="'.newToken().
'" />';
537print
'<div class="div-table-responsive-no-min">';
538print
'<table class="noborder centpercent">';
540print
'<tr class="liste_titre">';
542print
'<input type="hidden" name="action" value="setribchq">';
543print $langs->trans(
"PaymentMode").
'</td>';
544print
'<td align="right">';
545if (!isModEnabled(
'invoice')) {
546 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
551print
'<tr class="oddeven">';
552print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
554if (!isModEnabled(
'invoice')) {
555 if (isModEnabled(
"bank")) {
556 $sql =
"SELECT rowid, label";
557 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
558 $sql .=
" WHERE clos = 0";
559 $sql .=
" AND courant = 1";
560 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
561 $resql = $db->query($sql);
563 $num = $db->num_rows($resql);
566 print
'<select name="rib" class="flat" id="rib">';
567 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
569 $row = $db->fetch_row($resql);
571 print
'<option value="'.$row[0].
'"';
572 print $conf->global->FACTURE_RIB_NUMBER == $row[0] ?
' selected' :
'';
573 print
'>'.$row[1].
'</option>';
579 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
583 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
586 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
590print
'<tr class="oddeven">';
591print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
593if (!isModEnabled(
'invoice')) {
594 print
'<select class="flat" name="chq" id="chq">';
595 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
596 print
'<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.($mysoc->name ? $mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
598 $sql =
"SELECT rowid, label";
599 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
600 $sql .=
" WHERE clos = 0";
601 $sql .=
" AND courant = 1";
602 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
604 $resql = $db->query($sql);
606 $num = $db->num_rows($resql);
609 $row = $db->fetch_row($resql);
611 print
'<option value="'.$row[0].
'"';
612 print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ?
' selected' :
'';
613 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
620 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
637print
'<div class="div-table-responsive-no-min">';
638print
'<table class="noborder centpercent">';
639print
'<tr class="liste_titre">';
640print
'<td>'.$langs->trans(
"Parameter").
'</td>';
641print
'<td class="center" width="60">'.$langs->trans(
"Value").
'</td>';
642print
"<td> </td>\n";
646$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
647$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
648foreach ($substitutionarray as $key => $val) {
649 $htmltext .= $key.
'<br>';
653print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
654print
'<input type="hidden" name="token" value="'.newToken().
'">';
655print
'<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
656print
'<tr class="oddeven"><td colspan="2">';
657print $form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
658$variablename =
'ORDER_FREE_TEXT';
660 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
662 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
664 print $doleditor->Create();
666print
'</td><td class="right">';
667print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
673print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
674print
'<input type="hidden" name="token" value="'.newToken().
'">';
675print
'<input type="hidden" name="action" value="set_COMMANDE_DRAFT_WATERMARK">';
676print
'<tr class="oddeven"><td>';
677print $form->textwithpicto($langs->trans(
"WatermarkOnDraftOrders"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
679print
'<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'COMMANDE_DRAFT_WATERMARK')).
'">';
680print
'</td><td class="right">';
681print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
685print
'<tr class="oddeven">';
686print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
687print
'<td class="center" colspan="2">';
688print ajax_constantonoff(
'ORDER_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
693if (isModEnabled(
'invoice')) {
694 print
'<tr class="oddeven"><td>'.$langs->trans(
"InvoiceClassifyBilledSupplierOrderWithoutInvoice").
' ' ;
695 print $form->textwithpicto(
'', $langs->trans(
"InvoiceClassifyBilledSupplierOrderWithoutInvoiceHelp"), 1,
'help') .
'</td>';
696 print
'<td class="left" colspan="2">';
697 print ajax_constantonoff(
'ORDER_DISABLE_CLASSIFY_BILLED_FROM_ORDER');
757print
'<div class="div-table-responsive-no-min">';
758print
'<table class="noborder centpercent">';
759print
'<tr class="liste_titre">';
760print
'<td>'.$langs->trans(
"Parameter").
'</td>';
761print
'<td class="center" width="60"></td>';
762print
'<td width="80"> </td>';
765print
'<tr class="oddeven"><td colspan="2">';
766print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
767print
'</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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage customers orders.
Class to manage a WYSIWYG editor.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_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)
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
order_admin_prepare_head()
Return array head with list of tabs to view object information.
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.