diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php
index f5ac849db67..037969cd22f 100644
--- a/htdocs/admin/limits.php
+++ b/htdocs/admin/limits.php
@@ -37,11 +37,12 @@ if (!$user->admin)
if (isset($_POST["action"]) && $_POST["action"] == 'update')
{
- if ($_POST["MAIN_MAX_DECIMALS_UNIT"] > 8
- || $_POST["MAIN_MAX_DECIMALS_TTC"] > 8
- || $_POST["MAIN_MAX_DECIMALS_SHOWN"] > 8)
+ $MAXDEC=8;
+ if ($_POST["MAIN_MAX_DECIMALS_UNIT"] > $MAXDEC
+ || $_POST["MAIN_MAX_DECIMALS_TTC"] > $MAXDEC
+ || $_POST["MAIN_MAX_DECIMALS_SHOWN"] > $MAXDEC)
{
- $mesg='
'.$langs->trans("ErrorDecimalLargerThanAreForbidden").'
';
+ $mesg=''.$langs->trans("ErrorDecimalLargerThanAreForbidden",$MAXDEC).'
';
}
else
{
diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index f8311e430a8..57248c4411a 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -30,10 +30,22 @@ require("./pre.inc.php");
$langs->load("companies");
$langs->load("products");
$langs->load("admin");
+$langs->load("mails");
if (!$user->admin)
accessforbidden();
+$substitutionarrayfortest=array(
+'__ID__' => 'TESTIdRecord',
+'__EMAIL__' => 'TESTEMail',
+'__LASTNAME__' => 'TESTLastname',
+'__FIRSTNAME__' => 'TESTFirstname'
+);
+
+
+/*
+* Actions
+*/
if (isset($_POST["action"]) && $_POST["action"] == 'update')
{
@@ -48,6 +60,58 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update')
exit;
}
+// Action envoi test mailing
+if ($_POST["action"] == 'send' && ! $_POST["cancel"])
+{
+
+ $sendto = $_POST["sendto"];
+ $email_from= $conf->global->MAIN_MAIL_EMAIL_FROM;
+ $subject="Dolibarr test";
+ $body="This is a test";
+
+ if (! $sendto)
+ {
+ $message=''.$langs->trans("ErrorFieldRequired",$langs->trans("MailTo")).'
';
+ }
+ if ($sendto)
+ {
+ require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php");
+
+ $arr_file = array();
+ $arr_mime = array();
+ $arr_name = array();
+
+ // Le message est-il en html
+ $msgishtml=0; // Non par defaut
+ if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_MAILING) $msgishtml=1;
+ if (eregi('[ \t]*',$message)) $msgishtml=1;
+
+ // Pratique les substitutions sur le sujet et message
+ $subject=make_substitutions($subject,$substitutionarrayfortest);
+ $body=make_substitutions($body,$substitutionarrayfortest);
+
+ $mailfile = new CMailFile($subject,$sendto,$email_from,$body,
+ $arr_file,$arr_mime,$arr_name,
+ '', '', 0, $msgishtml);
+
+ $result=$mailfile->sendfile();
+ if ($result)
+ {
+ $message=''.$langs->trans("MailSuccessfulySent",$email_from,$sendto).'
';
+ }
+ else
+ {
+ $message=''.$langs->trans("ResultKo").'
'.$mailfile->error.' '.$result.'
';
+ }
+
+ $_GET["action"]='';
+ }
+}
+
+
+/*
+* Affichage page
+*/
llxHeader();
@@ -56,6 +120,8 @@ print_fiche_titre($langs->trans("EMailsSetup"),'','setup');
print $langs->trans("EMailsDesc")."
\n";
print "
\n";
+if ($message) print $message.'
';
+
if (isset($_GET["action"]) && $_GET["action"] == 'edit')
{
@@ -112,11 +178,50 @@ else
$var=!$var;
print '| '.$langs->trans("MAIN_DISABLE_ALL_MAILS").' | '.yn($conf->global->MAIN_DISABLE_ALL_MAILS).' |
';
- print '
';
+ print '';
+
+ // Boutons actions
print '';
+
+
+ // Affichage formulaire de TEST
+ if ($_GET["action"] == 'test')
+ {
+ print '
';
+ print_titre($langs->trans("TestMailing"));
+
+ // Créé l'objet formulaire mail
+ include_once("../html.formmail.class.php");
+ $formmail = new FormMail($db);
+ $formmail->fromname = $conf->global->MAIN_MAIL_EMAIL_FROM;
+ $formmail->frommail = $conf->global->MAIN_MAIL_EMAIL_FROM;
+ $formmail->withsubstit=0;
+ $formmail->withfrom=1;
+ $formmail->withto=$user->email?$user->email:1;
+ $formmail->withcc=0;
+ $formmail->withtopic=0;
+ $formmail->withtopicreadonly=1;
+ $formmail->withfile=0;
+ $formmail->withbody=0;
+ $formmail->withbodyreadonly=1;
+ $formmail->withcancel=1;
+ // Tableau des substitutions
+ $formmail->substit=$substitutionarrayfortest;
+ // Tableau des paramètres complémentaires du post
+ $formmail->param["action"]="send";
+ $formmail->param["models"]="body";
+ $formmail->param["mailid"]=$mil->id;
+ $formmail->param["returnurl"]=DOL_URL_ROOT."/admin/mails.php";
+
+ $formmail->show_form();
+
+ print '
';
+ }
+
}