Fix missing signature when sending email from user card

This commit is contained in:
Laurent Destailleur 2017-06-17 10:17:36 +02:00
parent 1d91ce90d3
commit 5b7a8e9c90
4 changed files with 28 additions and 47 deletions

View File

@ -2621,6 +2621,19 @@ if ($action == 'create' && $user->rights->commande->creer)
$outputlangs->load('commercial'); $outputlangs->load('commercial');
} }
// Show email form
// By default if $action=='presend'
$titreform='SendOrderByMail';
$topicmail='';
if (empty($object->ref_client)) {
$topicmail = $outputlangs->trans('SendOrderRef', '__ORDERREF__');
} else if (! empty($object->ref_client)) {
$topicmail = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)');
}
$action='send';
$modelmail='order_send';
// Build document if it not exists // Build document if it not exists
if (! $file || ! is_readable($file)) { if (! $file || ! is_readable($file)) {
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
@ -2635,7 +2648,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>'; print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print '<div class="clearboth"></div>'; print '<div class="clearboth"></div>';
print '<br>'; print '<br>';
print load_fiche_titre($langs->trans('SendOrderByMail')); print load_fiche_titre($langs->trans($titreform));
dol_fiche_head(''); dol_fiche_head('');
@ -2662,11 +2675,7 @@ if ($action == 'create' && $user->rights->commande->creer)
$formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste; $formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste;
$formmail->withtocc = $liste; $formmail->withtocc = $liste;
$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
if (empty($object->ref_client)) { $formmail->withtopic = $topicmail;
$formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__');
} else if (! empty($object->ref_client)) {
$formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)');
}
$formmail->withfile = 2; $formmail->withfile = 2;
$formmail->withbody = 1; $formmail->withbody = 1;
$formmail->withdeliveryreceipt = 1; $formmail->withdeliveryreceipt = 1;
@ -2696,8 +2705,8 @@ if ($action == 'create' && $user->rights->commande->creer)
} }
// Tableau des parametres complementaires // Tableau des parametres complementaires
$formmail->param['action'] = 'send'; $formmail->param['action'] = $action;
$formmail->param['models'] = 'order_send'; $formmail->param['models'] = $modelmail;
$formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['orderid'] = $object->id; $formmail->param['orderid'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;

View File

@ -288,14 +288,15 @@ class FormMail extends Form
$outputlangs->load('other'); $outputlangs->load('other');
} }
// Get message template // Get message template for $this->param["models"] into c_email_templates
$model_id=0; $model_id=0;
if (array_key_exists('models_id',$this->param)) if (array_key_exists('models_id',$this->param))
{ {
$model_id=$this->param["models_id"]; $model_id=$this->param["models_id"];
} }
$arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id);
//var_dump($arraydefaultmessage); //var_dump($this->param["models"]);
//var_dump($arraydefaultmessage);
$out.= "\n".'<!-- Begin form mail --><div id="mailformdiv"></div>'."\n"; $out.= "\n".'<!-- Begin form mail --><div id="mailformdiv"></div>'."\n";
if ($this->withform == 1) if ($this->withform == 1)
@ -876,6 +877,7 @@ class FormMail extends Form
elseif ($type_template=='shipping_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendShipping"); } elseif ($type_template=='shipping_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendShipping"); }
elseif ($type_template=='fichinter_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendFichInter"); } elseif ($type_template=='fichinter_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendFichInter"); }
elseif ($type_template=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); } elseif ($type_template=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); }
elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); }
$ret['label']='default'; $ret['label']='default';
$ret['topic']=''; $ret['topic']='';

View File

@ -81,6 +81,7 @@ PredefinedMailContentSendSupplierInvoice=__CONTACTCIVNAME__\n\nYou will find her
PredefinedMailContentSendShipping=__CONTACTCIVNAME__\n\nYou will find here the shipping __SHIPPINGREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendShipping=__CONTACTCIVNAME__\n\nYou will find here the shipping __SHIPPINGREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
PredefinedMailContentSendFichInter=__CONTACTCIVNAME__\n\nYou will find here the intervention __FICHINTERREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendFichInter=__CONTACTCIVNAME__\n\nYou will find here the intervention __FICHINTERREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
PredefinedMailContentThirdparty=__CONTACTCIVNAME__\n\n__PERSONALIZED__\n\n__SIGNATURE__ PredefinedMailContentThirdparty=__CONTACTCIVNAME__\n\n__PERSONALIZED__\n\n__SIGNATURE__
PredefinedMailContentUser=aa__PERSONALIZED__\n\n__SIGNATURE__
DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available. DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available.
ChooseYourDemoProfil=Choose the demo profile that best suits your needs... ChooseYourDemoProfil=Choose the demo profile that best suits your needs...
ChooseYourDemoProfilMore=...or build your own profile<br>(manual module selection) ChooseYourDemoProfilMore=...or build your own profile<br>(manual module selection)

View File

@ -1659,13 +1659,11 @@ else
} }
if ($action == 'presend') if ($action == 'presend')
{ {
/* // Show email form
* Affiche formulaire mail
*/
// By default if $action=='presend' // By default if $action=='presend'
$titreform='SendMail'; $titreform='SendMail';
$topicmail=''; $topicmail=1;
$action='send'; $action='send';
$modelmail='user'; $modelmail='user';
@ -1680,9 +1678,8 @@ else
$newlang = ''; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
$newlang = $_REQUEST['lang_id']; $newlang = $_REQUEST['lang_id'];
//if ($conf->global->MAIN_MULTILANGS && empty($newlang))
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) // $newlang = $object->thirdparty->default_lang;
$newlang = $object->default_lang;
// Cree l'objet formulaire mail // Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
@ -1701,7 +1698,7 @@ else
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'thi'.$object->id); $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'thi'.$object->id);
} }
$formmail->withfrom=1; $formmail->withfrom=1;
$formmail->withtopic=1; $formmail->withtopic=$topicmail;
$formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$object->email; $formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$object->email;
$formmail->withtofree=1; $formmail->withtofree=1;
$formmail->withtocc=1; $formmail->withtocc=1;
@ -1711,37 +1708,9 @@ else
$formmail->withdeliveryreceipt=1; $formmail->withdeliveryreceipt=1;
$formmail->withcancel=1; $formmail->withcancel=1;
// Tableau des substitutions // Tableau des substitutions
//$formmail->setSubstitFromObject($object); $formmail->setSubstitFromObject($object);
$formmail->substit['__LASTNAME__']=$object->lastname; $formmail->substit['__LASTNAME__']=$object->lastname;
$formmail->substit['__FIRSTNAME__']=$object->firstname; $formmail->substit['__FIRSTNAME__']=$object->firstname;
$formmail->substit['__SIGNATURE__']=$user->signature;
$formmail->substit['__PERSONALIZED__']='';
//Find the good contact adress
/*
$custcontact='';
$contactarr=array();
$contactarr=$object->liste_contact(-1,'external');
if (is_array($contactarr) && count($contactarr)>0)
{
foreach($contactarr as $contact)
{
if ($contact['libelle']==$langs->trans('TypeContact_facture_external_BILLING')) {
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
$contactstatic=new Contact($db);
$contactstatic->fetch($contact['id']);
$custcontact=$contactstatic->getFullName($langs,1);
}
}
if (!empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__']=$custcontact;
}
}*/
// Tableau des parametres complementaires du post // Tableau des parametres complementaires du post
$formmail->param['action']=$action; $formmail->param['action']=$action;