26 require
'../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/comm/mailing/class/mailing.class.php';
30 $langs->load(
"mails");
32 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
33 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
34 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
35 $optioncss =
GETPOST(
'optioncss',
'alpha');
37 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
40 $offset = $limit * $page;
41 $pageprev = $page - 1;
42 $pagenext = $page + 1;
47 $sortfield =
"m.date_creat";
50 $search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
51 $search_ref =
GETPOST(
"search_ref",
"alpha") ?
GETPOST(
"search_ref",
"alpha") :
GETPOST(
"sref",
"alpha");
52 $filteremail =
GETPOST(
'filteremail',
'alpha');
57 $hookmanager->initHooks(array(
'mailinglist'));
61 $extrafields->fetch_name_optionals_label($object->table_element);
63 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
66 $fieldstosearchall = array(
71 if (!$user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) {
82 if (
GETPOST(
'cancel',
'alpha')) {
83 $action =
'list'; $massaction =
'';
85 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
89 $parameters = array();
90 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
95 if (empty($reshook)) {
97 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
100 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
108 $search_array_options = array();
110 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
111 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
130 llxHeader(
'', $langs->trans(
"Mailing"),
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing');
135 $sql =
"SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,";
136 $sql .=
" mc.statut as sendstatut";
137 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
138 $sql .=
" WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
139 $sql .=
" AND mc.email = '".$db->escape($filteremail).
"'";
141 $sql .=
" AND m.rowid = '".$db->escape($search_ref).
"'";
144 $sql .=
" AND (m.titre like '%".$db->escape($search_all).
"%' OR m.sujet like '%".$db->escape($search_all).
"%' OR m.body like '%".$db->escape($search_all).
"%')";
150 $sortfield =
"m.rowid";
153 $sql =
"SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi";
154 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m";
155 $sql .=
" WHERE m.entity = ".$conf->entity;
157 $sql .=
" AND m.rowid = '".$db->escape($search_ref).
"'";
160 $sql .=
" AND (m.titre like '%".$db->escape($search_all).
"%' OR m.sujet like '%".$db->escape($search_all).
"%' OR m.body like '%".$db->escape($search_all).
"%')";
166 $sortfield =
"m.rowid";
170 $sql .= $db->order($sortfield, $sortorder);
173 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
174 $resql = $db->query($sql);
182 $sql .= $db->plimit($limit + 1, $offset);
185 dol_syslog(
"comm/mailing/list.php", LOG_DEBUG);
186 $resql = $db->query($sql);
188 $num = $db->num_rows(
$resql);
190 $title = $langs->trans(
"EMailings");
192 $title .=
' ('.$langs->trans(
"SentTo", $filteremail).
')';
196 if ($user->rights->mailing->creer) {
197 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewMailing'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/comm/mailing/card.php?action=create');
202 $param =
"&search_all=".urlencode($search_all);
203 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
204 $param .=
'&contextpage='.urlencode($contextpage);
206 if ($limit > 0 && $limit != $conf->liste_limit) {
207 $param .=
'&limit='.urlencode($limit);
210 $param .=
'&filteremail='.urlencode($filteremail);
213 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
214 if ($optioncss !=
'') {
215 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
217 print
'<input type="hidden" name="token" value="'.newToken().
'">';
218 print
'<input type="hidden" name="action" value="list">';
219 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
220 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
222 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num,
$nbtotalofrecords,
'object_email', 0, $newcardbutton,
'', $limit, 0, 0, 1);
226 print
'<div class="div-table-responsive">';
227 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
229 print
'<tr class="liste_titre_filter">';
230 print
'<td class="liste_titre">';
231 print
'<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
234 print
'<td class="liste_titre">';
235 print
'<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_all" value="'.dol_escape_htmltag($search_all).
'">';
237 print
'<td class="liste_titre"> </td>';
239 print
'<td class="liste_titre"> </td>';
241 print
'<td class="liste_titre"> </td>';
242 print
'<td class="liste_titre"> </td>';
243 print
'<td class="liste_titre maxwidthsearch">';
244 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
249 print
'<tr class="liste_titre">';
252 print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"m.date_creat", $param,
"",
'align="center"', $sortfield, $sortorder);
254 print_liste_field_titre(
"NbOfEMails", $_SERVER[
"PHP_SELF"],
"m.nbemail", $param,
"",
'align="center"', $sortfield, $sortorder);
257 print_liste_field_titre(
"DateLastSend", $_SERVER[
"PHP_SELF"],
"m.date_envoi", $param,
"",
'align="center"', $sortfield, $sortorder);
259 print_liste_field_titre(
"DateSending", $_SERVER[
"PHP_SELF"],
"mc.date_envoi", $param,
"",
'align="center"', $sortfield, $sortorder);
261 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"], ($filteremail ?
"mc.statut" :
"m.statut"), $param,
"",
'class="right"', $sortfield, $sortorder);
262 print_liste_field_titre(
'', $_SERVER[
"PHP_SELF"],
"",
'',
'',
'class="right"', $sortfield, $sortorder,
'maxwidthsearch ');
268 while ($i < min($num, $limit)) {
269 $obj = $db->fetch_object(
$resql);
271 $email->id = $obj->rowid;
272 $email->ref = $obj->rowid;
274 print
'<tr class="oddeven">';
277 print $email->getNomUrl(1);
281 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).
'">'.
dol_escape_htmltag($obj->title).
'</td>';
284 print
'<td class="center">';
290 print
'<td class="center nowraponall">';
291 $nbemail = $obj->nbemail;
306 print
'<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->date_envoi),
'day').
'</td>';
310 print
'<td class="nowrap right">';
312 print $email::libStatutDest($obj->sendstatut, 2);
314 print $email->LibStatut($obj->statut, 5);
328 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage emailings module.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$nbtotalofrecords
Count total nb of records.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.