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