dolibarr 22.0.5
targetemailing.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2024 Laurent Destailleur <eldy@users.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 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
32require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmailing.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
38
39
48// Load translation files required by the page
49$langs->loadLangs(array("mails", "admin"));
50
51$action = GETPOST('action', 'aZ09');
52$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
53$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
54$mode = GETPOST('mode', 'aZ'); // The display mode ('list', 'kanban', 'hierarchy', 'calendar', 'gantt', ...)
55
56// Load variable for pagination
57$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
58$sortfield = GETPOST('sortfield', 'aZ09comma');
59$sortorder = GETPOST('sortorder', 'aZ09comma');
60$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
61if (empty($page) || $page == -1) {
62 $page = 0;
63} // If $page is not defined, or '' or -1
64$offset = $limit * $page;
65$pageprev = $page - 1;
66$pagenext = $page + 1;
67if (!$sortfield) {
68 $sortfield = "mc.statut,email";
69}
70if (!$sortorder) {
71 $sortorder = "DESC,ASC";
72}
73
74$id = GETPOSTINT('id');
75$rowid = GETPOSTINT('rowid');
76$search_lastname = GETPOST("search_lastname", 'alphanohtml');
77$search_firstname = GETPOST("search_firstname", 'alphanohtml');
78$search_email = GETPOST("search_email", 'alphanohtml');
79$search_other = GETPOST("search_other", 'alphanohtml');
80$search_dest_status = GETPOST('search_dest_status', 'int');
81
82// Search modules dirs
83$modulesdir = dolGetModulesDirs('/mailings');
84
85$object = new Mailing($db);
86$result = $object->fetch($id);
87
88// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
89$hookmanager->initHooks(array('ciblescard', 'globalcard'));
90
91$sqlmessage = '';
92$mesgs = array();
93
94// List of sending methods
95$listofmethods = array();
96//$listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
97$listofmethods['mail'] = 'PHP mail function';
98//$listofmethods['simplemail']='Simplemail class';
99$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
100if (version_compare(phpversion(), '7.0', '>=')) {
101 $listofmethods['swiftmailer'] = 'Swift Mailer socket library';
102}
103
104// Security check
105if (!$user->hasRight('mailing', 'lire') || (!getDolGlobalString('EXTERNAL_USERS_ARE_AUTHORIZED') && $user->socid > 0)) {
107}
108if (empty($action) && empty($object->id)) {
109 accessforbidden('Object not found');
110}
111
112$permissiontoread = $user->hasRight('mailing', 'lire');
113$permissiontocreate = $user->hasRight('mailing', 'creer');
114$permissiontovalidatesend = $user->hasRight('mailing', 'valider');
115$permissiontodelete = $user->hasRight('mailing', 'supprimer');
116
117
118/*
119 * Actions
120 */
121if (GETPOST('cancel', 'alpha')) {
122 $action = 'list';
123 $massaction = '';
124}
125if (!GETPOST('confirmmassaction', 'alpha')) {
126 $massaction = '';
127}
128
129if ($action == 'add' && $permissiontocreate) { // Add recipients
130 $module = GETPOST("module", 'alpha');
131 $result = -1;
132 $obj = null;
133
134 foreach ($modulesdir as $dir) {
135 // Load modules attributes in arrays (name, numero, orders) from dir directory
136 //print $dir."\n<br>";
137 dol_syslog("Scan directory ".$dir." for modules");
138
139 // Loading Class
140 $file = $dir."/".$module.".modules.php";
141 $classname = "mailing_".$module;
142
143 if (file_exists($file)) {
144 include_once $file;
145
146 // Add targets into database
147 dol_syslog("Call add_to_target() on class ".$classname." evenunsubscribe=".$object->evenunsubscribe);
148
149 $obj = null;
150 if (class_exists($classname)) {
151 $obj = new $classname($db);
152 '@phan-var-force MailingTargets $obj';
153 $obj->evenunsubscribe = $object->evenunsubscribe;
154
155 $result = $obj->add_to_target($id);
156
157 $sqlmessage = $obj->sql;
158 } else {
159 $result = -1;
160 break;
161 }
162 }
163 }
164 if ($result > 0) {
165 // If status of emailing is sent completely, change to to send partially
166 if ($object->status == $object::STATUS_SENTCOMPLETELY) {
167 $object->setStatut($object::STATUS_SENTPARTIALY);
168 }
169
170 setEventMessages($langs->trans("XTargetsAdded", $result), null, 'mesgs');
171 $action = '';
172 }
173 if ($result == 0) {
174 setEventMessages($langs->trans("WarningNoEMailsAdded"), null, 'warnings');
175 }
176 if ($result < 0 && is_object($obj)) {
177 setEventMessages($langs->trans("Error").($obj->error ? ' '.$obj->error : ''), null, 'errors');
178 }
179}
180
181if (GETPOSTINT('clearlist') && $permissiontocreate) {
182 // Loading Class
183 $obj = new MailingTargets($db);
184 $obj->clear_target($id);
185 /* Avoid this to allow reposition
186 header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
187 exit;
188 */
189}
190
191if (GETPOSTINT('exportcsv') && $permissiontoread) { // @phpstan-ignore-line
192 $completefilename = 'targets_emailing'.$object->id.'_'.dol_print_date(dol_now(), 'dayhourlog').'.csv';
193 header('Content-Type: text/csv');
194 header('Content-Disposition: attachment;filename='.$completefilename);
195
196 // List of selected targets
197 $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,";
198 $sql .= " mc.source_id, mc.source_type, mc.error_text";
199 $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
200 $sql .= " WHERE mc.fk_mailing = ".((int) $object->id);
201 $sql .= $db->order($sortfield, $sortorder);
202
203 $resql = $db->query($sql);
204 if ($resql) {
205 $num = $db->num_rows($resql);
206 $sep = ',';
207
208 while ($obj = $db->fetch_object($resql)) {
209 print $obj->rowid.$sep;
210 print '"'.$obj->lastname.'"'.$sep;
211 print '"'.$obj->firstname.'"'.$sep;
212 print $obj->email.$sep;
213 print $obj->other.$sep;
214 print $obj->tms.$sep;
215 print $obj->source_type.$sep;
216 print $obj->source_id.$sep;
217 print $obj->date_envoi.$sep;
218 print $obj->status.$sep;
219 print '"'.$obj->error_text.'"'.$sep;
220 print "\n";
221 }
222
223 exit;
224 } else {
225 dol_print_error($db);
226 }
227 exit;
228}
229
230if ($action == 'delete' && $permissiontocreate) {
231 // Ici, rowid indique le destinataire et id le mailing
232 $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid = ".((int) $rowid);
233 $sql .= " AND fk_mailing = ".((int) $object->id);
234 $resql = $db->query($sql);
235 if ($resql) {
236 if (!empty($id)) {
237 $obj = new MailingTargets($db);
238 $obj->update_nb($id);
239
240 setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
241 } else {
242 header("Location: list.php");
243 exit;
244 }
245 } else {
246 dol_print_error($db);
247 }
248}
249
250if ($action == "confirm_reset_target" && $permissiontocreate) {
251 if ($object->id > 0) {
252 $db->begin();
253 $nbok = 0;
254 $error = 0;
255 foreach ($toselect as $toselectid) {
256 $result = $object->resetTargetErrorStatus($user, $toselectid);
257 if ($result < 0) {
258 setEventMessages($object->error, $object->errors, 'errors');
259 $error++;
260 break;
261 } elseif ($result > 0) {
262 $nbok++;
263 } else {
264 setEventMessages($object->error, $object->errors, 'errors');
265 $error++;
266 }
267 }
268 if (!$error) {
269 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
270 $db->commit();
271 } else {
272 $db->rollback();
273 }
274 }
275}
276
277// Purge search criteria
278if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
279 $search_lastname = '';
280 $search_firstname = '';
281 $search_email = '';
282 $search_other = '';
283 $search_dest_status = '';
284 $toselect = array();
285}
286
287// Action update description of emailing
288if (($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto' || $action == 'setevenunsubscribe') && $permissiontocreate) {
289 $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing');
290
291 if ($action == 'settitle') { // Test on permission already done
292 $object->title = trim(GETPOST('title', 'alpha'));
293 } elseif ($action == 'setemail_from') { // Test on permission already done
294 $object->email_from = trim(GETPOST('email_from', 'alphawithlgt')); // Must allow 'name <email>'
295 } elseif ($action == 'setemail_replyto') { // Test on permission already done
296 $object->email_replyto = trim(GETPOST('email_replyto', 'alphawithlgt')); // Must allow 'name <email>'
297 } elseif ($action == 'setemail_errorsto') { // Test on permission already done
298 $object->email_errorsto = trim(GETPOST('email_errorsto', 'alphawithlgt')); // Must allow 'name <email>'
299 } elseif ($action == 'settitle' && empty($object->title)) { // Test on permission already done
300 $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle"));
301 } elseif ($action == 'setfrom' && empty($object->email_from)) { // Test on permission already done
302 $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom"));
303 } elseif ($action == 'setevenunsubscribe') { // Test on permission already done
304 $object->evenunsubscribe = (GETPOST('evenunsubscribe') ? 1 : 0);
305 }
306
307 if (!$mesg) {
308 $result = $object->update($user);
309 if ($result >= 0) {
310 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
311 exit;
312 }
313 $mesg = $object->error;
314 }
315
316 setEventMessages($mesg, $mesgs, 'errors');
317 $action = "";
318}
319
320
321/*
322 * View
323 */
324
325$form = new Form($db);
326$formmailing = new FormMailing($db);
327
328$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
329llxHeader('', $langs->trans("Mailing"), $help_url);
330
331$arrayofselected = is_array($toselect) ? $toselect : array();
332$totalarray = [
333 'nbfield' => 0,
334];
335
336if ($object->fetch($id) >= 0) {
337 $head = emailing_prepare_head($object);
338
339 print dol_get_fiche_head($head, 'targets', $langs->trans("Mailing"), -1, 'email');
340
341 $linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
342
343 $morehtmlref = '<div class="refidno">';
344 // Ref customer
345 $morehtmlref .= $form->editfieldkey("", 'title', $object->title, $object, 0, 'string', '', 0, 1);
346 $morehtmlref .= $form->editfieldval("", 'title', $object->title, $object, 0, 'string', '', null, null, '', 1);
347 $morehtmlref .= '</div>';
348
349 $morehtmlstatus = '';
350 $nbtry = $nbok = 0;
351 if ($object->status == $object::STATUS_SENTPARTIALY || $object->status == $object::STATUS_SENTCOMPLETELY) {
352 $nbtry = $object->countNbOfTargets('alreadysent');
353 $nbko = $object->countNbOfTargets('alreadysentko');
354 $nbok = ($nbtry - $nbko);
355
356 $morehtmlstatus .= ' ('.$nbtry.'/'.$object->nbemail;
357 if ($nbko) {
358 $morehtmlstatus .= ' - '.$nbko.' '.$langs->trans("Error");
359 }
360 $morehtmlstatus .= ') &nbsp; ';
361 }
362
363 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus);
364
365 print '<div class="fichecenter">';
366 print '<div class="fichehalfleft">';
367 print '<div class="underbanner clearboth"></div>';
368
369 print '<table class="border centpercent tableforfield">'."\n";
370
371 // From
372 print '<tr><td class="titlefield">';
373 print $langs->trans("MailFrom").'</td><td>';
374 $emailarray = CMailFile::getArrayAddress($object->email_from);
375 foreach ($emailarray as $email => $name) {
376 if ($name && $name != $email) {
377 print dol_escape_htmltag($name).' &lt;'.$email;
378 print '&gt;';
379 if (!isValidEmail($email)) {
380 $langs->load("errors");
381 print img_warning($langs->trans("ErrorBadEMail", $email));
382 }
383 } else {
384 print dol_print_email($object->email_from, 0, 0, 0, 0, 1);
385 }
386 }
387
388 print '</td></tr>';
389
390 // Errors to
391 if ($object->messtype != 'sms') {
392 print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
393 $emailarray = CMailFile::getArrayAddress($object->email_errorsto);
394 foreach ($emailarray as $email => $name) {
395 if ($name != $email) {
396 print dol_escape_htmltag((string) $name).' &lt;'.$email;
397 print '&gt;';
398 if ($email && !isValidEmail($email)) {
399 $langs->load("errors");
400 print img_warning($langs->trans("ErrorBadEMail", $email));
401 } elseif ($email && !isValidMailDomain($email)) {
402 $langs->load("errors");
403 print img_warning($langs->trans("ErrorBadMXDomain", $email));
404 }
405 } else {
406 print dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1);
407 }
408 }
409 print '</td></tr>';
410 }
411
412 // Reply to
413 if ($object->messtype != 'sms') {
414 print '<tr><td>';
415 print $form->editfieldkey("MailReply", 'email_replyto', $object->email_replyto, $object, (int) ($user->hasRight('mailing', 'creer') && $object->status < $object::STATUS_SENTCOMPLETELY), 'string');
416 print '</td><td>';
417 print $form->editfieldval("MailReply", 'email_replyto', $object->email_replyto, $object, $user->hasRight('mailing', 'creer') && $object->status < $object::STATUS_SENTCOMPLETELY, 'string');
418 $email = CMailFile::getValidAddress($object->email_replyto, 2);
419 if ($action != 'editemail_replyto') {
420 if ($email && !isValidEmail($email)) {
421 $langs->load("errors");
422 print img_warning($langs->trans("ErrorBadEMail", $email));
423 } elseif ($email && !isValidMailDomain($email)) {
424 $langs->load("errors");
425 print img_warning($langs->trans("ErrorBadMXDomain", $email));
426 }
427 }
428 print '</td></tr>';
429 }
430
431 print '</table>';
432 print '</div>';
433
434
435 print '<div class="fichehalfright">';
436 print '<div class="underbanner clearboth"></div>';
437
438 print '<table class="border centpercent tableforfield">';
439
440 // Number of distinct emails
441 print '<tr><td>';
442 print $langs->trans("TotalNbOfDistinctRecipients");
443 print '</td><td>';
444 $nbemail = ($object->nbemail ? $object->nbemail : 0);
445 if (is_numeric($nbemail)) {
446 $htmltooltip = '';
447 if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') < $nbemail) && ($object->status == 1 || ($object->status == 2 && $nbtry < $nbemail))) {
448 if (getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') > 0) {
449 $htmltooltip .= $langs->trans('LimitSendingEmailing', getDolGlobalString('MAILING_LIMIT_SENDBYWEB'));
450 } else {
451 $htmltooltip .= $langs->trans('SendingFromWebInterfaceIsNotAllowed');
452 }
453 }
454 if (empty($nbemail)) {
455 $nbemail .= ' '.img_warning($langs->trans('ToAddRecipientsChooseHere'));//.' <span class="warning">'.$langs->trans("NoTargetYet").'</span>';
456 }
457 if ($htmltooltip) {
458 print $form->textwithpicto($nbemail, $htmltooltip, 1, 'info');
459 } else {
460 print $nbemail;
461 }
462 }
463 print '</td></tr>';
464
465 print '<tr><td>';
466 print $langs->trans("MAIN_MAIL_SENDMODE");
467 print '</td><td>';
468 if ($object->messtype != 'sms') {
469 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
470 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')];
471 } elseif (getDolGlobalString('MAIN_MAIL_SENDMODE')) {
472 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE')];
473 } else {
474 $text = $listofmethods['mail'];
475 }
476 print $text;
477 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
478 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'mail') {
479 print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER_EMAILING', getDolGlobalString('MAIN_MAIL_SMTP_SERVER')).')</span>';
480 }
481 } elseif (getDolGlobalString('MAIN_MAIL_SENDMODE') != 'mail' && getDolGlobalString('MAIN_MAIL_SMTP_SERVER')) {
482 print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER').')</span>';
483 }
484 } else {
485 print 'SMS ';
486 print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER').')</span>';
487 }
488 print '</td></tr>';
489
490 // Other attributes. Fields from hook formObjectOptions and Extrafields.
491 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
492
493 print '</table>';
494 print '</div>';
495 print '</div>';
496
497 print '<div class="clearboth"></div>';
498
499 print dol_get_fiche_end();
500
501 print '<br>';
502
503
504 $newcardbutton = '';
505 $allowaddtarget = ($object->status == $object::STATUS_DRAFT);
506 if (GETPOST('allowaddtarget')) {
507 $allowaddtarget = 1;
508 }
509 if (!$allowaddtarget) {
510 $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?id='.$object->id.'&allowaddtarget=1', '', $user->hasRight('mailing', 'creer'));
511 }
512
513 // Show email selectors
514 if ($allowaddtarget && $user->hasRight('mailing', 'creer')) {
515 print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere").'...', ($user->admin ? info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : ''), '');
516
517 print '<div class="div-table-responsive">';
518 print '<div class="tagtable centpercentwithout1imp liste_titre_bydiv borderbottom" id="tablelines">';
519
520 print '<div class="tagtr liste_titre">';
521 print '<div class="tagtd"></div>';
522 print '<div class="tagtd">'.$langs->trans("RecipientSelectionModules").'</div>';
523 print '<div class="tagtd center maxwidth150">';
524 if ($object->messtype != 'sms') {
525 print $langs->trans("NbOfUniqueEMails");
526 } else {
527 print $langs->trans("NbOfUniquePhones");
528 }
529 print '</div>';
530 print '<div class="tagtd left"><div class="inline-block">'.$langs->trans("Filters").'</div>';
531 if ($object->messtype != 'sms') {
532 print ' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class="inline-block valignmiddle">'.$langs->trans("EvenUnsubscribe").' ';
533 print ajax_object_onoff($object, 'evenunsubscribe', 'evenunsubscribe', 'EvenUnsubscribe:switch_on:warning', 'EvenUnsubscribe', array(), 'small valignmiddle reposition', '', 1);
534 print '</div>';
535 }
536 print '</div>';
537 print '<div class="tagtd">&nbsp;</div>';
538 print '</div>'; // End tr
539
540 clearstatcache();
541
542 foreach ($modulesdir as $dir) {
543 $modulenames = array();
544
545 // Load modules attributes in arrays (name, numero, orders) from dir directory
546 //print $dir."\n<br>";
547 dol_syslog("Scan directory ".$dir." for modules");
548 $handle = @opendir($dir);
549 if (is_resource($handle)) {
550 while (($file = readdir($handle)) !== false) {
551 if (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS') {
552 $reg = array();
553 if (preg_match("/(.*)\.modules\.php$/i", $file, $reg)) {
554 if ($reg[1] == 'example') {
555 continue;
556 }
557 $modulenames[] = $reg[1];
558 }
559 }
560 }
561 closedir($handle);
562 }
563
564 // Sort $modulenames
565 sort($modulenames);
566
567 $var = true;
568
569 // Loop on each submodule
570 foreach ($modulenames as $modulename) {
571 // Loading Class
572 $file = $dir.$modulename.".modules.php";
573 $classname = "mailing_".$modulename;
574 require_once $file;
575
576 $obj = new $classname($db);
577 '@phan-var-force MailingTargets $obj';
578
579 // Check if qualified
580 $qualified = (is_null($obj->enabled) ? 1 : (int) dol_eval((string) $obj->enabled, 1));
581
582 // Check dependencies
583 foreach ($obj->require_module as $key) {
584 if (empty($conf->$key->enabled) || (empty($user->admin) && $obj->require_admin)) {
585 $qualified = 0;
586 //print "Les prerequis d'activation du module mailing ne sont pas respectes. Il ne sera pas actif";
587 break;
588 }
589 }
590
591 // If module is qualified
592 if ($qualified) {
593 if ($allowaddtarget) {
594 print '<form class="oddeven trforbreakperms trforbreaknobg impair tagtr" name="'.$modulename.'" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&module='.$modulename.'" method="POST" enctype="multipart/form-data">';
595 print '<input type="hidden" name="token" value="'.newToken().'">';
596 print '<input type="hidden" name="action" value="add">';
597 print '<input type="hidden" name="page_y" value="'.newToken().'">';
598 } else {
599 print '<div class="oddeven trforbreakperms trforbreaknobg impair tagtr">';
600 }
601
602 print '<div class="tagtd paddingleftlarge marginleftonly paddingrightlarge marginrightonly valignmiddle center">';
603 if (empty($obj->picto)) {
604 $obj->picto = 'generic';
605 }
606 print img_object($langs->trans("EmailingTargetSelector").': '.get_class($obj), $obj->picto, 'class="valignmiddle width25 size15x"');
607 print '</div>';
608 print '<div class="tagtd valignmiddle">'; // style="height: 4em"
609 print $obj->getDesc();
610 print '</div>';
611
612 $nbofrecipient = -1;
613
614 try {
615 $obj->evenunsubscribe = $object->evenunsubscribe; // Set flag to include/exclude email that has opt-out.
616
617 $nbofrecipient = $obj->getNbOfRecipients('');
618 } catch (Exception $e) {
619 dol_syslog($e->getMessage(), LOG_ERR);
620 }
621
622 print '<div class="tagtd center valignmiddle">';
623 if ($nbofrecipient === '' || $nbofrecipient >= 0) {
624 print $nbofrecipient;
625 } else {
626 print $langs->trans("Error").' '.img_error($obj->error);
627 }
628 print '</div>';
629
630 print '<div class="tagtd left valignmiddle">';
631 if ($allowaddtarget) {
632 try {
633 $filter = $obj->formFilter();
634 } catch (Exception $e) {
635 dol_syslog($e->getMessage(), LOG_ERR);
636 }
637 if ($filter) {
638 print $filter;
639 } else {
640 print $langs->trans("None");
641 }
642 }
643 print '</div>';
644
645 print '<div class="tagtd right valignmiddle">';
646 if ($allowaddtarget) {
647 print '<input type="submit" class="button button-add small reposition" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
648 } else {
649 print '<input type="submit" class="button small disabled" disabled="disabled" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
650 //print $langs->trans("MailNoChangePossible");
651 print "&nbsp;";
652 }
653 print '</div>';
654
655 if ($allowaddtarget) {
656 print '</form>';
657 } else {
658 print '</div>';
659 }
660 }
661 }
662 } // End foreach dir
663
664 $parameters = array();
665 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
666 print $hookmanager->resPrint;
667
668 print '</div>'; // End table
669 print '</div>';
670
671 print '<br>';
672
673 if ($sqlmessage && $user->admin) {
674 print info_admin($langs->trans("SQLUsedForExport").':<br> '.$sqlmessage, 0, 0, '1', '', 'TechnicalInformation');
675 print '<br>';
676 }
677
678 print '<br><br>';
679 }
680
681
682
683 // List of selected targets
684 $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,";
685 $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text,";
686 $sql .= " COUNT(mu.rowid) as nb";
687 $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
688 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."mailing_unsubscribe as mu ON mu.email = mc.email";
689 $sql .= " WHERE mc.fk_mailing=".((int) $object->id);
690 $asearchcriteriahasbeenset = 0;
691 if ($search_lastname) {
692 $sql .= natural_search("mc.lastname", $search_lastname);
693 $asearchcriteriahasbeenset++;
694 }
695 if ($search_firstname) {
696 $sql .= natural_search("mc.firstname", $search_firstname);
697 $asearchcriteriahasbeenset++;
698 }
699 if ($search_email) {
700 $sql .= natural_search("mc.email", $search_email);
701 $asearchcriteriahasbeenset++;
702 }
703 if ($search_other) {
704 $sql .= natural_search("mc.other", $search_other);
705 $asearchcriteriahasbeenset++;
706 }
707 if ($search_dest_status != '' && (int) $search_dest_status >= -1) {
708 $sql .= " AND mc.statut = ".((int) $search_dest_status);
709 $asearchcriteriahasbeenset++;
710 }
711 $sql .= ' GROUP BY mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.tms, mc.source_url, mc.source_id, mc.source_type, mc.error_text';
712 $sql .= $db->order($sortfield, $sortorder);
713
714
715 // Count total nb of records
716 $nbtotalofrecords = '';
717 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
718 $result = $db->query($sql);
719 $nbtotalofrecords = $db->num_rows($result);
720 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
721 $page = 0;
722 $offset = 0;
723 }
724
725 // Fix/update nbemail on emailing record if it differs (may happen if user edit lines from database directly)
726 if (empty($asearchcriteriahasbeenset)) {
727 if ($nbtotalofrecords != $object->nbemail) {
728 dol_syslog("We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
729 //print "nbemail=".$object->nbemail." nbtotalofrecords=".$nbtotalofrecords;
730 $resultrefresh = $object->refreshNbOfTargets();
731 if ($resultrefresh < 0) {
732 dol_print_error($db, $object->error, $object->errors);
733 }
734 }
735 }
736 }
737
738 //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets
739 $sql .= $db->plimit($limit + 1, $offset);
740
741 $resql = $db->query($sql);
742 if ($resql) {
743 $num = $db->num_rows($resql);
744
745 $param = "&id=".$object->id;
746 //if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
747 if ($limit > 0 && $limit != $conf->liste_limit) {
748 $param .= '&limit='.((int) $limit);
749 }
750 if ($search_lastname) {
751 $param .= "&search_lastname=".urlencode($search_lastname);
752 }
753 if ($search_firstname) {
754 $param .= "&search_firstname=".urlencode($search_firstname);
755 }
756 if ($search_email) {
757 $param .= "&search_email=".urlencode($search_email);
758 }
759 if ($search_other) {
760 $param .= "&search_other=".urlencode($search_other);
761 }
762
763 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
764 print '<input type="hidden" name="token" value="'.newToken().'">';
765 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
766 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
767 print '<input type="hidden" name="page" value="'.$page.'">';
768 print '<input type="hidden" name="id" value="'.$object->id.'">';
769 print '<input type="hidden" name="page_y" value="">';
770
771 $morehtmlcenter = '';
772 $arrayofmassactions = array();
773 if ($permissiontocreate) {
774 $arrayofmassactions['reset_target'] = img_picto('', 'refresh', 'class="pictofixedwidth"').$langs->trans("ResetMailingTargetMassaction");
775 }
776 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
777 $morehtmlcenter .= $massactionbutton .'<br>';
778
779 if ($object->status == $object::STATUS_DRAFT) {
780 $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>';
781 }
782 $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>';
783
784 print '</form>';
785
786 print "\n<!-- List of selected targets -->\n";
787 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
788 print '<input type="hidden" name="token" value="'.newToken().'">';
789 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
790 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
791 print '<input type="hidden" name="page" value="'.$page.'">';
792 print '<input type="hidden" name="id" value="'.$object->id.'">';
793 print '<input type="hidden" name="limit" value="'.$limit.'">';
794 print '<input type="hidden" name="page_y" value="">';
795
796 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
797 print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit, 0, 0, 1);
798
799 if ($massaction == 'reset_target') {
800 // Confirm reset
801 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ConfirmResetMailingTargetMassaction"), $langs->trans("ConfirmResetMailingTargetMassactionQuestion"), "confirm_reset_target", null, '', 0, 0, 500, 1);
802 }
803
804 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
805 $htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column ? 'left' : ''); // This also change content of $arrayfields with user setup
806 $selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
807 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
808
809 print '<div class="div-table-responsive">';
810 print '<table class="noborder centpercent">';
811
812 // Line of filters
813 print '<tr class="liste_titre_filter">';
814
815 // Action column
816 if ($conf->main_checkbox_left_column) {
817 print '<td class="liste_titre maxwidthsearch">';
818 $searchpicto = $form->showFilterButtons('left');
819 print $searchpicto;
820 print '</td>';
821 }
822 // EMail
823 print '<td class="liste_titre">';
824 print '<input class="flat maxwidth75" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
825 print '</td>';
826 // Name
827 print '<td class="liste_titre">';
828 print '<input class="flat maxwidth50" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'">';
829 print '</td>';
830 // Firstname
831 print '<td class="liste_titre">';
832 print '<input class="flat maxwidth50" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'">';
833 print '</td>';
834 // Other
835 print '<td class="liste_titre">';
836 print '<input class="flat maxwidth100" type="text" name="search_other" value="'.dol_escape_htmltag($search_other).'">';
837 print '</td>';
838 // Source
839 print '<td class="liste_titre">';
840 print '&nbsp;';
841 print '</td>';
842
843 // Date last update
844 print '<td class="liste_titre">';
845 print '&nbsp;';
846 print '</td>';
847
848 // Date sending
849 print '<td class="liste_titre">';
850 print '&nbsp;';
851 print '</td>';
852
853 // Status
854 print '<td class="liste_titre center parentonrightofpage">';
855 print $formmailing->selectDestinariesStatus($search_dest_status, 'search_dest_status', 1, 'width100 onrightofpage');
856 print '</td>';
857
858 // Action column
859 if (!$conf->main_checkbox_left_column) {
860 print '<td class="liste_titre maxwidthsearch">';
861 $searchpicto = $form->showFilterButtons();
862 print $searchpicto;
863 print '</td>';
864 }
865
866 print '</tr>';
867
868 if ($page) {
869 $param .= "&page=".urlencode((string) ($page));
870 }
871
872 print '<tr class="liste_titre">';
873 // Action column
874 if ($conf->main_checkbox_left_column) {
875 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
876 $totalarray['nbfield']++;
877 }
878 print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "mc.email", '', $param, "", $sortfield, $sortorder);
879 print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "mc.lastname", '', $param, "", $sortfield, $sortorder);
880 print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "mc.firstname", '', $param, "", $sortfield, $sortorder);
881 print_liste_field_titre("OtherInformations", $_SERVER["PHP_SELF"], '', "", $param, "", $sortfield, $sortorder);
882 print_liste_field_titre("Source", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, 'center ');
883 // Date last update
884 print_liste_field_titre("DateLastModification", $_SERVER["PHP_SELF"], "mc.tms", '', $param, '', $sortfield, $sortorder, 'center ');
885 // Date sending
886 print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", '', $param, '', $sortfield, $sortorder, 'center ');
887 print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "mc.statut", '', $param, '', $sortfield, $sortorder, 'center ');
888 // Action column
889 if (!$conf->main_checkbox_left_column) {
890 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
891 $totalarray['nbfield']++;
892 }
893 print '</tr>';
894
895 $i = 0;
896
897 if ($num) {
898 include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
899 include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
900 include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
901 include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
902 include_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
903
904 $objectstaticmember = new Adherent($db);
905 $objectstaticuser = new User($db);
906 $objectstaticcompany = new Societe($db);
907 $objectstaticcontact = new Contact($db);
908 $objectstaticeventorganization = new ConferenceOrBoothAttendee($db);
909
910 while ($i < min($num, $limit)) {
911 $obj = $db->fetch_object($resql);
912
913 print '<tr class="oddeven">';
914
915 // Action column
916 if ($conf->main_checkbox_left_column) {
917 print '<td class="center nowraponall">';
918 print '<!-- ID mailing_cibles = '.$obj->rowid.' -->';
919 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
920 $selected = 0;
921 if (in_array($obj->rowid, $arrayofselected)) {
922 $selected = 1;
923 }
924 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
925 }
926 if ($obj->status == $object::STATUS_DRAFT) { // Not sent yet
927 if ($user->hasRight('mailing', 'creer')) {
928 print '<a class="reposition marginleftonly" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.((int) $obj->rowid).$param.'">'.img_delete($langs->trans("RemoveRecipient")).'</a>';
929 }
930 }
931 /*if ($obj->status == -1) // Sent with error
932 {
933 print '<a href="'.$_SERVER['PHP_SELF'].'?action=retry&rowid='.$obj->rowid.$param.'">'.$langs->trans("Retry").'</a>';
934 }*/
935 print '</td>';
936 }
937
938 print '<td class="tdoverflowmax150">';
939 print img_picto($obj->email, 'email', 'class="paddingright"');
940 if ($obj->nb > 0) {
941 print img_warning($langs->trans("EmailOptedOut"), 'warning', 'pictofixedwidth');
942 }
943 print dolPrintHTML($obj->email);
944 print '</td>';
945
946 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->lastname).'">'.dolPrintHTML($obj->lastname).'</td>';
947
948 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->firstname).'">'.dolPrintHTML($obj->firstname).'</td>';
949
950 print '<td class="tdoverflowmax300" title="'.dolPrintHTMLForAttribute($obj->other).'"><span class="small">'.dolPrintHTML($obj->other).'</small></td>';
951
952 print '<td class="center tdoverflowmax150">';
953 if (empty($obj->source_id) || empty($obj->source_type)) {
954 print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility
955 } else {
956 if ($obj->source_type == 'member') {
957 $objectstaticmember->fetch($obj->source_id);
958 print $objectstaticmember->getNomUrl(1);
959 } elseif ($obj->source_type == 'user') {
960 $objectstaticuser->fetch($obj->source_id);
961 print $objectstaticuser->getNomUrl(1);
962 } elseif ($obj->source_type == 'thirdparty') {
963 $objectstaticcompany->fetch($obj->source_id);
964 print $objectstaticcompany->getNomUrl(1);
965 } elseif ($obj->source_type == 'contact') {
966 $objectstaticcontact->fetch($obj->source_id);
967 print $objectstaticcontact->getNomUrl(1);
968 } elseif ($obj->source_type == 'eventorganizationattendee') {
969 $objectstaticeventorganization->fetch($obj->source_id);
970 print $objectstaticeventorganization->getNomUrl(1);
971 } else {
972 print $obj->source_url;
973 }
974 }
975 print '</td>';
976
977 // Date last update
978 print '<td class="center nowraponall">';
979 print dol_print_date($db->jdate($obj->tms), 'dayhour', 'tzuserrel');
980 print '</td>';
981
982 // Date sent
983 print '<td class="center nowraponall">';
984 if ($obj->status != $object::STATUS_DRAFT) { // If status of target line is not draft
985 // Date sent
986 print dol_print_date($db->jdate($obj->date_envoi), 'dayhour', 'tzuserrel'); // @TODO Must store date in date format
987 }
988 print '</td>';
989
990 // Status of recipient sending email (Warning != status of emailing)
991 print '<td class="nowrap center">';
992 if ($obj->status == $object::STATUS_DRAFT) { // If status of target line is not draft
993 print $object::libStatutDest((int) $obj->status, 2, '');
994 } else {
995 print $object::libStatutDest((int) $obj->status, 2, $obj->error_text);
996 }
997 print '</td>';
998
999 // Action column
1000 if (!$conf->main_checkbox_left_column) {
1001 print '<td class="center nowraponall">';
1002 print '<!-- ID mailing_cibles = '.$obj->rowid.' -->';
1003 if ($obj->status == $object::STATUS_DRAFT) { // If status of target line is not sent yet
1004 if ($user->hasRight('mailing', 'creer')) {
1005 print '<a class="reposition marginleftonly" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.((int) $obj->rowid).$param.'">'.img_delete($langs->trans("RemoveRecipient")).'</a>';
1006 }
1007 }
1008 /*if ($obj->status == -1) // Sent with error
1009 {
1010 print '<a href="'.$_SERVER['PHP_SELF'].'?action=retry&rowid='.$obj->rowid.$param.'">'.$langs->trans("Retry").'</a>';
1011 }*/
1012 print '</td>';
1013 }
1014 print '</tr>';
1015
1016 $i++;
1017 }
1018 } else {
1019 if ($object->status < $object::STATUS_SENTPARTIALY) {
1020 print '<tr><td colspan="9">';
1021 print '<span class="opacitymedium">'.$langs->trans("NoTargetYet").'</span>';
1022 print '</td></tr>';
1023 } else {
1024 print '<tr><td colspan="9">';
1025 print '<span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span>';
1026 print '</td></tr>';
1027 }
1028 }
1029 print "</table><br>";
1030 print '</div>';
1031
1032 print '</form>';
1033
1034 $db->free($resql);
1035 } else {
1036 dol_print_error($db);
1037 }
1038
1039 print "\n<!-- End list of selected targets -->\n";
1040}
1041
1042// End of page
1043llxFooter();
1044$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
$totalarray
Definition export.php:1206
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array(), $morecss='', $htmlname='', $forcenojs=0, $moreparam='')
On/off button to change a property status of an object This uses the ajax service objectonoff....
Definition ajax.lib.php:766
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage members of a foundation.
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
static getArrayAddress($address)
Return a formatted array of address string for SMTP protocol.
Class for ConferenceOrBoothAttendee.
Class to manage contact/addresses.
Class to manage generation of HTML components Only common components must be here.
Class to offer components to list and upload files.
Class to manage emailings module.
Parent class of emailing target selectors modules.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
emailing_prepare_head(Mailing $object)
Prepare array with list of tabs.
dolGetModulesDirs($subdir='')
Return list of directories that contain modules.
isValidMailDomain($mail)
Return true if email has a domain name that can be resolved to MX type.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_error($titlealt='default')
Show error logo.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.