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');
72include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
74if ($action ==
'updateMask') {
75 $maskconstorder =
GETPOST(
'maskconstorder',
'aZ09');
76 $maskorder =
GETPOST(
'maskorder',
'alpha');
80 if ($maskconstorder && preg_match(
'/_MASK$/', $maskconstorder)) {
93} elseif ($action ==
'specimen') {
94 $modele =
GETPOST(
'module',
'alpha');
97 $commande->initAsSpecimen();
102 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
103 foreach ($dirmodels as $reldir) {
104 $file =
dol_buildpath($reldir.
"core/modules/commande/doc/pdf_".$modele.
".modules.php", 0);
105 if (file_exists($file)) {
106 $classname =
"pdf_".$modele;
111 if ($classname !==
'') {
114 $module =
new $classname($db);
115 '@phan-var-force ModelePDFCommandes $module';
118 if ($module->write_file($commande, $langs) > 0) {
119 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=commande&file=SPECIMEN.pdf");
127 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
129} elseif ($action ==
'set') {
132} elseif ($action ==
'del') {
139} elseif ($action ==
'setdoc') {
144 $conf->global->COMMANDE_ADDON_PDF = $value;
152} elseif ($action ==
'setmod') {
157} elseif ($action ==
'set_COMMANDE_DRAFT_WATERMARK') {
158 $draft =
GETPOST(
"COMMANDE_DRAFT_WATERMARK");
170} elseif ($action ==
'set_ORDER_FREE_TEXT') {
171 $freetext =
GETPOST(
"ORDER_FREE_TEXT",
'restricthtml');
184} elseif ($action ==
'setribchq') {
185 $rib =
GETPOST(
'rib',
'alpha');
186 $chq =
GETPOST(
'chq',
'alpha');
200} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
213 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
216} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
228 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
266$form =
new Form($db);
268$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
270llxHeader(
"", $langs->trans(
"OrdersSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-order');
272$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
273print
load_fiche_titre($langs->trans(
"OrdersSetup"), $linkback,
'title_setup');
285print
'<div class="div-table-responsive-no-min">';
286print
'<table class="noborder centpercent">';
287print
'<tr class="liste_titre">';
288print
'<td>'.$langs->trans(
"Name").
'</td>';
289print
'<td>'.$langs->trans(
"Description").
'</td>';
290print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
291print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
292print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
297foreach ($dirmodels as $reldir) {
301 $handle = opendir($dir);
302 if (is_resource($handle)) {
303 while (($file = readdir($handle)) !==
false) {
304 if (substr($file, 0, 13) ==
'mod_commande_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
305 $file = substr($file, 0,
dol_strlen($file) - 4);
307 require_once $dir.$file.
'.php';
309 $module =
new $file($db);
311 '@phan-var-force ModeleNumRefCommandes $module';
314 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
317 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
321 if ($module->isEnabled()) {
322 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
323 print $module->info($langs);
327 print
'<td class="nowrap">';
328 $tmp = $module->getExample();
329 if (preg_match(
'/^Error/', $tmp)) {
330 $langs->load(
"errors");
331 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
332 } elseif ($tmp ==
'NotConfigured') {
333 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
339 print
'<td class="center">';
340 if (
$conf->global->COMMANDE_ADDON == $file) {
341 print
img_picto($langs->trans(
"Activated"),
'switch_on');
343 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
344 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
350 $commande->initAsSpecimen();
354 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
357 $nextval = $module->getNextValue($mysoc, $commande);
358 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
359 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
361 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
362 $nextval = $langs->trans($nextval);
364 $htmltooltip .= $nextval.
'<br>';
366 $htmltooltip .= $langs->trans($module->error).
'<br>';
370 print
'<td class="center">';
371 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
382print
"</table></div><br>\n";
394$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
395$sql .=
" WHERE type = '".$db->escape($type).
"'";
396$sql .=
" AND entity = ".$conf->entity;
397$resql = $db->query($sql);
400 $num_rows = $db->num_rows($resql);
401 while ($i < $num_rows) {
402 $array = $db->fetch_array($resql);
403 if (is_array($array)) {
404 array_push($def, $array[0]);
413print
'<div class="div-table-responsive-no-min">';
414print
'<table class="noborder centpercent">'.
"\n";
415print
'<tr class="liste_titre">'.
"\n";
416print
'<td>'.$langs->trans(
"Name").
'</td>';
417print
'<td>'.$langs->trans(
"Description").
'</td>';
418print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
419print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
420print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
421print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
426foreach ($dirmodels as $reldir) {
427 foreach (array(
'',
'/doc') as $valdir) {
428 $realpath = $reldir.
"core/modules/commande".$valdir;
432 $handle = opendir($dir);
433 if (is_resource($handle)) {
435 while (($file = readdir($handle)) !==
false) {
441 foreach ($filelist as $file) {
442 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
443 if (file_exists($dir.
'/'.$file)) {
444 $name = substr($file, 4,
dol_strlen($file) - 16);
445 $classname = substr($file, 0,
dol_strlen($file) - 12);
447 require_once $dir.
'/'.$file;
448 $module =
new $classname($db);
450 '@phan-var-force ModelePDFCommandes $module';
452 $modulequalified = 1;
453 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
454 $modulequalified = 0;
456 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
457 $modulequalified = 0;
460 if ($modulequalified) {
461 print
'<tr class="oddeven"><td width="100">';
462 print(empty($module->name) ? $name : $module->
name);
464 if (method_exists($module,
'info')) {
465 print $module->info($langs);
467 print $module->description;
472 if (in_array($name, $def)) {
473 print
'<td class="center">'.
"\n";
474 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
475 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
479 print
'<td class="center">'.
"\n";
480 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>';
485 print
'<td class="center">';
487 print
img_picto($langs->trans(
"Default"),
'on');
489 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>';
494 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
495 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
496 if ($module->type ==
'pdf') {
497 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
499 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
501 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
502 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
503 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
504 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
505 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
508 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
511 print
'<td class="center">';
512 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
516 print
'<td class="center">';
517 if ($module->type ==
'pdf') {
518 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
520 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
543print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInOrder"),
'',
'');
545print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
546print
'<input type="hidden" name="token" value="'.newToken().
'" />';
548print
'<div class="div-table-responsive-no-min">';
549print
'<table class="noborder centpercent">';
551print
'<tr class="liste_titre">';
553print
'<input type="hidden" name="action" value="setribchq">';
554print $langs->trans(
"PaymentMode").
'</td>';
555print
'<td align="right">';
556if (!isModEnabled(
'invoice')) {
557 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
562print
'<tr class="oddeven">';
563print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
565if (!isModEnabled(
'invoice')) {
566 if (isModEnabled(
"bank")) {
567 $sql =
"SELECT rowid, label";
568 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
569 $sql .=
" WHERE clos = 0";
570 $sql .=
" AND courant = 1";
571 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
572 $resql = $db->query($sql);
574 $num = $db->num_rows($resql);
577 print
'<select name="rib" class="flat" id="rib">';
578 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
580 $row = $db->fetch_row($resql);
582 print
'<option value="'.$row[0].
'"';
583 print
$conf->global->FACTURE_RIB_NUMBER == $row[0] ?
' selected' :
'';
584 print
'>'.$row[1].
'</option>';
590 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
594 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
597 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
601print
'<tr class="oddeven">';
602print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
604if (!isModEnabled(
'invoice')) {
605 print
'<select class="flat" name="chq" id="chq">';
606 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
607 print
'<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.($mysoc->name ? $mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
609 $sql =
"SELECT rowid, label";
610 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
611 $sql .=
" WHERE clos = 0";
612 $sql .=
" AND courant = 1";
613 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
615 $resql = $db->query($sql);
617 $num = $db->num_rows($resql);
620 $row = $db->fetch_row($resql);
622 print
'<option value="'.$row[0].
'"';
623 print
$conf->global->FACTURE_CHQ_NUMBER == $row[0] ?
' selected' :
'';
624 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
631 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
648print
'<div class="div-table-responsive-no-min">';
649print
'<table class="noborder centpercent">';
650print
'<tr class="liste_titre">';
651print
'<td>'.$langs->trans(
"Parameter").
'</td>';
652print
'<td class="center" width="60">'.$langs->trans(
"Value").
'</td>';
653print
"<td> </td>\n";
657$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
658$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
659foreach ($substitutionarray as $key => $val) {
660 $htmltext .= $key.
'<br>';
664print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
665print
'<input type="hidden" name="token" value="'.newToken().
'">';
666print
'<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
667print
'<tr class="oddeven"><td colspan="2">';
668print $form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
669$variablename =
'ORDER_FREE_TEXT';
671 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
673 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
675 print $doleditor->Create();
677print
'</td><td class="right">';
678print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
684print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
685print
'<input type="hidden" name="token" value="'.newToken().
'">';
686print
'<input type="hidden" name="action" value="set_COMMANDE_DRAFT_WATERMARK">';
687print
'<tr class="oddeven"><td>';
688print $form->textwithpicto($langs->trans(
"WatermarkOnDraftOrders"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
690print
'<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'COMMANDE_DRAFT_WATERMARK')).
'">';
691print
'</td><td class="right">';
692print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
696print
'<tr class="oddeven">';
697print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
698print
'<td class="left" colspan="2">';
699print ajax_constantonoff(
'ORDER_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
704if (isModEnabled(
'invoice')) {
705 print
'<tr class="oddeven"><td>'.$langs->trans(
"InvoiceClassifyBilledSupplierOrderWithoutInvoice").
' ' ;
706 print $form->textwithpicto(
'', $langs->trans(
"InvoiceClassifyBilledSupplierOrderWithoutInvoiceHelp"), 1,
'help') .
'</td>';
707 print
'<td class="left" colspan="2">';
708 print ajax_constantonoff(
'ORDER_DISABLE_CLASSIFY_BILLED_FROM_ORDER');
768print
'<div class="div-table-responsive-no-min">';
769print
'<table class="noborder centpercent">';
770print
'<tr class="liste_titre">';
771print
'<td>'.$langs->trans(
"Parameter").
'</td>';
772print
'<td class="center" width="60"></td>';
773print
'<td width="80"> </td>';
776print
'<tr class="oddeven"><td colspan="2">';
777print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
778print
'</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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.