FIXx format (html/text) of emails sent on leave request module

This commit is contained in:
Laurent Destailleur 2018-10-25 13:19:56 +02:00
parent 25a374bd9a
commit 9ccdd10a81
3 changed files with 135 additions and 126 deletions

View File

@ -117,7 +117,7 @@ class CMailFile
* @param string $sendcontext 'standard', 'emailing', ... (used to define with sending mode and parameters to use) * @param string $sendcontext 'standard', 'emailing', ... (used to define with sending mode and parameters to use)
* @param string $replyto Reply-to email (will be set to same value than From by default if not provided) * @param string $replyto Reply-to email (will be set to same value than From by default if not provided)
*/ */
function __construct($subject,$to,$from,$msg,$filename_list=array(),$mimetype_list=array(),$mimefilename_list=array(),$addr_cc="",$addr_bcc="",$deliveryreceipt=0,$msgishtml=0,$errors_to='',$css='',$trackid='',$moreinheader='',$sendcontext='standard',$replyto='') function __construct($subject, $to, $from, $msg, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $addr_cc="", $addr_bcc="", $deliveryreceipt=0, $msgishtml=0, $errors_to='', $css='', $trackid='', $moreinheader='', $sendcontext='standard', $replyto='')
{ {
global $conf, $dolibarr_main_data_root; global $conf, $dolibarr_main_data_root;

View File

@ -655,11 +655,12 @@ class Translate
* @param string $param2 chaine de param2 * @param string $param2 chaine de param2
* @param string $param3 chaine de param3 * @param string $param3 chaine de param3
* @param string $param4 chaine de param4 * @param string $param4 chaine de param4
* @param string $param5 chaine de param5
* @return string Translated string (encoded into UTF8) * @return string Translated string (encoded into UTF8)
*/ */
function transnoentities($key, $param1='', $param2='', $param3='', $param4='') function transnoentities($key, $param1='', $param2='', $param3='', $param4='', $param5='')
{ {
return $this->convToOutputCharset($this->transnoentitiesnoconv($key, $param1, $param2, $param3, $param4)); return $this->convToOutputCharset($this->transnoentitiesnoconv($key, $param1, $param2, $param3, $param4, $param5));
} }
@ -675,9 +676,10 @@ class Translate
* @param string $param2 chaine de param2 * @param string $param2 chaine de param2
* @param string $param3 chaine de param3 * @param string $param3 chaine de param3
* @param string $param4 chaine de param4 * @param string $param4 chaine de param4
* @param string $param5 chaine de param5
* @return string Translated string * @return string Translated string
*/ */
function transnoentitiesnoconv($key, $param1='', $param2='', $param3='', $param4='') function transnoentitiesnoconv($key, $param1='', $param2='', $param3='', $param4='', $param5='')
{ {
global $conf; global $conf;
@ -700,7 +702,7 @@ class Translate
if (! preg_match('/^Format/',$key)) if (! preg_match('/^Format/',$key))
{ {
//print $str; //print $str;
$str=sprintf($str,$param1,$param2,$param3,$param4); // Replace %s and %d except for FormatXXX strings. $str=sprintf($str, $param1, $param2, $param3, $param4, $param5); // Replace %s and %d except for FormatXXX strings.
} }
return $str; return $str;

View File

@ -375,7 +375,7 @@ if (empty($reshook))
*/ */
// PREPARE SEND // PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); $mailfile = new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename, '', '', 0, -1);
if ($mailfile) if ($mailfile)
{ {
@ -496,7 +496,7 @@ if (empty($reshook))
// PREPARE SEND // PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); $mailfile = new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename, '', '', 0, -1);
if ($mailfile) if ($mailfile)
{ {
@ -615,7 +615,7 @@ if (empty($reshook))
} }
*/ */
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); $mailfile = new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename, '', '', 0, -1);
if ($mailfile) if ($mailfile)
{ {
@ -735,7 +735,7 @@ if (empty($reshook))
*/ */
// PREPARE SEND // PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); $mailfile = new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename, '', '', 0, -1);
if ($mailfile) if ($mailfile)
{ {
@ -788,7 +788,13 @@ if (empty($reshook))
} }
//var_dump($user->id == $object->fk_user_validator);exit; //var_dump($user->id == $object->fk_user_validator);exit;
if ($action == "confirm_cancel" && GETPOST('confirm', 'alpha')=="yes" && GETPOST('detail_cancel', 'alpha') && $id > 0 && $user->rights->expensereport->creer) if ($action == "confirm_cancel" && GETPOST('confirm', 'alpha')=="yes" && $id > 0 && $user->rights->expensereport->creer)
{
if (! GETPOST('detail_cancel', 'alpha'))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors');
}
else
{ {
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$object->fetch($id); $object->fetch($id);
@ -840,7 +846,7 @@ if (empty($reshook))
// CONTENT // CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
$message = $langs->transnoentities("ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_cancel'], $link); $message = $langs->transnoentities("ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), GETPOST('detail_cancel','alpha'), $link);
// Rebuilt pdf // Rebuilt pdf
/* /*
@ -858,7 +864,7 @@ if (empty($reshook))
*/ */
// PREPARE SEND // PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); $mailfile = new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename, '', '', 0, -1);
if ($mailfile) if ($mailfile)
{ {
@ -910,6 +916,7 @@ if (empty($reshook))
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
}
if ($action == "confirm_brouillonner" && GETPOST('confirm', 'alpha')=="yes" && $id > 0 && $user->rights->expensereport->creer) if ($action == "confirm_brouillonner" && GETPOST('confirm', 'alpha')=="yes" && $id > 0 && $user->rights->expensereport->creer)
{ {
@ -1019,7 +1026,7 @@ if (empty($reshook))
$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
// PREPARE SEND // PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); $mailfile = new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename, '', '', 0, -1);
if ($mailfile) if ($mailfile)
{ {
@ -1614,7 +1621,7 @@ else
if ($action == 'cancel') if ($action == 'cancel')
{ {
$array_input = array('text'=>$langs->trans("ConfirmCancelTrip"), array('type'=>"text",'label'=>$langs->trans("Comment"),'name'=>"detail_cancel",'size'=>"50",'value'=>"")); $array_input = array('text'=>$langs->trans("ConfirmCancelTrip"), array('type'=>"text",'label'=>'<strong>'.$langs->trans("Comment").'</strong>','name'=>"detail_cancel",'size'=>"50",'value'=>""));
$formconfirm=$form->formconfirm($_SEVER["PHP_SELF"]."?id=".$id,$langs->trans("Cancel"),"","confirm_cancel",$array_input,"",1); $formconfirm=$form->formconfirm($_SEVER["PHP_SELF"]."?id=".$id,$langs->trans("Cancel"),"","confirm_cancel",$array_input,"",1);
} }