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