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);
301 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
304 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
308 if ($module->isEnabled()) {
309 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
310 print $module->info($langs);
314 print
'<td class="nowrap">';
315 $tmp = $module->getExample();
316 if (preg_match(
'/^Error/', $tmp)) {
317 $langs->load(
"errors");
318 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
319 } elseif ($tmp ==
'NotConfigured') {
320 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
326 print
'<td class="center">';
327 if ($conf->global->COMMANDE_ADDON == $file) {
328 print
img_picto($langs->trans(
"Activated"),
'switch_on');
330 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
331 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
337 $commande->initAsSpecimen();
341 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
344 $nextval = $module->getNextValue($mysoc, $commande);
345 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
346 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
348 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
349 $nextval = $langs->trans($nextval);
351 $htmltooltip .= $nextval.
'<br>';
353 $htmltooltip .= $langs->trans($module->error).
'<br>';
357 print
'<td class="center">';
358 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
369print
"</table></div><br>\n";
381$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
382$sql .=
" WHERE type = '".$db->escape($type).
"'";
383$sql .=
" AND entity = ".$conf->entity;
384$resql = $db->query($sql);
387 $num_rows = $db->num_rows($resql);
388 while ($i < $num_rows) {
389 $array = $db->fetch_array($resql);
390 if (is_array($array)) {
391 array_push($def, $array[0]);
400print
'<div class="div-table-responsive-no-min">';
401print
'<table class="noborder centpercent">'.
"\n";
402print
'<tr class="liste_titre">'.
"\n";
403print
'<td>'.$langs->trans(
"Name").
'</td>';
404print
'<td>'.$langs->trans(
"Description").
'</td>';
405print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
406print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
407print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
408print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
413foreach ($dirmodels as $reldir) {
414 foreach (array(
'',
'/doc') as $valdir) {
415 $realpath = $reldir.
"core/modules/commande".$valdir;
419 $handle = opendir($dir);
420 if (is_resource($handle)) {
422 while (($file = readdir($handle)) !==
false) {
428 foreach ($filelist as $file) {
429 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
430 if (file_exists($dir.
'/'.$file)) {
431 $name = substr($file, 4,
dol_strlen($file) - 16);
432 $classname = substr($file, 0,
dol_strlen($file) - 12);
434 require_once $dir.
'/'.$file;
435 $module =
new $classname($db);
437 $modulequalified = 1;
438 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
439 $modulequalified = 0;
441 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
442 $modulequalified = 0;
445 if ($modulequalified) {
446 print
'<tr class="oddeven"><td width="100">';
447 print(empty($module->name) ? $name : $module->
name);
449 if (method_exists($module,
'info')) {
450 print $module->info($langs);
452 print $module->description;
457 if (in_array($name, $def)) {
458 print
'<td class="center">'.
"\n";
459 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
460 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
464 print
'<td class="center">'.
"\n";
465 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>';
470 print
'<td class="center">';
472 print
img_picto($langs->trans(
"Default"),
'on');
474 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>';
479 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
480 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
481 if ($module->type ==
'pdf') {
482 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
484 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
486 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
487 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
488 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
489 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
490 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
493 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
496 print
'<td class="center">';
497 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
501 print
'<td class="center">';
502 if ($module->type ==
'pdf') {
503 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
505 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
528print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInOrder"),
'',
'');
530print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
531print
'<input type="hidden" name="token" value="'.newToken().
'" />';
533print
'<div class="div-table-responsive-no-min">';
534print
'<table class="noborder centpercent">';
536print
'<tr class="liste_titre">';
538print
'<input type="hidden" name="action" value="setribchq">';
539print $langs->trans(
"PaymentMode").
'</td>';
540print
'<td align="right">';
541if (!isModEnabled(
'invoice')) {
542 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
547print
'<tr class="oddeven">';
548print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
550if (!isModEnabled(
'invoice')) {
551 if (isModEnabled(
"bank")) {
552 $sql =
"SELECT rowid, label";
553 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
554 $sql .=
" WHERE clos = 0";
555 $sql .=
" AND courant = 1";
556 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
557 $resql = $db->query($sql);
559 $num = $db->num_rows($resql);
562 print
'<select name="rib" class="flat" id="rib">';
563 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
565 $row = $db->fetch_row($resql);
567 print
'<option value="'.$row[0].
'"';
568 print $conf->global->FACTURE_RIB_NUMBER == $row[0] ?
' selected' :
'';
569 print
'>'.$row[1].
'</option>';
575 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
579 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
582 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
586print
'<tr class="oddeven">';
587print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
589if (!isModEnabled(
'invoice')) {
590 print
'<select class="flat" name="chq" id="chq">';
591 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
592 print
'<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.($mysoc->name ? $mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
594 $sql =
"SELECT rowid, label";
595 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
596 $sql .=
" WHERE clos = 0";
597 $sql .=
" AND courant = 1";
598 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
600 $resql = $db->query($sql);
602 $num = $db->num_rows($resql);
605 $row = $db->fetch_row($resql);
607 print
'<option value="'.$row[0].
'"';
608 print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ?
' selected' :
'';
609 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
616 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
633print
'<div class="div-table-responsive-no-min">';
634print
'<table class="noborder centpercent">';
635print
'<tr class="liste_titre">';
636print
'<td>'.$langs->trans(
"Parameter").
'</td>';
637print
'<td class="center" width="60">'.$langs->trans(
"Value").
'</td>';
638print
"<td> </td>\n";
642$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
643$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
644foreach ($substitutionarray as $key => $val) {
645 $htmltext .= $key.
'<br>';
649print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
650print
'<input type="hidden" name="token" value="'.newToken().
'">';
651print
'<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
652print
'<tr class="oddeven"><td colspan="2">';
653print $form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
654$variablename =
'ORDER_FREE_TEXT';
656 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
658 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
660 print $doleditor->Create();
662print
'</td><td class="right">';
663print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
669print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
670print
'<input type="hidden" name="token" value="'.newToken().
'">';
671print
'<input type="hidden" name="action" value="set_COMMANDE_DRAFT_WATERMARK">';
672print
'<tr class="oddeven"><td>';
673print $form->textwithpicto($langs->trans(
"WatermarkOnDraftOrders"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
675print
'<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'COMMANDE_DRAFT_WATERMARK')).
'">';
676print
'</td><td class="right">';
677print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
681print
'<tr class="oddeven">';
682print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
683print
'<td class="center" colspan="2">';
684print ajax_constantonoff(
'ORDER_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
689if (isModEnabled(
'invoice')) {
690 print
'<tr class="oddeven"><td>'.$langs->trans(
"InvoiceClassifyBilledSupplierOrderWithoutInvoice").
' ' ;
691 print $form->textwithpicto(
'', $langs->trans(
"InvoiceClassifyBilledSupplierOrderWithoutInvoiceHelp"), 1,
'help') .
'</td>';
692 print
'<td class="left" colspan="2">';
693 print ajax_constantonoff(
'ORDER_DISABLE_CLASSIFY_BILLED_FROM_ORDER');
753print
'<div class="div-table-responsive-no-min">';
754print
'<table class="noborder centpercent">';
755print
'<tr class="liste_titre">';
756print
'<td>'.$langs->trans(
"Parameter").
'</td>';
757print
'<td class="center" width="60"></td>';
758print
'<td width="80"> </td>';
761print
'<tr class="oddeven"><td colspan="2">';
762print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
763print
'</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($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 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.