31require
'../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/comm/mailing/class/mailing.class.php';
40require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
46$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
47$massaction =
GETPOST(
'massaction',
'alpha');
49$confirm =
GETPOST(
'confirm',
'alpha');
50$cancel =
GETPOST(
'cancel',
'alpha');
51$toselect =
GETPOST(
'toselect',
'array:int');
52$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
53$backtopage =
GETPOST(
'backtopage',
'alpha');
54$optioncss =
GETPOST(
'optioncss',
'aZ');
59$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
60$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
62if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
66$offset = $limit * $page;
71$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
72$search_ref =
GETPOST(
"search_ref",
"alpha") ?
GETPOST(
"search_ref",
"alpha") :
GETPOST(
"sref",
"alpha");
73$search_title =
GETPOST(
"search_title",
"alpha");
74$search_subject =
GETPOST(
"search_subject",
"alpha");
75$search_messtype =
GETPOST(
"search_messtype",
"alpha");
76$filteremail =
GETPOST(
'filteremail',
'alpha');
78$search_refproject =
GETPOST(
'search_refproject',
'alpha');
79$search_project =
GETPOST(
'search_project',
'alpha');
84$hookmanager->initHooks(array($contextpage));
87$extrafields->fetch_name_optionals_label(
$object->table_element);
89$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
96 $sortfield =
"m.date_creat";
100$fieldstosearchall = array(
104$permissiontoread = $user->hasRight(
'mailing',
'lire');
105$permissiontoadd = $user->hasRight(
'mailing',
'creer');
106$permissiontodelete = $user->hasRight(
'mailing',
'delete');
109if (!$user->hasRight(
'mailing',
'lire') || (!
getDolGlobalString(
'EXTERNAL_USERS_ARE_AUTHORIZED') && $user->socid > 0)) {
119if (
GETPOST(
'cancel',
'alpha')) {
123if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
127$parameters = array();
128$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
133if (empty($reshook)) {
135 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
138 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
145 $search_subject =
'';
146 $search_messtype =
'';
147 $search_refproject =
'';
148 $search_project =
'';
151 $search_array_options = array();
153 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
154 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
159 $objectclass =
'Mailing';
160 $objectlabel =
'Mailing';
161 $uploaddir = $conf->mailing->dir_output;
162 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
170$form =
new Form($db);
171$projectstatic =
new Project($db);
175$help_url =
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
176$title = $langs->trans(
"Mailing");
183 $sql =
"SELECT m.rowid, m.messtype, m.titre as title, m.sujet as subject, m.nbemail, m.statut as status, m.date_creat as datec, m.date_envoi as date_envoi,";
184 $sql .=
" mc.statut as sendstatut,";
185 $sql .=
" pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label";
189 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
190 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as pr ON pr.rowid = m.fk_project";
191 $sql .=
" WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
192 $sql .=
" AND mc.email = '".$db->escape($filteremail).
"'";
197 $sql .=
" AND (m.titre LIKE '%".$db->escape($search_title).
"%')";
199 if ($search_subject) {
200 $sql .=
" AND (m.sujet LIKE '%".$db->escape($search_subject).
"%')";
202 if ($search_messtype) {
203 $sql .=
" AND m.messtype LIKE '".$db->escape($search_messtype).
"'";
206 $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).
"%')";
208 if ($search_refproject) {
211 if ($search_project) {
218 $sortfield =
"m.rowid";
221 $sql =
"SELECT m.rowid, m.messtype, m.titre as title, m.sujet as subject, m.nbemail, m.statut as status, m.date_creat as datec, m.date_envoi as date_envoi,";
222 $sql .=
" pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label";
226 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m";
227 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as pr ON pr.rowid = m.fk_project";
228 $sql .=
" WHERE m.entity = ".((int) $conf->entity);
233 $sql .=
" AND m.titre LIKE '%".$db->escape($search_title).
"%'";
235 if ($search_subject) {
236 $sql .=
" AND m.sujet LIKE '%".$db->escape($search_subject).
"%'";
238 if ($search_messtype) {
239 $sql .=
" AND m.messtype LIKE '%".$db->escape($search_messtype).
"%'";
242 $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).
"%')";
244 if ($search_refproject) {
247 if ($search_project) {
254 $sortfield =
"m.rowid";
258 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
262include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
264$parameters = array();
265$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
266$sql .= $hookmanager->resPrint;
269$nbtotalofrecords =
'';
272 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
273 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
274 $resql = $db->query($sqlforcount);
276 $objforcount = $db->fetch_object($resql);
277 $nbtotalofrecords = $objforcount->nbtotalofrecords;
282 if (($page * $limit) > (
int) $nbtotalofrecords) {
290$sql .= $db->order($sortfield, $sortorder);
292 $sql .= $db->plimit($limit + 1, $offset);
295$resql = $db->query($sql);
301$num = $db->num_rows($resql);
305if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
306 $obj = $db->fetch_object($resql);
308 header(
"Location: ".
dol_buildpath(
'/comm/mailing/card.php', 1).
'?id='.((
int)
$id));
316$title = $langs->trans(
"EMailings");
318 $title .=
' ('.$langs->trans(
"SentTo", $filteremail).
')';
321llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist');
323$arrayofselected = is_array($toselect) ? $toselect : array();
325$param =
"&search_all=".urlencode($search_all);
327 $param .=
'&mode='.urlencode($mode);
329if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
330 $param .=
'&contextpage='.urlencode($contextpage);
332if ($limit > 0 && $limit != $conf->liste_limit) {
333 $param .=
'&limit='.((int) $limit);
335if ($optioncss !=
'') {
336 $param .=
'&optioncss='.urlencode($optioncss);
338if ($search_ref !=
'') {
339 $param .=
'&search_ref='.urlencode($search_ref);
341if ($search_messtype !=
'') {
342 $param .=
'&search_type='.urlencode($search_messtype);
344if ($search_refproject !=
'') {
345 $param .=
'&search_refproject='.urlencode($search_refproject);
347if ($search_project !=
'') {
348 $param .=
'&search_project='.urlencode($search_project);
350if ($optioncss !=
'') {
351 $param .=
'&optioncss='.urlencode($optioncss);
355 $param .=
'&filteremail='.urlencode($filteremail);
358include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
360$parameters = array(
'param' => &$param);
361$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
362$param .= $hookmanager->resPrint;
365$arrayofmassactions = array(
371if (!empty($permissiontodelete)) {
372 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
374if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
375 $arrayofmassactions = array();
377$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
379print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
380if ($optioncss !=
'') {
381 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
383print
'<input type="hidden" name="token" value="'.newToken().
'">';
384print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
385print
'<input type="hidden" name="action" value="list">';
386print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
387print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
388print
'<input type="hidden" name="page" value="'.$page.
'">';
389print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
390print
'<input type="hidden" name="page_y" value="">';
391print
'<input type="hidden" name="mode" value="'.$mode.
'">';
394if ($user->hasRight(
'mailing',
'creer')) {
395 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewMailing'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/comm/mailing/card.php?action=create');
398print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_email', 0, $newcardbutton,
'', $limit, 0, 0, 1);
401$topicmail =
"SendMailingRef";
402$modelmail =
"mailing";
404$trackid =
'mailing'.$object->id;
405include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
409 foreach ($fieldstosearchall as $key => $val) {
410 $fieldstosearchall[$key] = $langs->trans($val);
411 $setupstring .= $key.
"=".$val.
";";
413 print
'<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
414 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
419$parameters = array();
420$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
421if (empty($reshook)) {
422 $moreforfilter .= $hookmanager->resPrint;
424 $moreforfilter = $hookmanager->resPrint;
427if (!empty($moreforfilter)) {
428 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
429 print $moreforfilter;
433$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
434$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
435$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
437print
'<div class="div-table-responsive">';
438print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
442print
'<tr class="liste_titre_filter">';
445 print
'<td class="liste_titre maxwidthsearch center">';
446 $searchpicto = $form->showFilterButtons(
'left');
450print
'<td class="liste_titre">';
451print
'<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
455 print
'<td class="liste_titre">';
456 print
'<input type="text" class="flat maxwidth50" name="search_messtype" value="'.dol_escape_htmltag($search_messtype).
'">';
460print
'<td class="liste_titre">';
461print
'<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_title" value="'.dol_escape_htmltag($search_title).
'">';
464print
'<td class="liste_titre">';
465print
'<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_subject" value="'.dol_escape_htmltag($search_subject).
'">';
468print
'<td class="liste_titre"> </td>';
471print
'<td class="liste_titre">';
472print
'<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_project" value="'.dol_escape_htmltag($search_project).
'">';
476 print
'<td class="liste_titre"> </td>';
478print
'<td class="liste_titre"> </td>';
479print
'<td class="liste_titre"> </td>';
481include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
483$parameters = array(
'arrayfields' => $arrayfields);
484$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
485print $hookmanager->resPrint;
488 print
'<td class="liste_titre center maxwidthsearch">';
489 $searchpicto = $form->showFilterButtons();
500print
'<tr class="liste_titre">';
502 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
516print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"m.date_creat",
"", $param,
'', $sortfield, $sortorder,
'center ');
520print_liste_field_titre(
"Project", $_SERVER[
"PHP_SELF"],
"project_label",
"", $param,
'', $sortfield, $sortorder);
524 $title = $langs->trans(
"NbOfEMails");
526 $title .=
' | '.$langs->trans(
"SMS");
528 print_liste_field_titre($title, $_SERVER[
"PHP_SELF"],
"m.nbemail",
"", $param,
'', $sortfield, $sortorder,
'center ');
532 print_liste_field_titre(
"DateLastSend", $_SERVER[
"PHP_SELF"],
"m.date_envoi",
"", $param,
'', $sortfield, $sortorder,
'center ');
535 print_liste_field_titre(
"DateSending", $_SERVER[
"PHP_SELF"],
"mc.date_envoi",
"", $param,
'', $sortfield, $sortorder,
'center ');
539include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
541$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
542$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
543print $hookmanager->resPrint;
544print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"], ($filteremail ?
"mc.statut" :
"m.statut"),
"", $param,
'', $sortfield, $sortorder,
'center ');
548 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
559$imaxinloop = ($limit ? min($num, $limit) : $num);
560while ($i < $imaxinloop) {
561 $obj = $db->fetch_object($resql);
569 $projectstatic->id = $obj->project_id;
570 $projectstatic->ref = $obj->project_ref;
571 $projectstatic->title = $obj->project_label;
574 print
'<tr data-rowid="'.$object->id.
'" class="oddeven row-with-select">';
577 print
'<td class="nowrap center">';
578 if ($massactionbutton || $massaction) {
580 if (in_array(
$object->id, $arrayofselected)) {
583 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
610 print
'<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($obj->title).
'">';
621 print
'<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($obj->subject).
'">';
629 print
'<td class="center">';
637 print
'<td class="nowraponall">';
638 print
'<a href="/projet/card.php?id='.((int) $projectstatic->id).
'">'.
dol_escape_htmltag($projectstatic->title).
'</a>';
646 print
'<td class="center nowraponall">';
647 $nbemail = $obj->nbemail;
665 print
'<td class="nowrap center">'.dol_print_date($db->jdate($obj->date_envoi),
'day').
'</td>';
672 print
'<td class="nowrap center">';
674 print $object::libStatutDest($obj->sendstatut, 2);
676 print
$object->LibStatut($obj->status, 5);
685 print
'<td class="nowrap center">';
686 if ($massactionbutton || $massaction) {
688 if (in_array(
$object->id, $arrayofselected)) {
691 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
705include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
709 $colspan = $savnbfield;
710 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
716$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
717$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
718print $hookmanager->resPrint;
720print
'</table>'.
"\n";
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $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.
Class to manage projects.
dol_now($mode='gmt')
Return date for now.
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, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.