Fix trackid from emailings

This commit is contained in:
Laurent Destailleur 2017-11-21 11:15:33 +01:00
parent 4b4412d5da
commit ff9a62e519
3 changed files with 17 additions and 16 deletions

View File

@ -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)

View File

@ -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").'<br><br>';
print '<input type="text" name="objectname" value="'.dol_escape_htmltag($modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ObjectKey")).'">';
print '<input type="text" name="objectname" value="'.dol_escape_htmltag(GETPOST('objectname','alpha')?GETPOST('objectname','alpha'):$modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ObjectKey")).'">';
print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("Create")).'"'.($dirins?'':' disabled="disabled"').'>';
print '</form>';
}

View File

@ -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)
{