35 require
'../main.inc.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
42 $langs->loadLangs(array(
'admin',
'errors',
'orders',
'other'));
48 $action =
GETPOST(
'action',
'aZ09');
49 $value =
GETPOST(
'value',
'alpha');
50 $modulepart =
GETPOST(
'modulepart',
'aZ09');
52 $label =
GETPOST(
'label',
'alpha');
53 $scandir =
GETPOST(
'scan_dir',
'alpha');
61 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
63 if ($action ==
'updateMask') {
64 $maskconstorder =
GETPOST(
'maskconstorder',
'aZ09');
65 $maskorder =
GETPOST(
'maskorder',
'alpha');
67 if ($maskconstorder && preg_match(
'/_MASK$/', $maskconstorder)) {
68 $res =
dolibarr_set_const($db, $maskconstorder, $maskorder,
'chaine', 0,
'', $conf->entity);
80 } elseif ($action ==
'specimen') {
81 $modele =
GETPOST(
'module',
'alpha');
84 $commande->initAsSpecimen();
87 $file =
''; $classname =
''; $filefound = 0;
88 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
89 foreach ($dirmodels as $reldir) {
90 $file =
dol_buildpath($reldir.
"core/modules/commande/doc/pdf_".$modele.
".modules.php", 0);
91 if (file_exists($file)) {
93 $classname =
"pdf_".$modele;
101 $module =
new $classname($db);
103 if ($module->write_file($commande, $langs) > 0) {
104 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=commande&file=SPECIMEN.pdf");
112 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
114 } elseif ($action ==
'set') {
117 } elseif ($action ==
'del') {
120 if ($conf->global->COMMANDE_ADDON_PDF ==
"$value") {
124 } elseif ($action ==
'setdoc') {
126 if (
dolibarr_set_const($db,
"COMMANDE_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
129 $conf->global->COMMANDE_ADDON_PDF = $value;
137 } elseif ($action ==
'setmod') {
142 } elseif ($action ==
'set_COMMANDE_DRAFT_WATERMARK') {
143 $draft =
GETPOST(
"COMMANDE_DRAFT_WATERMARK");
144 $res =
dolibarr_set_const($db,
"COMMANDE_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
155 } elseif ($action ==
'set_ORDER_FREE_TEXT') {
156 $freetext =
GETPOST(
"ORDER_FREE_TEXT",
'restricthtml');
158 $res =
dolibarr_set_const($db,
"ORDER_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
169 } elseif ($action ==
'setribchq') {
170 $rib =
GETPOST(
'rib',
'alpha');
171 $chq =
GETPOST(
'chq',
'alpha');
173 $res =
dolibarr_set_const($db,
"FACTURE_RIB_NUMBER", $rib,
'chaine', 0,
'', $conf->entity);
174 $res =
dolibarr_set_const($db,
"FACTURE_CHQ_NUMBER", $chq,
'chaine', 0,
'', $conf->entity);
185 } elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
198 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
201 } elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
213 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
253 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
255 llxHeader(
"", $langs->trans(
"OrdersSetup"));
257 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
258 print
load_fiche_titre($langs->trans(
"OrdersSetup"), $linkback,
'title_setup');
270 print
'<div class="div-table-responsive-no-min">';
271 print
'<table class="noborder centpercent">';
272 print
'<tr class="liste_titre">';
273 print
'<td>'.$langs->trans(
"Name").
'</td>';
274 print
'<td>'.$langs->trans(
"Description").
'</td>';
275 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
276 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
277 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
282 foreach ($dirmodels as $reldir) {
286 $handle = opendir($dir);
287 if (is_resource($handle)) {
288 while (($file = readdir($handle)) !==
false) {
289 if (substr($file, 0, 13) ==
'mod_commande_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
290 $file = substr($file, 0,
dol_strlen($file) - 4);
292 require_once $dir.$file.
'.php';
294 $module =
new $file($db);
297 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
300 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
304 if ($module->isEnabled()) {
305 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
306 print $module->info();
310 print
'<td class="nowrap">';
311 $tmp = $module->getExample();
312 if (preg_match(
'/^Error/', $tmp)) {
313 $langs->load(
"errors");
314 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
315 } elseif ($tmp ==
'NotConfigured') {
316 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
322 print
'<td class="center">';
323 if ($conf->global->COMMANDE_ADDON == $file) {
324 print
img_picto($langs->trans(
"Activated"),
'switch_on');
326 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
327 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
333 $commande->initAsSpecimen();
337 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
340 $nextval = $module->getNextValue($mysoc, $commande);
341 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
342 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
344 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
345 $nextval = $langs->trans($nextval);
347 $htmltooltip .= $nextval.
'<br>';
349 $htmltooltip .= $langs->trans($module->error).
'<br>';
353 print
'<td class="center">';
354 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
365 print
"</table></div><br>\n";
377 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
378 $sql .=
" WHERE type = '".$db->escape($type).
"'";
379 $sql .=
" AND entity = ".$conf->entity;
380 $resql = $db->query($sql);
383 $num_rows = $db->num_rows(
$resql);
384 while ($i < $num_rows) {
385 $array = $db->fetch_array(
$resql);
386 array_push($def, $array[0]);
394 print
'<div class="div-table-responsive-no-min">';
395 print
'<table class="noborder centpercent">'.
"\n";
396 print
'<tr class="liste_titre">'.
"\n";
397 print
'<td>'.$langs->trans(
"Name").
'</td>';
398 print
'<td>'.$langs->trans(
"Description").
'</td>';
399 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
400 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
401 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
402 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
407 foreach ($dirmodels as $reldir) {
408 foreach (array(
'',
'/doc') as $valdir) {
409 $realpath = $reldir.
"core/modules/commande".$valdir;
413 $handle = opendir($dir);
414 if (is_resource($handle)) {
415 while (($file = readdir($handle)) !==
false) {
421 foreach ($filelist as $file) {
422 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
423 if (file_exists($dir.
'/'.$file)) {
424 $name = substr($file, 4,
dol_strlen($file) - 16);
425 $classname = substr($file, 0,
dol_strlen($file) - 12);
427 require_once $dir.
'/'.$file;
428 $module =
new $classname($db);
430 $modulequalified = 1;
431 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
432 $modulequalified = 0;
434 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
435 $modulequalified = 0;
438 if ($modulequalified) {
439 print
'<tr class="oddeven"><td width="100">';
440 print (empty($module->name) ? $name : $module->name);
442 if (method_exists($module,
'info')) {
443 print $module->info($langs);
445 print $module->description;
450 if (in_array($name, $def)) {
451 print
'<td class="center">'.
"\n";
452 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
453 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
457 print
'<td class="center">'.
"\n";
458 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>';
463 print
'<td class="center">';
464 if ($conf->global->COMMANDE_ADDON_PDF == $name) {
465 print
img_picto($langs->trans(
"Default"),
'on');
467 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>';
472 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
473 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
474 if ($module->type ==
'pdf') {
475 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
477 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
479 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
480 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
481 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
482 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
483 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
486 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
489 print
'<td class="center">';
490 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
494 print
'<td class="center">';
495 if ($module->type ==
'pdf') {
496 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
498 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
521 print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInOrder"),
'',
'');
523 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
524 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
526 print
'<div class="div-table-responsive-no-min">';
527 print
'<table class="noborder centpercent">';
529 print
'<tr class="liste_titre">';
531 print
'<input type="hidden" name="action" value="setribchq">';
532 print $langs->trans(
"PaymentMode").
'</td>';
533 print
'<td align="right">';
534 if (empty($conf->facture->enabled)) {
535 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
540 print
'<tr class="oddeven">';
541 print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
543 if (empty($conf->facture->enabled)) {
545 $sql =
"SELECT rowid, label";
546 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
547 $sql .=
" WHERE clos = 0";
548 $sql .=
" AND courant = 1";
549 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
550 $resql = $db->query($sql);
552 $num = $db->num_rows(
$resql);
555 print
'<select name="rib" class="flat" id="rib">';
556 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
558 $row = $db->fetch_row(
$resql);
560 print
'<option value="'.$row[0].
'"';
561 print $conf->global->FACTURE_RIB_NUMBER == $row[0] ?
' selected' :
'';
562 print
'>'.$row[1].
'</option>';
568 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
572 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
575 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
579 print
'<tr class="oddeven">';
580 print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
582 if (empty($conf->facture->enabled)) {
583 print
'<select class="flat" name="chq" id="chq">';
584 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
585 print
'<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.($mysoc->name ? $mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
587 $sql =
"SELECT rowid, label";
588 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
589 $sql .=
" WHERE clos = 0";
590 $sql .=
" AND courant = 1";
591 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
593 $resql = $db->query($sql);
595 $num = $db->num_rows(
$resql);
598 $row = $db->fetch_row(
$resql);
600 print
'<option value="'.$row[0].
'"';
601 print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ?
' selected' :
'';
602 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
609 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
626 print
'<div class="div-table-responsive-no-min">';
627 print
'<table class="noborder centpercent">';
628 print
'<tr class="liste_titre">';
629 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
630 print
'<td class="center" width="60">'.$langs->trans(
"Value").
'</td>';
631 print
"<td> </td>\n";
635 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
636 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
637 foreach ($substitutionarray as $key => $val) {
638 $htmltext .= $key.
'<br>';
642 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
643 print
'<input type="hidden" name="token" value="'.newToken().
'">';
644 print
'<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
645 print
'<tr class="oddeven"><td colspan="2">';
646 print
$form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
647 $variablename =
'ORDER_FREE_TEXT';
648 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
649 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
651 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
653 print $doleditor->Create();
655 print
'</td><td class="right">';
656 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
657 print
"</td></tr>\n";
662 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
663 print
'<input type="hidden" name="token" value="'.newToken().
'">';
664 print
'<input type="hidden" name="action" value="set_COMMANDE_DRAFT_WATERMARK">';
665 print
'<tr class="oddeven"><td>';
666 print
$form->textwithpicto($langs->trans(
"WatermarkOnDraftOrders"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
668 print
'<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'COMMANDE_DRAFT_WATERMARK')).
'">';
669 print
'</td><td class="right">';
670 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
671 print
"</td></tr>\n";
674 print
'<tr class="oddeven">';
675 print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
676 print
'<td class="center" colspan="2">';
677 print
ajax_constantonoff(
'ORDER_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
737 print
'<div class="div-table-responsive-no-min">';
738 print
'<table class="noborder centpercent">';
739 print
'<tr class="liste_titre">';
740 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
741 print
'<td class="center" width="60"></td>';
742 print
'<td width="80"> </td>';
745 print
'<tr class="oddeven"><td colspan="2">';
746 print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
747 print
'</td><td class="right">';
748 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='')
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('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) 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 informations.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
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.