Work on new unsubscribe process
This commit is contained in:
parent
3213b3be07
commit
b47e7b2267
@ -745,7 +745,16 @@ class AdvanceTargetingMailing extends CommonObject
|
||||
$sqlwhere[]= " (t.civility IN ('".$this->db->escape(implode("','",$arrayquery['contact_civility']))."'))";
|
||||
}
|
||||
if ($arrayquery['contact_no_email']!='') {
|
||||
$sqlwhere[]= " (t.no_email='".$this->db->escape($arrayquery['contact_no_email'])."')";
|
||||
$tmpwhere = '';
|
||||
if (! empty($arrayquery['contact_no_email']))
|
||||
{
|
||||
$tmpwhere.= "(t.email IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE t.entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($arrayquery['contact_no_email'])."'))";
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmpwhere.= "(t.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE t.entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($arrayquery['contact_no_email'])."'))";
|
||||
}
|
||||
$sqlwhere[]= $tmpwhere;
|
||||
}
|
||||
if ($arrayquery['contact_update_st_dt']!='') {
|
||||
$sqlwhere[]= " (t.tms >= '".$this->db->idate($arrayquery['contact_update_st_dt'])."' AND t.tms <= '".$this->db->idate($arrayquery['contact_update_end_dt'])."')";
|
||||
|
||||
@ -194,7 +194,6 @@ if (empty($reshook))
|
||||
$object->phone_mobile = GETPOST("phone_mobile",'alpha');
|
||||
$object->fax = GETPOST("fax",'alpha');
|
||||
$object->jabberid = GETPOST("jabberid",'alpha');
|
||||
$object->no_email = GETPOST("no_email",'int');
|
||||
$object->priv = GETPOST("priv",'int');
|
||||
$object->note_public = GETPOST("note_public",'none');
|
||||
$object->note_private = GETPOST("note_private",'none');
|
||||
@ -367,7 +366,6 @@ if (empty($reshook))
|
||||
$object->phone_mobile = GETPOST("phone_mobile",'alpha');
|
||||
$object->fax = GETPOST("fax",'alpha');
|
||||
$object->jabberid = GETPOST("jabberid",'alpha');
|
||||
$object->no_email = GETPOST("no_email",'int');
|
||||
$object->priv = GETPOST("priv",'int');
|
||||
$object->note_public = GETPOST("note_public",'none');
|
||||
$object->note_private = GETPOST("note_private",'none');
|
||||
@ -651,8 +649,21 @@ else
|
||||
print '<td><input name="email" id="email" type="text" class="maxwidth100onsmartphone" value="'.dol_escape_htmltag(GETPOST("email",'alpha')?GETPOST("email",'alpha'):$object->email).'"></td>';
|
||||
if (! empty($conf->mailing->enabled))
|
||||
{
|
||||
$noemail = '';
|
||||
if (empty($noemail) && ! empty($object->email))
|
||||
{
|
||||
$sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'";
|
||||
//print $sql;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$db->fetch_object($resql);
|
||||
$noemail = $obj->nb;
|
||||
}
|
||||
}
|
||||
|
||||
print '<td><label for="no_email">'.$langs->trans("No_Email").'</label></td>';
|
||||
print '<td>'.$form->selectyesno('no_email',(GETPOST("no_email",'alpha')?GETPOST("no_email",'alpha'):$object->no_email), 1).'</td>';
|
||||
print '<td>'.$form->selectyesno('no_email',(GETPOSTISSET("no_email")?GETPOST("no_email",'alpha'):$noemail), 1).'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -925,8 +936,21 @@ else
|
||||
print '<tr>';
|
||||
if (! empty($conf->mailing->enabled))
|
||||
{
|
||||
$noemail = '';
|
||||
if (empty($noemail) && ! empty($object->email))
|
||||
{
|
||||
$sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'";
|
||||
//print $sql;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$db->fetch_object($resql);
|
||||
$noemail = $obj->nb;
|
||||
}
|
||||
}
|
||||
|
||||
print '<td><label for="no_email">'.$langs->trans("No_Email").'</label></td>';
|
||||
print '<td>'.$form->selectyesno('no_email',(isset($_POST["no_email"])?$_POST["no_email"]:$object->no_email), 1).'</td>';
|
||||
print '<td>'.$form->selectyesno('no_email',(GETPOSTISSET("no_email")?GETPOST("no_email",'alpha'):$noemail), 1).'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1160,10 +1184,23 @@ else
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/comm/mailing/list.php?filteremail='.urlencode($object->email).'">'.$object->getNbOfEMailings().'</a></td></tr>';
|
||||
}
|
||||
|
||||
// Unsubscribe
|
||||
// Unsubscribe opt-out
|
||||
if (!empty($conf->mailing->enabled))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("No_Email").'</td><td>'.yn($object->no_email).'</td></tr>';
|
||||
//print 'eee'.$object->email;
|
||||
$noemail = $object->no_email;
|
||||
if (empty($noemail) && ! empty($object->email))
|
||||
{
|
||||
$sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'";
|
||||
//print $sql;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$db->fetch_object($resql);
|
||||
$noemail = $obj->nb;
|
||||
}
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("No_Email").'</td><td>'.yn($noemail).'</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td>'.$langs->trans("ContactVisibility").'</td><td>';
|
||||
|
||||
@ -123,7 +123,6 @@ class Contact extends CommonObject
|
||||
|
||||
public $birthday;
|
||||
public $default_lang;
|
||||
public $no_email; // 1=Don't send e-mail to this contact, 0=do
|
||||
|
||||
public $ref_facturation; // Reference number of invoice for which it is contact
|
||||
public $ref_contrat; // Nb de reference contrat pour lequel il est contact
|
||||
@ -372,7 +371,6 @@ class Contact extends CommonObject
|
||||
$sql .= ", statut = ".$this->db->escape($this->statut);
|
||||
$sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape($user->id)."'":"NULL");
|
||||
$sql .= ", default_lang=".($this->default_lang?"'".$this->db->escape($this->default_lang)."'":"NULL");
|
||||
$sql .= ", no_email=".($this->no_email?"'".$this->db->escape($this->no_email)."'":"0");
|
||||
$sql .= ", entity = " . $this->db->escape($this->entity);
|
||||
$sql .= " WHERE rowid=".$this->db->escape($id);
|
||||
|
||||
@ -709,7 +707,7 @@ class Contact extends CommonObject
|
||||
$sql.= " c.birthday,";
|
||||
$sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype, c.twitter, c.facebook,";
|
||||
$sql.= " c.photo,";
|
||||
$sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.no_email, c.canvas,";
|
||||
$sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,";
|
||||
$sql.= " c.import_key,";
|
||||
$sql.= " c.datec as date_creation, c.tms as date_modification,";
|
||||
$sql.= " co.label as country, co.code as country_code,";
|
||||
@ -790,7 +788,6 @@ class Contact extends CommonObject
|
||||
$this->note_private = $obj->note_private;
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->default_lang = $obj->default_lang;
|
||||
$this->no_email = $obj->no_email;
|
||||
$this->user_id = $obj->user_id;
|
||||
$this->user_login = $obj->user_login;
|
||||
$this->canvas = $obj->canvas;
|
||||
|
||||
@ -53,7 +53,7 @@ create table llx_socpeople
|
||||
whatsapp varchar(255), --
|
||||
|
||||
photo varchar(255),
|
||||
no_email smallint NOT NULL DEFAULT 0,
|
||||
no_email smallint NOT NULL DEFAULT 0, -- deprecated. Use table llx_mailing_unsubscribe instead
|
||||
priv smallint NOT NULL DEFAULT 0,
|
||||
fk_user_creat integer DEFAULT 0, -- user qui a creel'enregistrement
|
||||
fk_user_modif integer,
|
||||
|
||||
@ -100,19 +100,21 @@ if (! empty($tag) && ($unsuscrib=='1'))
|
||||
$resql=$db->query($sql);
|
||||
if (! $resql) dol_print_error($db);
|
||||
|
||||
// Update status communication of thirdparty prospect (old data)
|
||||
/*
|
||||
// Update status communication of thirdparty prospect (old usage)
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=-1 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag = '".$db->escape($tag)."' AND source_type='thirdparty' AND source_id is not null)";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if (! $resql) dol_print_error($db);
|
||||
|
||||
// Update status communication of contact prospect (old data)
|
||||
// Update status communication of contact prospect (old usage)
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET no_email=1 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag = '".$db->escape($tag)."' AND source_type='contact' AND source_id is not null)";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if (! $resql) dol_print_error($db);
|
||||
*/
|
||||
|
||||
// Update status communication of contact prospect (old data)
|
||||
// Update status communication of email (new usage)
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email) VALUES ('".$db->idate(dol_now())."', ".$obj->entity.", '".$obj->email."')";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
|
||||
@ -105,7 +105,6 @@ $contact_fields = array(
|
||||
'birthday' => array('name'=>'birthday','type'=>'xsd:string'),
|
||||
'default_lang' => array('name'=>'default_lang','type'=>'xsd:string'),
|
||||
'note' => array('name'=>'note','type'=>'xsd:string'),
|
||||
'no_email' => array('name'=>'no_email','type'=>'xsd:string'),
|
||||
'ref_facturation' => array('name'=>'ref_facturation','type'=>'xsd:string'),
|
||||
'ref_contrat' => array('name'=>'ref_contrat','type'=>'xsd:string'),
|
||||
'ref_commande' => array('name'=>'ref_commande','type'=>'xsd:string'),
|
||||
@ -295,7 +294,6 @@ function getContact($authentication,$id,$ref_ext)
|
||||
'birthday' => $contact->birthday,
|
||||
'default_lang' => $contact->default_lang,
|
||||
'note' => $contact->note,
|
||||
'no_email' => $contact->no_email,
|
||||
'ref_facturation' => $contact->ref_facturation,
|
||||
'ref_contrat' => $contact->ref_contrat,
|
||||
'ref_commande' => $contact->ref_commande,
|
||||
@ -406,7 +404,6 @@ function createContact($authentication,$contact)
|
||||
$newobject->birthday=$contact['birthday'];
|
||||
$newobject->default_lang=$contact['default_lang'];
|
||||
$newobject->note=$contact['note'];
|
||||
$newobject->no_email=$contact['no_email'];
|
||||
$newobject->ref_facturation=$contact['ref_facturation'];
|
||||
$newobject->ref_contrat=$contact['ref_contrat'];
|
||||
$newobject->ref_commande=$contact['ref_commande'];
|
||||
@ -496,7 +493,7 @@ function getContactsForThirdParty($authentication,$idthirdparty)
|
||||
$sql.= " c.fk_departement,";
|
||||
$sql.= " c.birthday,";
|
||||
$sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid,";
|
||||
//$sql.= " c.priv, c.note, c.default_lang, c.no_email, c.canvas,";
|
||||
//$sql.= " c.priv, c.note, c.default_lang, c.canvas,";
|
||||
$sql.= " co.label as country, co.code as country_code,";
|
||||
$sql.= " d.nom as state, d.code_departement as state_code,";
|
||||
$sql.= " u.rowid as user_id, u.login as user_login,";
|
||||
@ -557,7 +554,6 @@ function getContactsForThirdParty($authentication,$idthirdparty)
|
||||
'birthday' => $contact->birthday?$contact->birthday:'',
|
||||
'default_lang' => $contact->default_lang?$contact->default_lang:'',
|
||||
'note' => $contact->note?$contact->note:'',
|
||||
'no_email' => $contact->no_email?$contact->no_email:'',
|
||||
'ref_facturation' => $contact->ref_facturation?$contact->ref_facturation:'',
|
||||
'ref_contrat' => $contact->ref_contrat?$contact->ref_contrat:'',
|
||||
'ref_commande' => $contact->ref_commande?$contact->ref_commande:'',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user