dolibarr  17.0.4
cibles.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005-2021 Laurent Destailleur <eldy@uers.sourceforge.net>
4  * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
27 // Load Dolibarr environment
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
30 require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmailing.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
35 
36 // Load translation files required by the page
37 $langs->load("mails");
38 
39 // Load variable for pagination
40 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
41 $sortfield = GETPOST('sortfield', 'aZ09comma');
42 $sortorder = GETPOST('sortorder', 'aZ09comma');
43 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
44 if (empty($page) || $page == -1) {
45  $page = 0;
46 } // If $page is not defined, or '' or -1
47 $offset = $limit * $page;
48 $pageprev = $page - 1;
49 $pagenext = $page + 1;
50 if (!$sortfield) {
51  $sortfield = "mc.statut,email";
52 }
53 if (!$sortorder) {
54  $sortorder = "DESC,ASC";
55 }
56 
57 $id = GETPOST('id', 'int');
58 $rowid = GETPOST('rowid', 'int');
59 $action = GETPOST('action', 'aZ09');
60 $search_lastname = GETPOST("search_lastname", 'alphanohtml');
61 $search_firstname = GETPOST("search_firstname", 'alphanohtml');
62 $search_email = GETPOST("search_email", 'alphanohtml');
63 $search_other = GETPOST("search_other", 'alphanohtml');
64 $search_dest_status = GETPOST('search_dest_status', 'int');
65 
66 // Search modules dirs
67 $modulesdir = dolGetModulesDirs('/mailings');
68 
69 $object = new Mailing($db);
70 $result = $object->fetch($id);
71 
72 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
73 $hookmanager->initHooks(array('ciblescard', 'globalcard'));
74 
75 // Security check
76 if (!$user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) {
78 }
79 //$result = restrictedArea($user, 'mailing');
80 
81 
82 /*
83  * Actions
84  */
85 
86 if ($action == 'add') {
87  $module = GETPOST("module", 'alpha');
88  $result = -1;
89 
90  foreach ($modulesdir as $dir) {
91  // Load modules attributes in arrays (name, numero, orders) from dir directory
92  //print $dir."\n<br>";
93  dol_syslog("Scan directory ".$dir." for modules");
94 
95  // Loading Class
96  $file = $dir."/".$module.".modules.php";
97  $classname = "mailing_".$module;
98 
99  if (file_exists($file)) {
100  require_once $file;
101 
102  // Add targets into database
103  $obj = new $classname($db);
104  dol_syslog("Call add_to_target on class ".$classname);
105  $result = $obj->add_to_target($id);
106  }
107  }
108  if ($result > 0) {
109  setEventMessages($langs->trans("XTargetsAdded", $result), null, 'mesgs');
110  $action = '';
111  }
112  if ($result == 0) {
113  setEventMessages($langs->trans("WarningNoEMailsAdded"), null, 'warnings');
114  }
115  if ($result < 0) {
116  setEventMessages($langs->trans("Error").($obj->error ? ' '.$obj->error : ''), null, 'errors');
117  }
118 }
119 
120 if (GETPOST('clearlist', 'int')) {
121  // Loading Class
122  $obj = new MailingTargets($db);
123  $obj->clear_target($id);
124  /* Avoid this to allow reposition
125  header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
126  exit;
127  */
128 }
129 
130 if (GETPOST('exportcsv', 'int')) {
131  $completefilename = 'targets_emailing'.$object->id.'_'.dol_print_date(dol_now(), 'dayhourlog').'.csv';
132  header('Content-Type: text/csv');
133  header('Content-Disposition: attachment;filename='.$completefilename);
134 
135  // List of selected targets
136  $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,";
137  $sql .= " mc.source_id, mc.source_type, mc.error_text";
138  $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
139  $sql .= " WHERE mc.fk_mailing = ".((int) $object->id);
140  $sql .= $db->order($sortfield, $sortorder);
141 
142  $resql = $db->query($sql);
143  if ($resql) {
144  $num = $db->num_rows($resql);
145  $sep = ',';
146 
147  while ($obj = $db->fetch_object($resql)) {
148  print $obj->rowid.$sep;
149  print '"'.$obj->lastname.'"'.$sep;
150  print '"'.$obj->firstname.'"'.$sep;
151  print $obj->email.$sep;
152  print $obj->other.$sep;
153  print $obj->tms.$sep;
154  print $obj->source_type.$sep;
155  print $obj->source_id.$sep;
156  print $obj->date_envoi.$sep;
157  print $obj->status.$sep;
158  print '"'.$obj->error_text.'"'.$sep;
159  print "\n";
160  }
161 
162  exit;
163  } else {
164  dol_print_error($db);
165  }
166  exit;
167 }
168 
169 if ($action == 'delete') {
170  // Ici, rowid indique le destinataire et id le mailing
171  $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid = ".((int) $rowid);
172  $resql = $db->query($sql);
173  if ($resql) {
174  if (!empty($id)) {
175  $obj = new MailingTargets($db);
176  $obj->update_nb($id);
177 
178  setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
179  } else {
180  header("Location: list.php");
181  exit;
182  }
183  } else {
184  dol_print_error($db);
185  }
186 }
187 
188 // Purge search criteria
189 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
190  $search_lastname = '';
191  $search_firstname = '';
192  $search_email = '';
193  $search_other = '';
194  $search_dest_status = '';
195 }
196 
197 
198 
199 /*
200  * View
201  */
202 
203 llxHeader('', $langs->trans("Mailing"), 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing');
204 
205 $form = new Form($db);
206 $formmailing = new FormMailing($db);
207 
208 if ($object->fetch($id) >= 0) {
209  $head = emailing_prepare_head($object);
210 
211  print dol_get_fiche_head($head, 'targets', $langs->trans("Mailing"), -1, 'email');
212 
213  $linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
214 
215  $morehtmlright = '';
216  $nbtry = $nbok = 0;
217  if ($object->statut == 2 || $object->statut == 3) {
218  $nbtry = $object->countNbOfTargets('alreadysent');
219  $nbko = $object->countNbOfTargets('alreadysentko');
220  $nbok = ($nbtry - $nbko);
221 
222  $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail;
223  if ($nbko) {
224  $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error");
225  }
226  $morehtmlright .= ') &nbsp; ';
227  }
228 
229  dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);
230 
231  print '<div class="fichecenter">';
232  print '<div class="underbanner clearboth"></div>';
233 
234  print '<table class="border centpercent tableforfield">';
235 
236  print '<tr><td class="titlefield">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$object->title.'</td></tr>';
237 
238  print '<tr><td>'.$langs->trans("MailFrom").'</td><td colspan="3">';
239  $emailarray = CMailFile::getArrayAddress($object->email_from);
240  foreach ($emailarray as $email => $name) {
241  if ($name && $name != $email) {
242  print dol_escape_htmltag($name).' &lt;'.$email;
243  print '&gt;';
244  if (!isValidEmail($email)) {
245  $langs->load("errors");
246  print img_warning($langs->trans("ErrorBadEMail", $email));
247  }
248  } else {
249  print dol_print_email($object->email_from, 0, 0, 0, 0, 1);
250  }
251  }
252  //print dol_print_email($object->email_from, 0, 0, 0, 0, 1);
253  //var_dump($object->email_from);
254  print '</td></tr>';
255 
256  // Errors to
257  print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td colspan="3">';
258  $emailarray = CMailFile::getArrayAddress($object->email_errorsto);
259  foreach ($emailarray as $email => $name) {
260  if ($name != $email) {
261  print dol_escape_htmltag($name).' &lt;'.$email;
262  print '&gt;';
263  if (!isValidEmail($email)) {
264  $langs->load("errors");
265  print img_warning($langs->trans("ErrorBadEMail", $email));
266  }
267  } else {
268  print dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1);
269  }
270  }
271  print '</td></tr>';
272 
273  // Nb of distinct emails
274  print '<tr><td>';
275  print $langs->trans("TotalNbOfDistinctRecipients");
276  print '</td><td colspan="3">';
277  $nbemail = ($object->nbemail ? $object->nbemail : 0);
278  if (is_numeric($nbemail)) {
279  $text = '';
280  if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) {
281  if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) {
282  $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
283  } else {
284  $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed');
285  }
286  }
287  if (empty($nbemail)) {
288  $nbemail .= ' '.img_warning('').' <span class="warning">'.$langs->trans("NoTargetYet").'</span>';
289  }
290  if ($text) {
291  print $form->textwithpicto($nbemail, $text, 1, 'warning');
292  } else {
293  print $nbemail;
294  }
295  }
296  print '</td></tr>';
297 
298  print '</table>';
299 
300  print "</div>";
301 
302  print dol_get_fiche_end();
303 
304  print '<br>';
305 
306 
307  $allowaddtarget = ($object->statut == 0);
308 
309  // Show email selectors
310  if ($allowaddtarget && $user->rights->mailing->creer) {
311  print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin ?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : ''), 'generic');
312 
313  print '<div class="div-table-responsive">';
314  print '<div class="tagtable centpercent liste_titre_bydiv borderbottom" id="tablelines">';
315 
316  print '<div class="tagtr liste_titre">';
317  print '<div class="tagtd"></div>';
318  print '<div class="tagtd">'.$langs->trans("RecipientSelectionModules").'</div>';
319  print '<div class="tagtd" align="center">'.$langs->trans("NbOfUniqueEMails").'</div>';
320  print '<div class="tagtd left">'.$langs->trans("Filter").'</div>';
321  print '<div class="tagtd">&nbsp;</div>';
322  print '</div>'; // End tr
323 
324  clearstatcache();
325 
326  foreach ($modulesdir as $dir) {
327  $modulenames = array();
328 
329  // Load modules attributes in arrays (name, numero, orders) from dir directory
330  //print $dir."\n<br>";
331  dol_syslog("Scan directory ".$dir." for modules");
332  $handle = @opendir($dir);
333  if (is_resource($handle)) {
334  while (($file = readdir($handle)) !== false) {
335  if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') {
336  $reg = array();
337  if (preg_match("/(.*)\.modules\.php$/i", $file, $reg)) {
338  if ($reg[1] == 'example') {
339  continue;
340  }
341  $modulenames[] = $reg[1];
342  }
343  }
344  }
345  closedir($handle);
346  }
347 
348  // Sort $modulenames
349  sort($modulenames);
350 
351  $var = true;
352 
353  // Loop on each submodule
354  foreach ($modulenames as $modulename) {
355  // Loading Class
356  $file = $dir.$modulename.".modules.php";
357  $classname = "mailing_".$modulename;
358  require_once $file;
359 
360  $obj = new $classname($db);
361 
362  // Check if qualified
363  $qualified = (is_null($obj->enabled) ? 1 : dol_eval($obj->enabled, 1));
364 
365  // Check dependencies
366  foreach ($obj->require_module as $key) {
367  if (empty($conf->$key->enabled) || (empty($user->admin) && $obj->require_admin)) {
368  $qualified = 0;
369  //print "Les prerequis d'activation du module mailing ne sont pas respectes. Il ne sera pas actif";
370  break;
371  }
372  }
373 
374  // If module is qualified
375  if ($qualified) {
376  $var = !$var;
377 
378  if ($allowaddtarget) {
379  print '<form '.$bctag[$var].' name="'.$modulename.'" action="'.$_SERVER['PHP_SELF'].'?action=add&token='.newToken().'&id='.$object->id.'&module='.$modulename.'" method="POST" enctype="multipart/form-data">';
380  print '<input type="hidden" name="token" value="'.newToken().'">';
381  print '<input type="hidden" name="page_y" value="'.newToken().'">';
382  } else {
383  print '<div '.$bctag[$var].'>';
384  }
385 
386  print '<div class="tagtd paddingleftimp marginleftonly paddingrightimp marginrightonly valignmiddle center">';
387  if (empty($obj->picto)) {
388  $obj->picto = 'generic';
389  }
390  print img_object($langs->trans("EmailingTargetSelector").': '.get_class($obj), $obj->picto, 'class="valignmiddle width25 size15x"');
391  print '</div>';
392  print '<div class="tagtd valignmiddle">'; // style="height: 4em"
393  print $obj->getDesc();
394  print '</div>';
395 
396  try {
397  $nbofrecipient = $obj->getNbOfRecipients('');
398  } catch (Exception $e) {
399  dol_syslog($e->getMessage(), LOG_ERR);
400  }
401 
402  print '<div class="tagtd center valignmiddle">';
403  if ($nbofrecipient === '' || $nbofrecipient >= 0) {
404  print $nbofrecipient;
405  } else {
406  print $langs->trans("Error").' '.img_error($obj->error);
407  }
408  print '</div>';
409 
410  print '<div class="tagtd left valignmiddle">';
411  if ($allowaddtarget) {
412  try {
413  $filter = $obj->formFilter();
414  } catch (Exception $e) {
415  dol_syslog($e->getMessage(), LOG_ERR);
416  }
417  if ($filter) {
418  print $filter;
419  } else {
420  print $langs->trans("None");
421  }
422  }
423  print '</div>';
424 
425  print '<div class="tagtd right valignmiddle">';
426  if ($allowaddtarget) {
427  print '<input type="submit" class="button button-add small reposition" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
428  } else {
429  print '<input type="submit" class="button small disabled" disabled="disabled" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
430  //print $langs->trans("MailNoChangePossible");
431  print "&nbsp;";
432  }
433  print '</div>';
434 
435  if ($allowaddtarget) {
436  print '</form>';
437  } else {
438  print '</div>';
439  }
440  }
441  }
442  } // End foreach dir
443 
444  $parameters = array();
445  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
446  print $hookmanager->resPrint;
447 
448  print '</div>'; // End table
449  print '</div>';
450 
451  print '<br><br>';
452  }
453 
454  // List of selected targets
455  $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.tms,";
456  $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text";
457  $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
458  $sql .= " WHERE mc.fk_mailing=".((int) $object->id);
459  $asearchcriteriahasbeenset = 0;
460  if ($search_lastname) {
461  $sql .= natural_search("mc.lastname", $search_lastname);
462  $asearchcriteriahasbeenset++;
463  }
464  if ($search_firstname) {
465  $sql .= natural_search("mc.firstname", $search_firstname);
466  $asearchcriteriahasbeenset++;
467  }
468  if ($search_email) {
469  $sql .= natural_search("mc.email", $search_email);
470  $asearchcriteriahasbeenset++;
471  }
472  if ($search_other) {
473  $sql .= natural_search("mc.other", $search_other);
474  $asearchcriteriahasbeenset++;
475  }
476  if ($search_dest_status != '' && $search_dest_status >= -1) {
477  $sql .= " AND mc.statut = ".((int) $search_dest_status);
478  $asearchcriteriahasbeenset++;
479  }
480  $sql .= $db->order($sortfield, $sortorder);
481 
482  // Count total nb of records
483  $nbtotalofrecords = '';
484  if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
485  $result = $db->query($sql);
486  $nbtotalofrecords = $db->num_rows($result);
487  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
488  $page = 0;
489  $offset = 0;
490  }
491 
492  // Fix/update nbemail on emailing record if it differs (may happen if user edit lines from database directly)
493  if (empty($asearchcriteriahasbeenset)) {
494  if ($nbtotalofrecords != $object->nbemail) {
495  dol_syslog("We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
496  //print "nbemail=".$object->nbemail." nbtotalofrecords=".$nbtotalofrecords;
497  $resultrefresh = $object->refreshNbOfTargets();
498  if ($resultrefresh < 0) {
499  dol_print_error($db, $object->error, $object->errors);
500  }
501  }
502  }
503  }
504 
505  //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets
506  $sql .= $db->plimit($limit + 1, $offset);
507 
508  $resql = $db->query($sql);
509  if ($resql) {
510  $num = $db->num_rows($resql);
511 
512  $param = "&id=".$object->id;
513  //if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
514  if ($limit > 0 && $limit != $conf->liste_limit) {
515  $param .= '&limit='.urlencode($limit);
516  }
517  if ($search_lastname) {
518  $param .= "&search_lastname=".urlencode($search_lastname);
519  }
520  if ($search_firstname) {
521  $param .= "&search_firstname=".urlencode($search_firstname);
522  }
523  if ($search_email) {
524  $param .= "&search_email=".urlencode($search_email);
525  }
526  if ($search_other) {
527  $param .= "&search_other=".urlencode($search_other);
528  }
529 
530  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
531  print '<input type="hidden" name="token" value="'.newToken().'">';
532  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
533  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
534  print '<input type="hidden" name="page" value="'.$page.'">';
535  print '<input type="hidden" name="id" value="'.$object->id.'">';
536 
537  $morehtmlcenter = '';
538  if ($allowaddtarget) {
539  $morehtmlcenter = '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ToClearAllRecipientsClickHere").'</span> <a href="'.$_SERVER["PHP_SELF"].'?clearlist=1&id='.$object->id.'" class="button reposition smallpaddingimp">'.$langs->trans("TargetsReset").'</a>';
540  }
541  $morehtmlcenter .= ' &nbsp; <a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=exportcsv&token='.newToken().'&exportcsv=1&id='.$object->id.'">'.img_picto('', 'download', 'class="pictofixedwidth"').$langs->trans("Download").'</a>';
542 
543  $massactionbutton = '';
544 
545  print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit, 0, 0, 1);
546 
547  print '</form>';
548 
549  print "\n<!-- Liste destinataires selectionnes -->\n";
550  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
551  print '<input type="hidden" name="token" value="'.newToken().'">';
552  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
553  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
554  print '<input type="hidden" name="page" value="'.$page.'">';
555  print '<input type="hidden" name="id" value="'.$object->id.'">';
556  print '<input type="hidden" name="limit" value="'.$limit.'">';
557  print '<input type="hidden" name="page_y" value="">';
558 
559  print '<div class="div-table-responsive">';
560  print '<table class="noborder centpercent">';
561 
562  // Ligne des champs de filtres
563  print '<tr class="liste_titre_filter">';
564  // EMail
565  print '<td class="liste_titre">';
566  print '<input class="flat maxwidth75" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
567  print '</td>';
568  // Name
569  print '<td class="liste_titre">';
570  print '<input class="flat maxwidth50" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'">';
571  print '</td>';
572  // Firstname
573  print '<td class="liste_titre">';
574  print '<input class="flat maxwidth50" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'">';
575  print '</td>';
576  // Other
577  print '<td class="liste_titre">';
578  print '<input class="flat maxwidth100" type="text" name="search_other" value="'.dol_escape_htmltag($search_other).'">';
579  print '</td>';
580  // Source
581  print '<td class="liste_titre">';
582  print '&nbsp;';
583  print '</td>';
584 
585  // Date last update
586  print '<td class="liste_titre">';
587  print '&nbsp;';
588  print '</td>';
589 
590  // Date sending
591  print '<td class="liste_titre">';
592  print '&nbsp;';
593  print '</td>';
594 
595  //Statut
596  print '<td class="liste_titre right">';
597  print $formmailing->selectDestinariesStatus($search_dest_status, 'search_dest_status', 1);
598  print '</td>';
599  // Action column
600  print '<td class="liste_titre maxwidthsearch">';
601  $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
602  print $searchpicto;
603  print '</td>';
604  print '</tr>';
605 
606  if ($page) {
607  $param .= "&page=".urlencode($page);
608  }
609 
610  print '<tr class="liste_titre">';
611  print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "mc.email", $param, "", "", $sortfield, $sortorder);
612  print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "mc.lastname", $param, "", "", $sortfield, $sortorder);
613  print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "mc.firstname", $param, "", "", $sortfield, $sortorder);
614  print_liste_field_titre("OtherInformations", $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
615  print_liste_field_titre("Source", $_SERVER["PHP_SELF"], "", $param, "", 'align="center"', $sortfield, $sortorder);
616  // Date last update
617  print_liste_field_titre("DateLastModification", $_SERVER["PHP_SELF"], "mc.tms", $param, "", 'align="center"', $sortfield, $sortorder);
618  // Date sending
619  print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, '', 'align="center"', $sortfield, $sortorder);
620  print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "mc.statut", $param, '', 'class="right"', $sortfield, $sortorder);
621  print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
622  print '</tr>';
623 
624  $i = 0;
625 
626  if ($num) {
627  include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
628  include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
629  include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
630  include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
631  include_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
632  $objectstaticmember = new Adherent($db);
633  $objectstaticuser = new User($db);
634  $objectstaticcompany = new Societe($db);
635  $objectstaticcontact = new Contact($db);
636  $objectstaticeventorganization = new ConferenceOrBoothAttendee($db);
637 
638  while ($i < min($num, $limit)) {
639  $obj = $db->fetch_object($resql);
640 
641  print '<tr class="oddeven">';
642  print '<td class="tdoverflowmax150">'.img_picto('$obj->email', 'email', 'class="paddingright"').dol_escape_htmltag($obj->email).'</td>';
643  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->lastname).'">'.dol_escape_htmltag($obj->lastname).'</td>';
644  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->firstname).'">'.dol_escape_htmltag($obj->firstname).'</td>';
645  print '<td><span class="small">'.dol_escape_htmltag($obj->other).'</small></td>';
646  print '<td class="center tdoverflowmax150">';
647  if (empty($obj->source_id) || empty($obj->source_type)) {
648  print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility
649  } else {
650  if ($obj->source_type == 'member') {
651  $objectstaticmember->fetch($obj->source_id);
652  print $objectstaticmember->getNomUrl(1);
653  } elseif ($obj->source_type == 'user') {
654  $objectstaticuser->fetch($obj->source_id);
655  print $objectstaticuser->getNomUrl(1);
656  } elseif ($obj->source_type == 'thirdparty') {
657  $objectstaticcompany->fetch($obj->source_id);
658  print $objectstaticcompany->getNomUrl(1);
659  } elseif ($obj->source_type == 'contact') {
660  $objectstaticcontact->fetch($obj->source_id);
661  print $objectstaticcontact->getNomUrl(1);
662  } elseif ($obj->source_type == 'eventorganizationattendee') {
663  $objectstaticeventorganization->fetch($obj->source_id);
664  print $objectstaticeventorganization->getNomUrl(1);
665  } else {
666  print $obj->source_url;
667  }
668  }
669  print '</td>';
670 
671  // Date last update
672  print '<td class="center nowraponall">';
673  print dol_print_date($obj->tms, 'dayhour');
674  print '</td>';
675 
676  // Status of recipient sending email (Warning != status of emailing)
677  if ($obj->statut == 0) {
678  // Date sent
679  print '<td align="center"></td>';
680 
681  print '<td class="nowrap right">';
682  print $object::libStatutDest($obj->statut, 2, '');
683  print '</td>';
684  } else {
685  // Date sent
686  print '<td class="center nowraponall">'.$obj->date_envoi.'</td>';
687 
688  print '<td class="nowrap right">';
689  print $object::libStatutDest($obj->statut, 2, $obj->error_text);
690  print '</td>';
691  }
692 
693  // Search Icon
694  print '<td class="right">';
695  print '<!-- ID mailing_cibles = '.$obj->rowid.' -->';
696  if ($obj->statut == 0) { // Not sent yet
697  if (!empty($user->rights->mailing->creer) && $allowaddtarget) {
698  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.$obj->rowid.$param.'">'.img_delete($langs->trans("RemoveRecipient")).'</a>';
699  }
700  }
701  /*if ($obj->statut == -1) // Sent with error
702  {
703  print '<a href="'.$_SERVER['PHP_SELF'].'?action=retry&rowid='.$obj->rowid.$param.'">'.$langs->trans("Retry").'</a>';
704  }*/
705  print '</td>';
706  print '</tr>';
707 
708  $i++;
709  }
710  } else {
711  if ($object->statut < 2) {
712  print '<tr><td colspan="9" class="opacitymedium">';
713  print $langs->trans("NoTargetYet");
714  print '</td></tr>';
715  }
716  }
717  print "</table><br>";
718  print '</div>';
719 
720  print '</form>';
721 
722  $db->free($resql);
723  } else {
724  dol_print_error($db);
725  }
726 
727  print "\n<!-- Fin liste destinataires selectionnes -->\n";
728 }
729 
730 // End of page
731 llxFooter();
732 $db->close();
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage members of a foundation.
static getArrayAddress($address)
Return a formatted array of address string for SMTP protocol.
Class for ConferenceOrBoothAttendee.
Class to manage contact/addresses.
Class to manage generation of HTML components Only common components must be here.
Class to offer components to list and upload files.
Class to manage emailings module.
Parent class of emailing target selectors modules.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
Definition: user.class.php:47
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
emailing_prepare_head(Mailing $object)
Prepare array with list of tabs.
dolGetModulesDirs($subdir='')
Return list of modules directories.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show 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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
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.
img_error($titlealt='default')
Show error logo.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.