diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 219cd85c2fe..03cce1dff09 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -86,8 +86,8 @@ if ($action == 'update' && empty($_POST["cancel"])) // Actions to send emails $id=0; -$actiontypecode=''; -$trigger_name=''; +$actiontypecode=''; // Not an event for agenda +$trigger_name=''; // Disable triggers $paramname='id'; $mode='emailfortest'; $trackid=(($action == 'testhtml')?"testhtml":"test"); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 0ee995e4784..df86464281a 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -644,7 +644,7 @@ if (empty($reshook)) */ // Actions to send emails - $actiontypecode='AC_PROP'; + $actiontypecode='AC_OTH_AUTO'; $trigger_name='PROPAL_SENTBYMAIL'; $paramname='id'; $mode='emailfromproposal'; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 07f25b40ed8..fe91f0b6ff8 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1259,7 +1259,6 @@ if (empty($reshook)) // Actions to send emails - $actiontypecode='AC_COM'; $trigger_name='ORDER_SENTBYMAIL'; $paramname='id'; $mode='emailfromorder'; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 02b67c814ef..4835b53b277 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1911,7 +1911,6 @@ if (empty($reshook)) // Actions to send emails if (empty($id)) $id=$facid; - $actiontypecode='AC_FAC'; $trigger_name='BILL_SENTBYMAIL'; $paramname='id'; $mode='emailfrominvoice'; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 0e0f8c84090..f00816e9d4b 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -953,7 +953,6 @@ if (empty($reshook)) */ // Actions to send emails - $actiontypecode='AC_CONT'; $trigger_name='CONTRACT_SENTBYMAIL'; $paramname='id'; $mode='emailfromcontract'; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 58e47a29ec8..92d1011b923 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -274,12 +274,12 @@ if (! $error && $massaction == 'confirm_presend') // Insert logs into agenda foreach($listofqualifiedinvoice as $invid => $object) { - if ($objectclass == 'Propale') $actiontypecode='AC_PROP'; + /*if ($objectclass == 'Propale') $actiontypecode='AC_PROP'; if ($objectclass == 'Commande') $actiontypecode='AC_COM'; if ($objectclass == 'Facture') $actiontypecode='AC_FAC'; if ($objectclass == 'Supplier_Proposal') $actiontypecode='AC_SUP_PRO'; if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD'; - if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV'; + if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/ $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) @@ -289,10 +289,10 @@ if (! $error && $massaction == 'confirm_presend') $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); $actionmsg = dol_concatdesc($actionmsg, $message); } - + $actionmsg2=''; + // Initialisation donnees $object->sendtoid = 0; - $object->actiontypecode = $actiontypecode; $object->actionmsg = $actionmsg; // Long text $object->actionmsg2 = $actionmsg2; // Short text $object->fk_element = $invid; diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index cf50d05d6bf..dded23e6cbf 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -23,11 +23,11 @@ // $mysoc must be defined // $id must be defined -// $actiontypecode must be defined // $paramname must be defined // $mode must be defined -// $object and $uobject may be defined. - +// $trigger_name must be set (can be '') +// $actiontypecode can be set +// $object and $uobject may be defined /* * Add file in email form @@ -155,7 +155,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } } - else dol_print_error('','Use actions_sendmails.in.php for a type that is not supported'); + else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported'); } else $thirdparty = $mysoc; @@ -347,7 +347,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $error=0; - // FIXME This must be moved into a trigger for action $trigger_name + // FIXME This must be moved into the trigger for action $trigger_name if (! empty($conf->dolimail->enabled)) { $mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0); // Original mail id is set ? @@ -370,21 +370,26 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // Initialisation of datas if (is_object($object)) { - $object->socid = $sendtosocid; // To link to a company - $object->sendtoid = $sendtoid; // To link to contacts/addresses. This is an array. - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; // Long text - $object->actionmsg2 = $actionmsg2; // Short text + if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically + + $object->socid = $sendtosocid; // To link to a company + $object->sendtoid = $sendtoid; // To link to contacts/addresses. This is an array. + $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $object->actionmsg = $actionmsg; // Long text + $object->actionmsg2 = $actionmsg2; // Short text $object->trackid = $trackid; $object->fk_element = $object->id; $object->elementtype = $object->element; // Call of triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); - if ($result < 0) { - $error++; $errors=$interface->errors; + if (! empty($trigger_name)) + { + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($db); + $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); + if ($result < 0) { + $error++; $errors=$interface->errors; + } } } @@ -398,8 +403,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // This avoid sending mail twice if going out and then back to page $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); setEventMessages($mesg, null, 'mesgs'); - if ($conf->dolimail->enabled) header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id.'&'.($paramname2?$paramname2:'mid').'='.$parm2val); - else header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id); + if ($conf->dolimail->enabled) + { + header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').'&'.($paramname2?$paramname2:'mid').'='.$parm2val); + exit; + } + header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'')); exit; } } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 020382095a3..3641ac87cef 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -297,7 +297,7 @@ class FormMail extends Form $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); //var_dump($arraydefaultmessage); - $out.= "\n\n"; + $out.= "\n".'
'."\n"; if ($this->withform == 1) { $out.= ''; - } - print "