dolibarr  x.y.z
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 '<table class="noborder centpercent">';
314 
315  print '<div class="div-table-responsive">';
316  print '<div class="tagtable centpercent liste_titre_bydiv borderbottom" id="tablelines">';
317 
318  //print '<tr class="liste_titre">';
319  print '<div class="tagtr liste_titre">';
320  //print '<td class="liste_titre">'.$langs->trans("RecipientSelectionModules").'</td>';
321  print '<div class="tagtd">'.$langs->trans("RecipientSelectionModules").'</div>';
322  //print '<td class="liste_titre" align="center">'.$langs->trans("NbOfUniqueEMails").'</td>';
323  print '<div class="tagtd" align="center">'.$langs->trans("NbOfUniqueEMails").'</div>';
324  //print '<td class="liste_titre" align="left">'.$langs->trans("Filter").'</td>';
325  print '<div class="tagtd left">'.$langs->trans("Filter").'</div>';
326  //print '<td class="liste_titre" align="center">&nbsp;</td>';
327  print '<div class="tagtd">&nbsp;</div>';
328  //print "</tr>\n";
329  print '</div>'; // End tr
330 
331  clearstatcache();
332 
333  foreach ($modulesdir as $dir) {
334  $modulenames = array();
335 
336  // Load modules attributes in arrays (name, numero, orders) from dir directory
337  //print $dir."\n<br>";
338  dol_syslog("Scan directory ".$dir." for modules");
339  $handle = @opendir($dir);
340  if (is_resource($handle)) {
341  while (($file = readdir($handle)) !== false) {
342  if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') {
343  $reg = array();
344  if (preg_match("/(.*)\.modules\.php$/i", $file, $reg)) {
345  if ($reg[1] == 'example') {
346  continue;
347  }
348  $modulenames[] = $reg[1];
349  }
350  }
351  }
352  closedir($handle);
353  }
354 
355  // Sort $modulenames
356  sort($modulenames);
357 
358  $var = true;
359 
360  // Loop on each submodule
361  foreach ($modulenames as $modulename) {
362  // Loading Class
363  $file = $dir.$modulename.".modules.php";
364  $classname = "mailing_".$modulename;
365  require_once $file;
366 
367  $obj = new $classname($db);
368 
369  // Check if qualified
370  $qualified = (is_null($obj->enabled) ? 1 : dol_eval($obj->enabled, 1));
371 
372  // Check dependencies
373  foreach ($obj->require_module as $key) {
374  if (empty($conf->$key->enabled) || (empty($user->admin) && $obj->require_admin)) {
375  $qualified = 0;
376  //print "Les prerequis d'activation du module mailing ne sont pas respectes. Il ne sera pas actif";
377  break;
378  }
379  }
380 
381  // If module is qualified
382  if ($qualified) {
383  $var = !$var;
384 
385  if ($allowaddtarget) {
386  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">';
387  print '<input type="hidden" name="token" value="'.newToken().'">';
388  print '<input type="hidden" name="page_y" value="'.newToken().'">';
389  } else {
390  print '<div '.$bctag[$var].'>';
391  }
392 
393  print '<div class="tagtd">';
394  if (empty($obj->picto)) {
395  $obj->picto = 'generic';
396  }
397  print img_object($langs->trans("EmailingTargetSelector").': '.get_class($obj), $obj->picto, 'class="valignmiddle pictomodule pictofixedwidth"');
398  print ' ';
399  print $obj->getDesc();
400  print '</div>';
401 
402  try {
403  $nbofrecipient = $obj->getNbOfRecipients('');
404  } catch (Exception $e) {
405  dol_syslog($e->getMessage(), LOG_ERR);
406  }
407 
408  print '<div class="tagtd center">';
409  if ($nbofrecipient === '' || $nbofrecipient >= 0) {
410  print $nbofrecipient;
411  } else {
412  print $langs->trans("Error").' '.img_error($obj->error);
413  }
414  print '</div>';
415 
416  print '<div class="tagtd left">';
417  if ($allowaddtarget) {
418  try {
419  $filter = $obj->formFilter();
420  } catch (Exception $e) {
421  dol_syslog($e->getMessage(), LOG_ERR);
422  }
423  if ($filter) {
424  print $filter;
425  } else {
426  print $langs->trans("None");
427  }
428  }
429  print '</div>';
430 
431  print '<div class="tagtd right">';
432  if ($allowaddtarget) {
433  print '<input type="submit" class="button button-add small reposition" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
434  } else {
435  print '<input type="submit" class="button small disabled" disabled="disabled" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
436  //print $langs->trans("MailNoChangePossible");
437  print "&nbsp;";
438  }
439  print '</div>';
440 
441  if ($allowaddtarget) {
442  print '</form>';
443  } else {
444  print '</div>';
445  }
446  }
447  }
448  } // End foreach dir
449 
450  $parameters = array();
451  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
452  print $hookmanager->resPrint;
453 
454  print '</div>'; // End table
455  print '</div>';
456 
457  print '<br><br>';
458  }
459 
460  // List of selected targets
461  $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.tms,";
462  $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text";
463  $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
464  $sql .= " WHERE mc.fk_mailing=".((int) $object->id);
465  $asearchcriteriahasbeenset = 0;
466  if ($search_lastname) {
467  $sql .= natural_search("mc.lastname", $search_lastname);
468  $asearchcriteriahasbeenset++;
469  }
470  if ($search_firstname) {
471  $sql .= natural_search("mc.firstname", $search_firstname);
472  $asearchcriteriahasbeenset++;
473  }
474  if ($search_email) {
475  $sql .= natural_search("mc.email", $search_email);
476  $asearchcriteriahasbeenset++;
477  }
478  if ($search_other) {
479  $sql .= natural_search("mc.other", $search_other);
480  $asearchcriteriahasbeenset++;
481  }
482  if ($search_dest_status != '' && $search_dest_status >= -1) {
483  $sql .= " AND mc.statut = ".((int) $search_dest_status);
484  $asearchcriteriahasbeenset++;
485  }
486  $sql .= $db->order($sortfield, $sortorder);
487 
488  // Count total nb of records
489  $nbtotalofrecords = '';
490  if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
491  $result = $db->query($sql);
492  $nbtotalofrecords = $db->num_rows($result);
493  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
494  $page = 0;
495  $offset = 0;
496  }
497 
498  // Fix/update nbemail on emailing record if it differs (may happen if user edit lines from database directly)
499  if (empty($asearchcriteriahasbeenset)) {
500  if ($nbtotalofrecords != $object->nbemail) {
501  dol_syslog("We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
502  //print "nbemail=".$object->nbemail." nbtotalofrecords=".$nbtotalofrecords;
503  $resultrefresh = $object->refreshNbOfTargets();
504  if ($resultrefresh < 0) {
505  dol_print_error($db, $object->error, $object->errors);
506  }
507  }
508  }
509  }
510 
511  //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets
512  $sql .= $db->plimit($limit + 1, $offset);
513 
514  $resql = $db->query($sql);
515  if ($resql) {
516  $num = $db->num_rows($resql);
517 
518  $param = "&id=".$object->id;
519  //if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
520  if ($limit > 0 && $limit != $conf->liste_limit) {
521  $param .= '&limit='.urlencode($limit);
522  }
523  if ($search_lastname) {
524  $param .= "&search_lastname=".urlencode($search_lastname);
525  }
526  if ($search_firstname) {
527  $param .= "&search_firstname=".urlencode($search_firstname);
528  }
529  if ($search_email) {
530  $param .= "&search_email=".urlencode($search_email);
531  }
532  if ($search_other) {
533  $param .= "&search_other=".urlencode($search_other);
534  }
535 
536  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
537  print '<input type="hidden" name="token" value="'.newToken().'">';
538  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
539  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
540  print '<input type="hidden" name="page" value="'.$page.'">';
541  print '<input type="hidden" name="id" value="'.$object->id.'">';
542 
543  $morehtmlcenter = '';
544  if ($allowaddtarget) {
545  $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>';
546  }
547  $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>';
548 
549  $massactionbutton = '';
550 
551  print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit);
552 
553  print '</form>';
554 
555  print "\n<!-- Liste destinataires selectionnes -->\n";
556  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
557  print '<input type="hidden" name="token" value="'.newToken().'">';
558  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
559  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
560  print '<input type="hidden" name="page" value="'.$page.'">';
561  print '<input type="hidden" name="id" value="'.$object->id.'">';
562  print '<input type="hidden" name="limit" value="'.$limit.'">';
563 
564  print '<div class="div-table-responsive">';
565  print '<table class="noborder centpercent">';
566 
567  // Ligne des champs de filtres
568  print '<tr class="liste_titre_filter">';
569  // EMail
570  print '<td class="liste_titre">';
571  print '<input class="flat maxwidth75" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
572  print '</td>';
573  // Name
574  print '<td class="liste_titre">';
575  print '<input class="flat maxwidth50" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'">';
576  print '</td>';
577  // Firstname
578  print '<td class="liste_titre">';
579  print '<input class="flat maxwidth50" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'">';
580  print '</td>';
581  // Other
582  print '<td class="liste_titre">';
583  print '<input class="flat maxwidth100" type="text" name="search_other" value="'.dol_escape_htmltag($search_other).'">';
584  print '</td>';
585  // Source
586  print '<td class="liste_titre">';
587  print '&nbsp;';
588  print '</td>';
589 
590  // Date last update
591  print '<td class="liste_titre">';
592  print '&nbsp;';
593  print '</td>';
594 
595  // Date sending
596  print '<td class="liste_titre">';
597  print '&nbsp;';
598  print '</td>';
599 
600  //Statut
601  print '<td class="liste_titre right">';
602  print $formmailing->selectDestinariesStatus($search_dest_status, 'search_dest_status', 1);
603  print '</td>';
604  // Action column
605  print '<td class="liste_titre maxwidthsearch">';
606  $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
607  print $searchpicto;
608  print '</td>';
609  print '</tr>';
610 
611  if ($page) {
612  $param .= "&page=".urlencode($page);
613  }
614 
615  print '<tr class="liste_titre">';
616  print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "mc.email", $param, "", "", $sortfield, $sortorder);
617  print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "mc.lastname", $param, "", "", $sortfield, $sortorder);
618  print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "mc.firstname", $param, "", "", $sortfield, $sortorder);
619  print_liste_field_titre("OtherInformations", $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
620  print_liste_field_titre("Source", $_SERVER["PHP_SELF"], "", $param, "", 'align="center"', $sortfield, $sortorder);
621  // Date last update
622  print_liste_field_titre("DateLastModification", $_SERVER["PHP_SELF"], "mc.tms", $param, "", 'align="center"', $sortfield, $sortorder);
623  // Date sending
624  print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, '', 'align="center"', $sortfield, $sortorder);
625  print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "mc.statut", $param, '', 'class="right"', $sortfield, $sortorder);
626  print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
627  print '</tr>';
628 
629  $i = 0;
630 
631  if ($num) {
632  include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
633  include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
634  include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
635  include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
636  include_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
637  $objectstaticmember = new Adherent($db);
638  $objectstaticuser = new User($db);
639  $objectstaticcompany = new Societe($db);
640  $objectstaticcontact = new Contact($db);
641  $objectstaticeventorganization = new ConferenceOrBoothAttendee($db);
642 
643  while ($i < min($num, $limit)) {
644  $obj = $db->fetch_object($resql);
645 
646  print '<tr class="oddeven">';
647  print '<td class="tdoverflowmax150">'.img_picto('$obj->email', 'email', 'class="paddingright"').dol_escape_htmltag($obj->email).'</td>';
648  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->lastname).'">'.dol_escape_htmltag($obj->lastname).'</td>';
649  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->firstname).'">'.dol_escape_htmltag($obj->firstname).'</td>';
650  print '<td><span class="small">'.dol_escape_htmltag($obj->other).'</small></td>';
651  print '<td class="center tdoverflowmax150">';
652  if (empty($obj->source_id) || empty($obj->source_type)) {
653  print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility
654  } else {
655  if ($obj->source_type == 'member') {
656  $objectstaticmember->fetch($obj->source_id);
657  print $objectstaticmember->getNomUrl(1);
658  } elseif ($obj->source_type == 'user') {
659  $objectstaticuser->fetch($obj->source_id);
660  print $objectstaticuser->getNomUrl(1);
661  } elseif ($obj->source_type == 'thirdparty') {
662  $objectstaticcompany->fetch($obj->source_id);
663  print $objectstaticcompany->getNomUrl(1);
664  } elseif ($obj->source_type == 'contact') {
665  $objectstaticcontact->fetch($obj->source_id);
666  print $objectstaticcontact->getNomUrl(1);
667  } elseif ($obj->source_type == 'eventorganizationattendee') {
668  $objectstaticeventorganization->fetch($obj->source_id);
669  print $objectstaticeventorganization->getNomUrl(1);
670  } else {
671  print $obj->source_url;
672  }
673  }
674  print '</td>';
675 
676  // Date last update
677  print '<td class="center nowraponall">';
678  print dol_print_date($obj->tms, 'dayhour');
679  print '</td>';
680 
681  // Status of recipient sending email (Warning != status of emailing)
682  if ($obj->statut == 0) {
683  // Date sent
684  print '<td align="center"></td>';
685 
686  print '<td class="nowrap right">';
687  print $object::libStatutDest($obj->statut, 2, '');
688  print '</td>';
689  } else {
690  // Date sent
691  print '<td class="center nowraponall">'.$obj->date_envoi.'</td>';
692 
693  print '<td class="nowrap right">';
694  print $object::libStatutDest($obj->statut, 2, $obj->error_text);
695  print '</td>';
696  }
697 
698  // Search Icon
699  print '<td class="right">';
700  print '<!-- ID mailing_cibles = '.$obj->rowid.' -->';
701  if ($obj->statut == 0) { // Not sent yet
702  if (!empty($user->rights->mailing->creer) && $allowaddtarget) {
703  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.$obj->rowid.$param.'">'.img_delete($langs->trans("RemoveRecipient")).'</a>';
704  }
705  }
706  /*if ($obj->statut == -1) // Sent with error
707  {
708  print '<a href="'.$_SERVER['PHP_SELF'].'?action=retry&rowid='.$obj->rowid.$param.'">'.$langs->trans("Retry").'</a>';
709  }*/
710  print '</td>';
711  print '</tr>';
712 
713  $i++;
714  }
715  } else {
716  if ($object->statut < 2) {
717  print '<tr><td colspan="9" class="opacitymedium">';
718  print $langs->trans("NoTargetYet");
719  print '</td></tr>';
720  }
721  }
722  print "</table><br>";
723  print '</div>';
724 
725  print '</form>';
726 
727  $db->free($resql);
728  } else {
729  dol_print_error($db);
730  }
731 
732  print "\n<!-- Fin liste destinataires selectionnes -->\n";
733 }
734 
735 // End of page
736 llxFooter();
737 $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:45
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.