34 require
'../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
41 $langs->loadLangs(array(
'admin',
'errors',
'orders',
'other'));
47 $action =
GETPOST(
'action',
'aZ09');
48 $value =
GETPOST(
'value',
'alpha');
49 $modulepart =
GETPOST(
'modulepart',
'aZ09');
51 $label =
GETPOST(
'label',
'alpha');
52 $scandir =
GETPOST(
'scan_dir',
'alpha');
60 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
62 if ($action ==
'updateMask') {
63 $maskconstorder =
GETPOST(
'maskconstorder',
'alpha');
64 $maskorder =
GETPOST(
'maskorder',
'alpha');
66 if ($maskconstorder) {
67 $res =
dolibarr_set_const($db, $maskconstorder, $maskorder,
'chaine', 0,
'', $conf->entity);
79 } elseif ($action ==
'specimen') {
80 $modele =
GETPOST(
'module',
'alpha');
83 $commande->initAsSpecimen();
86 $file =
''; $classname =
''; $filefound = 0;
87 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
88 foreach ($dirmodels as $reldir) {
89 $file =
dol_buildpath($reldir.
"core/modules/commande/doc/pdf_".$modele.
".modules.php", 0);
90 if (file_exists($file)) {
92 $classname =
"pdf_".$modele;
100 $module =
new $classname($db);
102 if ($module->write_file($commande, $langs) > 0) {
103 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=commande&file=SPECIMEN.pdf");
111 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
113 } elseif ($action ==
'set') {
116 } elseif ($action ==
'del') {
119 if ($conf->global->COMMANDE_ADDON_PDF ==
"$value") {
123 } elseif ($action ==
'setdoc') {
125 if (
dolibarr_set_const($db,
"COMMANDE_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
128 $conf->global->COMMANDE_ADDON_PDF = $value;
136 } elseif ($action ==
'setmod') {
141 } elseif ($action ==
'set_COMMANDE_DRAFT_WATERMARK') {
142 $draft =
GETPOST(
"COMMANDE_DRAFT_WATERMARK");
143 $res =
dolibarr_set_const($db,
"COMMANDE_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
154 } elseif ($action ==
'set_ORDER_FREE_TEXT') {
155 $freetext =
GETPOST(
"ORDER_FREE_TEXT",
'restricthtml');
157 $res =
dolibarr_set_const($db,
"ORDER_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
168 } elseif ($action ==
'setribchq') {
169 $rib =
GETPOST(
'rib',
'alpha');
170 $chq =
GETPOST(
'chq',
'alpha');
172 $res =
dolibarr_set_const($db,
"FACTURE_RIB_NUMBER", $rib,
'chaine', 0,
'', $conf->entity);
173 $res =
dolibarr_set_const($db,
"FACTURE_CHQ_NUMBER", $chq,
'chaine', 0,
'', $conf->entity);
184 } elseif ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER') {
186 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value,
'chaine', 0,
'', $conf->entity);
197 } elseif ($action ==
'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') {
199 $res =
dolibarr_set_const($db,
"WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value,
'chaine', 0,
'', $conf->entity);
219 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
221 llxHeader(
"", $langs->trans(
"OrdersSetup"));
223 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
224 print
load_fiche_titre($langs->trans(
"OrdersSetup"), $linkback,
'title_setup');
236 print
'<div class="div-table-responsive-no-min">';
237 print
'<table class="noborder centpercent">';
238 print
'<tr class="liste_titre">';
239 print
'<td>'.$langs->trans(
"Name").
'</td>';
240 print
'<td>'.$langs->trans(
"Description").
'</td>';
241 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
242 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
243 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
248 foreach ($dirmodels as $reldir) {
252 $handle = opendir($dir);
253 if (is_resource($handle)) {
254 while (($file = readdir($handle)) !==
false) {
255 if (substr($file, 0, 13) ==
'mod_commande_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
256 $file = substr($file, 0,
dol_strlen($file) - 4);
258 require_once $dir.$file.
'.php';
260 $module =
new $file($db);
263 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
266 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
270 if ($module->isEnabled()) {
271 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
272 print $module->info();
276 print
'<td class="nowrap">';
277 $tmp = $module->getExample();
278 if (preg_match(
'/^Error/', $tmp)) {
279 $langs->load(
"errors");
280 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
281 } elseif ($tmp ==
'NotConfigured') {
282 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
288 print
'<td class="center">';
289 if ($conf->global->COMMANDE_ADDON == $file) {
290 print
img_picto($langs->trans(
"Activated"),
'switch_on');
292 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
293 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
299 $commande->initAsSpecimen();
303 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
306 $nextval = $module->getNextValue($mysoc, $commande);
307 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
308 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
310 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
311 $nextval = $langs->trans($nextval);
313 $htmltooltip .= $nextval.
'<br>';
315 $htmltooltip .= $langs->trans($module->error).
'<br>';
319 print
'<td class="center">';
320 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
331 print
"</table></div><br>\n";
343 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
344 $sql .=
" WHERE type = '".$db->escape($type).
"'";
345 $sql .=
" AND entity = ".$conf->entity;
346 $resql = $db->query($sql);
349 $num_rows = $db->num_rows(
$resql);
350 while ($i < $num_rows) {
351 $array = $db->fetch_array(
$resql);
352 array_push($def, $array[0]);
360 print
'<div class="div-table-responsive-no-min">';
361 print
'<table class="noborder centpercent">'.
"\n";
362 print
'<tr class="liste_titre">'.
"\n";
363 print
'<td>'.$langs->trans(
"Name").
'</td>';
364 print
'<td>'.$langs->trans(
"Description").
'</td>';
365 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
366 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
367 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
368 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
373 foreach ($dirmodels as $reldir) {
374 foreach (array(
'',
'/doc') as $valdir) {
375 $realpath = $reldir.
"core/modules/commande".$valdir;
379 $handle = opendir($dir);
380 if (is_resource($handle)) {
381 while (($file = readdir($handle)) !==
false) {
387 foreach ($filelist as $file) {
388 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
389 if (file_exists($dir.
'/'.$file)) {
390 $name = substr($file, 4,
dol_strlen($file) - 16);
391 $classname = substr($file, 0,
dol_strlen($file) - 12);
393 require_once $dir.
'/'.$file;
394 $module =
new $classname($db);
396 $modulequalified = 1;
397 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
398 $modulequalified = 0;
400 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
401 $modulequalified = 0;
404 if ($modulequalified) {
405 print
'<tr class="oddeven"><td width="100">';
406 print (empty($module->name) ? $name : $module->name);
408 if (method_exists($module,
'info')) {
409 print $module->info($langs);
411 print $module->description;
416 if (in_array($name, $def)) {
417 print
'<td class="center">'.
"\n";
418 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
419 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
423 print
'<td class="center">'.
"\n";
424 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>';
429 print
'<td class="center">';
430 if ($conf->global->COMMANDE_ADDON_PDF == $name) {
431 print
img_picto($langs->trans(
"Default"),
'on');
433 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>';
438 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
439 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
440 if ($module->type ==
'pdf') {
441 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
443 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
445 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
446 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
447 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
448 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
449 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
452 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
455 print
'<td class="center">';
456 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
460 print
'<td class="center">';
461 if ($module->type ==
'pdf') {
462 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
464 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
487 print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInOrder"),
'',
'');
489 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
490 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
492 print
'<div class="div-table-responsive-no-min">';
493 print
'<table class="noborder centpercent">';
495 print
'<tr class="liste_titre">';
497 print
'<input type="hidden" name="action" value="setribchq">';
498 print $langs->trans(
"PaymentMode").
'</td>';
499 print
'<td align="right">';
500 if (empty($conf->facture->enabled)) {
501 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
506 print
'<tr class="oddeven">';
507 print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
509 if (empty($conf->facture->enabled)) {
510 if (!empty($conf->banque->enabled)) {
511 $sql =
"SELECT rowid, label";
512 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
513 $sql .=
" WHERE clos = 0";
514 $sql .=
" AND courant = 1";
515 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
516 $resql = $db->query($sql);
518 $num = $db->num_rows(
$resql);
521 print
'<select name="rib" class="flat" id="rib">';
522 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
524 $row = $db->fetch_row(
$resql);
526 print
'<option value="'.$row[0].
'"';
527 print $conf->global->FACTURE_RIB_NUMBER == $row[0] ?
' selected' :
'';
528 print
'>'.$row[1].
'</option>';
534 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
538 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
541 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
545 print
'<tr class="oddeven">';
546 print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
548 if (empty($conf->facture->enabled)) {
549 print
'<select class="flat" name="chq" id="chq">';
550 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
551 print
'<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.($mysoc->name ? $mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
553 $sql =
"SELECT rowid, label";
554 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
555 $sql .=
" WHERE clos = 0";
556 $sql .=
" AND courant = 1";
557 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
559 $resql = $db->query($sql);
561 $num = $db->num_rows(
$resql);
564 $row = $db->fetch_row(
$resql);
566 print
'<option value="'.$row[0].
'"';
567 print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ?
' selected' :
'';
568 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
575 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
592 print
'<div class="div-table-responsive-no-min">';
593 print
'<table class="noborder centpercent">';
594 print
'<tr class="liste_titre">';
595 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
596 print
'<td class="center" width="60">'.$langs->trans(
"Value").
'</td>';
597 print
"<td> </td>\n";
601 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
602 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
603 foreach ($substitutionarray as $key => $val) {
604 $htmltext .= $key.
'<br>';
608 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
609 print
'<input type="hidden" name="token" value="'.newToken().
'">';
610 print
'<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
611 print
'<tr class="oddeven"><td colspan="2">';
612 print
$form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
613 $variablename =
'ORDER_FREE_TEXT';
614 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
615 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
617 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
619 print $doleditor->Create();
621 print
'</td><td class="right">';
622 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
623 print
"</td></tr>\n";
628 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
629 print
'<input type="hidden" name="token" value="'.newToken().
'">';
630 print
'<input type="hidden" name="action" value="set_COMMANDE_DRAFT_WATERMARK">';
631 print
'<tr class="oddeven"><td>';
632 print
$form->textwithpicto($langs->trans(
"WatermarkOnDraftOrders"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
634 print
'<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'COMMANDE_DRAFT_WATERMARK')).
'">';
635 print
'</td><td class="right">';
636 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
637 print
"</td></tr>\n";
695 print
'<div class="div-table-responsive-no-min">';
696 print
'<table class="noborder centpercent">';
697 print
'<tr class="liste_titre">';
698 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
699 print
'<td class="center" width="60"></td>';
700 print
'<td width="80"> </td>';
703 print
'<tr class="oddeven"><td colspan="2">';
704 print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
705 print
'</td><td class="right">';
706 print
"</td></tr>\n";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
delDocumentModel($name, $type)
Delete document model used by doc generator.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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).
addDocumentModel($name, $type, $label= '', $description= '')
Add document model used by doc generator.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
order_admin_prepare_head()
Return array head with list of tabs to view object informations.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Class to manage customers orders.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Class to manage a WYSIWYG editor.