Fix: Sending email from thirdparty must add event into agenda if option
is on.
This commit is contained in:
parent
5ea7c34956
commit
db7bcfd748
@ -70,14 +70,17 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||||||
|
|
||||||
$result=$object->fetch($id);
|
$result=$object->fetch($id);
|
||||||
|
|
||||||
|
$sendtosocid=0;
|
||||||
if (method_exists($object,"fetch_thirdparty") && $object->element != 'societe')
|
if (method_exists($object,"fetch_thirdparty") && $object->element != 'societe')
|
||||||
{
|
{
|
||||||
$result=$object->fetch_thirdparty();
|
$result=$object->fetch_thirdparty();
|
||||||
$thirdparty=$object->thirdparty;
|
$thirdparty=$object->thirdparty;
|
||||||
|
$sendtosocid=$thirdparty->id;
|
||||||
}
|
}
|
||||||
else if ($object->element == 'societe')
|
else if ($object->element == 'societe')
|
||||||
{
|
{
|
||||||
$thirdparty=$object;
|
$thirdparty=$object;
|
||||||
|
$sendtosocid=$thirdparty->id;
|
||||||
}
|
}
|
||||||
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 a type that is not supported');
|
||||||
|
|
||||||
@ -114,28 +117,17 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||||||
$sendtocc = $_POST['sendtocc'];
|
$sendtocc = $_POST['sendtocc'];
|
||||||
$deliveryreceipt = $_POST['deliveryreceipt'];
|
$deliveryreceipt = $_POST['deliveryreceipt'];
|
||||||
|
|
||||||
if ($action == 'send')
|
if ($action == 'send' || $action == 'relance')
|
||||||
{
|
{
|
||||||
if (dol_strlen($_POST['subject'])) $subject = $_POST['subject'];
|
if (dol_strlen($_POST['subject'])) $subject = $_POST['subject'];
|
||||||
$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
|
$actionmsg2=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
|
||||||
if ($message)
|
if ($message)
|
||||||
{
|
{
|
||||||
|
$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
|
||||||
$actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n";
|
$actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n";
|
||||||
$actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
|
$actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
|
||||||
$actionmsg.=$message;
|
$actionmsg.=$message;
|
||||||
}
|
}
|
||||||
//$actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
|
|
||||||
}
|
|
||||||
if ($action == 'relance')
|
|
||||||
{
|
|
||||||
if (dol_strlen($_POST['subject'])) $subject = $_POST['subject'];
|
|
||||||
$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
|
|
||||||
if ($message) {
|
|
||||||
$actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n";
|
|
||||||
$actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
|
|
||||||
$actionmsg.=$message;
|
|
||||||
}
|
|
||||||
//$actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create form object
|
// Create form object
|
||||||
@ -162,7 +154,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
// Initialisation donnees
|
// Initialisation donnees
|
||||||
$object->sendtoid = $sendtoid;
|
$object->socid = $sendtosocid; // To link to a company
|
||||||
|
$object->sendtoid = $sendtoid; // To link to a contact/address
|
||||||
$object->actiontypecode = $actiontypecode;
|
$object->actiontypecode = $actiontypecode;
|
||||||
$object->actionmsg = $actionmsg; // Long text
|
$object->actionmsg = $actionmsg; // Long text
|
||||||
$object->actionmsg2 = $actionmsg2; // Short text
|
$object->actionmsg2 = $actionmsg2; // Short text
|
||||||
@ -172,7 +165,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
$interface=new Interfaces($db);
|
$interface=new Interfaces($db);
|
||||||
$result=$interface->run_triggers('THIRDPARTY_EMAILSENT',$object,$user,$langs,$conf);
|
$result=$interface->run_triggers('COMPANY_SENTBYMAIL',$object,$user,$langs,$conf);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++; $this->errors=$interface->errors;
|
$error++; $this->errors=$interface->errors;
|
||||||
}
|
}
|
||||||
@ -188,7 +181,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||||||
// This avoid sending mail twice if going out and then back to page
|
// 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));
|
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
|
||||||
setEventMessage($mesg);
|
setEventMessage($mesg);
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id);
|
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,6 +74,7 @@ class modAgenda extends DolibarrModules
|
|||||||
// Constantes
|
// Constantes
|
||||||
//-----------
|
//-----------
|
||||||
$this->const = array();
|
$this->const = array();
|
||||||
|
$this->const[15] = array("MAIN_AGENDA_ACTIONAUTO_COMPANY_SENTBYMAIL","chaine","1");
|
||||||
$this->const[0] = array("MAIN_AGENDA_ACTIONAUTO_COMPANY_CREATE","chaine","1");
|
$this->const[0] = array("MAIN_AGENDA_ACTIONAUTO_COMPANY_CREATE","chaine","1");
|
||||||
$this->const[1] = array("MAIN_AGENDA_ACTIONAUTO_CONTRACT_VALIDATE","chaine","1");
|
$this->const[1] = array("MAIN_AGENDA_ACTIONAUTO_CONTRACT_VALIDATE","chaine","1");
|
||||||
$this->const[2] = array("MAIN_AGENDA_ACTIONAUTO_PROPAL_VALIDATE","chaine","1");
|
$this->const[2] = array("MAIN_AGENDA_ACTIONAUTO_PROPAL_VALIDATE","chaine","1");
|
||||||
|
|||||||
@ -140,6 +140,20 @@ class InterfaceActionsAuto
|
|||||||
$object->socid=$object->id;
|
$object->socid=$object->id;
|
||||||
$ok=1;
|
$ok=1;
|
||||||
}
|
}
|
||||||
|
elseif ($action == 'COMPANY_SENTBYMAIL')
|
||||||
|
{
|
||||||
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
$langs->load("orders");
|
||||||
|
$langs->load("agenda");
|
||||||
|
|
||||||
|
if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO';
|
||||||
|
if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR);
|
||||||
|
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||||
|
|
||||||
|
// Parameters $object->sendtoid defined by caller
|
||||||
|
//$object->sendtoid=0;
|
||||||
|
$ok=1;
|
||||||
|
}
|
||||||
elseif ($action == 'CONTRACT_VALIDATE')
|
elseif ($action == 'CONTRACT_VALIDATE')
|
||||||
{
|
{
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|||||||
@ -37,6 +37,7 @@ insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang)
|
|||||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (4,'ORDER_SUPPLIER_REFUSE','Supplier order request refused','Executed when a supplier order is refused','order_supplier',13);
|
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (4,'ORDER_SUPPLIER_REFUSE','Supplier order request refused','Executed when a supplier order is refused','order_supplier',13);
|
||||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (5,'ORDER_VALIDATE','Customer order validate','Executed when a customer order is validated','commande',4);
|
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (5,'ORDER_VALIDATE','Customer order validate','Executed when a customer order is validated','commande',4);
|
||||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (6,'PROPAL_VALIDATE','Customer proposal validated','Executed when a commercial proposal is validated','propal',2);
|
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (6,'PROPAL_VALIDATE','Customer proposal validated','Executed when a commercial proposal is validated','propal',2);
|
||||||
|
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (9,'COMPANY_SENTBYMAIL','Mails sent from third party card','Executed when you send email from third party card','societe',1);
|
||||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (10,'COMPANY_CREATE','Third party created','Executed when a third party is created','societe',1);
|
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (10,'COMPANY_CREATE','Third party created','Executed when a third party is created','societe',1);
|
||||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (11,'CONTRACT_VALIDATE','Contract validated','Executed when a contract is validated','contrat',18);
|
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (11,'CONTRACT_VALIDATE','Contract validated','Executed when a contract is validated','contrat',18);
|
||||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (12,'PROPAL_SENTBYMAIL','Commercial proposal sent by mail','Executed when a commercial proposal is sent by mail','propal',3);
|
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (12,'PROPAL_SENTBYMAIL','Commercial proposal sent by mail','Executed when a commercial proposal is sent by mail','propal',3);
|
||||||
|
|||||||
@ -298,3 +298,6 @@ ALTER TABLE llx_facture_fourn ADD fk_mode_reglement integer NULL AFTER fk_cond_r
|
|||||||
ALTER TABLE llx_facture_fourn MODIFY COLUMN fk_mode_reglement integer NULL;
|
ALTER TABLE llx_facture_fourn MODIFY COLUMN fk_mode_reglement integer NULL;
|
||||||
ALTER TABLE llx_facture_fourn MODIFY COLUMN fk_cond_reglement integer NULL;
|
ALTER TABLE llx_facture_fourn MODIFY COLUMN fk_cond_reglement integer NULL;
|
||||||
|
|
||||||
|
|
||||||
|
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (9,'COMPANY_SENTBYMAIL','Mails sent from third party card','Executed when you send email from third party card','societe',1);
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ AutoActions= Alimentation automatique
|
|||||||
AgendaAutoActionDesc= Définissez dans cet onglet les événements pour lesquels Dolibarr créera automatiquement une action dans l'agenda. Si aucune case n'est cochée (par défaut), seules les actions manuelles seront incluses dans l'agenda.
|
AgendaAutoActionDesc= Définissez dans cet onglet les événements pour lesquels Dolibarr créera automatiquement une action dans l'agenda. Si aucune case n'est cochée (par défaut), seules les actions manuelles seront incluses dans l'agenda.
|
||||||
AgendaSetupOtherDesc= Cette page permet de configurer quelques options permettant d'exporter une vue de votre agenda Dolibarr vers un calendrier externe (Thunderbird, Google calendar, …)
|
AgendaSetupOtherDesc= Cette page permet de configurer quelques options permettant d'exporter une vue de votre agenda Dolibarr vers un calendrier externe (Thunderbird, Google calendar, …)
|
||||||
AgendaExtSitesDesc=Cette page permet d'ajouter des sources de calendriers externes pour les visualiser au sein de l'agenda Dolibarr.
|
AgendaExtSitesDesc=Cette page permet d'ajouter des sources de calendriers externes pour les visualiser au sein de l'agenda Dolibarr.
|
||||||
ActionsEvents= Événements pour lesquels Dolibarr doit créer une action dans l'agenda en automatique.
|
ActionsEvents= Événements pour lesquels Dolibarr doit insérer un évènement dans l'agenda en automatique.
|
||||||
PropalValidatedInDolibarr= Proposition %s validée
|
PropalValidatedInDolibarr= Proposition %s validée
|
||||||
InvoiceValidatedInDolibarr= Facture %s validée
|
InvoiceValidatedInDolibarr= Facture %s validée
|
||||||
InvoiceBackToDraftInDolibarr=Facture %s repassée en brouillon
|
InvoiceBackToDraftInDolibarr=Facture %s repassée en brouillon
|
||||||
|
|||||||
@ -454,6 +454,7 @@ if (empty($reshook))
|
|||||||
// Actions to send emails
|
// Actions to send emails
|
||||||
$id=$socid;
|
$id=$socid;
|
||||||
$actiontypecode='AC_OTH_AUTO';
|
$actiontypecode='AC_OTH_AUTO';
|
||||||
|
$paramname='socid';
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
|
||||||
|
|
||||||
|
|
||||||
@ -1778,7 +1779,14 @@ else
|
|||||||
*/
|
*/
|
||||||
print '<div class="tabsAction">'."\n";
|
print '<div class="tabsAction">'."\n";
|
||||||
|
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendMail').'</a></div>';
|
if (! empty($object->email))
|
||||||
|
{
|
||||||
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendMail').'</a></div>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEmailDefined")).'">'.$langs->trans('SendMail').'</a></div>';
|
||||||
|
}
|
||||||
|
|
||||||
if ($user->rights->societe->creer)
|
if ($user->rights->societe->creer)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user