Skip to content

Commit

Permalink
Merge pull request #116 from FHenry/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
hregis committed Mar 1, 2012
2 parents e0d8fae + 0cf4619 commit 2d3854a
Show file tree
Hide file tree
Showing 12 changed files with 186 additions and 20 deletions.
1 change: 1 addition & 0 deletions htdocs/comm/mailing/cibles.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
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 '</td>';
}
print '</tr>';
Expand Down
12 changes: 8 additions & 4 deletions htdocs/comm/mailing/fiche.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
$substitutionarray=array(
'__ID__' => 'IdRecord',
'__EMAIL__' => 'EMail',
'__CHECK_READ__' => 'CheckMailIsRead',
'__CHECK_READ__' => 'CheckMail',
'__UNSUSCRIBE__' => 'Unsuscribe',
'__LASTNAME__' => 'Lastname',
'__FIRSTNAME__' => 'Firstname',
'__OTHER1__' => 'Other1',
Expand All @@ -52,7 +53,8 @@
$substitutionarrayfortest=array(
'__ID__' => 'TESTIdRecord',
'__EMAIL__' => 'TESTEMail',
'__CHECK_READ__' => 'TESTCheckMailIsRead',
'__CHECK_READ__' => 'TESTCheckMail',
'__UNSUSCRIBE__' => 'TESTUnsuscribe',
'__LASTNAME__' => 'TESTLastname',
'__FIRSTNAME__' => 'TESTFirstname',
'__OTHER1__' => 'TESTOther1',
Expand Down Expand Up @@ -135,7 +137,7 @@

// 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;

Expand Down Expand Up @@ -180,7 +182,8 @@
$substitutionarray=array(
'__ID__' => $obj->source_id,
'__EMAIL__' => $obj->email,
'__CHECK_READ__' => '<IMG SRC="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?mail_cbl_id='.$obj->rowid.'&mail='.$obj->email.'" style="width:0px;height:0px" border="0"/>',
'__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'" style="width:0px;height:0px" border="0"/>',
'__UNSUSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-usubscribe.php?tag='.$obj->tag.'&unsuscrib=1" target="_blank"/>'.$langs->trans("MailUnsubcribe").'</a>',
'__LASTNAME__' => $obj->nom,
'__FIRSTNAME__' => $obj->prenom,
'__OTHER1__' => $other1,
Expand Down Expand Up @@ -1030,6 +1033,7 @@
print '__ID__ = '.$langs->trans("IdRecord").'<br>';
print '__EMAIL__ = '.$langs->trans("EMail").'<br>';
print '__CHECK_READ__ = '.$langs->trans("CheckRead").'<br>';
print '__UNSUSCRIBE__ = '.$langs->trans("MailUnsubcribe").'<br>';
print '__LASTNAME__ = '.$langs->trans("Lastname").'<br>';
print '__FIRSTNAME__ = '.$langs->trans("Firstname").'<br>';
print '__OTHER1__ = '.$langs->trans("Other").'1<br>';
Expand Down
12 changes: 11 additions & 1 deletion htdocs/core/modules/mailings/modules_mailings.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function add_to_target($mailing_id, $cibles)
$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'])."',";
Expand All @@ -162,6 +162,7 @@ function add_to_target($mailing_id, $cibles)
$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)
Expand All @@ -183,6 +184,15 @@ function add_to_target($mailing_id, $cibles)

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();
Expand Down
11 changes: 11 additions & 0 deletions htdocs/fourn/commande/fiche.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
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);
Expand Down Expand Up @@ -1322,6 +1327,12 @@

if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '<br>';

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;
Expand Down
12 changes: 12 additions & 0 deletions htdocs/fourn/facture/fiche.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
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);


Expand Down Expand Up @@ -1643,6 +1648,13 @@
print '<tr '.$bc[$var].'>';
print '<td colspan="4">';
$form->select_produits_fournisseurs($object->socid,'','idprodfournprice','',$filtre);

if (is_object($hookmanager))
{
$parameters=array('filtre'=>$filtre);
echo $hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action);
}

print '</td>';
print '<td align="right"><input type="text" name="qty" value="1" size="1"></td>';
print '<td>&nbsp;</td>';
Expand Down
7 changes: 6 additions & 1 deletion htdocs/langs/en_US/mails.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?
Expand All @@ -70,6 +72,9 @@ CloneReceivers=Cloner recipients
DateLastSend=Date of last sending
DateSending=Date sending
SentTo=Sent to <b>%s</b>
MailingStatusRead=Read
CheckRead=Read Receipt
YourMailUnsubcribeOK=The email <b>%s</b> is correctly unsubcribe from mailing list

