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