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';
52$langs->loadLangs(array(
'admin',
'errors',
'orders',
'other'));
58$action =
GETPOST(
'action',
'aZ09');
59$value =
GETPOST(
'value',
'alpha');
60$modulepart =
GETPOST(
'modulepart',
'aZ09');
62$label =
GETPOST(
'label',
'alpha');
63$scandir =
GETPOST(
'scan_dir',
'alpha');
73include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
75if ($action ==
'updateMask') {
76 $maskconstorder =
GETPOST(
'maskconstorder',
'aZ09');
77 $maskorder =
GETPOST(
'maskorder',
'alpha');
81 if ($maskconstorder && preg_match(
'/_MASK$/', $maskconstorder)) {
82 $res =
dolibarr_set_const($db, $maskconstorder, $maskorder,
'chaine', 0,
'', $conf->entity);
94} elseif ($action ==
'specimen') {
95 $modele =
GETPOST(
'module',
'alpha');
98 $commande->initAsSpecimen();
103 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
104 foreach ($dirmodels as $reldir) {
105 $file =
dol_buildpath($reldir.
"core/modules/commande/doc/pdf_".$modele.
".modules.php", 0);
106 if (file_exists($file)) {
107 $classname =
"pdf_".$modele;
112 if ($classname !==
'') {
115 $module =
new $classname($db);
116 '@phan-var-force ModelePDFCommandes $module';
119 if ($module->write_file($commande, $langs) > 0) {
120 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=commande&file=SPECIMEN.pdf");
128 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
130} elseif ($action ==
'set') {
133} elseif ($action ==
'del') {
140} elseif ($action ==
'setdoc') {
142 if (
dolibarr_set_const($db,
"COMMANDE_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
145 $conf->global->COMMANDE_ADDON_PDF = $value;
153} elseif ($action ==
'setmod') {
158} elseif ($action ==
'set_COMMANDE_DRAFT_WATERMARK') {
159 $draft =
GETPOST(
"COMMANDE_DRAFT_WATERMARK");
160 $res =
dolibarr_set_const($db,
"COMMANDE_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
171} elseif ($action ==
'set_ORDER_FREE_TEXT') {
172 $freetext =
GETPOST(
"ORDER_FREE_TEXT",
'restricthtml');
174 $res =
dolibarr_set_const($db,
"ORDER_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
185} elseif ($action ==
'setribchq') {
186 $rib =
GETPOST(
'rib',
'alpha');
187 $chq =
GETPOST(
'chq',
'alpha');
189 $res =
dolibarr_set_const($db,
"FACTURE_RIB_NUMBER", $rib,
'chaine', 0,
'', $conf->entity);
190 $res =
dolibarr_set_const($db,
"FACTURE_CHQ_NUMBER", $chq,
'chaine', 0,
'', $conf->entity);
201} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
214 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
217} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
229 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
254$form =
new Form($db);
256$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
258llxHeader(
"", $langs->trans(
"OrdersSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-order');
260$linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'restore_lastsearch_values' => 1]).
'">'.
img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></a>';
262print
load_fiche_titre($langs->trans(
"OrdersSetup"), $linkback,
'title_setup');
273print
'<div class="div-table-responsive-no-min">';
274print
'<table class="noborder centpercent">';
275print
'<tr class="liste_titre">';
276print
'<td>'.$langs->trans(
"Name").
'</td>';
277print
'<td>'.$langs->trans(
"Description").
'</td>';
278print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
279print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
280print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
285$arrayofmodules = array();
288foreach ($dirmodels as $reldir) {
292 $handle = opendir($dir);
293 if (is_resource($handle)) {
294 while (($file = readdir($handle)) !==
false) {
295 if (substr($file, 0, 13) ==
'mod_commande_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
296 $file = substr($file, 0,
dol_strlen($file) - 4);
298 if (!class_exists($file)) {
299 require_once $dir.$file.
'.php';
301 $module =
new $file($db);
303 '@phan-var-force ModeleNumRefCommandes $module';
305 $arrayofmodules[] = $module;
316'@phan-var-force ModeleNumRefCommandes[] $arrayofmodules';
318foreach ($arrayofmodules as $module) {
319 $file = strtolower($module->getName($langs));
320 if (!preg_match(
'/^mod_commande_/', $file)) {
321 $file =
'mod_commande_'.$file;
325 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
328 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
332 if ($module->isEnabled()) {
333 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
334 print $module->info($langs);
338 print
'<td class="nowrap">';
339 $tmp = $module->getExample();
340 if (preg_match(
'/^Error/', $tmp)) {
341 $langs->load(
"errors");
342 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
343 } elseif ($tmp ==
'NotConfigured') {
344 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
350 print
'<td class="center">';
352 print
img_picto($langs->trans(
"Activated"),
'switch_on');
354 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
355 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
361 $commande->initAsSpecimen();
365 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
368 $nextval = $module->getNextValue(
$mysoc, $commande);
369 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
370 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
372 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
373 $nextval = $langs->trans($nextval);
375 $htmltooltip .= $nextval.
'<br>';
377 $htmltooltip .= $langs->trans($module->error).
'<br>';
381 print
'<td class="center">';
382 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
388print
"</table></div><br>\n";
400$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
401$sql .=
" WHERE type = '".$db->escape($type).
"'";
402$sql .=
" AND entity = ".((int) $conf->entity);
403$resql = $db->query($sql);
406 $num_rows = $db->num_rows($resql);
407 while ($i < $num_rows) {
408 $array = $db->fetch_array($resql);
409 if (is_array($array)) {
410 array_push($def, $array[0]);
419print
'<div class="div-table-responsive-no-min">';
420print
'<table class="noborder centpercent">'.
"\n";
421print
'<tr class="liste_titre">'.
"\n";
422print
'<td>'.$langs->trans(
"Name").
'</td>';
423print
'<td>'.$langs->trans(
"Description").
'</td>';
424print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
425print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
426print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
427print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
432foreach ($dirmodels as $reldir) {
433 foreach (array(
'',
'/doc') as $valdir) {
434 $realpath = $reldir.
"core/modules/commande".$valdir;
438 $handle = opendir($dir);
439 if (is_resource($handle)) {
441 while (($file = readdir($handle)) !==
false) {
447 foreach ($filelist as $file) {
448 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
449 if (file_exists($dir.
'/'.$file)) {
450 $name = substr($file, 4,
dol_strlen($file) - 16);
451 $classname = substr($file, 0,
dol_strlen($file) - 12);
453 require_once $dir.
'/'.$file;
454 $module =
new $classname($db);
456 '@phan-var-force ModelePDFCommandes $module';
458 $modulequalified = 1;
459 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
460 $modulequalified = 0;
462 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
463 $modulequalified = 0;
466 if ($modulequalified) {
467 print
'<tr class="oddeven"><td width="100">';
468 print(empty($module->name) ? $name : $module->
name);
470 if (method_exists($module,
'info')) {
471 print $module->info($langs);
473 print $module->description;
478 if (in_array($name, $def)) {
479 print
'<td class="center">'.
"\n";
480 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
481 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
485 print
'<td class="center">'.
"\n";
486 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>';
491 print
'<td class="center">';
493 print
img_picto($langs->trans(
"Default"),
'on');
495 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>';
500 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
501 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
502 if ($module->type ==
'pdf') {
503 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
505 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
507 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
508 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
509 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
510 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
511 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
514 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
517 print
'<td class="center">';
518 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
522 print
'<td class="center">';
523 if ($module->type ==
'pdf') {
524 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
526 print
img_object($langs->transnoentitiesnoconv(
"PreviewNotAvailable"),
'generic');
549print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInOrder"),
'',
'');
551print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
552print
'<input type="hidden" name="token" value="'.newToken().
'" />';
554print
'<div class="div-table-responsive-no-min">';
555print
'<table class="noborder centpercent">';
557print
'<tr class="liste_titre">';
559print
'<input type="hidden" name="action" value="setribchq">';
560print $langs->trans(
"PaymentMode").
'</td>';
561print
'<td align="right">';
563 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
568print
'<tr class="oddeven">';
569print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
573 $sql =
"SELECT rowid, label";
574 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
575 $sql .=
" WHERE clos = 0";
576 $sql .=
" AND courant = 1";
577 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
578 $resql = $db->query($sql);
580 $num = $db->num_rows($resql);
583 print
'<select name="rib" class="flat" id="rib">';
584 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
586 $row = $db->fetch_row($resql);
588 print
'<option value="'.$row[0].
'"';
590 print
'>'.$row[1].
'</option>';
596 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
600 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
603 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
607print
'<tr class="oddeven">';
608print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
611 print
'<select class="flat" name="chq" id="chq">';
612 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
613 print
'<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.(
$mysoc->name ?
$mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
615 $sql =
"SELECT rowid, label";
616 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
617 $sql .=
" WHERE clos = 0";
618 $sql .=
" AND courant = 1";
619 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
621 $resql = $db->query($sql);
623 $num = $db->num_rows($resql);
626 $row = $db->fetch_row($resql);
628 print
'<option value="'.$row[0].
'"';
630 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
637 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
654print
'<div class="div-table-responsive-no-min">';
655print
'<table class="noborder centpercent">';
656print
'<tr class="liste_titre">';
657print
'<td>'.$langs->trans(
"Parameter").
'</td>';
658print
'<td class="center" width="60"></td>';
659print
"<td> </td>\n";
663$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
664$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
665foreach ($substitutionarray as $key => $val) {
666 $htmltext .= $key.
'<br>';
670print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
671print
'<input type="hidden" name="token" value="'.newToken().
'">';
672print
'<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
673print
'<tr class="oddeven"><td colspan="2">';
674print $form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
675$variablename =
'ORDER_FREE_TEXT';
677 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
679 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
681 print $doleditor->Create();
683print
'</td><td class="right">';
684print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
690print
'<form method="post" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
691print
'<input type="hidden" name="token" value="'.newToken().
'">';
692print
'<input type="hidden" name="action" value="set_COMMANDE_DRAFT_WATERMARK">';
693print
'<tr class="oddeven"><td>';
694print $form->textwithpicto($langs->trans(
"WatermarkOnDraftOrders"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
696print
'<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'COMMANDE_DRAFT_WATERMARK')).
'">';
697print
'</td><td class="right">';
698print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
702print
'<tr class="oddeven">';
703print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
704print
'<td class="left" colspan="2">';
705print ajax_constantonoff(
'ORDER_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
711 print
'<tr class="oddeven"><td>'.$langs->trans(
"InvoiceClassifyBilledSupplierOrderWithoutInvoice").
' ' ;
712 print $form->textwithpicto(
'', $langs->trans(
"InvoiceClassifyBilledSupplierOrderWithoutInvoiceHelp"), 1,
'help') .
'</td>';
713 print
'<td class="left" colspan="2">';
714 print ajax_constantonoff(
'ORDER_DISABLE_CLASSIFY_BILLED_FROM_ORDER');
719print
'<tr class="oddeven">';
720print
'<td>'.img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"Notifications").
'</td>';
721print
'<td colspan="2">';
722print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification");
726print
'<tr class="oddeven">';
727print
'<td>'.img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"MoreOptionsRelatedToPDF").
'</td>';
728print
'<td colspan="2">';
729print
img_picto(
'',
'url',
'class="pictofixedwidth"').
'<a href="'.DOL_URL_ROOT.
'/admin/pdf_other.php">'.$langs->trans(
"SeeInPDFSetupPage").
'</a>';
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.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
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, $allowothertags=array())
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, $morecssdiv='')
Show tabs of a record.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.