2005-01-04 17:24:44 +01:00
|
|
|
|
<?php
|
2009-02-16 21:30:30 +01:00
|
|
|
|
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
|
|
|
|
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
2012-12-30 15:13:49 +01:00
|
|
|
|
* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
|
2005-01-04 17:24:44 +01:00
|
|
|
|
*
|
|
|
|
|
|
* 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
|
2013-01-16 15:36:08 +01:00
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2005-01-04 17:24:44 +01:00
|
|
|
|
* (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
|
2011-08-03 02:45:22 +02:00
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-01-04 17:24:44 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2005-02-26 20:06:39 +01:00
|
|
|
|
/**
|
2009-08-12 14:59:14 +02:00
|
|
|
|
* \file htdocs/comm/mailing/index.php
|
|
|
|
|
|
* \ingroup mailing
|
|
|
|
|
|
* \brief Page accueil de la zone mailing
|
|
|
|
|
|
*/
|
2009-02-16 21:30:30 +01:00
|
|
|
|
|
2012-08-22 23:24:21 +02:00
|
|
|
|
require '../../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
|
require_once DOL_DOCUMENT_ROOT .'/comm/mailing/class/mailing.class.php';
|
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
2005-01-04 17:24:44 +01:00
|
|
|
|
|
2018-05-26 20:32:23 +02:00
|
|
|
|
// Load translation files required by the page
|
|
|
|
|
|
$langs->loadLangs(array('commercial', 'orders'));
|
2005-01-04 17:24:44 +01:00
|
|
|
|
|
2013-01-02 18:43:59 +01:00
|
|
|
|
|
2013-01-10 08:27:12 +01:00
|
|
|
|
// Security check
|
|
|
|
|
|
$result=restrictedArea($user,'mailing');
|
2009-02-16 21:30:30 +01:00
|
|
|
|
|
2005-04-07 01:49:06 +02:00
|
|
|
|
|
2005-01-04 17:24:44 +01:00
|
|
|
|
/*
|
2008-06-16 16:12:02 +02:00
|
|
|
|
* View
|
2005-01-04 17:24:44 +01:00
|
|
|
|
*/
|
2009-02-16 21:30:30 +01:00
|
|
|
|
|
2009-08-24 19:11:30 +02:00
|
|
|
|
$help_url='EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
|
|
|
|
|
|
llxHeader('','EMailing',$help_url);
|
2005-01-04 17:24:44 +01:00
|
|
|
|
|
2015-09-24 18:33:48 +02:00
|
|
|
|
print load_fiche_titre($langs->trans("MailingArea"));
|
2005-01-04 17:24:44 +01:00
|
|
|
|
|
2013-03-16 14:53:15 +01:00
|
|
|
|
//print '<table class="notopnoleftnoright" width="100%">';
|
|
|
|
|
|
//print '<tr><td valign="top" width="30%" class="notopnoleft">';
|
2013-03-30 14:27:13 +01:00
|
|
|
|
print '<div class="fichecenter"><div class="fichethirdleft">';
|
2005-01-04 17:24:44 +01:00
|
|
|
|
|
2005-05-14 02:36:01 +02:00
|
|
|
|
|
2017-02-21 14:17:44 +01:00
|
|
|
|
//if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
|
|
|
|
|
|
//{
|
|
|
|
|
|
// Recherche emails
|
|
|
|
|
|
print '<form method="post" action="'.DOL_URL_ROOT.'/comm/mailing/list.php">';
|
|
|
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
|
|
|
|
print '<table class="noborder nohover" width="100%">';
|
|
|
|
|
|
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAMailing").'</td></tr>';
|
2017-04-14 13:02:29 +02:00
|
|
|
|
print '<tr class="oddeven"><td class="nowrap">';
|
2017-02-21 14:17:44 +01:00
|
|
|
|
print $langs->trans("Ref").':</td><td><input type="text" class="flat inputsearch" name="sref"></td>';
|
|
|
|
|
|
print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
|
2017-04-14 13:02:29 +02:00
|
|
|
|
print '<tr class="oddeven"><td class="nowrap">';
|
2017-02-21 14:17:44 +01:00
|
|
|
|
print $langs->trans("Other").':</td><td><input type="text" class="flat inputsearch" name="sall"></td>';
|
2018-04-22 19:27:37 +02:00
|
|
|
|
|
2017-02-21 14:17:44 +01:00
|
|
|
|
print "</table></form><br>\n";
|
|
|
|
|
|
//}
|
2005-05-14 02:36:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
2005-02-12 18:41:13 +01:00
|
|
|
|
// Affiche stats de tous les modules de destinataires mailings
|
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
|
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("TargetsStatistics").'</td></tr>';
|
2005-01-04 17:24:44 +01:00
|
|
|
|
|
2011-10-24 14:11:49 +02:00
|
|
|
|
$dir=DOL_DOCUMENT_ROOT."/core/modules/mailings";
|
2005-02-12 18:41:13 +01:00
|
|
|
|
$handle=opendir($dir);
|
2005-01-04 17:24:44 +01:00
|
|
|
|
|
2010-12-15 19:15:08 +01:00
|
|
|
|
if (is_resource($handle))
|
2005-01-04 17:24:44 +01:00
|
|
|
|
{
|
2010-12-15 19:15:08 +01:00
|
|
|
|
while (($file = readdir($handle))!==false)
|
2005-01-04 17:24:44 +01:00
|
|
|
|
{
|
2010-12-15 19:15:08 +01:00
|
|
|
|
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
|
2005-03-05 20:17:21 +01:00
|
|
|
|
{
|
2010-12-15 19:15:08 +01:00
|
|
|
|
if (preg_match("/(.*)\.(.*)\.(.*)/i",$file,$reg))
|
|
|
|
|
|
{
|
|
|
|
|
|
$modulename=$reg[1];
|
|
|
|
|
|
if ($modulename == 'example') continue;
|
2005-02-12 18:41:13 +01:00
|
|
|
|
|
2015-11-06 09:46:18 +01:00
|
|
|
|
// Loading Class
|
2010-12-15 19:15:08 +01:00
|
|
|
|
$file = $dir."/".$modulename.".modules.php";
|
|
|
|
|
|
$classname = "mailing_".$modulename;
|
2012-08-22 23:11:24 +02:00
|
|
|
|
require_once $file;
|
2010-12-15 19:15:08 +01:00
|
|
|
|
$mailmodule = new $classname($db);
|
2009-02-16 21:30:30 +01:00
|
|
|
|
|
2010-12-15 19:15:08 +01:00
|
|
|
|
$qualified=1;
|
|
|
|
|
|
foreach ($mailmodule->require_module as $key)
|
2005-02-12 18:41:13 +01:00
|
|
|
|
{
|
2010-12-15 19:15:08 +01:00
|
|
|
|
if (! $conf->$key->enabled || (! $user->admin && $mailmodule->require_admin))
|
|
|
|
|
|
{
|
|
|
|
|
|
$qualified=0;
|
|
|
|
|
|
//print "Les pr<70>requis d'activation du module mailing ne sont pas respect<63>s. Il ne sera pas actif";
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2005-03-05 20:17:21 +01:00
|
|
|
|
}
|
2005-03-15 17:32:24 +01:00
|
|
|
|
|
2010-12-15 19:15:08 +01:00
|
|
|
|
// Si le module mailing est qualifi<66>
|
|
|
|
|
|
if ($qualified)
|
2005-02-12 18:41:13 +01:00
|
|
|
|
{
|
2010-12-15 19:15:08 +01:00
|
|
|
|
foreach ($mailmodule->getSqlArrayForStats() as $sql)
|
2005-03-05 20:17:21 +01:00
|
|
|
|
{
|
2017-04-14 11:22:48 +02:00
|
|
|
|
print '<tr class="oddeven">';
|
2009-02-16 21:30:30 +01:00
|
|
|
|
|
2010-12-15 19:15:08 +01:00
|
|
|
|
$result=$db->query($sql);
|
|
|
|
|
|
if ($result)
|
|
|
|
|
|
{
|
|
|
|
|
|
$num = $db->num_rows($result);
|
2009-02-16 21:30:30 +01:00
|
|
|
|
|
2010-12-15 19:15:08 +01:00
|
|
|
|
$i = 0;
|
|
|
|
|
|
|
|
|
|
|
|
while ($i < $num )
|
|
|
|
|
|
{
|
|
|
|
|
|
$obj = $db->fetch_object($result);
|
|
|
|
|
|
print '<td>'.img_object('',$mailmodule->picto).' '.$obj->label.'</td><td align="right">'.$obj->nb.'<td>';
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$db->free($result);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2005-03-05 20:17:21 +01:00
|
|
|
|
{
|
2010-12-15 19:15:08 +01:00
|
|
|
|
dol_print_error($db);
|
2005-03-05 20:17:21 +01:00
|
|
|
|
}
|
2010-12-15 19:15:08 +01:00
|
|
|
|
print '</tr>';
|
2009-02-16 21:30:30 +01:00
|
|
|
|
}
|
2005-02-12 18:41:13 +01:00
|
|
|
|
}
|
2009-02-16 21:30:30 +01:00
|
|
|
|
}
|
2005-02-12 18:41:13 +01:00
|
|
|
|
}
|
2005-01-04 17:24:44 +01:00
|
|
|
|
}
|
2010-12-15 19:15:08 +01:00
|
|
|
|
closedir($handle);
|
2005-02-12 18:41:13 +01:00
|
|
|
|
}
|
2005-01-04 17:24:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
2005-02-12 18:41:13 +01:00
|
|
|
|
print "</table><br>";
|
2005-01-04 17:24:44 +01:00
|
|
|
|
|
2013-03-16 14:53:15 +01:00
|
|
|
|
|
|
|
|
|
|
//print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
|
2013-03-30 14:27:13 +01:00
|
|
|
|
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
2005-01-04 17:24:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-02-16 21:30:30 +01:00
|
|
|
|
* List of last emailings
|
2005-01-04 17:24:44 +01:00
|
|
|
|
*/
|
2009-02-16 21:30:30 +01:00
|
|
|
|
$limit=10;
|
|
|
|
|
|
$sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat";
|
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."mailing as m";
|
|
|
|
|
|
$sql.= " ORDER BY m.date_creat DESC";
|
|
|
|
|
|
$sql.= " LIMIT ".$limit;
|
2005-02-26 20:06:39 +01:00
|
|
|
|
$result=$db->query($sql);
|
2009-02-16 21:30:30 +01:00
|
|
|
|
if ($result)
|
2005-01-04 17:24:44 +01:00
|
|
|
|
{
|
2005-02-26 20:06:39 +01:00
|
|
|
|
print '<table class="noborder" width="100%">';
|
2005-08-25 18:55:11 +02:00
|
|
|
|
print '<tr class="liste_titre">';
|
2009-02-16 21:30:30 +01:00
|
|
|
|
print '<td colspan="2">'.$langs->trans("LastMailings",$limit).'</td>';
|
|
|
|
|
|
print '<td align="center">'.$langs->trans("DateCreation").'</td>';
|
2005-09-16 00:44:29 +02:00
|
|
|
|
print '<td align="center">'.$langs->trans("NbOfEMails").'</td>';
|
2014-09-18 20:33:37 +02:00
|
|
|
|
print '<td align="right"><a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("AllEMailings").'</a></td></tr>';
|
2005-02-26 20:06:39 +01:00
|
|
|
|
|
|
|
|
|
|
$num = $db->num_rows($result);
|
2005-01-04 17:24:44 +01:00
|
|
|
|
if ($num > 0)
|
2018-04-22 19:27:37 +02:00
|
|
|
|
{
|
2005-01-04 17:24:44 +01:00
|
|
|
|
$i = 0;
|
2009-02-16 21:30:30 +01:00
|
|
|
|
|
2018-04-22 19:27:37 +02:00
|
|
|
|
while ($i < $num )
|
2005-01-04 17:24:44 +01:00
|
|
|
|
{
|
2005-02-26 20:06:39 +01:00
|
|
|
|
$obj = $db->fetch_object($result);
|
2009-02-16 21:30:30 +01:00
|
|
|
|
|
2017-04-14 11:22:48 +02:00
|
|
|
|
print '<tr class="oddeven">';
|
2014-09-18 21:18:25 +02:00
|
|
|
|
print '<td class="nowrap"><a href="card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowEMail"),"email").' '.$obj->rowid.'</a></td>';
|
2009-02-20 23:53:15 +01:00
|
|
|
|
print '<td>'.dol_trunc($obj->titre,38).'</td>';
|
2013-04-05 09:23:31 +02:00
|
|
|
|
print '<td align="center">'.dol_print_date($db->jdate($obj->date_creat),'day').'</td>';
|
2005-09-16 00:44:29 +02:00
|
|
|
|
print '<td align="center">'.($obj->nbemail?$obj->nbemail:"0").'</td>';
|
2006-06-25 17:52:12 +02:00
|
|
|
|
$mailstatic=new Mailing($db);
|
|
|
|
|
|
print '<td align="right">'.$mailstatic->LibStatut($obj->statut,5).'</td>';
|
2005-01-29 01:57:06 +01:00
|
|
|
|
print '</tr>';
|
2005-01-04 17:24:44 +01:00
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2009-02-16 21:30:30 +01:00
|
|
|
|
else
|
2005-02-26 20:06:39 +01:00
|
|
|
|
{
|
2016-06-07 15:58:02 +02:00
|
|
|
|
print '<tr><td class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
2005-02-26 20:06:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
print "</table><br>";
|
|
|
|
|
|
$db->free($result);
|
2009-02-16 21:30:30 +01:00
|
|
|
|
}
|
2005-01-04 17:24:44 +01:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2009-02-20 23:53:15 +01:00
|
|
|
|
dol_print_error($db);
|
2005-01-04 17:24:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-16 14:53:15 +01:00
|
|
|
|
//print '</td></tr></table>';
|
2013-03-30 19:40:52 +01:00
|
|
|
|
print '</div></div></div>';
|
2005-01-04 17:24:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
2005-05-14 00:43:56 +02:00
|
|
|
|
if ($langs->file_exists("html/spam.html",0)) {
|
2005-09-03 21:22:29 +02:00
|
|
|
|
print "<br><br><br><br>".$langs->trans("Note")."<br>";
|
2005-05-14 02:36:01 +02:00
|
|
|
|
print '<div style="padding: 4px; background: #FAFAFA; border: 1px solid #BBBBBB;" >';
|
2009-02-20 21:28:16 +01:00
|
|
|
|
dol_print_file($langs,"html/spam.html",0);
|
2005-05-14 00:43:56 +02:00
|
|
|
|
print '</div>';
|
2009-02-16 21:30:30 +01:00
|
|
|
|
|
2005-05-14 00:43:56 +02:00
|
|
|
|
print '<br>';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-27 16:24:16 +02:00
|
|
|
|
llxFooter();
|
2005-01-04 17:24:44 +01:00
|
|
|
|
|
2013-03-30 14:27:13 +01:00
|
|
|
|
$db->close();
|