From 06ab1f6f94e0b8dd47de3b4d0c0f2844d9189855 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 22 Aug 2012 22:59:10 +0200 Subject: [PATCH 1/4] Task 515 : New field added on contact : no_email --- htdocs/contact/class/contact.class.php | 5 ++++- htdocs/contact/fiche.php | 15 ++++++++++----- htdocs/install/mysql/migration/3.2.0-3.3.0.sql | 2 ++ htdocs/install/mysql/tables/llx_socpeople.sql | 1 + htdocs/langs/en_US/companies.lang | 1 + htdocs/langs/fr_FR/companies.lang | 1 + 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 60873f86a32..0cb2d9f7c6e 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -72,6 +72,7 @@ class Contact extends CommonObject var $birthday; var $default_lang; var $note; // Private note + var $no_email; // 1=Don't send e-mail to this contact, 0=do var $ref_facturation; // Nb de reference facture pour lequel il est contact var $ref_contrat; // Nb de reference contrat pour lequel il est contact @@ -250,6 +251,7 @@ class Contact extends CommonObject $sql .= ", priv = '".$this->priv."'"; $sql .= ", fk_user_modif=".($user->id > 0 ? "'".$user->id."'":"null"); $sql .= ", default_lang=".($this->default_lang?"'".$this->default_lang."'":"null"); + $sql .= ", no_email=".($this->no_email?"'".$this->no_email."'":"null"); $sql .= " WHERE rowid=".$id; dol_syslog(get_class($this)."::update sql=".$sql,LOG_DEBUG); @@ -468,7 +470,7 @@ class Contact extends CommonObject $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.canvas,"; + $sql.= " c.priv, c.note, c.default_lang, c.no_email, c.canvas,"; $sql.= " c.import_key,"; $sql.= " p.libelle as country, p.code as country_code,"; $sql.= " d.nom as state, d.code_departement as state_code,"; @@ -536,6 +538,7 @@ class Contact extends CommonObject $this->birthday = $this->db->jdate($obj->birthday); $this->note = $obj->note; $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; diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index f42414a980b..53d7f40d91a 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -146,6 +146,7 @@ if (empty($reshook)) $object->phone_mobile = $_POST["phone_mobile"]; $object->fax = $_POST["fax"]; $object->jabberid = $_POST["jabberid"]; + $object->no_email = $_POST["no_email"]; $object->priv = $_POST["priv"]; $object->note = $_POST["note"]; @@ -237,6 +238,7 @@ if (empty($reshook)) $object->phone_mobile = $_POST["phone_mobile"]; $object->fax = $_POST["fax"]; $object->jabberid = $_POST["jabberid"]; + $object->no_email = $_POST["no_email"]; $object->priv = $_POST["priv"]; $object->note = $_POST["note"]; @@ -448,8 +450,9 @@ else if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party print ''.$langs->trans("Email").'email).'">'; - // Instant message - print ''.$langs->trans("IM").'jabberid).'">'; + // Instant message and no email + print ''.$langs->trans("IM").'jabberid).'">'; + print ''.$langs->trans("No_Email").''.$form->selectyesno('no_email',(isset($_POST["no_email"])?$_POST["no_email"]:$object->no_email)).''; // Visibility print ''.$langs->trans("ContactVisibility").''; @@ -623,7 +626,8 @@ else print ''; // Jabberid - print 'Jabberidjabberid).'">'; + print 'Jabberidjabberid).'">'; + print ''.$langs->trans("No_Email").''.$form->selectyesno('no_email',(isset($_POST["no_email"])?$_POST["no_email"]:$object->no_email)).''; // Visibility print ''.$langs->trans("ContactVisibility").''; @@ -815,8 +819,9 @@ else } print ''; - // Instant message - print ''.$langs->trans("IM").''.$object->jabberid.''; + // Instant message and no email + print ''.$langs->trans("IM").''.$object->jabberid.''; + print ''.$langs->trans("No_Email").''.$object->no_email.''; print ''.$langs->trans("ContactVisibility").''; print $object->LibPubPriv($object->priv); diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index e1d124eee8b..57f61c19bdd 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -71,3 +71,5 @@ ALTER TABLE llx_commande_fournisseur CHANGE fk_methode_commande fk_input_method INSERT INTO llx_const (name, value, type, note, visible) values ('PRODUCT_CODEPRODUCT_ADDON','mod_codeproduct_leopard','yesno','Module to control product codes',0); ALTER TABLE llx_c_barcode_type ADD UNIQUE INDEX uk_c_barcode_type(code, entity); + +ALTER TABLE llx_socpeople ADD column no_email SMALLINT NOT NULL DEFAULT 0 AFTER priv; diff --git a/htdocs/install/mysql/tables/llx_socpeople.sql b/htdocs/install/mysql/tables/llx_socpeople.sql index 534d0abbdd6..532f752d331 100644 --- a/htdocs/install/mysql/tables/llx_socpeople.sql +++ b/htdocs/install/mysql/tables/llx_socpeople.sql @@ -41,6 +41,7 @@ create table llx_socpeople fax varchar(30), email varchar(255), jabberid varchar(255), + no_email smallint NOT NULL DEFAULT 0, priv smallint NOT NULL DEFAULT 0, fk_user_creat integer DEFAULT 0, -- user qui a creel'enregistrement fk_user_modif integer, diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index b2bf2106f90..d2c6af5167b 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -68,6 +68,7 @@ Phone=Phone PhonePro=Prof. phone PhonePerso=Pers. phone PhoneMobile=Mobile +No_Email=Don't send e-mail Fax=Fax Zip=Zip Code Town=City diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index ae6b8c44369..2c0144f449e 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -70,6 +70,7 @@ Phone=Téléphone PhonePro=Tél pro. PhonePerso=Tél perso. PhoneMobile=Tél portable +No_Email=Ne pas envoyer d'e-mail Fax=Fax Zip=Code postal Town=Ville From 5fd10d14be4c2b1a968bd56b97410b2d05f37526 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 23 Aug 2012 00:00:01 +0200 Subject: [PATCH 2/4] Task 515 : Corrections + target modules modifications --- htdocs/contact/fiche.php | 6 +++--- htdocs/core/modules/mailings/contacts1.modules.php | 3 +++ htdocs/core/modules/mailings/contacts2.modules.php | 3 +++ htdocs/core/modules/mailings/contacts3.modules.php | 3 +++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 53d7f40d91a..c7ebc12f56f 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -452,7 +452,7 @@ else // Instant message and no email print ''.$langs->trans("IM").'jabberid).'">'; - print ''.$langs->trans("No_Email").''.$form->selectyesno('no_email',(isset($_POST["no_email"])?$_POST["no_email"]:$object->no_email)).''; + print ''.$langs->trans("No_Email").''.$form->selectyesno('no_email',(isset($_POST["no_email"])?$_POST["no_email"]:$object->no_email), 1).''; // Visibility print ''.$langs->trans("ContactVisibility").''; @@ -627,7 +627,7 @@ else // Jabberid print 'Jabberidjabberid).'">'; - print ''.$langs->trans("No_Email").''.$form->selectyesno('no_email',(isset($_POST["no_email"])?$_POST["no_email"]:$object->no_email)).''; + print ''.$langs->trans("No_Email").''.$form->selectyesno('no_email',(isset($_POST["no_email"])?$_POST["no_email"]:$object->no_email), 1).''; // Visibility print ''.$langs->trans("ContactVisibility").''; @@ -821,7 +821,7 @@ else // Instant message and no email print ''.$langs->trans("IM").''.$object->jabberid.''; - print ''.$langs->trans("No_Email").''.$object->no_email.''; + print ''.$langs->trans("No_Email").''.yn($object->no_email).''; print ''.$langs->trans("ContactVisibility").''; print $object->LibPubPriv($object->priv); diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 5aeed0d784a..e24c09aebe5 100755 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -77,6 +77,7 @@ class mailing_contacts1 extends MailingTargets $statssql[0].= " AND c.entity IN (".getEntity('societe', 1).")"; $statssql[0].= " AND s.client IN (1, 3)"; $statssql[0].= " AND c.email != ''"; // Note that null != '' is false + $statssql[0].= " AND c.no_email = 0"; return $statssql; } @@ -99,6 +100,7 @@ class mailing_contacts1 extends MailingTargets $sql .= " WHERE s.rowid = c.fk_soc"; $sql .= " AND c.entity IN (".getEntity('societe', 1).")"; $sql .= " AND c.email != ''"; // Note that null != '' is false + $sql .= " AND c.no_email = 0"; // La requete doit retourner un champ "nb" pour etre comprise // par parent::getNbOfRecipients @@ -205,6 +207,7 @@ class mailing_contacts1 extends MailingTargets $sql.= " WHERE s.rowid = c.fk_soc"; $sql.= " AND c.entity IN (".getEntity('societe', 1).")"; $sql.= " AND c.email != ''"; + $sql.= " AND c.no_email = 0"; foreach($filtersarray as $key) { if ($key == 'prospects') $sql.= " AND s.client=2"; diff --git a/htdocs/core/modules/mailings/contacts2.modules.php b/htdocs/core/modules/mailings/contacts2.modules.php index ed1905d634e..bb309037f64 100755 --- a/htdocs/core/modules/mailings/contacts2.modules.php +++ b/htdocs/core/modules/mailings/contacts2.modules.php @@ -84,6 +84,7 @@ class mailing_contacts2 extends MailingTargets $sql.= " ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE s.rowid = sp.fk_soc"; $sql.= " AND sp.email != ''"; // Note that null != '' is false + $sql.= " AND sp.no_email = 0"; //$sql.= " AND sp.poste != ''"; $sql.= " AND sp.entity IN (".getEntity('societe', 1).")"; if ($filtersarray[0]<>'all') $sql.= " AND sp.poste ='".$filtersarray[0]."'"; @@ -165,6 +166,7 @@ class mailing_contacts2 extends MailingTargets $sql.= " WHERE s.rowid = sp.fk_soc"; $sql.= " AND sp.entity IN (".getEntity('societe', 1).")"; $sql.= " AND sp.email != ''"; // Note that null != '' is false + $sql.= " AND sp.no_email = 0"; //$sql.= " AND sp.poste != ''"; // La requete doit retourner un champ "nb" pour etre comprise // par parent::getNbOfRecipients @@ -189,6 +191,7 @@ class mailing_contacts2 extends MailingTargets $sql.= " WHERE s.rowid = sp.fk_soc"; $sql.= " AND sp.entity IN (".getEntity('societe', 1).")"; $sql.= " AND sp.email != ''"; // Note that null != '' is false + $sql.= " AND sp.email = 0"; $sql.= " AND (sp.poste IS NOT NULL AND sp.poste != '')"; $sql.= " GROUP BY sp.poste"; $sql.= " ORDER BY sp.poste"; diff --git a/htdocs/core/modules/mailings/contacts3.modules.php b/htdocs/core/modules/mailings/contacts3.modules.php index 9f0453ada2f..be2372426fc 100755 --- a/htdocs/core/modules/mailings/contacts3.modules.php +++ b/htdocs/core/modules/mailings/contacts3.modules.php @@ -85,6 +85,7 @@ class mailing_contacts3 extends MailingTargets if ($filtersarray[0] <> 'all') $sql.= " ".MAIN_DB_PREFIX."categorie_societe as cs"; $sql.= " WHERE s.rowid = sp.fk_soc"; $sql.= " AND sp.email != ''"; // Note that null != '' is false + $sql.= " AND sp.no_email = 0"; $sql.= " AND sp.entity IN (".getEntity('societe', 1).")"; if ($filtersarray[0] <> 'all') $sql.= " AND cs.fk_categorie = c.rowid"; if ($filtersarray[0] <> 'all') $sql.= " AND cs.fk_societe = sp.fk_soc"; @@ -171,6 +172,7 @@ class mailing_contacts3 extends MailingTargets $sql.= " WHERE s.rowid = c.fk_soc"; $sql.= " AND c.entity IN (".getEntity('societe', 1).")"; $sql.= " AND c.email != ''"; // Note that null != '' is false + $sql.= " AND c.no_email = 0"; /* $sql = "SELECT count(distinct(sp.email)) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp,"; @@ -207,6 +209,7 @@ class mailing_contacts3 extends MailingTargets $sql.= " ".MAIN_DB_PREFIX."categorie_societe as cs"; $sql.= " WHERE s.rowid = sp.fk_soc"; $sql.= " AND sp.email != ''"; // Note that null != '' is false + $sql.= " AND sp.no_email = 0"; $sql.= " AND sp.entity IN (".getEntity('societe', 1).")"; $sql.= " AND cs.fk_categorie = c.rowid"; $sql.= " AND cs.fk_societe = sp.fk_soc"; From 39de1cb0100b8257263c11ded3901540d43a0f84 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 23 Aug 2012 08:43:29 +0200 Subject: [PATCH 3/4] Task 515 : Correction on SQL request --- htdocs/core/modules/mailings/contacts2.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/mailings/contacts2.modules.php b/htdocs/core/modules/mailings/contacts2.modules.php index bb309037f64..5332210fe73 100755 --- a/htdocs/core/modules/mailings/contacts2.modules.php +++ b/htdocs/core/modules/mailings/contacts2.modules.php @@ -191,7 +191,7 @@ class mailing_contacts2 extends MailingTargets $sql.= " WHERE s.rowid = sp.fk_soc"; $sql.= " AND sp.entity IN (".getEntity('societe', 1).")"; $sql.= " AND sp.email != ''"; // Note that null != '' is false - $sql.= " AND sp.email = 0"; + $sql.= " AND sp.no_email = 0"; $sql.= " AND (sp.poste IS NOT NULL AND sp.poste != '')"; $sql.= " GROUP BY sp.poste"; $sql.= " ORDER BY sp.poste"; From 332ee652c38899decb7d76a89ed2250c1d36f520 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 23 Aug 2012 08:45:45 +0200 Subject: [PATCH 4/4] Clear action was called with a rowid instead of id (rowid is for a target of the emailing, id is for the emailing) --- htdocs/comm/mailing/cibles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index f092d263999..8f4c722f4b6 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -347,7 +347,7 @@ if ($object->fetch($id) >= 0) print ''; print '
'; - print '
'; + print ''; print ''; print_titre($langs->trans("ToClearAllRecipientsClickHere")); print '';