36 require
'../main.inc.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
40 require_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');
62 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
64 if ($action ==
'updateMask') {
65 $maskconstorder =
GETPOST(
'maskconstorder',
'aZ09');
66 $maskorder =
GETPOST(
'maskorder',
'alpha');
68 if ($maskconstorder && preg_match(
'/_MASK$/', $maskconstorder)) {
69 $res =
dolibarr_set_const($db, $maskconstorder, $maskorder,
'chaine', 0,
'', $conf->entity);
81 } elseif ($action ==
'specimen') {
82 $modele =
GETPOST(
'module',
'alpha');
85 $commande->initAsSpecimen();
90 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
91 foreach ($dirmodels as $reldir) {
92 $file =
dol_buildpath($reldir.
"core/modules/commande/doc/pdf_".$modele.
".modules.php", 0);
93 if (file_exists($file)) {
94 $classname =
"pdf_".$modele;
99 if ($classname !==
'') {
102 $module =
new $classname($db);
103 '@phan-var-force ModelePDFCommandes $module';
105 if ($module->write_file($commande, $langs) > 0) {
106 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=commande&file=SPECIMEN.pdf");
114 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
116 } elseif ($action ==
'set') {
119 } elseif ($action ==
'del') {
126 } elseif ($action ==
'setdoc') {
128 if (
dolibarr_set_const($db,
"COMMANDE_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
131 $conf->global->COMMANDE_ADDON_PDF = $value;
139 } elseif ($action ==
'setmod') {
144 } elseif ($action ==
'set_COMMANDE_DRAFT_WATERMARK') {
145 $draft =
GETPOST(
"COMMANDE_DRAFT_WATERMARK");
146 $res =
dolibarr_set_const($db,
"COMMANDE_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
157 } elseif ($action ==
'set_ORDER_FREE_TEXT') {
158 $freetext =
GETPOST(
"ORDER_FREE_TEXT",
'restricthtml');
160 $res =
dolibarr_set_const($db,
"ORDER_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
171 } elseif ($action ==
'setribchq') {
172 $rib =
GETPOST(
'rib',
'alpha');
173 $chq =
GETPOST(
'chq',
'alpha');
175 $res =
dolibarr_set_const($db,
"FACTURE_RIB_NUMBER", $rib,
'chaine', 0,
'', $conf->entity);
176 $res =
dolibarr_set_const($db,
"FACTURE_CHQ_NUMBER", $chq,
'chaine', 0,
'', $conf->entity);
187 } elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
200 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
203 } elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
215 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
255 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
257 llxHeader(
"", $langs->trans(
"OrdersSetup"));
259 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
260 print
load_fiche_titre($langs->trans(
"OrdersSetup"), $linkback,
'title_setup');
272 print
'<div class="div-table-responsive-no-min">';
273 print
'<table class="noborder centpercent">';
274 print
'<tr class="liste_titre">';
275 print
'<td>'.$langs->trans(
"Name").
'</td>';
276 print
'<td>'.$langs->trans(
"Description").
'</td>';
277 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
278 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
279 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
284 foreach ($dirmodels as $reldir) {
288 $handle = opendir($dir);
289 if (is_resource($handle)) {
290 while (($file = readdir($handle)) !==
false) {
291 if (substr($file, 0, 13) ==
'mod_commande_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
292 $file = substr($file, 0,
dol_strlen($file) - 4);
294 require_once $dir.$file.
'.php';
296 $module =
new $file($db);
299 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
302 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
306 if ($module->isEnabled()) {
307 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
308 print $module->info($langs);
312 print
'<td class="nowrap">';
313 $tmp = $module->getExample();
314 if (preg_match(
'/^Error/', $tmp)) {
315 $langs->load(
"errors");
316 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
317 } elseif ($tmp ==
'NotConfigured') {
318 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
324 print
'<td class="center">';
325 if ($conf->global->COMMANDE_ADDON == $file) {
326 print
img_picto($langs->trans(
"Activated"),
'switch_on');
328 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
329 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
335 $commande->initAsSpecimen();
339 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
342 $nextval = $module->getNextValue($mysoc, $commande);
343 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
344 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
346 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
347 $nextval = $langs->trans($nextval);
349 $htmltooltip .= $nextval.
'<br>';
351 $htmltooltip .= $langs->trans($module->error).
'<br>';
355 print
'<td class="center">';
356 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
367 print
"</table></div><br>\n";
379 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
380 $sql .=
" WHERE type = '".$db->escape($type).
"'";
381 $sql .=
" AND entity = ".$conf->entity;
382 $resql = $db->query(
$sql);
385 $num_rows = $db->num_rows($resql);
386 while ($i < $num_rows) {
387 $array = $db->fetch_array($resql);
388 if (is_array($array)) {
389 array_push($def, $array[0]);
398 print
'<div class="div-table-responsive-no-min">';
399 print
'<table class="noborder centpercent">'.
"\n";
400 print
'<tr class="liste_titre">'.
"\n";
401 print
'<td>'.$langs->trans(
"Name").
'</td>';
402 print
'<td>'.$langs->trans(
"Description").
'</td>';
403 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
404 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
405 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
406 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
411 foreach ($dirmodels as $reldir) {
412 foreach (array(
'',
'/doc') as $valdir) {
413 $realpath = $reldir.
"core/modules/commande".$valdir;
417 $handle = opendir($dir);
418 if (is_resource($handle)) {
420 while (($file = readdir($handle)) !==
false) {
426 foreach ($filelist as $file) {
427 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
428 if (file_exists($dir.
'/'.$file)) {
429 $name = substr($file, 4,
dol_strlen($file) - 16);
430 $classname = substr($file, 0,
dol_strlen($file) - 12);
432 require_once $dir.
'/'.$file;
433 $module =
new $classname($db);
435 $modulequalified = 1;
436 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
437 $modulequalified = 0;
439 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
440 $modulequalified = 0;
443 if ($modulequalified) {
444 print
'<tr class="oddeven"><td width="100">';
445 print(empty($module->name) ? $name : $module->name);
447 if (method_exists($module,
'info')) {
448 print $module->info($langs);
450 print $module->description;
455 if (in_array($name, $def)) {
456 print
'<td class="center">'.
"\n";
457 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
458 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
462 print
'<td class="center">'.
"\n";
463 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>';
468 print
'<td class="center">';
470 print
img_picto($langs->trans(
"Default"),
'on');
472 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>';
477 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
478 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
479 if ($module->type ==
'pdf') {
480 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
482 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
484 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
485 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
486 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
487 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
488 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
491 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
494 print
'<td class="center">';
495 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
499 print
'<td class="center">';
500 if ($module->type ==
'pdf') {
501 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
503 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
526 print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInOrder"),
'',
'');
528 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
529 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
531 print
'<div class="div-table-responsive-no-min">';
532 print
'<table class="noborder centpercent">';
534 print
'<tr class="liste_titre">';
536 print
'<input type="hidden" name="action" value="setribchq">';
537 print $langs->trans(
"PaymentMode").
'</td>';
538 print
'<td align="right">';
540 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
545 print
'<tr class="oddeven">';
546 print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
550 $sql =
"SELECT rowid, label";
551 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
552 $sql .=
" WHERE clos = 0";
553 $sql .=
" AND courant = 1";
554 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
555 $resql = $db->query(
$sql);
557 $num = $db->num_rows($resql);
560 print
'<select name="rib" class="flat" id="rib">';
561 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
563 $row = $db->fetch_row($resql);
565 print
'<option value="'.$row[0].
'"';
566 print $conf->global->FACTURE_RIB_NUMBER == $row[0] ?
' selected' :
'';
567 print
'>'.$row[1].
'</option>';
573 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
577 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
580 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
584 print
'<tr class="oddeven">';
585 print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
588 print
'<select class="flat" name="chq" id="chq">';
589 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
590 print
'<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.($mysoc->name ? $mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
592 $sql =
"SELECT rowid, label";
593 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
594 $sql .=
" WHERE clos = 0";
595 $sql .=
" AND courant = 1";
596 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
598 $resql = $db->query(
$sql);
600 $num = $db->num_rows($resql);
603 $row = $db->fetch_row($resql);
605 print
'<option value="'.$row[0].
'"';
606 print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ?
' selected' :
'';
607 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
614 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
631 print
'<div class="div-table-responsive-no-min">';
632 print
'<table class="noborder centpercent">';
633 print
'<tr class="liste_titre">';
634 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
635 print
'<td class="center" width="60">'.$langs->trans(
"Value").
'</td>';
636 print
"<td> </td>\n";
640 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
641 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
642 foreach ($substitutionarray as $key => $val) {
643 $htmltext .= $key.
'<br>';
647 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
648 print
'<input type="hidden" name="token" value="'.newToken().
'">';
649 print
'<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
650 print
'<tr class="oddeven"><td colspan="2">';
651 print
$form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
652 $variablename =
'ORDER_FREE_TEXT';
654 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
656 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
658 print $doleditor->Create();
660 print
'</td><td class="right">';
661 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
662 print
"</td></tr>\n";
667 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
668 print
'<input type="hidden" name="token" value="'.newToken().
'">';
669 print
'<input type="hidden" name="action" value="set_COMMANDE_DRAFT_WATERMARK">';
670 print
'<tr class="oddeven"><td>';
671 print
$form->textwithpicto($langs->trans(
"WatermarkOnDraftOrders"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
673 print
'<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'COMMANDE_DRAFT_WATERMARK')).
'">';
674 print
'</td><td class="right">';
675 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
676 print
"</td></tr>\n";
679 print
'<tr class="oddeven">';
680 print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
681 print
'<td class="center" colspan="2">';
682 print
ajax_constantonoff(
'ORDER_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
742 print
'<div class="div-table-responsive-no-min">';
743 print
'<table class="noborder centpercent">';
744 print
'<tr class="liste_titre">';
745 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
746 print
'<td class="center" width="60"></td>';
747 print
'<td width="80"> </td>';
750 print
'<tr class="oddeven"><td colspan="2">';
751 print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
752 print
'</td><td class="right">';
753 print
"</td></tr>\n";
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.
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='inline-block')
On/off button for constant.
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.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
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).
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.