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';
108 if ($module->write_file($commande, $langs) > 0) {
109 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=commande&file=SPECIMEN.pdf");
117 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
119} elseif ($action ==
'set') {
122} elseif ($action ==
'del') {
129} elseif ($action ==
'setdoc') {
131 if (
dolibarr_set_const($db,
"COMMANDE_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
134 $conf->global->COMMANDE_ADDON_PDF = $value;
142} elseif ($action ==
'setmod') {
147} elseif ($action ==
'set_COMMANDE_DRAFT_WATERMARK') {
148 $draft =
GETPOST(
"COMMANDE_DRAFT_WATERMARK");
149 $res =
dolibarr_set_const($db,
"COMMANDE_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
160} elseif ($action ==
'set_ORDER_FREE_TEXT') {
161 $freetext =
GETPOST(
"ORDER_FREE_TEXT",
'restricthtml');
163 $res =
dolibarr_set_const($db,
"ORDER_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
174} elseif ($action ==
'setribchq') {
175 $rib =
GETPOST(
'rib',
'alpha');
176 $chq =
GETPOST(
'chq',
'alpha');
178 $res =
dolibarr_set_const($db,
"FACTURE_RIB_NUMBER", $rib,
'chaine', 0,
'', $conf->entity);
179 $res =
dolibarr_set_const($db,
"FACTURE_CHQ_NUMBER", $chq,
'chaine', 0,
'', $conf->entity);
190} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
203 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
206} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
218 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
256$form =
new Form($db);
258$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
260llxHeader(
"", $langs->trans(
"OrdersSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-order');
262$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
263print
load_fiche_titre($langs->trans(
"OrdersSetup"), $linkback,
'title_setup');
275print
'<div class="div-table-responsive-no-min">';
276print
'<table class="noborder centpercent">';
277print
'<tr class="liste_titre">';
278print
'<td>'.$langs->trans(
"Name").
'</td>';
279print
'<td>'.$langs->trans(
"Description").
'</td>';
280print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
281print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
282print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
287foreach ($dirmodels as $reldir) {
291 $handle = opendir($dir);
292 if (is_resource($handle)) {
293 while (($file = readdir($handle)) !==
false) {
294 if (substr($file, 0, 13) ==
'mod_commande_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
295 $file = substr($file, 0,
dol_strlen($file) - 4);
297 require_once $dir.$file.
'.php';
299 $module =
new $file($db);
301 '@phan-var-force ModeleNumRefCommandes $module';
304 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
307 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
311 if ($module->isEnabled()) {
312 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
313 print $module->info($langs);
317 print
'<td class="nowrap">';
318 $tmp = $module->getExample();
319 if (preg_match(
'/^Error/', $tmp)) {
320 $langs->load(
"errors");
321 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
322 } elseif ($tmp ==
'NotConfigured') {
323 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
329 print
'<td class="center">';
330 if ($conf->global->COMMANDE_ADDON == $file) {
331 print
img_picto($langs->trans(
"Activated"),
'switch_on');
333 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
334 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
340 $commande->initAsSpecimen();
344 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
347 $nextval = $module->getNextValue($mysoc, $commande);
348 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
349 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
351 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
352 $nextval = $langs->trans($nextval);
354 $htmltooltip .= $nextval.
'<br>';
356 $htmltooltip .= $langs->trans($module->error).
'<br>';
360 print
'<td class="center">';
361 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
372print
"</table></div><br>\n";
384$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
385$sql .=
" WHERE type = '".$db->escape($type).
"'";
386$sql .=
" AND entity = ".$conf->entity;
387$resql = $db->query($sql);
390 $num_rows = $db->num_rows($resql);
391 while ($i < $num_rows) {
392 $array = $db->fetch_array($resql);
393 if (is_array($array)) {
394 array_push($def, $array[0]);
403print
'<div class="div-table-responsive-no-min">';
404print
'<table class="noborder centpercent">'.
"\n";
405print
'<tr class="liste_titre">'.
"\n";
406print
'<td>'.$langs->trans(
"Name").
'</td>';
407print
'<td>'.$langs->trans(
"Description").
'</td>';
408print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
409print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
410print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
411print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
416foreach ($dirmodels as $reldir) {
417 foreach (array(
'',
'/doc') as $valdir) {
418 $realpath = $reldir.
"core/modules/commande".$valdir;
422 $handle = opendir($dir);
423 if (is_resource($handle)) {
425 while (($file = readdir($handle)) !==
false) {
431 foreach ($filelist as $file) {
432 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
433 if (file_exists($dir.
'/'.$file)) {
434 $name = substr($file, 4,
dol_strlen($file) - 16);
435 $classname = substr($file, 0,
dol_strlen($file) - 12);
437 require_once $dir.
'/'.$file;
438 $module =
new $classname($db);
440 '@phan-var-force ModelePDFCommandes $module';
442 $modulequalified = 1;
443 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
444 $modulequalified = 0;
446 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
447 $modulequalified = 0;
450 if ($modulequalified) {
451 print
'<tr class="oddeven"><td width="100">';
452 print(empty($module->name) ? $name : $module->
name);
454 if (method_exists($module,
'info')) {
455 print $module->info($langs);
457 print $module->description;
462 if (in_array($name, $def)) {
463 print
'<td class="center">'.
"\n";
464 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
465 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
469 print
'<td class="center">'.
"\n";
470 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>';
475 print
'<td class="center">';
477 print
img_picto($langs->trans(
"Default"),
'on');
479 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>';
484 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
485 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
486 if ($module->type ==
'pdf') {
487 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
489 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
491 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
492 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
493 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
494 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
495 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
498 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
501 print
'<td class="center">';
502 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
506 print
'<td class="center">';
507 if ($module->type ==
'pdf') {
508 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
510 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
533print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInOrder"),
'',
'');
535print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
536print
'<input type="hidden" name="token" value="'.newToken().
'" />';
538print
'<div class="div-table-responsive-no-min">';
539print
'<table class="noborder centpercent">';
541print
'<tr class="liste_titre">';
543print
'<input type="hidden" name="action" value="setribchq">';
544print $langs->trans(
"PaymentMode").
'</td>';
545print
'<td align="right">';
546if (!isModEnabled(
'invoice')) {
547 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
552print
'<tr class="oddeven">';
553print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
555if (!isModEnabled(
'invoice')) {
556 if (isModEnabled(
"bank")) {
557 $sql =
"SELECT rowid, label";
558 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
559 $sql .=
" WHERE clos = 0";
560 $sql .=
" AND courant = 1";
561 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
562 $resql = $db->query($sql);
564 $num = $db->num_rows($resql);
567 print
'<select name="rib" class="flat" id="rib">';
568 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
570 $row = $db->fetch_row($resql);
572 print
'<option value="'.$row[0].
'"';
573 print $conf->global->FACTURE_RIB_NUMBER == $row[0] ?
' selected' :
'';
574 print
'>'.$row[1].
'</option>';
580 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
584 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
587 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
591print
'<tr class="oddeven">';
592print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
594if (!isModEnabled(
'invoice')) {
595 print
'<select class="flat" name="chq" id="chq">';
596 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
597 print
'<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.($mysoc->name ? $mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
599 $sql =
"SELECT rowid, label";
600 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
601 $sql .=
" WHERE clos = 0";
602 $sql .=
" AND courant = 1";
603 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
605 $resql = $db->query($sql);
607 $num = $db->num_rows($resql);
610 $row = $db->fetch_row($resql);
612 print
'<option value="'.$row[0].
'"';
613 print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ?
' selected' :
'';
614 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
621 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
638print
'<div class="div-table-responsive-no-min">';
639print
'<table class="noborder centpercent">';
640print
'<tr class="liste_titre">';
641print
'<td>'.$langs->trans(
"Parameter").
'</td>';
642print
'<td class="center" width="60">'.$langs->trans(
"Value").
'</td>';
643print
"<td> </td>\n";
647$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
648$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
649foreach ($substitutionarray as $key => $val) {
650 $htmltext .= $key.
'<br>';
654print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
655print
'<input type="hidden" name="token" value="'.newToken().
'">';
656print
'<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
657print
'<tr class="oddeven"><td colspan="2">';
658print $form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
659$variablename =
'ORDER_FREE_TEXT';
661 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
663 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
665 print $doleditor->Create();
667print
'</td><td class="right">';
668print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
674print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
675print
'<input type="hidden" name="token" value="'.newToken().
'">';
676print
'<input type="hidden" name="action" value="set_COMMANDE_DRAFT_WATERMARK">';
677print
'<tr class="oddeven"><td>';
678print $form->textwithpicto($langs->trans(
"WatermarkOnDraftOrders"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
680print
'<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'COMMANDE_DRAFT_WATERMARK')).
'">';
681print
'</td><td class="right">';
682print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
686print
'<tr class="oddeven">';
687print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
688print
'<td class="center" colspan="2">';
689print ajax_constantonoff(
'ORDER_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
694if (isModEnabled(
'invoice')) {
695 print
'<tr class="oddeven"><td>'.$langs->trans(
"InvoiceClassifyBilledSupplierOrderWithoutInvoice").
' ' ;
696 print $form->textwithpicto(
'', $langs->trans(
"InvoiceClassifyBilledSupplierOrderWithoutInvoiceHelp"), 1,
'help') .
'</td>';
697 print
'<td class="left" colspan="2">';
698 print ajax_constantonoff(
'ORDER_DISABLE_CLASSIFY_BILLED_FROM_ORDER');
758print
'<div class="div-table-responsive-no-min">';
759print
'<table class="noborder centpercent">';
760print
'<tr class="liste_titre">';
761print
'<td>'.$langs->trans(
"Parameter").
'</td>';
762print
'<td class="center" width="60"></td>';
763print
'<td width="80"> </td>';
766print
'<tr class="oddeven"><td colspan="2">';
767print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
768print
'</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)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.