From b2a37be5e79942781dcdc3a880abe4fc7d974e73 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Aug 2005 16:55:11 +0000 Subject: [PATCH] Ajoute page listant tous les mailings --- htdocs/comm/mailing/liste.php | 132 ++++++++++++++++++++++ htdocs/comm/mailing/pre.inc.php | 43 +++---- htdocs/includes/menus/barre_left/eldy.php | 12 +- 3 files changed, 164 insertions(+), 23 deletions(-) create mode 100644 htdocs/comm/mailing/liste.php diff --git a/htdocs/comm/mailing/liste.php b/htdocs/comm/mailing/liste.php new file mode 100644 index 00000000000..224cbfa8afc --- /dev/null +++ b/htdocs/comm/mailing/liste.php @@ -0,0 +1,132 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/comm/mailing/liste.php + \ingroup mailing + \brief Liste des mailings + \version $Revision$ +*/ + +require("./pre.inc.php"); + +if (!$user->rights->mailing->lire) accessforbidden(); + +// Sécurité accés client +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} + +$page=$_GET["page"]; +$sortorder=$_GET["sortorder"]; +$sortfield=$_GET["sortfield"]; + +if ($page == -1) { $page = 0 ; } +$offset = $conf->liste_limit * $_GET["page"] ; +$pageprev = $_GET["page"] - 1; +$pagenext = $_GET["page"] + 1; + +$sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"]; +$sref=isset($_GET["sref"])?$_GET["sref"]:$_POST["sref"]; + + +llxHeader(); + + +$sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec"; +$sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; +$sql.= " WHERE 1=1"; +if ($sref) $sql.= " AND m.rowid = '".$sref."'"; +if ($sall) $sql.= " AND (m.titre like '%".$sall."%' OR m.sujet like '%".$sall."%' OR m.body like '%".$sall."%')"; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="m.titre"; +$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit +1, $offset); + +$result = $db->query($sql); +if ($result) +{ + $num = $db->num_rows($result); + + print_barre_liste($langs->trans("ListOfEMailings"), $page, "liste.php","",$sortfield,$sortorder,"",$num); + + $i = 0; + + $addu = "&sall=".$sall; + print ''; + print ''; + print_liste_field_titre($langs->trans("Ref"),"liste.php","m.rowid",$addu,"","",$sortfield); + print_liste_field_titre($langs->trans("Title"),"liste.php","m.titre",$addu,"","",$sortfield); + print_liste_field_titre($langs->trans("DateCreation"),"liste.php","m.date_creat",$addu,"",'align="center"',$sortfield); + print_liste_field_titre($langs->trans("NbOfEMails"),"liste.php","m.nbemail",$addu,"",'align="center"',$sortfield); + print_liste_field_titre($langs->trans("Status"),"liste.php","m.statut",$addu,"",'align="center"',$sortfield); + print ''; + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '"; + print "\n"; + print ''; + + $var=True; + + $email=new Mailing($db); + + while ($i < min($num,$conf->liste_limit)) + { + $obj = $db->fetch_object($result); + + $var=!$var; + + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + $i++; + } + print "
 
'; + print ''; + print ''; + print ''; + print '   '; + print "
'; + print img_object($langs->trans("ShowEMail"),"email").' '.stripslashes($obj->rowid).''.$obj->titre.''.dolibarr_print_date($obj->datec).''.$obj->nbemail.''.$email->statuts[$obj->statut].($obj->statut==2?' '.img_warning():'').' 
"; + $db->free($result); +} +else +{ + dolibarr_print_error($db); +} + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/comm/mailing/pre.inc.php b/htdocs/comm/mailing/pre.inc.php index 3795dd1f094..9850353dd76 100644 --- a/htdocs/comm/mailing/pre.inc.php +++ b/htdocs/comm/mailing/pre.inc.php @@ -18,7 +18,6 @@ * * $Id$ * $Source$ - * */ /** @@ -36,24 +35,30 @@ $langs->load("companies"); $langs->load("mails"); -function llxHeader($head = "", $title = "") { - global $user, $conf, $langs; - - top_menu($head, $title); - - $menu = new Menu(); - - if ($user->rights->mailing->lire) { - $menu->add(DOL_URL_ROOT."/comm/mailing/index.php", $langs->trans("Mailings")); - } - - if ($user->rights->mailing->creer) { - $menu->add_submenu(DOL_URL_ROOT."/comm/mailing/fiche.php?action=create", $langs->trans("NewMailing")); - } - - left_menu($menu->liste); - +function llxHeader($head = "", $title = "") +{ + global $user, $conf, $langs; + + top_menu($head, $title); + + $menu = new Menu(); + + if ($user->rights->mailing->lire) + { + $menu->add(DOL_URL_ROOT."/comm/mailing/index.php", $langs->trans("Mailings")); + } + + if ($user->rights->mailing->creer) + { + $menu->add_submenu(DOL_URL_ROOT."/comm/mailing/fiche.php?action=create", $langs->trans("NewMailing")); + } + + if ($user->rights->mailing->lire) + { + $menu->add_submenu(DOL_URL_ROOT."/comm/mailing/liste.php", $langs->trans("List")); + } + + left_menu($menu->liste); } - ?> diff --git a/htdocs/includes/menus/barre_left/eldy.php b/htdocs/includes/menus/barre_left/eldy.php index 83af2e7be4c..a742f153ae6 100644 --- a/htdocs/includes/menus/barre_left/eldy.php +++ b/htdocs/includes/menus/barre_left/eldy.php @@ -17,7 +17,6 @@ * * $Id$ * $Source$ - * */ /** @@ -458,7 +457,8 @@ class MenuLeft { /* * Menu FOURNISSEURS */ - if ($mainmenu == 'suppliers') { + if ($mainmenu == 'suppliers') + { $langs->load("suppliers"); @@ -501,7 +501,8 @@ class MenuLeft { /* * Menu OUTILS */ - if ($mainmenu == 'tools') { + if ($mainmenu == 'tools') + { if ($conf->mailing->enabled) { @@ -510,6 +511,7 @@ class MenuLeft { $newmenu->add(DOL_URL_ROOT."/comm/mailing/index.php?leftmenu=mailing", $langs->trans("EMailings"), 0, $user->rights->mailing->lire); $newmenu->add_submenu(DOL_URL_ROOT."/comm/mailing/fiche.php?leftmenu=mailing&action=create", $langs->trans("NewMailing"), 1, $user->rights->mailing->creer); + $newmenu->add_submenu(DOL_URL_ROOT."/comm/mailing/liste.php?leftmenu=mailing", $langs->trans("List"), 1, $user->rights->mailing->lire); } if ($conf->projet->enabled) @@ -517,6 +519,7 @@ class MenuLeft { $langs->load("projects"); $newmenu->add(DOL_URL_ROOT."/projet/index.php?leftmenu=projects", $langs->trans("Projects"), 0, $user->rights->projet->lire); $newmenu->add_submenu(DOL_URL_ROOT."/comm/clients.php?leftmenu=projects", $langs->trans("NewProject"), 1, $user->rights->projet->creer); + $newmenu->add_submenu(DOL_URL_ROOT."/projet/liste.php?leftmenu=projects", $langs->trans("List"), 1, $user->rights->projet->lire); } $langs->load("other"); @@ -528,7 +531,8 @@ class MenuLeft { /* * Menu MEMBERS */ - if ($mainmenu == 'members') { + if ($mainmenu == 'members') + { if ($conf->adherent->enabled) {