# Libelle des modules de liste de destinataires mailing
MailingModuleDescContactCompanies=Contacts of all third parties (customer, prospect, supplier, ...)
Expand Down
7 changes: 6 additions & 1 deletion htdocs/langs/es_ES/mails.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -70,6 +71,10 @@ CloneReceivers=Clonar destinatarios
DateLastSend=Fecha último envío
DateSending=Fecha envío
SentTo=Enviado a <b>%s</b>
MailingStatusRead=Leido
CheckRead=Confirmación de lectura
YourMailUnsubcribeOK=El correo electrónico <b>%s</b> es correcta desuscribe.

# Libelle des modules de liste de destinataires mailing=
MailingModuleDescContactCompanies=Contactos de terceros (clientes potenciales, clientes, proveedores...)
MailingModuleDescDolibarrUsers=Usuarios de Dolibarr
Expand Down
7 changes: 6 additions & 1 deletion htdocs/langs/fr_FR/mails.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?
Expand All @@ -70,6 +72,9 @@ CloneReceivers=Cloner destinataires
DateLastSend=Date du dernier envoi
DateSending=Date envoi
SentTo=Envoyés à <b>%s</b>
MailingStatusRead=Lu
CheckRead=Accusé de lecture
YourMailUnsubcribeOK=L'adresse e-mail <b>%s</b> est bien désincrite de la liste.

# Libelle des modules de liste de destinataires mailing
MailingModuleDescContactCompanies=Contacts de tiers (prospects, clients, fournisseurs...)
Expand Down
13 changes: 12 additions & 1 deletion htdocs/product/fournisseurs.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
$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');
Expand Down Expand Up @@ -273,7 +278,13 @@
}
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 '</td></tr>';

Expand Down
25 changes: 16 additions & 9 deletions htdocs/public/emailing/mailing-read.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,23 @@

require("../../main.inc.php");

$id=GETPOST('mail_cbl_id');
$mail_reader=GETPOST('mail');
$id=GETPOST('tag');


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);
}


$statut='2';

$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();
?>
94 changes: 94 additions & 0 deletions htdocs/public/emailing/mailing-usubscribe.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
/*
* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro>
*
* 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 <http://www.gnu.org/licenses/>.
*/


/**
* \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 '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
print "\n";
print "<html>\n";
print "<head>\n";
print '<meta name="robots" content="noindex,nofollow">'."\n";
print '<meta name="keywords" content="dolibarr,mailing">'."\n";
print '<meta name="description" content="Welcome on Dolibarr Mailing unsubcribe">'."\n";
print "<title>".$langs->trans("MailUnsubcribe")."</title>\n";
print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.$conf->css.'?lang='.$langs->defaultlang.'">'."\n";
print '<style type="text/css">';
print '.CTableRow1 { margin: 1px; padding: 3px; font: 12px verdana,arial; background: #e6E6eE; color: #000000; -moz-border-radius-topleft:6px; -moz-border-radius-topright:6px; -moz-border-radius-bottomleft:6px; -moz-border-radius-bottomright:6px;}';
print '.CTableRow2 { margin: 1px; padding: 3px; font: 12px verdana,arial; background: #FFFFFF; color: #000000; -moz-border-radius-topleft:6px; -moz-border-radius-topright:6px; -moz-border-radius-bottomleft:6px; -moz-border-radius-bottomright:6px;}';
print '</style>';

print "</head>\n";
print '<body style="margin: 20px;">'."\n";
print '<table><tr><td style="text_align:center;">';
print $langs->trans("YourMailUnsubcribeOK",$obj->email)."<br>\n";
print '</td></tr></table>';
print "</body>\n";
print "</html>\n";


}

$db->close();
?>
5 changes: 3 additions & 2 deletions scripts/emailings/mailing-send.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

// 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;

Expand Down Expand Up @@ -135,7 +135,8 @@
$substitutionarray=array(
'__ID__' => $obj->source_id,
'__EMAIL__' => $obj->email,
'__CHECK_READ__' => '<IMG SRC="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?mail_cbl_id='.$obj->rowid.'&mail='.$obj->email.'" style="width:0px;height:0px" border="0"/>',
'__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'" style="width:0px;height:0px" border="0"/>',
'__UNSUSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-usubscribe.php?tag='.$obj->tag.'&unsuscrib=1" target="_blank"/>'.$langs->trans("MailUnsubcribe").'</a>',
'__LASTNAME__' => $obj->lastname,
'__FIRSTNAME__' => $obj->firstname,
'__OTHER1__' => $other1,
Expand Down

0 comments on commit 2d3854a

Please sign in to comment.