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