From 59f424bde3df84484cbb67513dc9ceb3205b4067 Mon Sep 17 00:00:00 2001 From: FHenry Date: Wed, 29 Feb 2012 14:32:22 +0100 Subject: [PATCH 1/2] add hook for select produit --- htdocs/fourn/commande/fiche.php | 11 +++++++++++ htdocs/fourn/facture/fiche.php | 12 ++++++++++++ htdocs/product/fournisseurs.php | 13 ++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index b30dd309167..ef5e30ff7d2 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -59,6 +59,11 @@ $projectid = GETPOST("projectid"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'commande_fournisseur', $id,''); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +$hookmanager=new HookManager($db); +$hookmanager->callHooks(array('fournordercard')); + $mesg=''; $object = new CommandeFournisseur($db); @@ -1318,6 +1323,12 @@ if ($id > 0 || ! empty($ref)) if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; + if (is_object($hookmanager)) + { + $parameters=array('filtre'=>$filtre); + echo $hookmanager->executeHooks('formCreateProductFournOptions',$parameters,$object,$action); + } + // Editor wysiwyg require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); $nbrows=ROWS_2; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 001666bea71..2769bb79adc 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -50,6 +50,11 @@ $confirm = GETPOST("confirm"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +$hookmanager=new HookManager($db); +$hookmanager->callHooks(array('fournpricecard')); + $object=new FactureFournisseur($db); @@ -1645,6 +1650,13 @@ else print ''; print ''; $form->select_produits_fournisseurs($object->socid,'','idprodfournprice','',$filtre); + + if (is_object($hookmanager)) + { + $parameters=array('filtre'=>$filtre); + echo $hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); + } + print ''; print ''; print ' '; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index b274009897a..d9a48c6d8d7 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -53,6 +53,11 @@ $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service&fournisseur',$fieldvalue,'product&product','','',$fieldtype); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +$hookmanager=new HookManager($db); +$hookmanager->callHooks(array('fournpricecard')); + $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -273,7 +278,13 @@ if ($id || $ref) } else { - print $form->select_company($_POST["id_fourn"],'id_fourn','fournisseur=1',1); + print $form->select_company(GETPOST("id_fourn"),'id_fourn','fournisseur=1',1); + + if (is_object($hookmanager)) + { + $parameters=array('filtre'=>"fournisseur=1",'html_name'=>'id_fourn','selected'=>GETPOST("id_fourn"),'showempty'=>1,'prod_id'=>$product->id); + echo $hookmanager->executeHooks('formCreateCompagnyOptions',$parameters,$object,$action); + } } print ''; From 0cf46196829bfd36e702b676c3e1b8324add3baa Mon Sep 17 00:00:00 2001 From: FHenry Date: Thu, 1 Mar 2012 14:51:07 +0100 Subject: [PATCH 2/2] Emailing campaign- unsubcribe and use of md5 tag --- htdocs/comm/mailing/cibles.php | 1 + htdocs/comm/mailing/fiche.php | 12 ++- .../modules/mailings/modules_mailings.php | 12 ++- htdocs/langs/en_US/mails.lang | 7 +- htdocs/langs/es_ES/mails.lang | 7 +- htdocs/langs/fr_FR/mails.lang | 7 +- htdocs/public/emailing/mailing-read.php | 21 +++-- htdocs/public/emailing/mailing-usubscribe.php | 94 +++++++++++++++++++ scripts/emailings/mailing-send.php | 5 +- 9 files changed, 149 insertions(+), 17 deletions(-) create mode 100644 htdocs/public/emailing/mailing-usubscribe.php diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 01cd0bd4347..14b55e80b75 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -516,6 +516,7 @@ if ($mil->fetch($id) >= 0) if ($obj->statut==-1) print $langs->trans("MailingStatusError").' '.img_error(); if ($obj->statut==1) print $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6'); if ($obj->statut==2) print $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6'); + if ($obj->statut==3) print $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut8'); print ''; } print ''; diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 7abf5287ef6..6cf95d57994 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -40,7 +40,8 @@ $message = ''; $substitutionarray=array( '__ID__' => 'IdRecord', '__EMAIL__' => 'EMail', -'__CHECK_READ__' => 'CheckMailIsRead', +'__CHECK_READ__' => 'CheckMail', +'__UNSUSCRIBE__' => 'Unsuscribe', '__LASTNAME__' => 'Lastname', '__FIRSTNAME__' => 'Firstname', '__OTHER1__' => 'Other1', @@ -52,7 +53,8 @@ $substitutionarray=array( $substitutionarrayfortest=array( '__ID__' => 'TESTIdRecord', '__EMAIL__' => 'TESTEMail', -'__CHECK_READ__' => 'TESTCheckMailIsRead', +'__CHECK_READ__' => 'TESTCheckMail', +'__UNSUSCRIBE__' => 'TESTUnsuscribe', '__LASTNAME__' => 'TESTLastname', '__FIRSTNAME__' => 'TESTFirstname', '__OTHER1__' => 'TESTOther1', @@ -135,7 +137,7 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes') // On choisit les mails non deja envoyes pour ce mailing (statut=0) // ou envoyes en erreur (statut=-1) - $sql = "SELECT mc.rowid, mc.nom, mc.prenom, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type"; + $sql = "SELECT mc.rowid, mc.nom, mc.prenom, 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 = ".$id; @@ -180,7 +182,8 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes') $substitutionarray=array( '__ID__' => $obj->source_id, '__EMAIL__' => $obj->email, - '__CHECK_READ__' => '', + '__CHECK_READ__' => '', + '__UNSUSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'', '__LASTNAME__' => $obj->nom, '__FIRSTNAME__' => $obj->prenom, '__OTHER1__' => $other1, @@ -1030,6 +1033,7 @@ else print '__ID__ = '.$langs->trans("IdRecord").'
'; print '__EMAIL__ = '.$langs->trans("EMail").'
'; print '__CHECK_READ__ = '.$langs->trans("CheckRead").'
'; + print '__UNSUSCRIBE__ = '.$langs->trans("MailUnsubcribe").'
'; print '__LASTNAME__ = '.$langs->trans("Lastname").'
'; print '__FIRSTNAME__ = '.$langs->trans("Firstname").'
'; print '__OTHER1__ = '.$langs->trans("Other").'1
'; diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 1f468399cf5..bc5939676a7 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -153,7 +153,7 @@ class MailingTargets // This can't be abstract as it is used for some method $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " (fk_mailing,"; $sql .= " fk_contact,"; - $sql .= " nom, prenom, email, other, source_url, source_id, source_type)"; + $sql .= " nom, prenom, email, other, source_url, source_id, tag, source_type)"; $sql .= " VALUES (".$mailing_id.","; $sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .","; $sql .= "'".$this->db->escape($cibles[$i]['name'])."',"; @@ -162,6 +162,7 @@ class MailingTargets // This can't be abstract as it is used for some method $sql .= "'".$this->db->escape($cibles[$i]['other'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',"; + $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id))."',"; $sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')"; $result=$this->db->query($sql); if ($result) @@ -183,6 +184,15 @@ class MailingTargets // This can't be abstract as it is used for some method dol_syslog(get_class($this)."::add_to_target: mailing ".$j." targets added"); + //Update the status to show poelple that don't want to be contacted anymore' + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; + $sql .= " SET statut=3"; + $sql .= " WHERE fk_mailing=".$mailing_id." and email in (SELECT email FROM ".MAIN_DB_PREFIX."societe where fk_stcomm=-1)"; + $result=$this->db->query($sql); + + dol_syslog("MailingTargets::add_to_target: mailing update status to display people that do not want to be contacted sql:".$sql); + + $this->update_nb($mailing_id); $this->db->commit(); diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 04eddbf9791..9ada97fc97b 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -39,12 +39,14 @@ MailingStatusDraft=Draft MailingStatusValidated=Validated MailingStatusApproved=Approved MailingStatusSent=Sent -MailingStatusRead=Read MailingStatusSentPartialy=Sent partialy MailingStatusSentCompletely=Sent completely MailingStatusError=Error MailingStatusNotSent=Not sent MailSuccessfulySent=Email successfully sent (from %s to %s) +MailUnsubcribe=Unsubscribe +Unsuscribe=Unsubscribe +MailingStatusNotContact=Don't contact anymore ErrorMailRecipientIsEmpty=Email recipient is empty WarningNoEMailsAdded=No new Email to add to recipient's list. ConfirmValidMailing=Are you sure you want to validate this emailing ? @@ -70,6 +72,9 @@ CloneReceivers=Cloner recipients DateLastSend=Date of last sending DateSending=Date sending SentTo=Sent to %s +MailingStatusRead=Read +CheckRead=Read Receipt +YourMailUnsubcribeOK=The email %s is correctly unsubcribe from mailing list # Libelle des modules de liste de destinataires mailing MailingModuleDescContactCompanies=Contacts of all third parties (customer, prospect, supplier, ...) diff --git a/htdocs/langs/es_ES/mails.lang b/htdocs/langs/es_ES/mails.lang index 3957b886cae..c068a7d57d4 100644 --- a/htdocs/langs/es_ES/mails.lang +++ b/htdocs/langs/es_ES/mails.lang @@ -39,12 +39,13 @@ MailingStatusDraft=Borrador MailingStatusValidated=Validado MailingStatusApproved=Aprovado MailingStatusSent=Enviado -MailingStatusRead=Leido MailingStatusSentPartialy=Enviado parcialmente MailingStatusSentCompletely=Enviado completamente MailingStatusError=Error MailingStatusNotSent=No enviado MailSuccessfulySent=E-Mail enviado correctamente (de %s a %s) +MailUnsubcribe=Desuscribe +Unsuscribe=Desuscribe ErrorMailRecipientIsEmpty=La dirección del destinatario está vacía WarningNoEMailsAdded=Ningún nuevo E-Mailing a añadir a la lista destinatarios. ConfirmValidMailing=¿Confirma la validación del E-Mailing? @@ -70,6 +71,10 @@ CloneReceivers=Clonar destinatarios DateLastSend=Fecha último envío DateSending=Fecha envío SentTo=Enviado a %s +MailingStatusRead=Leido +CheckRead=Confirmación de lectura +YourMailUnsubcribeOK=El correo electrónico %s es correcta desuscribe. + # Libelle des modules de liste de destinataires mailing= MailingModuleDescContactCompanies=Contactos de terceros (clientes potenciales, clientes, proveedores...) MailingModuleDescDolibarrUsers=Usuarios de Dolibarr diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index 591000e00d8..c80a79615aa 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -39,12 +39,14 @@ MailingStatusDraft=Brouillon MailingStatusValidated=Validé MailingStatusApproved=Approuvé MailingStatusSent=Envoyé -MailingStatusRead=Lu MailingStatusSentPartialy=Envoyé partiellement MailingStatusSentCompletely=Envoyé complètement MailingStatusError=Erreur MailingStatusNotSent=Non envoyé MailSuccessfulySent=Mail correctement envoyé (de %s à %s) +MailUnsubcribe=Desinscription +Unsuscribe=Desinscription +MailingStatusNotContact=Ne plus contacter ErrorMailRecipientIsEmpty=L'adresse du destinataire est vide WarningNoEMailsAdded=Aucun nouvel e-mail à ajouter à la liste des destinataires. ConfirmValidMailing=Confirmez-vous la validation du mailing ? @@ -70,6 +72,9 @@ CloneReceivers=Cloner destinataires DateLastSend=Date du dernier envoi DateSending=Date envoi SentTo=Envoyés à %s +MailingStatusRead=Lu +CheckRead=Accusé de lecture +YourMailUnsubcribeOK=L'adresse e-mail %s est bien désincrite de la liste. # Libelle des modules de liste de destinataires mailing MailingModuleDescContactCompanies=Contacts de tiers (prospects, clients, fournisseurs...) diff --git a/htdocs/public/emailing/mailing-read.php b/htdocs/public/emailing/mailing-read.php index e1271a71f41..9b5721b70da 100644 --- a/htdocs/public/emailing/mailing-read.php +++ b/htdocs/public/emailing/mailing-read.php @@ -31,16 +31,23 @@ define("NOCSRFCHECK",1); // We accept to go on this page from external web site. require("../../main.inc.php"); -$id=GETPOST('mail_cbl_id'); -$mail_reader=GETPOST('mail'); +$id=GETPOST('tag'); -$statut='2'; +if ($id!='') +{ + $statut='2'; + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".$statut." WHERE tag='".$id."'"; + dol_syslog("public/emailing/mailing-read.php : Mail read : ".$sql, LOG_DEBUG); + + $resql=$db->query($sql); + + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag='".$id."')"; + dol_syslog("public/emailing/mailing-read.php : Mail read : ".$sql, LOG_DEBUG); + + $resql=$db->query($sql); +} -$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".$statut." WHERE rowid=".$id." AND email='".$mail_reader."'"; -dol_syslog("public/emailing/mailing-read.php : Mail read : ".$sql, LOG_DEBUG); - -$resql=$db->query($sql); $db->close(); ?> diff --git a/htdocs/public/emailing/mailing-usubscribe.php b/htdocs/public/emailing/mailing-usubscribe.php new file mode 100644 index 00000000000..a46946b9661 --- /dev/null +++ b/htdocs/public/emailing/mailing-usubscribe.php @@ -0,0 +1,94 @@ + + * Copyright (C) 2005-2011 Laurent Destailleur + * Copyright (C) 2012 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +/** + * \file scripts/emailings/mailing-read.php + * \ingroup mailing + * \brief Script use to update unsubcribe contact to prospect mailing list + */ + +define("NOLOGIN",1); // This means this output page does not require to be logged. +define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + +require("../../main.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); + +global $user, $conf, $langs; + +$langs->load("main"); +$langs->load("mails"); + +$id=GETPOST('tag'); +$unsuscrib=GETPOST('unsuscrib'); + + +if (($id!='') && ($unsuscrib=='1')) +{ + //Udate status of mail in Destinaries maling list + $statut='3'; + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".$statut." WHERE tag='".$id."'"; + dol_syslog("public/emailing/mailing-read.php : Mail unsubcribe : ".$sql, LOG_DEBUG); + + $resql=$db->query($sql); + + //Update status communication of prospect + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=-1 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag='".$id."' AND source_type='thirdparty')"; + dol_syslog("public/emailing/mailing-read.php : Mail unsubcribe : ".$sql, LOG_DEBUG); + + $resql=$db->query($sql); + + $sql = "SELECT mc.email"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; + $sql .= " WHERE mc.tag='".$id."'"; + + $resql=$db->query($sql); + + $obj = $db->fetch_object($resql); + + header("Content-type: text/html; charset=".$conf->file->character_set_client); + + print ''; + print "\n"; + print "\n"; + print "\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print "".$langs->trans("MailUnsubcribe")."\n"; + print ''."\n"; + print ''; + + print "\n"; + print ''."\n"; + print '
'; + print $langs->trans("YourMailUnsubcribeOK",$obj->email)."
\n"; + print '
'; + print "\n"; + print "\n"; + + +} + +$db->close(); +?> diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 13d28f95eda..f3923ed0567 100644 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -93,7 +93,7 @@ $nbok=0; $nbko=0; // On choisit les mails non deja envoyes pour ce mailing (statut=0) // ou envoyes en erreur (statut=-1) -$sql = "SELECT mc.rowid, mc.nom as lastname, mc.prenom as firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type"; +$sql = "SELECT mc.rowid, mc.nom as lastname, mc.prenom as 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 = ".$id; @@ -135,7 +135,8 @@ if ($resql) $substitutionarray=array( '__ID__' => $obj->source_id, '__EMAIL__' => $obj->email, - '__CHECK_READ__' => '', + '__CHECK_READ__' => '', + '__UNSUSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'', '__LASTNAME__' => $obj->lastname, '__FIRSTNAME__' => $obj->firstname, '__OTHER1__' => $other1,