Better target emailing status mangement
This commit is contained in:
parent
c57c7fdca6
commit
c19eabf711
@ -2,6 +2,7 @@
|
|||||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@uers.sourceforge.net>
|
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@uers.sourceforge.net>
|
||||||
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
|
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -26,6 +27,7 @@
|
|||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmailing.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
@ -54,6 +56,7 @@ $action=GETPOST("action");
|
|||||||
$search_lastname=GETPOST("search_lastname");
|
$search_lastname=GETPOST("search_lastname");
|
||||||
$search_firstname=GETPOST("search_firstname");
|
$search_firstname=GETPOST("search_firstname");
|
||||||
$search_email=GETPOST("search_email");
|
$search_email=GETPOST("search_email");
|
||||||
|
$search_dest_status=GETPOST('search_dest_status');
|
||||||
|
|
||||||
// Search modules dirs
|
// Search modules dirs
|
||||||
$modulesdir = dolGetModulesDirs('/mailings');
|
$modulesdir = dolGetModulesDirs('/mailings');
|
||||||
@ -168,6 +171,7 @@ if ($_POST["button_removefilter"])
|
|||||||
llxHeader('',$langs->trans("Mailing"),'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing');
|
llxHeader('',$langs->trans("Mailing"),'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing');
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
$formmailing = new FormMailing($db);
|
||||||
|
|
||||||
if ($object->fetch($id) >= 0)
|
if ($object->fetch($id) >= 0)
|
||||||
{
|
{
|
||||||
@ -220,7 +224,7 @@ if ($object->fetch($id) >= 0)
|
|||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
$allowaddtarget=($object->statut == 0 || $object->statut == 1);
|
$allowaddtarget=($object->statut == 0);
|
||||||
|
|
||||||
// Show email selectors
|
// Show email selectors
|
||||||
if ($allowaddtarget && $user->rights->mailing->creer)
|
if ($allowaddtarget && $user->rights->mailing->creer)
|
||||||
@ -357,6 +361,7 @@ if ($object->fetch($id) >= 0)
|
|||||||
if ($search_lastname) $sql.= " AND mc.lastname LIKE '%".$db->escape($search_lastname)."%'";
|
if ($search_lastname) $sql.= " AND mc.lastname LIKE '%".$db->escape($search_lastname)."%'";
|
||||||
if ($search_firstname) $sql.= " AND mc.firstname LIKE '%".$db->escape($search_firstname)."%'";
|
if ($search_firstname) $sql.= " AND mc.firstname LIKE '%".$db->escape($search_firstname)."%'";
|
||||||
if ($search_email) $sql.= " AND mc.email LIKE '%".$db->escape($search_email)."%'";
|
if ($search_email) $sql.= " AND mc.email LIKE '%".$db->escape($search_email)."%'";
|
||||||
|
if (!empty($search_dest_status)) $sql.= " AND mc.statut=".$db->escape($search_dest_status)." ";
|
||||||
$sql .= $db->order($sortfield,$sortorder);
|
$sql .= $db->order($sortfield,$sortorder);
|
||||||
$sql .= $db->plimit($conf->liste_limit+1, $offset);
|
$sql .= $db->plimit($conf->liste_limit+1, $offset);
|
||||||
|
|
||||||
@ -376,7 +381,9 @@ if ($object->fetch($id) >= 0)
|
|||||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||||
|
|
||||||
$cleartext='<br></div><div>'.$langs->trans("ToClearAllRecipientsClickHere").': '.'<input type="submit" name="clearlist" class="button" value="'.$langs->trans("TargetsReset").'">';
|
if ($allowaddtarget) {
|
||||||
|
$cleartext='<br></div><div>'.$langs->trans("ToClearAllRecipientsClickHere").': '.'<input type="submit" name="clearlist" class="button" value="'.$langs->trans("TargetsReset").'">';
|
||||||
|
}
|
||||||
|
|
||||||
print_barre_liste($langs->trans("MailSelectedRecipients").$cleartext,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,"",$num,$object->nbemail,'');
|
print_barre_liste($langs->trans("MailSelectedRecipients").$cleartext,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,"",$num,$object->nbemail,'');
|
||||||
|
|
||||||
@ -399,7 +406,7 @@ if ($object->fetch($id) >= 0)
|
|||||||
print_liste_field_titre($langs->trans("OtherInformations"),$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("OtherInformations"),$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Source"),$_SERVER["PHP_SELF"],"",$param,"",'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Source"),$_SERVER["PHP_SELF"],"",$param,"",'align="center"',$sortfield,$sortorder);
|
||||||
|
|
||||||
// Date sendinf
|
// Date sending
|
||||||
if ($object->statut < 2)
|
if ($object->statut < 2)
|
||||||
{
|
{
|
||||||
print '<td class="liste_titre"> </td>';
|
print '<td class="liste_titre"> </td>';
|
||||||
@ -412,6 +419,11 @@ if ($object->fetch($id) >= 0)
|
|||||||
// Statut
|
// Statut
|
||||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"mc.statut",$param,'','align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"mc.statut",$param,'','align="right"',$sortfield,$sortorder);
|
||||||
|
|
||||||
|
//Search Icon
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print ' ';
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Ligne des champs de filtres
|
// Ligne des champs de filtres
|
||||||
@ -433,7 +445,20 @@ if ($object->fetch($id) >= 0)
|
|||||||
print ' ';
|
print ' ';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
// Source
|
// Source
|
||||||
print '<td class="liste_titre" align="right" colspan="3">';
|
print '<td class="liste_titre">';
|
||||||
|
print ' ';
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
// Date sending
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print ' ';
|
||||||
|
print '</td>';
|
||||||
|
//Statut
|
||||||
|
print '<td class="liste_titre" align="right">';
|
||||||
|
print $formmailing->select_destinaries_status($search_dest_status,'search_dest_status',1);
|
||||||
|
print '</td>';
|
||||||
|
//Search Icon
|
||||||
|
print '<td class="liste_titre" align="right">';
|
||||||
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||||
print ' ';
|
print ' ';
|
||||||
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
|
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
|
||||||
@ -495,7 +520,7 @@ if ($object->fetch($id) >= 0)
|
|||||||
{
|
{
|
||||||
print '<td align="center"> </td>';
|
print '<td align="center"> </td>';
|
||||||
print '<td align="right" class="nowrap">'.$langs->trans("MailingStatusNotSent");
|
print '<td align="right" class="nowrap">'.$langs->trans("MailingStatusNotSent");
|
||||||
if ($user->rights->mailing->creer) {
|
if ($user->rights->mailing->creer && $allowaddtarget) {
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$obj->rowid.$param.'">'.img_delete($langs->trans("RemoveRecipient"));
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$obj->rowid.$param.'">'.img_delete($langs->trans("RemoveRecipient"));
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -504,12 +529,12 @@ if ($object->fetch($id) >= 0)
|
|||||||
{
|
{
|
||||||
print '<td align="center">'.$obj->date_envoi.'</td>';
|
print '<td align="center">'.$obj->date_envoi.'</td>';
|
||||||
print '<td align="right" class="nowrap">';
|
print '<td align="right" class="nowrap">';
|
||||||
if ($obj->statut==-1) print $langs->trans("MailingStatusError").' '.img_error();
|
print $object::LibStatutDest($obj->statut,2);
|
||||||
if ($obj->statut==1) print $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut4');
|
|
||||||
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"),'statut5');
|
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Sreach Icon
|
||||||
|
print '<td></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
@ -60,6 +60,9 @@ class Mailing extends CommonObject
|
|||||||
|
|
||||||
var $extraparams=array();
|
var $extraparams=array();
|
||||||
|
|
||||||
|
public $statut_dest=array();
|
||||||
|
public $statuts=array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -75,6 +78,12 @@ class Mailing extends CommonObject
|
|||||||
$this->statuts[1] = 'MailingStatusValidated';
|
$this->statuts[1] = 'MailingStatusValidated';
|
||||||
$this->statuts[2] = 'MailingStatusSentPartialy';
|
$this->statuts[2] = 'MailingStatusSentPartialy';
|
||||||
$this->statuts[3] = 'MailingStatusSentCompletely';
|
$this->statuts[3] = 'MailingStatusSentCompletely';
|
||||||
|
|
||||||
|
$this->statut_dest[-1] = 'MailingStatusError';
|
||||||
|
$this->statut_dest[1] = 'MailingStatusSent';
|
||||||
|
$this->statut_dest[2] = 'MailingStatusRead';
|
||||||
|
$this->statut_dest[3] = 'MailingStatusNotContact';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -512,5 +521,60 @@ class Mailing extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renvoi le libelle d'un statut donne
|
||||||
|
*
|
||||||
|
* @param int $statut Id statut
|
||||||
|
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||||
|
* @return string Label
|
||||||
|
*/
|
||||||
|
static public function LibStatutDest($statut,$mode=0)
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
$langs->load('mails');
|
||||||
|
|
||||||
|
if ($mode == 0)
|
||||||
|
{
|
||||||
|
return $langs->trans($this->statut_dest[$statut]);
|
||||||
|
}
|
||||||
|
if ($mode == 1)
|
||||||
|
{
|
||||||
|
return $langs->trans($this->statut_dest[$statut]);
|
||||||
|
}
|
||||||
|
if ($mode == 2)
|
||||||
|
{
|
||||||
|
if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error();
|
||||||
|
if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut4');
|
||||||
|
if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6');
|
||||||
|
if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut8');
|
||||||
|
}
|
||||||
|
if ($mode == 3)
|
||||||
|
{
|
||||||
|
if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error();
|
||||||
|
if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut4');
|
||||||
|
if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6');
|
||||||
|
if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut8');
|
||||||
|
}
|
||||||
|
if ($mode == 4)
|
||||||
|
{
|
||||||
|
if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error();
|
||||||
|
if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut4');
|
||||||
|
if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6');
|
||||||
|
if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut8');
|
||||||
|
}
|
||||||
|
if ($mode == 5)
|
||||||
|
{
|
||||||
|
if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error();
|
||||||
|
if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut4');
|
||||||
|
if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6');
|
||||||
|
if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut8');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -839,7 +839,7 @@ else
|
|||||||
{
|
{
|
||||||
print "\n\n<div class=\"tabsAction\">\n";
|
print "\n\n<div class=\"tabsAction\">\n";
|
||||||
|
|
||||||
if (($object->statut == 0 || $object->statut == 1) && $user->rights->mailing->creer)
|
if (($object->statut == 0) && $user->rights->mailing->creer)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$object->id.'">'.$langs->trans("EditMailing").'</a>';
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$object->id.'">'.$langs->trans("EditMailing").'</a>';
|
||||||
}
|
}
|
||||||
|
|||||||
77
htdocs/core/class/html.formmailing.class.php
Normal file
77
htdocs/core/class/html.formmailing.class.php
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2014 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 3 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 htdocs/core/class/html.formmailing.class.php
|
||||||
|
* \ingroup core
|
||||||
|
* \brief File of predefined functions for HTML forms for mailing module
|
||||||
|
*/
|
||||||
|
require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to offer components to list and upload files
|
||||||
|
*/
|
||||||
|
class FormMailing extends Form
|
||||||
|
{
|
||||||
|
public $db;
|
||||||
|
public $error;
|
||||||
|
public $errors=array();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param DoliDB $db Database handler
|
||||||
|
*/
|
||||||
|
function __construct($db)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function select_destinaries_status($selectedid='',$htmlname='dest_status', $show_empty=0) {
|
||||||
|
|
||||||
|
global $langs;
|
||||||
|
$langs->load("mails");
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
|
||||||
|
$mailing = new Mailing($this->db);
|
||||||
|
|
||||||
|
|
||||||
|
$array = $mailing->statut_dest;
|
||||||
|
//Cannot use form->selectarray because empty value is defaulted to -1 in this method and we use here status -1...
|
||||||
|
|
||||||
|
$out = '<select name="'.$htmlname.'" class="flat">';
|
||||||
|
|
||||||
|
if ($show_empty) {
|
||||||
|
$out .= '<option value=""></option>';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($mailing->statut_dest as $id=>$status) {
|
||||||
|
if ($selectedid==$id) {
|
||||||
|
$selected=" selected=selected ";
|
||||||
|
}else {
|
||||||
|
$selected="";
|
||||||
|
}
|
||||||
|
$out .= '<option '.$selected.' value="'.$id.'">'.$langs->trans($status).'</option>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$out .= '</select>';
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -148,7 +148,7 @@ class mailing_pomme extends MailingTargets
|
|||||||
|
|
||||||
// La requete doit retourner: id, email, fk_contact, name, firstname
|
// La requete doit retourner: id, email, fk_contact, name, firstname
|
||||||
$sql = "SELECT u.rowid as id, u.email as email, null as fk_contact,";
|
$sql = "SELECT u.rowid as id, u.email as email, null as fk_contact,";
|
||||||
$sql.= " u.lastname as name, u.firstname as firstname, u.civilite as civility_id, u.login, u.office_phone";
|
$sql.= " u.lastname, u.firstname as firstname, u.civilite as civility_id, u.login, u.office_phone";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||||
$sql.= " WHERE u.email <> ''"; // u.email IS NOT NULL est implicite dans ce test
|
$sql.= " WHERE u.email <> ''"; // u.email IS NOT NULL est implicite dans ce test
|
||||||
$sql.= " AND u.entity IN (0,".$conf->entity.")";
|
$sql.= " AND u.entity IN (0,".$conf->entity.")";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user