From cbe65fbc79f0ee5037b0cd253439ed23f9738c4d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Jan 2016 13:05:56 +0100 Subject: [PATCH] Fix: fields added into 3.8 to store email event was not enough. To late to use them. Will be done into 4.0 --- htdocs/comm/action/class/actioncomm.class.php | 10 ++++++++++ ...terface_50_modAgenda_ActionsAuto.class.php | 19 +++++++++++++------ htdocs/fourn/facture/card.php | 13 ++++++++++--- .../install/mysql/migration/3.8.0-3.9.0.sql | 5 +++++ .../install/mysql/tables/llx_actioncomm.sql | 3 +++ 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 9f051b902cc..68eb6994e5a 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -157,7 +157,17 @@ class ActionComm extends CommonObject var $actions=array(); + // Fields for emails + var $email_msgid; + var $email_from; + var $email_sender; + var $email_to; + var $email_tocc; + var $email_tobcc; + var $email_subject; + var $errors_to; + /** * Constructor * diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 0912e7aee10..40a06f11648 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -698,9 +698,9 @@ class InterfaceActionsAuto extends DolibarrTriggers require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $actioncomm = new ActionComm($this->db); $actioncomm->type_code = $object->actiontypecode; // code of parent table llx_c_actioncomm (will be deprecated) - $actioncomm->code='AC_'.$action; + $actioncomm->code = 'AC_'.$action; $actioncomm->label = $object->actionmsg2; - $actioncomm->note = $object->actionmsg; + $actioncomm->note = $object->actionmsg; // TODO Replace with $actioncomm->email_msgid ? $object->email_content : $object->actionmsg $actioncomm->datep = $now; $actioncomm->datef = $now; $actioncomm->durationp = 0; @@ -712,15 +712,22 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->contactid = $contactforaction->id; $actioncomm->authorid = $user->id; // User saving action $actioncomm->userownerid = $user->id; // Owner of action - //$actioncomm->userdone = $user; // User doing action (not used anymore) - //$actioncomm->userdoneid = $user->id; // User doing action (not used anymore) + // Fields when action is en email (coentent should be into note) + $actioncomm->email_msgid = $object->email_msgid; + $actioncomm->email_from = $object->email_from; + $actioncomm->email_sender= $object->email_sender; + $actioncomm->email_to = $object->email_to; + $actioncomm->email_tocc = $object->email_tocc; + $actioncomm->email_tobcc = $object->email_tobcc; + $actioncomm->email_subject = $object->email_subject; + $actioncomm->errors_to = $object->errors_to; $actioncomm->fk_element = $object->id; $actioncomm->elementtype = $object->element; - $ret=$actioncomm->add($user); // User qui saisit l'action + $ret=$actioncomm->add($user); // User creating action - unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse vallue of first action. + unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. if ($ret > 0) { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index edda6ea421e..a72a6f61aa3 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1007,22 +1007,29 @@ if (empty($reshook)) $error=0; - // Initialisation donnees + // Init data for trigger $object->sendtoid = $sendtoid; $object->actiontypecode = $actiontypecode; $object->actionmsg = $actionmsg; $object->actionmsg2 = $actionmsg2; $object->fk_element = $object->id; $object->elementtype = $object->element; + + $object->email_subject = $subject; + $object->email_to = $sendto; + $object->email_tocc = $sendtocc; + $object->email_tobcc = $sendtobcc; + $object->email_from = $from; + $object->email_content = $_POST['message']; - // Appel des triggers + // Call triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($db); $result=$interface->run_triggers('BILL_SUPPLIER_SENTBYMAIL',$object,$user,$langs,$conf); if ($result < 0) { $error++; $object->errors=$interface->errors; } - // Fin appel triggers + // End call triggers if ($error) { diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index e6e92a65fc7..7c372a5c394 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -29,6 +29,11 @@ ALTER TABLE llx_don ADD COLUMN fk_country integer NOT NULL DEFAULT 0 after count UPDATE llx_user set api_key = null where api_key = ''; +ALTER TABLE llx_actioncomm ADD COLUMN email_subject varchar(256) after email_msgid; +ALTER TABLE llx_actioncomm ADD COLUMN email_tocc varchar(256) after email_to; +ALTER TABLE llx_actioncomm ADD COLUMN email_tobcc varchar(256) after email_tocc; + + UPDATE llx_commande_fourn set billed=1 where statut = 8; UPDATE llx_commande_fourn set statut=5 where statut = 8 and billed=1; diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql index 62eaae22e6f..b2f0ecc6920 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.sql @@ -55,10 +55,13 @@ create table llx_actioncomm label varchar(256) NOT NULL, -- label/title of event or topic of email note text, -- note of event or content of email + email_subject varchar(256), -- when event was an email, we store here the subject. content is stored into note. email_msgid varchar(256), -- when event was an email, we store here the msgid email_from varchar(256), -- when event was an email, we store here the from email_sender varchar(256), -- when event was an email, we store here the sender email_to varchar(256), -- when event was an email, we store here the email_to + email_tocc varchar(256), -- when event was an email, we store here the email_tocc + email_tobcc varchar(256), -- when event was an email, we store here the email_tobcc errors_to varchar(256), -- when event was an email, we store here the erros_to recurid varchar(128), -- used to store event id to link all recurring event records each other