From ff9a62e51934ebe918a81edb68644405e7d35335 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Nov 2017 11:15:33 +0100 Subject: [PATCH] Fix trackid from emailings --- htdocs/comm/mailing/card.php | 4 ++-- htdocs/modulebuilder/index.php | 3 ++- scripts/emailings/mailing-send.php | 26 +++++++++++++------------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index c8338d22379..efae8bd8e80 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -153,7 +153,7 @@ if (empty($reshook)) // On choisit les mails non deja envoyes pour ce mailing (statut=0) // ou envoyes en erreur (statut=-1) - $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; + $sql = "SELECT mc.rowid, mc.fk_mailing, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$object->id; @@ -283,7 +283,7 @@ if (empty($reshook)) } // Fabrication du mail - $trackid='emailing-'.$obj2->source_type.$obj2->source_id; + $trackid='emailing-'.$obj->fk_mailing.'-'.$obj->rowid; $mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css, $trackid, '', 'emailing'); if ($mail->error) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 2658b105c35..df84d29ff72 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -186,6 +186,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); + $tabobj='newobject'; } $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; @@ -1422,7 +1423,7 @@ elseif (! empty($module)) print $langs->trans("EnterNameOfObjectDesc").'

'; - print ''; + print ''; print ''; print ''; } diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index a56c2be2055..ef9a35fc1ed 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -113,7 +113,7 @@ if ($resql) // On choisit les mails non deja envoyes pour ce mailing (statut=0) // ou envoyes en erreur (statut=-1) - $sql2 = "SELECT mc.rowid, mc.lastname as lastname, mc.firstname as firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; + $sql2 = "SELECT mc.rowid, mc.fk_mailing, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; $sql2.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql2.= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id; if ($conf->global->MAILING_LIMIT_SENDBYCLI > 0) @@ -149,13 +149,13 @@ if ($resql) $res=1; $now=dol_now(); - $obj2 = $db->fetch_object($resql2); + $obj = $db->fetch_object($resql2); // sendto en RFC2822 - $sendto = str_replace(',',' ',dolGetFirstLastname($obj2->firstname, $obj2->lastname) ." <".$obj2->email.">"); + $sendto = str_replace(',',' ',dolGetFirstLastname($obj->firstname, $obj->lastname) ." <".$obj->email.">"); // Make subtsitutions on topic and body - $other=explode(';',$obj2->other); + $other=explode(';',$obj->other); $tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); @@ -230,7 +230,7 @@ if ($resql) $substitutionisok=true; // Fabrication du mail - $trackid='emailing-'.$obj2->source_type.$obj2->source_id; + $trackid='emailing-'.$obj->fk_mailing.'-'.$obj->rowid; $mail = new CMailFile( $newsubject, $sendto, @@ -277,13 +277,13 @@ if ($resql) // We must union table llx_mailing_taget for event tab OR enter 1 event with a special table link (id of email in event) // Run trigger /* - if ($obj2->source_type == 'contact') + if ($obj->source_type == 'contact') { - $emailing->sendtoid = $obj2->source_id; + $emailing->sendtoid = $obj->source_id; } - if ($obj2->source_type == 'thirdparty') + if ($obj->source_type == 'thirdparty') { - $emailing->socid = $obj2->source_id; + $emailing->socid = $obj->source_id; } // Call trigger $result=$emailing->call_trigger('EMAILING_SENTBYMAIL',$user); @@ -292,7 +292,7 @@ if ($resql) */ $sqlok ="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sqlok.=" SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj2->rowid; + $sqlok.=" SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid; $resqlok=$db->query($sqlok); if (! $resqlok) { @@ -305,7 +305,7 @@ if ($resql) if (strpos($message, '__CHECK_READ__') !== false) { //Update status communication of thirdparty prospect - $sqlx = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj2->rowid.")"; + $sqlx = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj->rowid.")"; dol_syslog("card.php: set prospect thirdparty status", LOG_DEBUG); $resqlx=$db->query($sqlx); if (! $resqlx) @@ -315,7 +315,7 @@ if ($resql) } //Update status communication of contact prospect - $sqlx = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj2->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; + $sqlx = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; dol_syslog("card.php: set prospect contact status", LOG_DEBUG); $resqlx=$db->query($sqlx); @@ -340,7 +340,7 @@ if ($resql) dol_syslog("error for emailing id ".$id." #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); $sqlerror="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sqlerror.=" SET statut=-1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj2->rowid; + $sqlerror.=" SET statut=-1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid; $resqlerror=$db->query($sqlerror); if (! $resqlerror) {