25 require
'../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/comm/mailing/class/mailing.class.php';
29 $langs->load(
"mails");
34 $sortfield =
GETPOST(
"sortfield",
'alpha');
35 $sortorder =
GETPOST(
"sortorder",
'alpha');
36 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
37 $optioncss =
GETPOST(
'optioncss',
'alpha');
39 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) { $page = 0; }
40 $offset = $limit * $page;
41 $pageprev = $page - 1;
42 $pagenext = $page + 1;
43 if (!$sortorder) $sortorder =
"DESC";
44 if (!$sortfield) $sortfield =
"m.date_creat";
46 $search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
47 $search_ref =
GETPOST(
"search_ref",
"alpha") ?
GETPOST(
"search_ref",
"alpha") :
GETPOST(
"sref",
"alpha");
48 $filteremail =
GETPOST(
'filteremail',
'alpha');
53 $hookmanager->initHooks(array(
'mailinglist'));
57 $extrafields->fetch_name_optionals_label($object->table_element);
59 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
62 $fieldstosearchall = array(
73 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
74 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
76 $parameters = array();
77 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
78 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
83 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
86 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
95 $search_array_options = array();
97 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
98 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha'))
118 llxHeader(
'', $langs->trans(
"Mailing"),
'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing');
120 $form =
new Form($db);
123 $sql =
"SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,";
124 $sql .=
" mc.statut as sendstatut";
125 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
126 $sql .=
" WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
127 $sql .=
" AND mc.email = '".$db->escape($filteremail).
"'";
128 if ($search_ref) $sql .=
" AND m.rowid = '".$db->escape($search_ref).
"'";
129 if ($search_all) $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).
"%')";
130 if (!$sortorder) $sortorder =
"ASC";
131 if (!$sortfield) $sortfield =
"m.rowid";
133 $sql =
"SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi";
134 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m";
135 $sql .=
" WHERE m.entity = ".$conf->entity;
136 if ($search_ref) $sql .=
" AND m.rowid = '".$db->escape($search_ref).
"'";
137 if ($search_all) $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).
"%')";
138 if (!$sortorder) $sortorder =
"ASC";
139 if (!$sortfield) $sortfield =
"m.rowid";
142 $sql .= $db->order($sortfield, $sortorder);
144 $nbtotalofrecords =
'';
145 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
147 $resql = $db->query($sql);
148 $nbtotalofrecords = $db->num_rows(
$resql);
149 if (($page * $limit) > $nbtotalofrecords)
156 $sql .= $db->plimit($limit + 1, $offset);
159 dol_syslog(
"comm/mailing/list.php", LOG_DEBUG);
160 $resql = $db->query($sql);
163 $num = $db->num_rows(
$resql);
165 $title = $langs->trans(
"ListOfEMailings");
166 if ($filteremail) $title .=
' ('.$langs->trans(
"SentTo", $filteremail).
')';
169 if ($user->rights->mailing->creer)
171 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewMailing'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/comm/mailing/card.php?action=create');
176 $param =
"&search_all=".urlencode($search_all);
177 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
178 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
179 if ($filteremail) $param .=
'&filteremail='.urlencode($filteremail);
181 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
182 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
183 print '<input type="hidden" name="token" value="'.newToken().
'">';
184 print '<input type="hidden" name="action" value="list">';
185 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
186 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
188 print_barre_liste($title, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'object_email', 0, $newcardbutton,
'', $limit, 0, 0, 1);
192 print '<div class="div-table-responsive">';
193 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
195 print '<tr class="liste_titre_filter">';
196 print
'<td class="liste_titre">';
197 print
'<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
200 print
'<td class="liste_titre">';
201 print
'<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_all" value="'.dol_escape_htmltag($search_all).
'">';
203 print
'<td class="liste_titre"> </td>';
204 if (!$filteremail) print
'<td class="liste_titre"> </td>';
205 print
'<td class="liste_titre"> </td>';
206 print
'<td class="liste_titre"> </td>';
207 print
'<td class="liste_titre maxwidthsearch">';
208 $searchpicto = $form->showFilterAndCheckAddButtons(0);
213 print
'<tr class="liste_titre">';
218 if (!$filteremail)
print_liste_field_titre(
"DateLastSend",
$_SERVER[
"PHP_SELF"],
"m.date_envoi", $param,
"",
'align="center"', $sortfield, $sortorder);
220 print_liste_field_titre(
"Status",
$_SERVER[
"PHP_SELF"], ($filteremail ?
"mc.statut" :
"m.statut"), $param,
"",
'class="right"', $sortfield, $sortorder);
227 while ($i < min($num, $limit))
229 $obj = $db->fetch_object(
$resql);
231 $email->id = $obj->rowid;
232 $email->ref = $obj->rowid;
234 print
'<tr class="oddeven">';
237 print $email->getNomUrl(1);
241 print
'<td>'.$obj->title.
'</td>';
244 print
'<td class="center">';
251 print
'<td class="center">';
252 $nbemail = $obj->nbemail;
267 print
'<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->date_envoi),
'day').
'</td>';
271 print
'<td class="nowrap right">';
274 print $email::libStatutDest($obj->sendstatut, 2);
276 print $email->LibStatut($obj->statut, 5);
287 if (!$filteremail) $colspan++;
288 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
Class to manage emailings module.
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...