30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/comm/mailing/class/mailing.class.php';
45$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
46$massaction =
GETPOST(
'massaction',
'alpha');
48$confirm =
GETPOST(
'confirm',
'alpha');
49$cancel =
GETPOST(
'cancel',
'alpha');
50$toselect =
GETPOST(
'toselect',
'array');
51$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
52$backtopage =
GETPOST(
'backtopage',
'alpha');
53$optioncss =
GETPOST(
'optioncss',
'aZ');
58$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
59$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
61if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
65$offset = $limit * $page;
70$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
71$search_ref =
GETPOST(
"search_ref",
"alpha") ?
GETPOST(
"search_ref",
"alpha") :
GETPOST(
"sref",
"alpha");
72$search_messtype =
GETPOST(
"search_messtype",
"alpha");
73$filteremail =
GETPOST(
'filteremail',
'alpha');
78$hookmanager->initHooks(array($contextpage));
81$extrafields->fetch_name_optionals_label(
$object->table_element);
83$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
90 $sortfield =
"m.date_creat";
94$fieldstosearchall = array(
98$permissiontoread = $user->hasRight(
'mailing',
'lire');
99$permissiontoadd = $user->hasRight(
'mailing',
'creer');
100$permissiontodelete = $user->hasRight(
'mailing',
'delete');
103if (!$user->hasRight(
'mailing',
'lire') || (!
getDolGlobalString(
'EXTERNAL_USERS_ARE_AUTHORIZED') && $user->socid > 0)) {
113if (
GETPOST(
'cancel',
'alpha')) {
117if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
121$parameters = array();
122$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
127if (empty($reshook)) {
129 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
132 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
138 $search_messtype =
'';
141 $search_array_options = array();
143 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
144 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
149 $objectclass =
'Mailing';
150 $objectlabel =
'Mailing';
151 $uploaddir =
$conf->mailing->dir_output;
152 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
160$form =
new Form($db);
164$help_url =
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
165$title = $langs->trans(
"Mailing");
172 $sql =
"SELECT m.rowid, m.messtype, m.titre as title, m.nbemail, m.statut as status, m.date_creat as datec, m.date_envoi as date_envoi,";
173 $sql .=
" mc.statut as sendstatut";
177 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
178 $sql .=
" WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
179 $sql .=
" AND mc.email = '".$db->escape($filteremail).
"'";
181 $sql .=
" AND m.rowid = '".$db->escape($search_ref).
"'";
183 if ($search_messtype) {
184 $sql .=
" AND m.messtype LIKE '".$db->escape($search_messtype).
"'";
187 $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).
"%')";
193 $sortfield =
"m.rowid";
196 $sql =
"SELECT m.rowid, m.messtype, m.titre as title, m.nbemail, m.statut as status, m.date_creat as datec, m.date_envoi as date_envoi";
200 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m";
201 $sql .=
" WHERE m.entity = ".((int)
$conf->entity);
203 $sql .=
" AND m.rowid = '".$db->escape($search_ref).
"'";
205 if ($search_messtype) {
206 $sql .=
" AND m.messtype LIKE '".$db->escape($search_messtype).
"'";
209 $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).
"%')";
215 $sortfield =
"m.rowid";
219 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
223include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
225$parameters = array();
226$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
227$sql .= $hookmanager->resPrint;
230$nbtotalofrecords =
'';
233 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
234 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
235 $resql = $db->query($sqlforcount);
237 $objforcount = $db->fetch_object($resql);
238 $nbtotalofrecords = $objforcount->nbtotalofrecords;
243 if (($page * $limit) > $nbtotalofrecords) {
251$sql .= $db->order($sortfield, $sortorder);
253 $sql .= $db->plimit($limit + 1, $offset);
256$resql = $db->query($sql);
262$num = $db->num_rows($resql);
266if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
267 $obj = $db->fetch_object($resql);
277$title = $langs->trans(
"EMailings");
279 $title .=
' ('.$langs->trans(
"SentTo", $filteremail).
')';
282llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist');
284$arrayofselected = is_array($toselect) ? $toselect : array();
286$param =
"&search_all=".urlencode($search_all);
288 $param .=
'&mode='.urlencode($mode);
290if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
291 $param .=
'&contextpage='.urlencode($contextpage);
293if ($limit > 0 && $limit !=
$conf->liste_limit) {
294 $param .=
'&limit='.((int) $limit);
296if ($optioncss !=
'') {
297 $param .=
'&optioncss='.urlencode($optioncss);
299if ($search_ref !=
'') {
300 $param .=
'&search_ref='.urlencode($search_ref);
302if ($search_messtype !=
'') {
303 $param .=
'&search_type='.urlencode($search_messtype);
305if ($optioncss !=
'') {
306 $param .=
'&optioncss='.urlencode($optioncss);
310 $param .=
'&filteremail='.urlencode($filteremail);
313include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
315$parameters = array(
'param' => &$param);
316$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
317$param .= $hookmanager->resPrint;
320$arrayofmassactions = array(
326if (!empty($permissiontodelete)) {
327 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
329if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
330 $arrayofmassactions = array();
332$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
334print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
335if ($optioncss !=
'') {
336 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
338print
'<input type="hidden" name="token" value="'.newToken().
'">';
339print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
340print
'<input type="hidden" name="action" value="list">';
341print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
342print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
343print
'<input type="hidden" name="page" value="'.$page.
'">';
344print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
345print
'<input type="hidden" name="page_y" value="">';
346print
'<input type="hidden" name="mode" value="'.$mode.
'">';
349if ($user->hasRight(
'mailing',
'creer')) {
350 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewMailing'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/comm/mailing/card.php?action=create');
353print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_email', 0, $newcardbutton,
'', $limit, 0, 0, 1);
356$topicmail =
"SendMailingRef";
357$modelmail =
"mailing";
359$trackid =
'mailing'.$object->id;
360include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
364 foreach ($fieldstosearchall as $key => $val) {
365 $fieldstosearchall[$key] = $langs->trans($val);
366 $setupstring .= $key.
"=".$val.
";";
368 print
'<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
369 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
374$parameters = array();
375$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
376if (empty($reshook)) {
377 $moreforfilter .= $hookmanager->resPrint;
379 $moreforfilter = $hookmanager->resPrint;
382if (!empty($moreforfilter)) {
383 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
384 print $moreforfilter;
388$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
389$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
390$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
392print
'<div class="div-table-responsive">';
393print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
397print
'<tr class="liste_titre_filter">';
400 print
'<td class="liste_titre maxwidthsearch center">';
401 $searchpicto = $form->showFilterButtons(
'left');
405print
'<td class="liste_titre">';
406print
'<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
410 print
'<td class="liste_titre">';
411 print
'<input type="text" class="flat maxwidth50" name="search_messtype" value="'.dol_escape_htmltag($search_messtype).
'">';
415print
'<td class="liste_titre">';
416print
'<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_all" value="'.dol_escape_htmltag($search_all).
'">';
418print
'<td class="liste_titre"> </td>';
420 print
'<td class="liste_titre"> </td>';
422print
'<td class="liste_titre"> </td>';
423print
'<td class="liste_titre"> </td>';
425include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
427$parameters = array(
'arrayfields' => $arrayfields);
428$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
429print $hookmanager->resPrint;
432 print
'<td class="liste_titre center maxwidthsearch">';
433 $searchpicto = $form->showFilterButtons();
444print
'<tr class="liste_titre">';
446 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
458print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"m.date_creat",
"", $param,
'', $sortfield, $sortorder,
'center ');
461 $title = $langs->trans(
"NbOfEMails");
463 $title .=
' | '.$langs->trans(
"SMS");
465 print_liste_field_titre($title, $_SERVER[
"PHP_SELF"],
"m.nbemail",
"", $param,
'', $sortfield, $sortorder,
'center ');
469 print_liste_field_titre(
"DateLastSend", $_SERVER[
"PHP_SELF"],
"m.date_envoi",
"", $param,
'', $sortfield, $sortorder,
'center ');
472 print_liste_field_titre(
"DateSending", $_SERVER[
"PHP_SELF"],
"mc.date_envoi",
"", $param,
'', $sortfield, $sortorder,
'center ');
476include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
478$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
479$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
480print $hookmanager->resPrint;
481print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"], ($filteremail ?
"mc.statut" :
"m.statut"),
"", $param,
'', $sortfield, $sortorder,
'center ');
485 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
500$imaxinloop = ($limit ? min($num, $limit) : $num);
501while ($i < $imaxinloop) {
502 $obj = $db->fetch_object($resql);
512 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
515 print
'<td class="nowrap center">';
516 if ($massactionbutton || $massaction) {
518 if (in_array(
$object->id, $arrayofselected)) {
521 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
542 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).
'">'.
dol_escape_htmltag($obj->title).
'</td>';
545 print
'<td class="center">';
551 print
'<td class="center nowraponall">';
552 $nbemail = $obj->nbemail;
567 print
'<td class="nowrap center">'.dol_print_date($db->jdate($obj->date_envoi),
'day').
'</td>';
571 print
'<td class="nowrap center">';
573 print $object::libStatutDest($obj->sendstatut, 2);
575 print
$object->LibStatut($obj->status, 5);
581 print
'<td class="nowrap center">';
582 if ($massactionbutton || $massaction) {
584 if (in_array(
$object->id, $arrayofselected)) {
587 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
601include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
609 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
615$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
616$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
617print $hookmanager->resPrint;
619print
'</table>'.
"\n";
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage emailings module.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a 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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.