26require
'../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/comm/mailing/class/mailing.class.php';
33$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
34$massaction =
GETPOST(
'massaction',
'alpha');
35$show_files =
GETPOST(
'show_files',
'int');
36$confirm =
GETPOST(
'confirm',
'alpha');
37$cancel =
GETPOST(
'cancel',
'alpha');
38$toselect =
GETPOST(
'toselect',
'array');
39$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
40$backtopage =
GETPOST(
'backtopage',
'alpha');
41$optioncss =
GETPOST(
'optioncss',
'aZ');
45$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
46$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
47$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
48$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
49if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
53$offset = $limit * $page;
58$search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
59$search_ref =
GETPOST(
"search_ref",
"alpha") ?
GETPOST(
"search_ref",
"alpha") :
GETPOST(
"sref",
"alpha");
60$filteremail =
GETPOST(
'filteremail',
'alpha');
65$hookmanager->initHooks(array($contextpage));
68$extrafields->fetch_name_optionals_label($object->table_element);
70$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
77 $sortfield =
"m.date_creat";
81$fieldstosearchall = array(
85$permissiontoread = $user->hasRight(
'mailing',
'lire');
86$permissiontoadd = $user->hasRight(
'mailing',
'creer');
87$permissiontodelete = $user->hasRight(
'mailing',
'delete');
90if (!$user->hasRight(
'mailing',
'lire') || (!
getDolGlobalString(
'EXTERNAL_USERS_ARE_AUTHORIZED') && $user->socid > 0)) {
100if (
GETPOST(
'cancel',
'alpha')) {
104if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
108$parameters = array();
109$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
114if (empty($reshook)) {
116 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
119 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
127 $search_array_options = array();
129 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
130 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
135 $objectclass =
'Mailing';
136 $objectlabel =
'Mailing';
137 $uploaddir = $conf->mailing->dir_output;
138 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
146$form =
new Form($db);
150$help_url =
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
151$title = $langs->trans(
"Mailing");
158 $sql =
"SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,";
159 $sql .=
" mc.statut as sendstatut";
163 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
164 $sql .=
" WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
165 $sql .=
" AND mc.email = '".$db->escape($filteremail).
"'";
167 $sql .=
" AND m.rowid = '".$db->escape($search_ref).
"'";
170 $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).
"%')";
176 $sortfield =
"m.rowid";
179 $sql =
"SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi";
183 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m";
184 $sql .=
" WHERE m.entity = ".$conf->entity;
186 $sql .=
" AND m.rowid = '".$db->escape($search_ref).
"'";
189 $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).
"%')";
195 $sortfield =
"m.rowid";
199 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
203include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
205$parameters = array();
206$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
207$sql .= $hookmanager->resPrint;
210$nbtotalofrecords =
'';
213 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
214 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
215 $resql = $db->query($sqlforcount);
217 $objforcount = $db->fetch_object($resql);
218 $nbtotalofrecords = $objforcount->nbtotalofrecords;
223 if (($page * $limit) > $nbtotalofrecords) {
231$sql .= $db->order($sortfield, $sortorder);
233 $sql .= $db->plimit($limit + 1, $offset);
236$resql = $db->query($sql);
242$num = $db->num_rows($resql);
246if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
247 $obj = $db->fetch_object($resql);
249 header(
"Location: ".
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.$id);
257$title = $langs->trans(
"EMailings");
259 $title .=
' ('.$langs->trans(
"SentTo", $filteremail).
')';
264$arrayofselected = is_array($toselect) ? $toselect : array();
266$param =
"&search_all=".urlencode($search_all);
268 $param .=
'&mode='.urlencode($mode);
270if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
271 $param .=
'&contextpage='.urlencode($contextpage);
273if ($limit > 0 && $limit != $conf->liste_limit) {
274 $param .=
'&limit='.((int) $limit);
276if ($optioncss !=
'') {
277 $param .=
'&optioncss='.urlencode($optioncss);
280 $param .=
'&filteremail='.urlencode($filteremail);
283include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
285$parameters = array(
'param' => &$param);
286$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
287$param .= $hookmanager->resPrint;
290$arrayofmassactions = array(
296if (!empty($permissiontodelete)) {
297 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
299if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
300 $arrayofmassactions = array();
302$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
304print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
305if ($optioncss !=
'') {
306 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
308print
'<input type="hidden" name="token" value="'.newToken().
'">';
309print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
310print
'<input type="hidden" name="action" value="list">';
311print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
312print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
313print
'<input type="hidden" name="page" value="'.$page.
'">';
314print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
315print
'<input type="hidden" name="page_y" value="">';
316print
'<input type="hidden" name="mode" value="'.$mode.
'">';
319if ($user->hasRight(
'mailing',
'creer')) {
320 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewMailing'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/comm/mailing/card.php?action=create');
323print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_email', 0, $newcardbutton,
'', $limit, 0, 0, 1);
326$topicmail =
"SendMailingRef";
327$modelmail =
"mailing";
329$trackid =
'mailing'.$object->id;
330include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
334 foreach ($fieldstosearchall as $key => $val) {
335 $fieldstosearchall[$key] = $langs->trans($val);
336 $setupstring .= $key.
"=".$val.
";";
338 print
'<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
339 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
344$parameters = array();
345$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
346if (empty($reshook)) {
347 $moreforfilter .= $hookmanager->resPrint;
349 $moreforfilter = $hookmanager->resPrint;
352if (!empty($moreforfilter)) {
353 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
354 print $moreforfilter;
355 $parameters = array(
'type'=>$type);
356 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
357 print $hookmanager->resPrint;
361$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
362$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
363$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
365print
'<div class="div-table-responsive">';
366print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
370print
'<tr class="liste_titre_filter">';
373 print
'<td class="liste_titre maxwidthsearch center">';
374 $searchpicto = $form->showFilterButtons(
'left');
378print
'<td class="liste_titre">';
379print
'<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
382print
'<td class="liste_titre">';
383print
'<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_all" value="'.dol_escape_htmltag($search_all).
'">';
385print
'<td class="liste_titre"> </td>';
387 print
'<td class="liste_titre"> </td>';
389print
'<td class="liste_titre"> </td>';
390print
'<td class="liste_titre"> </td>';
392include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
394$parameters = array(
'arrayfields'=>$arrayfields);
395$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
396print $hookmanager->resPrint;
399 print
'<td class="liste_titre center maxwidthsearch">';
400 $searchpicto = $form->showFilterButtons();
406$totalarray = array();
407$totalarray[
'nbfield'] = 0;
411print
'<tr class="liste_titre">';
413 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
414 $totalarray[
'nbfield']++;
417$totalarray[
'nbfield']++;
419$totalarray[
'nbfield']++;
420print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"m.date_creat", $param,
"",
'align="center"', $sortfield, $sortorder);
421$totalarray[
'nbfield']++;
423 print_liste_field_titre(
"NbOfEMails", $_SERVER[
"PHP_SELF"],
"m.nbemail", $param,
"",
'align="center"', $sortfield, $sortorder);
424 $totalarray[
'nbfield']++;
427 print_liste_field_titre(
"DateLastSend", $_SERVER[
"PHP_SELF"],
"m.date_envoi", $param,
"",
'align="center"', $sortfield, $sortorder);
428 $totalarray[
'nbfield']++;
430 print_liste_field_titre(
"DateSending", $_SERVER[
"PHP_SELF"],
"mc.date_envoi", $param,
"",
'align="center"', $sortfield, $sortorder);
431 $totalarray[
'nbfield']++;
434include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
436$parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
437$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
438print $hookmanager->resPrint;
439print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"], ($filteremail ?
"mc.statut" :
"m.statut"), $param,
"",
'', $sortfield, $sortorder,
'center ');
440$totalarray[
'nbfield']++;
443 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
444 $totalarray[
'nbfield']++;
448$totalarray = array();
449$totalarray[
'nbfield'] = 0;
455$savnbfield = $totalarray[
'nbfield'];
456$totalarray = array();
457$totalarray[
'nbfield'] = 0;
458$imaxinloop = ($limit ? min($num, $limit) : $num);
459while ($i < $imaxinloop) {
460 $obj = $db->fetch_object($resql);
465 $object->id = $obj->rowid;
466 $object->ref = $obj->rowid;
470 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
473 print
'<td class="nowrap center">';
474 if ($massactionbutton || $massaction) {
476 if (in_array($object->id, $arrayofselected)) {
479 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
483 $totalarray[
'nbfield']++;
488 print $object->getNomUrl(1);
492 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).
'">'.
dol_escape_htmltag($obj->title).
'</td>';
495 print
'<td class="center">';
501 print
'<td class="center nowraponall">';
502 $nbemail = $obj->nbemail;
517 print
'<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->date_envoi),
'day').
'</td>';
521 print
'<td class="nowrap center">';
523 print $object::libStatutDest($obj->sendstatut, 2);
525 print $object->LibStatut($obj->statut, 5);
531 print
'<td class="nowrap center">';
532 if ($massactionbutton || $massaction) {
534 if (in_array($object->id, $arrayofselected)) {
537 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
541 $totalarray[
'nbfield']++;
551include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
559 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
565$parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
566$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
567print $hookmanager->resPrint;
569print
'</table>'.
"\n";
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.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get 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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.