33 require
'../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
40 $langs->loadLangs(array(
'admin',
'errors',
'orders',
'other'));
44 $action =
GETPOST(
'action',
'aZ09');
45 $value =
GETPOST(
'value',
'alpha');
46 $label =
GETPOST(
'label',
'alpha');
47 $scandir =
GETPOST(
'scan_dir',
'alpha');
55 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
57 if ($action ==
'updateMask')
59 $maskconstorder =
GETPOST(
'maskconstorder',
'alpha');
60 $maskorder =
GETPOST(
'maskorder',
'alpha');
62 if ($maskconstorder) $res =
dolibarr_set_const($db, $maskconstorder, $maskorder,
'chaine', 0,
'', $conf->entity);
64 if (!($res > 0)) $error++;
72 } elseif ($action ==
'specimen')
74 $modele =
GETPOST(
'module',
'alpha');
77 $commande->initAsSpecimen();
80 $file =
''; $classname =
''; $filefound = 0;
81 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
82 foreach ($dirmodels as $reldir)
84 $file =
dol_buildpath($reldir.
"core/modules/commande/doc/pdf_".$modele.
".modules.php", 0);
85 if (file_exists($file))
88 $classname =
"pdf_".$modele;
97 $module =
new $classname($db);
99 if ($module->write_file($commande, $langs) > 0)
101 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=commande&file=SPECIMEN.pdf");
109 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
114 elseif ($action ==
'set') {
116 } elseif ($action ==
'del') {
120 if ($conf->global->COMMANDE_ADDON_PDF ==
"$value")
dolibarr_del_const($db,
'COMMANDE_ADDON_PDF', $conf->entity);
125 elseif ($action ==
'setdoc') {
126 if (
dolibarr_set_const($db,
"COMMANDE_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity))
130 $conf->global->COMMANDE_ADDON_PDF = $value;
139 } elseif ($action ==
'setmod') {
144 } elseif ($action ==
'set_COMMANDE_DRAFT_WATERMARK')
146 $draft =
GETPOST(
"COMMANDE_DRAFT_WATERMARK");
147 $res =
dolibarr_set_const($db,
"COMMANDE_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
149 if (!($res > 0)) $error++;
157 } elseif ($action ==
'set_ORDER_FREE_TEXT')
159 $freetext =
GETPOST(
"ORDER_FREE_TEXT",
'restricthtml');
161 $res =
dolibarr_set_const($db,
"ORDER_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
163 if (!($res > 0)) $error++;
171 } elseif ($action ==
"setshippableiconinlist") {
173 $setshippableiconinlist =
GETPOST(
'value',
'int');
174 $res =
dolibarr_set_const($db,
"SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist,
'yesno', 0,
'', $conf->entity);
175 if (!($res > 0)) $error++;
181 } elseif ($action ==
'setribchq')
183 $rib =
GETPOST(
'rib',
'alpha');
184 $chq =
GETPOST(
'chq',
'alpha');
186 $res =
dolibarr_set_const($db,
"FACTURE_RIB_NUMBER", $rib,
'chaine', 0,
'', $conf->entity);
187 $res =
dolibarr_set_const($db,
"FACTURE_CHQ_NUMBER", $chq,
'chaine', 0,
'', $conf->entity);
189 if (!($res > 0)) $error++;
200 elseif ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER')
202 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value,
'chaine', 0,
'', $conf->entity);
204 if (!($res > 0)) $error++;
215 elseif ($action ==
'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')
217 $res =
dolibarr_set_const($db,
"WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value,
'chaine', 0,
'', $conf->entity);
219 if (!($res > 0)) $error++;
234 $form =
new Form($db);
236 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
238 llxHeader(
"", $langs->trans(
"OrdersSetup"));
240 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
253 print '<div class="div-table-responsive-no-min">';
254 print
'<table class="noborder centpercent">';
255 print
'<tr class="liste_titre">';
256 print
'<td>'.$langs->trans(
"Name").
'</td>';
257 print
'<td>'.$langs->trans(
"Description").
'</td>';
258 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
259 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
260 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
265 foreach ($dirmodels as $reldir)
271 $handle = opendir($dir);
272 if (is_resource($handle))
274 while (($file = readdir($handle)) !==
false)
276 if (substr($file, 0, 13) ==
'mod_commande_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php')
278 $file = substr($file, 0,
dol_strlen($file) - 4);
280 require_once $dir.$file.
'.php';
282 $module =
new $file($db);
285 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
286 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
288 if ($module->isEnabled())
290 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
291 print $module->info();
295 print
'<td class="nowrap">';
296 $tmp = $module->getExample();
297 if (preg_match(
'/^Error/', $tmp)) {
298 $langs->load(
"errors");
299 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
300 } elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
304 print '<td class="center">';
305 if ($conf->global->COMMANDE_ADDON == $file)
307 print
img_picto($langs->trans(
"Activated"),
'switch_on');
309 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
310 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
316 $commande->initAsSpecimen();
320 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
322 $nextval = $module->getNextValue($mysoc, $commande);
323 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
324 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
326 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
327 $nextval = $langs->trans($nextval);
328 $htmltooltip .= $nextval.
'<br>';
330 $htmltooltip .= $langs->trans($module->error).
'<br>';
334 print
'<td class="center">';
335 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
346 print
"</table></div><br>\n";
358 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
359 $sql .=
" WHERE type = '".$db->escape($type).
"'";
360 $sql .=
" AND entity = ".$conf->entity;
361 $resql = $db->query($sql);
365 $num_rows = $db->num_rows(
$resql);
366 while ($i < $num_rows)
368 $array = $db->fetch_array(
$resql);
369 array_push($def, $array[0]);
377 print
'<div class="div-table-responsive-no-min">';
378 print
"<table class=\"noborder\" width=\"100%\">\n";
379 print
"<tr class=\"liste_titre\">\n";
380 print
'<td>'.$langs->trans(
"Name").
'</td>';
381 print
'<td>'.$langs->trans(
"Description").
'</td>';
382 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
383 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
384 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
385 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
390 foreach ($dirmodels as $reldir)
392 foreach (array(
'',
'/doc') as $valdir)
394 $realpath = $reldir.
"core/modules/commande".$valdir;
399 $handle = opendir($dir);
400 if (is_resource($handle))
402 while (($file = readdir($handle)) !==
false)
409 foreach ($filelist as $file)
411 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file))
413 if (file_exists($dir.
'/'.$file))
415 $name = substr($file, 4,
dol_strlen($file) - 16);
416 $classname = substr($file, 0,
dol_strlen($file) - 12);
418 require_once $dir.
'/'.$file;
419 $module =
new $classname($db);
421 $modulequalified = 1;
422 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
423 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
425 if ($modulequalified)
427 print
'<tr class="oddeven"><td width="100">';
428 print (empty($module->name) ? $name : $module->name);
430 if (method_exists($module,
'info')) print $module->info($langs);
431 else print $module->description;
435 if (in_array($name, $def))
437 print
'<td class="center">'.
"\n";
438 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.$name.
'">';
439 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
443 print
'<td class="center">'.
"\n";
444 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
449 print
'<td class="center">';
450 if ($conf->global->COMMANDE_ADDON_PDF == $name)
452 print
img_picto($langs->trans(
"Default"),
'on');
454 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
459 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
460 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
461 if ($module->type ==
'pdf')
463 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
465 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
467 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
468 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
469 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
470 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
471 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
474 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
477 print
'<td class="center">';
478 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
482 print
'<td class="center">';
483 if ($module->type ==
'pdf')
485 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
487 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
510 print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInOrder"),
'',
'');
512 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
513 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
515 print
'<table class="noborder centpercent">';
517 print
'<tr class="liste_titre">';
519 print
'<input type="hidden" name="action" value="setribchq">';
520 print $langs->trans(
"PaymentMode").
'</td>';
521 print
'<td align="right">';
522 if (empty($conf->facture->enabled)) {
523 print
'<input type="submit" class="button" value="'.$langs->trans(
"Modify").
'">';
528 print
'<tr class="oddeven">';
529 print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
531 if (empty($conf->facture->enabled))
533 if (!empty($conf->banque->enabled))
535 $sql =
"SELECT rowid, label";
536 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
537 $sql .=
" WHERE clos = 0";
538 $sql .=
" AND courant = 1";
539 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
540 $resql = $db->query($sql);
543 $num = $db->num_rows(
$resql);
547 print
'<select name="rib" class="flat" id="rib">';
548 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
551 $row = $db->fetch_row(
$resql);
553 print
'<option value="'.$row[0].
'"';
554 print $conf->global->FACTURE_RIB_NUMBER == $row[0] ?
' selected' :
'';
555 print
'>'.$row[1].
'</option>';
561 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
565 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
568 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
572 print
'<tr class="oddeven">';
573 print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
575 if (empty($conf->facture->enabled))
577 print
'<select class="flat" name="chq" id="chq">';
578 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
579 print
'<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.($mysoc->name ? $mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
581 $sql =
"SELECT rowid, label";
582 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
583 $sql .=
" WHERE clos = 0";
584 $sql .=
" AND courant = 1";
585 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
587 $resql = $db->query($sql);
590 $num = $db->num_rows(
$resql);
594 $row = $db->fetch_row(
$resql);
596 print
'<option value="'.$row[0].
'"';
597 print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ?
' selected' :
'';
598 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
605 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
619 print
'<table class="noborder centpercent">';
620 print
'<tr class="liste_titre">';
621 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
622 print
'<td class="center" width="60">'.$langs->trans(
"Value").
'</td>';
623 print
"<td> </td>\n";
627 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
628 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
629 foreach ($substitutionarray as $key => $val) $htmltext .= $key.
'<br>';
632 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
633 print
'<input type="hidden" name="token" value="'.newToken().
'">';
634 print
'<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
635 print
'<tr class="oddeven"><td colspan="2">';
636 print $form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
637 $variablename =
'ORDER_FREE_TEXT';
638 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
640 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.$conf->global->$variablename.
'</textarea>';
642 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
643 $doleditor =
new DolEditor($variablename, $conf->global->$variablename,
'', 80,
'dolibarr_notes');
644 print $doleditor->Create();
646 print
'</td><td class="right">';
647 print
'<input type="submit" class="button" value="'.$langs->trans(
"Modify").
'">';
648 print
"</td></tr>\n";
653 print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
654 print
'<input type="hidden" name="token" value="'.newToken().
'">';
655 print
"<input type=\"hidden\" name=\"action\" value=\"set_COMMANDE_DRAFT_WATERMARK\">";
656 print
'<tr class="oddeven"><td>';
657 print $form->textwithpicto($langs->trans(
"WatermarkOnDraftOrders"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
659 print
'<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.$conf->global->COMMANDE_DRAFT_WATERMARK.
'">';
660 print
'</td><td class="right">';
661 print
'<input type="submit" class="button" value="'.$langs->trans(
"Modify").
'">';
662 print
"</td></tr>\n";
755 print
'<table class="noborder centpercent">';
756 print
'<tr class="liste_titre">';
757 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
758 print
'<td class="center" width="60"></td>';
759 print
'<td width="80"> </td>';
762 print
'<tr class="oddeven"><td colspan="2">';
763 print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
764 print
'</td><td class="right">';
765 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.
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.
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)
Effacement d'une constante dans la base de donnees.
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.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
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 ...
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.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
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'.
print $_SERVER["PHP_SELF"] n
Edit parameters.
Class to manage a WYSIWYG editor.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.