Fix opt-out email
This commit is contained in:
parent
f081768baa
commit
4c9e6e1997
@ -265,7 +265,7 @@ if ($object->fetch($id) >= 0) {
|
|||||||
|
|
||||||
$morehtmlright = '';
|
$morehtmlright = '';
|
||||||
$nbtry = $nbok = 0;
|
$nbtry = $nbok = 0;
|
||||||
if ($object->statut == 2 || $object->statut == 3) {
|
if ($object->statut == $object::STATUS_SENTPARTIALY || $object->statut == $object::STATUS_SENTCOMPLETELY) {
|
||||||
$nbtry = $object->countNbOfTargets('alreadysent');
|
$nbtry = $object->countNbOfTargets('alreadysent');
|
||||||
$nbko = $object->countNbOfTargets('alreadysentko');
|
$nbko = $object->countNbOfTargets('alreadysentko');
|
||||||
$nbok = ($nbtry - $nbko);
|
$nbok = ($nbtry - $nbko);
|
||||||
@ -767,7 +767,7 @@ if ($object->fetch($id) >= 0) {
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Status of recipient sending email (Warning != status of emailing)
|
// Status of recipient sending email (Warning != status of emailing)
|
||||||
if ($obj->statut == 0) {
|
if ($obj->statut == $object::STATUS_DRAFT) {
|
||||||
// Date sent
|
// Date sent
|
||||||
print '<td align="center"></td>';
|
print '<td align="center"></td>';
|
||||||
|
|
||||||
|
|||||||
@ -905,7 +905,7 @@ class Mailing extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the label of a given status of a recipient
|
* Return the label of a given status of a recipient
|
||||||
* TODO Add class mailin_target.class.php
|
* TODO Add class mailin_target.class.php
|
||||||
*
|
*
|
||||||
* @param int $status Id status
|
* @param int $status Id status
|
||||||
|
|||||||
@ -158,7 +158,7 @@ class MailingTargets // This can't be abstract as it is used for some method
|
|||||||
$nb = $obj->nb;
|
$nb = $obj->nb;
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing";
|
||||||
$sql .= " SET nbemail = ".$nb." WHERE rowid = ".((int) $mailing_id);
|
$sql .= " SET nbemail = ".((int) $nb)." WHERE rowid = ".((int) $mailing_id);
|
||||||
if (!$this->db->query($sql)) {
|
if (!$this->db->query($sql)) {
|
||||||
dol_syslog($this->db->error());
|
dol_syslog($this->db->error());
|
||||||
$this->error = $this->db->error();
|
$this->error = $this->db->error();
|
||||||
@ -171,11 +171,11 @@ class MailingTargets // This can't be abstract as it is used for some method
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a list of targets int the database
|
* Add a list of targets into the database
|
||||||
*
|
*
|
||||||
* @param int $mailing_id Id of emailing
|
* @param int $mailing_id Id of emailing
|
||||||
* @param array $cibles Array with targets
|
* @param array $cibles Array with targets
|
||||||
* @return int < 0 si erreur, nb ajout si ok
|
* @return int < 0 if error, nb added if OK
|
||||||
*/
|
*/
|
||||||
public function addTargetsToDatabase($mailing_id, $cibles)
|
public function addTargetsToDatabase($mailing_id, $cibles)
|
||||||
{
|
{
|
||||||
@ -241,16 +241,20 @@ class MailingTargets // This can't be abstract as it is used for some method
|
|||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
|
if (empty($this->evenunsubscribe)) {
|
||||||
$sql .= " SET statut=3";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
|
||||||
$sql .= " WHERE fk_mailing = ".((int) $mailing_id)." AND email IN (SELECT mu.email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe AS mu WHERE mu.entity IN ('".getEntity('mailing')."'))";
|
$sql .= " SET statut = 3";
|
||||||
|
$sql .= " WHERE fk_mailing = ".((int) $mailing_id);
|
||||||
|
$sql .= " AND EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = email and mu.entity = ".((int) $conf->entity).")";
|
||||||
|
|
||||||
dol_syslog(__METHOD__.":mailing update status to display emails that do not want to be contacted anymore", LOG_DEBUG);
|
dol_syslog(__METHOD__.":mailing update status to display emails that do not want to be contacted anymore", LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update nb of recipient into emailing record
|
||||||
$this->update_nb($mailing_id);
|
$this->update_nb($mailing_id);
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user