28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/comm/mailing/class/mailing.class.php';
35$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
36$massaction =
GETPOST(
'massaction',
'alpha');
38$confirm =
GETPOST(
'confirm',
'alpha');
39$cancel =
GETPOST(
'cancel',
'alpha');
40$toselect =
GETPOST(
'toselect',
'array');
41$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
42$backtopage =
GETPOST(
'backtopage',
'alpha');
43$optioncss =
GETPOST(
'optioncss',
'aZ');
48$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
49$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
51if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
55$offset = $limit * $page;
60$search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
61$search_ref =
GETPOST(
"search_ref",
"alpha") ?
GETPOST(
"search_ref",
"alpha") :
GETPOST(
"sref",
"alpha");
62$search_messtype =
GETPOST(
"search_messtype",
"alpha");
63$filteremail =
GETPOST(
'filteremail',
'alpha');
68$hookmanager->initHooks(array($contextpage));
71$extrafields->fetch_name_optionals_label(
$object->table_element);
73$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
80 $sortfield =
"m.date_creat";
84$fieldstosearchall = array(
88$permissiontoread = $user->hasRight(
'mailing',
'lire');
89$permissiontoadd = $user->hasRight(
'mailing',
'creer');
90$permissiontodelete = $user->hasRight(
'mailing',
'delete');
93if (!$user->hasRight(
'mailing',
'lire') || (!
getDolGlobalString(
'EXTERNAL_USERS_ARE_AUTHORIZED') && $user->socid > 0)) {
103if (
GETPOST(
'cancel',
'alpha')) {
107if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
111$parameters = array();
112$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
117if (empty($reshook)) {
119 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
122 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
128 $search_messtype =
'';
131 $search_array_options = array();
133 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
134 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
139 $objectclass =
'Mailing';
140 $objectlabel =
'Mailing';
141 $uploaddir = $conf->mailing->dir_output;
142 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
150$form =
new Form($db);
154$help_url =
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
155$title = $langs->trans(
"Mailing");
162 $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,";
163 $sql .=
" mc.statut as sendstatut";
167 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
168 $sql .=
" WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
169 $sql .=
" AND mc.email = '".$db->escape($filteremail).
"'";
171 $sql .=
" AND m.rowid = '".$db->escape($search_ref).
"'";
173 if ($search_messtype) {
174 $sql .=
" AND m.messtype LIKE '".$db->escape($search_messtype).
"'";
177 $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).
"%')";
183 $sortfield =
"m.rowid";
186 $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";
190 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m";
191 $sql .=
" WHERE m.entity = ".((int) $conf->entity);
193 $sql .=
" AND m.rowid = '".$db->escape($search_ref).
"'";
195 if ($search_messtype) {
196 $sql .=
" AND m.messtype LIKE '".$db->escape($search_messtype).
"'";
199 $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).
"%')";
205 $sortfield =
"m.rowid";
209 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
213include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
215$parameters = array();
216$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
217$sql .= $hookmanager->resPrint;
220$nbtotalofrecords =
'';
223 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
224 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
225 $resql = $db->query($sqlforcount);
227 $objforcount = $db->fetch_object($resql);
228 $nbtotalofrecords = $objforcount->nbtotalofrecords;
233 if (($page * $limit) > $nbtotalofrecords) {
241$sql .= $db->order($sortfield, $sortorder);
243 $sql .= $db->plimit($limit + 1, $offset);
246$resql = $db->query($sql);
252$num = $db->num_rows($resql);
256if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
257 $obj = $db->fetch_object($resql);
259 header(
"Location: ".
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.
$id);
267$title = $langs->trans(
"EMailings");
269 $title .=
' ('.$langs->trans(
"SentTo", $filteremail).
')';
272llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist');
274$arrayofselected = is_array($toselect) ? $toselect : array();
276$param =
"&search_all=".urlencode($search_all);
278 $param .=
'&mode='.urlencode($mode);
280if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
281 $param .=
'&contextpage='.urlencode($contextpage);
283if ($limit > 0 && $limit != $conf->liste_limit) {
284 $param .=
'&limit='.((int) $limit);
286if ($optioncss !=
'') {
287 $param .=
'&optioncss='.urlencode($optioncss);
289if ($search_ref !=
'') {
290 $param .=
'&search_ref='.urlencode($search_ref);
292if ($search_messtype !=
'') {
293 $param .=
'&search_type='.urlencode($search_messtype);
295if ($optioncss !=
'') {
296 $param .=
'&optioncss='.urlencode($optioncss);
300 $param .=
'&filteremail='.urlencode($filteremail);
303include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
305$parameters = array(
'param' => &$param);
306$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
307$param .= $hookmanager->resPrint;
310$arrayofmassactions = array(
316if (!empty($permissiontodelete)) {
317 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
319if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
320 $arrayofmassactions = array();
322$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
324print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
325if ($optioncss !=
'') {
326 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
328print
'<input type="hidden" name="token" value="'.newToken().
'">';
329print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
330print
'<input type="hidden" name="action" value="list">';
331print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
332print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
333print
'<input type="hidden" name="page" value="'.$page.
'">';
334print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
335print
'<input type="hidden" name="page_y" value="">';
336print
'<input type="hidden" name="mode" value="'.$mode.
'">';
339if ($user->hasRight(
'mailing',
'creer')) {
340 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewMailing'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/comm/mailing/card.php?action=create');
343print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_email', 0, $newcardbutton,
'', $limit, 0, 0, 1);
346$topicmail =
"SendMailingRef";
347$modelmail =
"mailing";
349$trackid =
'mailing'.$object->id;
350include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
354 foreach ($fieldstosearchall as $key => $val) {
355 $fieldstosearchall[$key] = $langs->trans($val);
356 $setupstring .= $key.
"=".$val.
";";
358 print
'<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
359 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
364$parameters = array();
365$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
366if (empty($reshook)) {
367 $moreforfilter .= $hookmanager->resPrint;
369 $moreforfilter = $hookmanager->resPrint;
372if (!empty($moreforfilter)) {
373 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
374 print $moreforfilter;
378$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
379$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
380$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
382print
'<div class="div-table-responsive">';
383print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
387print
'<tr class="liste_titre_filter">';
390 print
'<td class="liste_titre maxwidthsearch center">';
391 $searchpicto = $form->showFilterButtons(
'left');
395print
'<td class="liste_titre">';
396print
'<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
400 print
'<td class="liste_titre">';
401 print
'<input type="text" class="flat maxwidth50" name="search_messtype" value="'.dol_escape_htmltag($search_messtype).
'">';
405print
'<td class="liste_titre">';
406print
'<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_all" value="'.dol_escape_htmltag($search_all).
'">';
408print
'<td class="liste_titre"> </td>';
410 print
'<td class="liste_titre"> </td>';
412print
'<td class="liste_titre"> </td>';
413print
'<td class="liste_titre"> </td>';
415include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
417$parameters = array(
'arrayfields' => $arrayfields);
418$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
419print $hookmanager->resPrint;
422 print
'<td class="liste_titre center maxwidthsearch">';
423 $searchpicto = $form->showFilterButtons();
429$totalarray = array();
430$totalarray[
'nbfield'] = 0;
434print
'<tr class="liste_titre">';
436 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
437 $totalarray[
'nbfield']++;
440$totalarray[
'nbfield']++;
444 $totalarray[
'nbfield']++;
447$totalarray[
'nbfield']++;
448print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"m.date_creat", $param,
"",
'', $sortfield, $sortorder,
'center ');
449$totalarray[
'nbfield']++;
451 $title = $langs->trans(
"NbOfEMails");
453 $title .=
' | '.$langs->trans(
"SMS");
455 print_liste_field_titre($title, $_SERVER[
"PHP_SELF"],
"m.nbemail", $param,
"",
'', $sortfield, $sortorder,
'center ');
456 $totalarray[
'nbfield']++;
459 print_liste_field_titre(
"DateLastSend", $_SERVER[
"PHP_SELF"],
"m.date_envoi", $param,
"",
'', $sortfield, $sortorder,
'center ');
460 $totalarray[
'nbfield']++;
462 print_liste_field_titre(
"DateSending", $_SERVER[
"PHP_SELF"],
"mc.date_envoi", $param,
"",
'', $sortfield, $sortorder,
'center ');
463 $totalarray[
'nbfield']++;
466include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
468$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
469$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
470print $hookmanager->resPrint;
471print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"], ($filteremail ?
"mc.statut" :
"m.statut"), $param,
"",
'', $sortfield, $sortorder,
'center ');
472$totalarray[
'nbfield']++;
475 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
476 $totalarray[
'nbfield']++;
480$totalarray = array();
481$totalarray[
'nbfield'] = 0;
487$savnbfield = $totalarray[
'nbfield'];
488$totalarray = array();
489$totalarray[
'nbfield'] = 0;
490$imaxinloop = ($limit ? min($num, $limit) : $num);
491while ($i < $imaxinloop) {
492 $obj = $db->fetch_object($resql);
502 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
505 print
'<td class="nowrap center">';
506 if ($massactionbutton || $massaction) {
508 if (in_array(
$object->id, $arrayofselected)) {
511 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
515 $totalarray[
'nbfield']++;
532 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).
'">'.
dol_escape_htmltag($obj->title).
'</td>';
535 print
'<td class="center">';
541 print
'<td class="center nowraponall">';
542 $nbemail = $obj->nbemail;
557 print
'<td class="nowrap center">'.dol_print_date($db->jdate($obj->date_envoi),
'day').
'</td>';
561 print
'<td class="nowrap center">';
563 print $object::libStatutDest($obj->sendstatut, 2);
565 print
$object->LibStatut($obj->status, 5);
571 print
'<td class="nowrap center">';
572 if ($massactionbutton || $massaction) {
574 if (in_array(
$object->id, $arrayofselected)) {
577 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
581 $totalarray[
'nbfield']++;
591include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
599 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
605$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
606$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
607print $hookmanager->resPrint;
609print
'</table>'.
"\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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_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)
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).
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.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.