29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/comm/mailing/class/mailing.class.php';
44$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
45$massaction =
GETPOST(
'massaction',
'alpha');
47$confirm =
GETPOST(
'confirm',
'alpha');
48$cancel =
GETPOST(
'cancel',
'alpha');
49$toselect =
GETPOST(
'toselect',
'array');
50$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
51$backtopage =
GETPOST(
'backtopage',
'alpha');
52$optioncss =
GETPOST(
'optioncss',
'aZ');
57$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
58$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
60if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
64$offset = $limit * $page;
69$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
70$search_ref =
GETPOST(
"search_ref",
"alpha") ?
GETPOST(
"search_ref",
"alpha") :
GETPOST(
"sref",
"alpha");
71$search_messtype =
GETPOST(
"search_messtype",
"alpha");
72$filteremail =
GETPOST(
'filteremail',
'alpha');
77$hookmanager->initHooks(array($contextpage));
80$extrafields->fetch_name_optionals_label(
$object->table_element);
82$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
89 $sortfield =
"m.date_creat";
93$fieldstosearchall = array(
97$permissiontoread = $user->hasRight(
'mailing',
'lire');
98$permissiontoadd = $user->hasRight(
'mailing',
'creer');
99$permissiontodelete = $user->hasRight(
'mailing',
'delete');
102if (!$user->hasRight(
'mailing',
'lire') || (!
getDolGlobalString(
'EXTERNAL_USERS_ARE_AUTHORIZED') && $user->socid > 0)) {
112if (
GETPOST(
'cancel',
'alpha')) {
116if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
120$parameters = array();
121$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
126if (empty($reshook)) {
128 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
131 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
137 $search_messtype =
'';
140 $search_array_options = array();
142 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
143 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
148 $objectclass =
'Mailing';
149 $objectlabel =
'Mailing';
150 $uploaddir =
$conf->mailing->dir_output;
151 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
159$form =
new Form($db);
163$help_url =
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
164$title = $langs->trans(
"Mailing");
171 $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,";
172 $sql .=
" mc.statut as sendstatut";
176 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
177 $sql .=
" WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
178 $sql .=
" AND mc.email = '".$db->escape($filteremail).
"'";
180 $sql .=
" AND m.rowid = '".$db->escape($search_ref).
"'";
182 if ($search_messtype) {
183 $sql .=
" AND m.messtype LIKE '".$db->escape($search_messtype).
"'";
186 $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).
"%')";
192 $sortfield =
"m.rowid";
195 $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";
199 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m";
200 $sql .=
" WHERE m.entity = ".((int)
$conf->entity);
202 $sql .=
" AND m.rowid = '".$db->escape($search_ref).
"'";
204 if ($search_messtype) {
205 $sql .=
" AND m.messtype LIKE '".$db->escape($search_messtype).
"'";
208 $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).
"%')";
214 $sortfield =
"m.rowid";
218 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
222include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
224$parameters = array();
225$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
226$sql .= $hookmanager->resPrint;
229$nbtotalofrecords =
'';
232 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
233 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
234 $resql = $db->query($sqlforcount);
236 $objforcount = $db->fetch_object($resql);
237 $nbtotalofrecords = $objforcount->nbtotalofrecords;
242 if (($page * $limit) > $nbtotalofrecords) {
250$sql .= $db->order($sortfield, $sortorder);
252 $sql .= $db->plimit($limit + 1, $offset);
255$resql = $db->query($sql);
261$num = $db->num_rows($resql);
265if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
266 $obj = $db->fetch_object($resql);
268 header(
"Location: ".
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.
$id);
276$title = $langs->trans(
"EMailings");
278 $title .=
' ('.$langs->trans(
"SentTo", $filteremail).
')';
281llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist');
283$arrayofselected = is_array($toselect) ? $toselect : array();
285$param =
"&search_all=".urlencode($search_all);
287 $param .=
'&mode='.urlencode($mode);
289if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
290 $param .=
'&contextpage='.urlencode($contextpage);
292if ($limit > 0 && $limit !=
$conf->liste_limit) {
293 $param .=
'&limit='.((int) $limit);
295if ($optioncss !=
'') {
296 $param .=
'&optioncss='.urlencode($optioncss);
298if ($search_ref !=
'') {
299 $param .=
'&search_ref='.urlencode($search_ref);
301if ($search_messtype !=
'') {
302 $param .=
'&search_type='.urlencode($search_messtype);
304if ($optioncss !=
'') {
305 $param .=
'&optioncss='.urlencode($optioncss);
309 $param .=
'&filteremail='.urlencode($filteremail);
312include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
314$parameters = array(
'param' => &$param);
315$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
316$param .= $hookmanager->resPrint;
319$arrayofmassactions = array(
325if (!empty($permissiontodelete)) {
326 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
328if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
329 $arrayofmassactions = array();
331$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
333print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
334if ($optioncss !=
'') {
335 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
337print
'<input type="hidden" name="token" value="'.newToken().
'">';
338print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
339print
'<input type="hidden" name="action" value="list">';
340print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
341print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
342print
'<input type="hidden" name="page" value="'.$page.
'">';
343print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
344print
'<input type="hidden" name="page_y" value="">';
345print
'<input type="hidden" name="mode" value="'.$mode.
'">';
348if ($user->hasRight(
'mailing',
'creer')) {
349 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewMailing'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/comm/mailing/card.php?action=create');
352print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_email', 0, $newcardbutton,
'', $limit, 0, 0, 1);
355$topicmail =
"SendMailingRef";
356$modelmail =
"mailing";
358$trackid =
'mailing'.$object->id;
359include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
363 foreach ($fieldstosearchall as $key => $val) {
364 $fieldstosearchall[$key] = $langs->trans($val);
365 $setupstring .= $key.
"=".$val.
";";
367 print
'<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
368 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
373$parameters = array();
374$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
375if (empty($reshook)) {
376 $moreforfilter .= $hookmanager->resPrint;
378 $moreforfilter = $hookmanager->resPrint;
381if (!empty($moreforfilter)) {
382 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
383 print $moreforfilter;
387$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
388$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
389$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
391print
'<div class="div-table-responsive">';
392print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
396print
'<tr class="liste_titre_filter">';
399 print
'<td class="liste_titre maxwidthsearch center">';
400 $searchpicto = $form->showFilterButtons(
'left');
404print
'<td class="liste_titre">';
405print
'<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
409 print
'<td class="liste_titre">';
410 print
'<input type="text" class="flat maxwidth50" name="search_messtype" value="'.dol_escape_htmltag($search_messtype).
'">';
414print
'<td class="liste_titre">';
415print
'<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_all" value="'.dol_escape_htmltag($search_all).
'">';
417print
'<td class="liste_titre"> </td>';
419 print
'<td class="liste_titre"> </td>';
421print
'<td class="liste_titre"> </td>';
422print
'<td class="liste_titre"> </td>';
424include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
426$parameters = array(
'arrayfields' => $arrayfields);
427$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
428print $hookmanager->resPrint;
431 print
'<td class="liste_titre center maxwidthsearch">';
432 $searchpicto = $form->showFilterButtons();
438$totalarray = array();
439$totalarray[
'nbfield'] = 0;
443print
'<tr class="liste_titre">';
445 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
446 $totalarray[
'nbfield']++;
449$totalarray[
'nbfield']++;
453 $totalarray[
'nbfield']++;
456$totalarray[
'nbfield']++;
457print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"m.date_creat", $param,
"",
'', $sortfield, $sortorder,
'center ');
458$totalarray[
'nbfield']++;
460 $title = $langs->trans(
"NbOfEMails");
462 $title .=
' | '.$langs->trans(
"SMS");
464 print_liste_field_titre($title, $_SERVER[
"PHP_SELF"],
"m.nbemail", $param,
"",
'', $sortfield, $sortorder,
'center ');
465 $totalarray[
'nbfield']++;
468 print_liste_field_titre(
"DateLastSend", $_SERVER[
"PHP_SELF"],
"m.date_envoi", $param,
"",
'', $sortfield, $sortorder,
'center ');
469 $totalarray[
'nbfield']++;
471 print_liste_field_titre(
"DateSending", $_SERVER[
"PHP_SELF"],
"mc.date_envoi", $param,
"",
'', $sortfield, $sortorder,
'center ');
472 $totalarray[
'nbfield']++;
475include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
477$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
478$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
479print $hookmanager->resPrint;
480print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"], ($filteremail ?
"mc.statut" :
"m.statut"), $param,
"",
'', $sortfield, $sortorder,
'center ');
481$totalarray[
'nbfield']++;
484 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
485 $totalarray[
'nbfield']++;
489$totalarray = array();
490$totalarray[
'nbfield'] = 0;
496$savnbfield = $totalarray[
'nbfield'];
497$totalarray = array();
498$totalarray[
'nbfield'] = 0;
499$imaxinloop = ($limit ? min($num, $limit) : $num);
500while ($i < $imaxinloop) {
501 $obj = $db->fetch_object($resql);
511 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
514 print
'<td class="nowrap center">';
515 if ($massactionbutton || $massaction) {
517 if (in_array(
$object->id, $arrayofselected)) {
520 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
524 $totalarray[
'nbfield']++;
541 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).
'">'.
dol_escape_htmltag($obj->title).
'</td>';
544 print
'<td class="center">';
550 print
'<td class="center nowraponall">';
551 $nbemail = $obj->nbemail;
566 print
'<td class="nowrap center">'.dol_print_date($db->jdate($obj->date_envoi),
'day').
'</td>';
570 print
'<td class="nowrap center">';
572 print $object::libStatutDest($obj->sendstatut, 2);
574 print
$object->LibStatut($obj->status, 5);
580 print
'<td class="nowrap center">';
581 if ($massactionbutton || $massaction) {
583 if (in_array(
$object->id, $arrayofselected)) {
586 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
590 $totalarray[
'nbfield']++;
600include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
608 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
614$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
615$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
616print $hookmanager->resPrint;
618print
'</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...
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.