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');
36 $massaction =
GETPOST(
'massaction',
'alpha');
38 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
41 $offset = $limit * $page;
42 $pageprev = $page - 1;
43 $pagenext = $page + 1;
48 $sortfield =
"m.date_creat";
51 $search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
52 $search_ref =
GETPOST(
"search_ref",
"alpha") ?
GETPOST(
"search_ref",
"alpha") :
GETPOST(
"sref",
"alpha");
53 $filteremail =
GETPOST(
'filteremail',
'alpha');
58 $hookmanager->initHooks(array(
'mailinglist'));
62 $extrafields->fetch_name_optionals_label($object->table_element);
64 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
67 $fieldstosearchall = array(
72 if (!$user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) {
83 if (
GETPOST(
'cancel',
'alpha')) {
84 $action =
'list'; $massaction =
'';
86 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
90 $parameters = array();
91 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
96 if (empty($reshook)) {
98 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
101 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
109 $search_array_options = array();
111 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
112 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
131 llxHeader(
'', $langs->trans(
"Mailing"),
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing');
136 $sql =
"SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,";
137 $sql .=
" mc.statut as sendstatut";
138 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
139 $sql .=
" WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
140 $sql .=
" AND mc.email = '".$db->escape($filteremail).
"'";
142 $sql .=
" AND m.rowid = '".$db->escape($search_ref).
"'";
145 $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).
"%')";
151 $sortfield =
"m.rowid";
154 $sql =
"SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi";
155 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m";
156 $sql .=
" WHERE m.entity = ".$conf->entity;
158 $sql .=
" AND m.rowid = '".$db->escape($search_ref).
"'";
161 $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).
"%')";
167 $sortfield =
"m.rowid";
171 $sql .= $db->order($sortfield, $sortorder);
174 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
175 $resql = $db->query($sql);
183 $sql .= $db->plimit($limit + 1, $offset);
186 dol_syslog(
"comm/mailing/list.php", LOG_DEBUG);
187 $resql = $db->query($sql);
189 $num = $db->num_rows(
$resql);
191 $title = $langs->trans(
"EMailings");
193 $title .=
' ('.$langs->trans(
"SentTo", $filteremail).
')';
197 if ($user->rights->mailing->creer) {
198 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewMailing'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/comm/mailing/card.php?action=create');
203 $param =
"&search_all=".urlencode($search_all);
204 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
205 $param .=
'&contextpage='.urlencode($contextpage);
207 if ($limit > 0 && $limit != $conf->liste_limit) {
208 $param .=
'&limit='.urlencode($limit);
211 $param .=
'&filteremail='.urlencode($filteremail);
214 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
215 if ($optioncss !=
'') {
216 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
218 print
'<input type="hidden" name="token" value="'.newToken().
'">';
219 print
'<input type="hidden" name="action" value="list">';
220 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
221 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
223 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num,
$nbtotalofrecords,
'object_email', 0, $newcardbutton,
'', $limit, 0, 0, 1);
227 print
'<div class="div-table-responsive">';
228 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
230 print
'<tr class="liste_titre_filter">';
231 print
'<td class="liste_titre">';
232 print
'<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
235 print
'<td class="liste_titre">';
236 print
'<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_all" value="'.dol_escape_htmltag($search_all).
'">';
238 print
'<td class="liste_titre"> </td>';
240 print
'<td class="liste_titre"> </td>';
242 print
'<td class="liste_titre"> </td>';
243 print
'<td class="liste_titre"> </td>';
244 print
'<td class="liste_titre maxwidthsearch">';
245 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
250 print
'<tr class="liste_titre">';
253 print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"m.date_creat", $param,
"",
'align="center"', $sortfield, $sortorder);
255 print_liste_field_titre(
"NbOfEMails", $_SERVER[
"PHP_SELF"],
"m.nbemail", $param,
"",
'align="center"', $sortfield, $sortorder);
258 print_liste_field_titre(
"DateLastSend", $_SERVER[
"PHP_SELF"],
"m.date_envoi", $param,
"",
'align="center"', $sortfield, $sortorder);
260 print_liste_field_titre(
"DateSending", $_SERVER[
"PHP_SELF"],
"mc.date_envoi", $param,
"",
'align="center"', $sortfield, $sortorder);
262 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"], ($filteremail ?
"mc.statut" :
"m.statut"), $param,
"",
'class="right"', $sortfield, $sortorder);
263 print_liste_field_titre(
'', $_SERVER[
"PHP_SELF"],
"",
'',
'',
'class="right"', $sortfield, $sortorder,
'maxwidthsearch ');
269 while ($i < min($num, $limit)) {
270 $obj = $db->fetch_object(
$resql);
272 $email->id = $obj->rowid;
273 $email->ref = $obj->rowid;
275 print
'<tr class="oddeven">';
278 print $email->getNomUrl(1);
282 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).
'">'.
dol_escape_htmltag($obj->title).
'</td>';
285 print
'<td class="center">';
291 print
'<td class="center nowraponall">';
292 $nbemail = $obj->nbemail;
307 print
'<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->date_envoi),
'day').
'</td>';
311 print
'<td class="nowrap right">';
313 print $email::libStatutDest($obj->sendstatut, 2);
315 print $email->LibStatut($obj->statut, 5);
329 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.