dolibarr  18.0.0-alpha
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  $morehtmlref = '<div class="refidno">';
216  // Ref customer
217  $morehtmlref .= $form->editfieldkey("", 'title', $object->title, $object, 0, 'string', '', 0, 1);
218  $morehtmlref .= $form->editfieldval("", 'title', $object->title, $object, 0, 'string', '', null, null, '', 1);
219  $morehtmlref .= '</div>';
220 
221  $morehtmlright = '';
222  $nbtry = $nbok = 0;
223  if ($object->statut == 2 || $object->statut == 3) {
224  $nbtry = $object->countNbOfTargets('alreadysent');
225  $nbko = $object->countNbOfTargets('alreadysentko');
226  $nbok = ($nbtry - $nbko);
227 
228  $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail;
229  if ($nbko) {
230  $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error");
231  }
232  $morehtmlright .= ') &nbsp; ';
233  }
234 
235  dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
236 
237  print '<div class="fichecenter">';
238  print '<div class="underbanner clearboth"></div>';
239 
240  print '<table class="border centpercent tableforfield">';
241 
242  //print '<tr><td class="titlefield">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$object->title.'</td></tr>';
243 
244  print '<tr><td class="titlefield">'.$langs->trans("MailFrom").'</td><td colspan="3">';
245  $emailarray = CMailFile::getArrayAddress($object->email_from);
246  foreach ($emailarray as $email => $name) {
247  if ($name && $name != $email) {
248  print dol_escape_htmltag($name).' &lt;'.$email;
249  print '&gt;';
250  if (!isValidEmail($email)) {
251  $langs->load("errors");
252  print img_warning($langs->trans("ErrorBadEMail", $email));
253  }
254  } else {
255  print dol_print_email($object->email_from, 0, 0, 0, 0, 1);
256  }
257  }
258  //print dol_print_email($object->email_from, 0, 0, 0, 0, 1);
259  //var_dump($object->email_from);
260  print '</td></tr>';
261 
262  // Errors to
263  print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td colspan="3">';
264  $emailarray = CMailFile::getArrayAddress($object->email_errorsto);
265  foreach ($emailarray as $email => $name) {
266  if ($name != $email) {
267  print dol_escape_htmltag($name).' &lt;'.$email;
268  print '&gt;';
269  if (!isValidEmail($email)) {
270  $langs->load("errors");
271  print img_warning($langs->trans("ErrorBadEMail", $email));
272  }
273  } else {
274  print dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1);
275  }
276  }
277  print '</td></tr>';
278 
279  // Nb of distinct emails
280  print '<tr><td>';
281  print $langs->trans("TotalNbOfDistinctRecipients");
282  print '</td><td colspan="3">';
283  $nbemail = ($object->nbemail ? $object->nbemail : 0);
284  if (is_numeric($nbemail)) {
285  $text = '';
286  if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) {
287  if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) {
288  $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
289  } else {
290  $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed');
291  }
292  }
293  if (empty($nbemail)) {
294  $nbemail .= ' '.img_warning('');//.' <span class="warning">'.$langs->trans("NoTargetYet").'</span>';
295  }
296  if ($text) {
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 
308  print dol_get_fiche_end();
309 
310  print '<br>';
311 
312 
313  $allowaddtarget = ($object->statut == 0);
314 
315  // Show email selectors
316  if ($allowaddtarget && $user->rights->mailing->creer) {
317  print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin ?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : ''), 'generic');
318 
319  print '<div class="div-table-responsive">';
320  print '<div class="tagtable centpercent liste_titre_bydiv borderbottom" id="tablelines">';
321 
322  print '<div class="tagtr liste_titre">';
323  print '<div class="tagtd"></div>';
324  print '<div class="tagtd">'.$langs->trans("RecipientSelectionModules").'</div>';
325  print '<div class="tagtd" align="center">'.$langs->trans("NbOfUniqueEMails").'</div>';
326  print '<div class="tagtd left">'.$langs->trans("Filter").'</div>';
327  print '<div class="tagtd">&nbsp;</div>';
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 paddingleftimp marginleftonly paddingrightimp marginrightonly valignmiddle center">';
393  if (empty($obj->picto)) {
394  $obj->picto = 'generic';
395  }
396  print img_object($langs->trans("EmailingTargetSelector").': '.get_class($obj), $obj->picto, 'class="valignmiddle width25 size15x"');
397  print '</div>';
398  print '<div class="tagtd valignmiddle">'; // style="height: 4em"
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 valignmiddle">';
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 valignmiddle">';
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 valignmiddle">';
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, 0, 0, 1);
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  print '<input type="hidden" name="page_y" value="">';
564 
565  print '<div class="div-table-responsive">';
566  print '<table class="noborder centpercent">';
567 
568  // Ligne des champs de filtres
569  print '<tr class="liste_titre_filter">';
570  // EMail
571  print '<td class="liste_titre">';
572  print '<input class="flat maxwidth75" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
573  print '</td>';
574  // Name
575  print '<td class="liste_titre">';
576  print '<input class="flat maxwidth50" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'">';
577  print '</td>';
578  // Firstname
579  print '<td class="liste_titre">';
580  print '<input class="flat maxwidth50" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'">';
581  print '</td>';
582  // Other
583  print '<td class="liste_titre">';
584  print '<input class="flat maxwidth100" type="text" name="search_other" value="'.dol_escape_htmltag($search_other).'">';
585  print '</td>';
586  // Source
587  print '<td class="liste_titre">';
588  print '&nbsp;';
589  print '</td>';
590 
591  // Date last update
592  print '<td class="liste_titre">';
593  print '&nbsp;';
594  print '</td>';
595 
596  // Date sending
597  print '<td class="liste_titre">';
598  print '&nbsp;';
599  print '</td>';
600 
601  //Statut
602  print '<td class="liste_titre right">';
603  print $formmailing->selectDestinariesStatus($search_dest_status, 'search_dest_status', 1);
604  print '</td>';
605  // Action column
606  print '<td class="liste_titre maxwidthsearch">';
607  $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
608  print $searchpicto;
609  print '</td>';
610  print '</tr>';
611 
612  if ($page) {
613  $param .= "&page=".urlencode($page);
614  }
615 
616  print '<tr class="liste_titre">';
617  print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "mc.email", $param, "", "", $sortfield, $sortorder);
618  print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "mc.lastname", $param, "", "", $sortfield, $sortorder);
619  print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "mc.firstname", $param, "", "", $sortfield, $sortorder);
620  print_liste_field_titre("OtherInformations", $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
621  print_liste_field_titre("Source", $_SERVER["PHP_SELF"], "", $param, "", 'align="center"', $sortfield, $sortorder);
622  // Date last update
623  print_liste_field_titre("DateLastModification", $_SERVER["PHP_SELF"], "mc.tms", $param, "", 'align="center"', $sortfield, $sortorder);
624  // Date sending
625  print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, '', 'align="center"', $sortfield, $sortorder);
626  print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "mc.statut", $param, '', 'class="right"', $sortfield, $sortorder);
627  print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
628  print '</tr>';
629 
630  $i = 0;
631 
632  if ($num) {
633  include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
634  include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
635  include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
636  include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
637  include_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
638  $objectstaticmember = new Adherent($db);
639  $objectstaticuser = new User($db);
640  $objectstaticcompany = new Societe($db);
641  $objectstaticcontact = new Contact($db);
642  $objectstaticeventorganization = new ConferenceOrBoothAttendee($db);
643 
644  while ($i < min($num, $limit)) {
645  $obj = $db->fetch_object($resql);
646 
647  print '<tr class="oddeven">';
648  print '<td class="tdoverflowmax150">'.img_picto('$obj->email', 'email', 'class="paddingright"').dol_escape_htmltag($obj->email).'</td>';
649  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->lastname).'">'.dol_escape_htmltag($obj->lastname).'</td>';
650  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->firstname).'">'.dol_escape_htmltag($obj->firstname).'</td>';
651  print '<td><span class="small">'.dol_escape_htmltag($obj->other).'</small></td>';
652  print '<td class="center tdoverflowmax150">';
653  if (empty($obj->source_id) || empty($obj->source_type)) {
654  print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility
655  } else {
656  if ($obj->source_type == 'member') {
657  $objectstaticmember->fetch($obj->source_id);
658  print $objectstaticmember->getNomUrl(1);
659  } elseif ($obj->source_type == 'user') {
660  $objectstaticuser->fetch($obj->source_id);
661  print $objectstaticuser->getNomUrl(1);
662  } elseif ($obj->source_type == 'thirdparty') {
663  $objectstaticcompany->fetch($obj->source_id);
664  print $objectstaticcompany->getNomUrl(1);
665  } elseif ($obj->source_type == 'contact') {
666  $objectstaticcontact->fetch($obj->source_id);
667  print $objectstaticcontact->getNomUrl(1);
668  } elseif ($obj->source_type == 'eventorganizationattendee') {
669  $objectstaticeventorganization->fetch($obj->source_id);
670  print $objectstaticeventorganization->getNomUrl(1);
671  } else {
672  print $obj->source_url;
673  }
674  }
675  print '</td>';
676 
677  // Date last update
678  print '<td class="center nowraponall">';
679  print dol_print_date(dol_stringtotime($obj->tms), 'dayhour');
680  print '</td>';
681 
682  // Status of recipient sending email (Warning != status of emailing)
683  if ($obj->statut == 0) {
684  // Date sent
685  print '<td align="center"></td>';
686 
687  print '<td class="nowrap right">';
688  print $object::libStatutDest($obj->statut, 2, '');
689  print '</td>';
690  } else {
691  // Date sent
692  print '<td class="center nowraponall">'.$obj->date_envoi.'</td>';
693 
694  print '<td class="nowrap right">';
695  print $object::libStatutDest($obj->statut, 2, $obj->error_text);
696  print '</td>';
697  }
698 
699  // Search Icon
700  print '<td class="right">';
701  print '<!-- ID mailing_cibles = '.$obj->rowid.' -->';
702  if ($obj->statut == 0) { // Not sent yet
703  if (!empty($user->rights->mailing->creer) && $allowaddtarget) {
704  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.$obj->rowid.$param.'">'.img_delete($langs->trans("RemoveRecipient")).'</a>';
705  }
706  }
707  /*if ($obj->statut == -1) // Sent with error
708  {
709  print '<a href="'.$_SERVER['PHP_SELF'].'?action=retry&rowid='.$obj->rowid.$param.'">'.$langs->trans("Retry").'</a>';
710  }*/
711  print '</td>';
712  print '</tr>';
713 
714  $i++;
715  }
716  } else {
717  if ($object->statut < $object::STATUS_SENTPARTIALY) {
718  print '<tr><td colspan="9">';
719  print '<span class="opacitymedium">'.$langs->trans("NoTargetYet").'</span>';
720  print '</td></tr>';
721  } else {
722  print '<tr><td colspan="9">';
723  print '<span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span>';
724  print '</td></tr>';
725  }
726  }
727  print "</table><br>";
728  print '</div>';
729 
730  print '</form>';
731 
732  $db->free($resql);
733  } else {
734  dol_print_error($db);
735  }
736 
737  print "\n<!-- Fin liste destinataires selectionnes -->\n";
738 }
739 
740 // End of page
741 llxFooter();
742 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:50
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:1504
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
img_error
img_error($titlealt='default')
Show error logo.
Definition: functions.lib.php:4689
$sql
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)) $sql
Social contributions to pay.
Definition: index.php:745
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5363
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:530
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:4994
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:4671
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:143
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:2097
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:2566
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:4025
llxHeader
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
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:4579
CMailFile\getArrayAddress
static getArrayAddress($address)
Return a formatted array of address string for SMTP protocol.
Definition: CMailFile.class.php:1935
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:3799
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1639
Contact
Class to manage contact/addresses.
Definition: contact.class.php:41
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:5416
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:1873
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:4950
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:11317
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2069
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:431
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:5181
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:9823
dol_eval
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
Definition: functions.lib.php:8985
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:4361
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:3068
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2947
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8509
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1106
$nbtotalofrecords
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
ConferenceOrBoothAttendee
Class for ConferenceOrBoothAttendee.
Definition: conferenceorboothattendee.class.php:33
dol_stringtotime
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
Definition: date.lib.php:408