* Copyright (C) 2005-2010 Regis Houssin * * 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 . */ /** * \file htdocs/comm/mailing/list.php * \ingroup mailing * \brief Liste des mailings */ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; $langs->load("mails"); // Security check $result=restrictedArea($user,'mailing'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="m.date_creat"; $sall=GETPOST("sall","alpha"); $sref=GETPOST("sref","alpha"); $filteremail=GETPOST('filteremail','alpha'); /* * View */ llxHeader('',$langs->trans("Mailing"),'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'); $form = new Form($db); if ($filteremail) { $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,"; $sql.= " mc.statut as sendstatut"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql.= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity; $sql.= " AND mc.email = '".$db->escape($filteremail)."'"; if ($sref) $sql.= " AND m.rowid = '".$db->escape($sref)."'"; if ($sall) $sql.= " AND (m.titre like '%".$db->escape($sall)."%' OR m.sujet like '%".$db->escape($sall)."%' OR m.body like '%".$db->escape($sall)."%')"; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="m.rowid"; $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($conf->liste_limit +1, $offset); } else { $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; $sql.= " WHERE m.entity = ".$conf->entity; if ($sref) $sql.= " AND m.rowid = '".$db->escape($sref)."'"; if ($sall) $sql.= " AND (m.titre like '%".$db->escape($sall)."%' OR m.sujet like '%".$db->escape($sall)."%' OR m.body like '%".$db->escape($sall)."%')"; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="m.rowid"; $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($conf->liste_limit +1, $offset); } //print $sql; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $title=$langs->trans("ListOfEMailings"); if ($filteremail) $title.=' ('.$langs->trans("SentTo",$filteremail).')'; print_barre_liste($title, $page, $_SERVER["PHP_SELF"],"",$sortfield,$sortorder,"",$num); $i = 0; $param = "&sall=".urlencode($sall); if ($filteremail) $param.='&filteremail='.urlencode($filteremail); print '
'; print ''; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"m.rowid",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Title"),$_SERVER["PHP_SELF"],"m.titre",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"m.date_creat",$param,"",'align="center"',$sortfield,$sortorder); if (! $filteremail) print_liste_field_titre($langs->trans("NbOfEMails"),$_SERVER["PHP_SELF"],"m.nbemail",$param,"",'align="center"',$sortfield,$sortorder); if (! $filteremail) print_liste_field_titre($langs->trans("DateLastSend"),$_SERVER["PHP_SELF"],"m.date_envoi",$param,"",'align="center"',$sortfield,$sortorder); else print_liste_field_titre($langs->trans("DateSending"),$_SERVER["PHP_SELF"],"mc.date_envoi",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],($filteremail?"mc.statut":"m.statut"),$param,"",'align="right"',$sortfield,$sortorder); print "\n"; print ''; print ''; // Title print ''; print ''; if (! $filteremail) print ''; print ''; print '"; print "\n"; $var=True; $email=new Mailing($db); while ($i < min($num,$conf->liste_limit)) { $obj = $db->fetch_object($result); $var=!$var; print ""; print ''; print ''; // Date creation print ''; // Nb of email if (! $filteremail) { print ''; } // Last send print ''; print ''; // Status print ''; print "\n"; $i++; } print '
'; print ''; print ''; print ''; print '   '; print "
'; print img_object($langs->trans("ShowEMail"),"email").' '.stripslashes($obj->rowid).''.$obj->titre.''; print dol_print_date($db->jdate($obj->datec),'day'); print ''; $nbemail = $obj->nbemail; if ($obj->statut != 3 && !empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) { $text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB); print $form->textwithpicto($nbemail,$text,1,'warning'); } else { print $nbemail; } print ''.dol_print_date($db->jdate($obj->date_envoi),'day').''; if ($filteremail) { if ($obj->sendstatut==-1) print $langs->trans("MailingStatusError").' '.img_error(); if ($obj->sendstatut==1) print $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6'); } else { print $email->LibStatut($obj->statut,5); } print '
'; $db->free($result); } else { dol_print_error($db); } llxFooter(); $db->close();