dolibarr 23.0.4
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 $sql .= " AND fk_mailing = ".((int) $object->id);
233 $resql = $db->query($sql);
234 if ($resql) {
235 if (!empty($id)) {
236 $obj = new MailingTargets($db);
237 $obj->update_nb($id);
238
239 setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
240 } else {
241 header("Location: list.php");
242 exit;
243 }
244 } else {
245 dol_print_error($db);
246 }
247}
248
249if ($action == "confirm_reset_target" && $permissiontocreate) {
250 if ($object->id > 0) {
251 $db->begin();
252 $nbok = 0;
253 $error = 0;
254 foreach ($toselect as $toselectid) {
255 $result = $object->resetTargetErrorStatus($user, $toselectid);
256 if ($result < 0) {
257 setEventMessages($object->error, $object->errors, 'errors');
258 $error++;
259 break;
260 } elseif ($result > 0) {
261 $nbok++;
262 } else {
263 setEventMessages($object->error, $object->errors, 'errors');
264 $error++;
265 }
266 }
267 if (!$error) {
268 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
269 $db->commit();
270 } else {
271 $db->rollback();
272 }
273 }
274}
275
276// Purge search criteria
277if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
278 $search_lastname = '';
279 $search_firstname = '';
280 $search_email = '';
281 $search_other = '';
282 $search_dest_status = '';
283 $toselect = array();
284}
285
286// Action update description of emailing
287if (($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto' || $action == 'setevenunsubscribe') && $permissiontocreate) {
288 $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, getDolGlobalInt('MAILING_USE_NEW_PATH_FOR_FILES') ? 0 : 2, 0, 1, $object, 'mailing');
289
290 if ($action == 'settitle') { // Test on permission already done
291 $object->title = trim(GETPOST('title', 'alpha'));
292 } elseif ($action == 'setemail_from') { // Test on permission already done
293 $object->email_from = trim(GETPOST('email_from', 'alphawithlgt')); // Must allow 'name <email>'
294 } elseif ($action == 'setemail_replyto') { // Test on permission already done
295 $object->email_replyto = trim(GETPOST('email_replyto', 'alphawithlgt')); // Must allow 'name <email>'
296 } elseif ($action == 'setemail_errorsto') { // Test on permission already done
297 $object->email_errorsto = trim(GETPOST('email_errorsto', 'alphawithlgt')); // Must allow 'name <email>'
298 } elseif ($action == 'settitle' && empty($object->title)) { // Test on permission already done
299 $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle"));
300 } elseif ($action == 'setfrom' && empty($object->email_from)) { // Test on permission already done
301 $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom"));
302 } elseif ($action == 'setevenunsubscribe') { // Test on permission already done
303 $object->evenunsubscribe = (GETPOST('evenunsubscribe') ? 1 : 0);
304 }
305
306 if (!$mesg) {
307 $result = $object->update($user);
308 if ($result >= 0) {
309 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
310 exit;
311 }
312 $mesg = $object->error;
313 }
314
315 setEventMessages($mesg, $mesgs, 'errors');
316 $action = "";
317}
318
319
320/*
321 * View
322 */
323
324$form = new Form($db);
325$formmailing = new FormMailing($db);
326
327$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
328llxHeader('', $langs->trans("Mailing"), $help_url);
329
330$arrayofselected = is_array($toselect) ? $toselect : array();
331$totalarray = [
332 'nbfield' => 0,
333];
334
335if ($object->fetch($id) >= 0) {
336 $head = emailing_prepare_head($object);
337
338 print dol_get_fiche_head($head, 'targets', $langs->trans("Mailing"), -1, $object->picto);
339
340 $linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
341
342 $morehtmlref = '<div class="refidno">';
343 // Ref customer
344 $morehtmlref .= $form->editfieldkey("", 'title', $object->title, $object, 0, 'string', '', 0, 1);
345 $morehtmlref .= $form->editfieldval("", 'title', $object->title, $object, 0, 'string', '', null, null, '', 1);
346 $morehtmlref .= '</div>';
347
348 $morehtmlstatus = '';
349 $nbtry = $nbok = 0;
350 if ($object->status == $object::STATUS_SENTPARTIALY || $object->status == $object::STATUS_SENTCOMPLETELY) {
351 $nbtry = $object->countNbOfTargets('alreadysent');
352 $nbko = $object->countNbOfTargets('alreadysentko');
353 $nbok = ($nbtry - $nbko);
354
355 $morehtmlstatus .= ' ('.$nbtry.'/'.$object->nbemail;
356 if ($nbko) {
357 $morehtmlstatus .= ' - '.$nbko.' '.$langs->trans("Error");
358 }
359 $morehtmlstatus .= ') &nbsp; ';
360 }
361
362 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus);
363
364 print '<div class="fichecenter">';
365 print '<div class="fichehalfleft">';
366 print '<div class="underbanner clearboth"></div>';
367
368 print '<table class="border centpercent tableforfield">'."\n";
369
370 // From
371 print '<tr><td class="titlefield">';
372 print $langs->trans("MailFrom").'</td><td>';
373 $emailarray = CMailFile::getArrayAddress($object->email_from);
374 foreach ($emailarray as $email => $name) {
375 if ($name && $name != $email) {
376 print dol_escape_htmltag($name).' &lt;'.$email;
377 print '&gt;';
378 if (!isValidEmail($email)) {
379 $langs->load("errors");
380 print img_warning($langs->trans("ErrorBadEMail", $email));
381 }
382 } else {
383 print dol_print_email($object->email_from, 0, 0, 0, 0, 1);
384 }
385 }
386
387 print '</td></tr>';
388
389 // Errors to
390 if ($object->messtype != 'sms') {
391 print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
392 $emailarray = CMailFile::getArrayAddress($object->email_errorsto);
393 foreach ($emailarray as $email => $name) {
394 if ($name != $email) {
395 print dol_escape_htmltag((string) $name).' &lt;'.$email;
396 print '&gt;';
397 if ($email && !isValidEmail($email)) {
398 $langs->load("errors");
399 print img_warning($langs->trans("ErrorBadEMail", $email));
400 } elseif ($email && !isValidMailDomain($email)) {
401 $langs->load("errors");
402 print img_warning($langs->trans("ErrorBadMXDomain", $email));
403 }
404 } else {
405 print dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1);
406 }
407 }
408 print '</td></tr>';
409 }
410
411 // Reply to
412 if ($object->messtype != 'sms') {
413 print '<tr><td>';
414 print $form->editfieldkey("MailReply", 'email_replyto', $object->email_replyto, $object, (int) ($user->hasRight('mailing', 'creer') && $object->status < $object::STATUS_SENTCOMPLETELY), 'string');
415 print '</td><td>';
416 print $form->editfieldval("MailReply", 'email_replyto', $object->email_replyto, $object, $user->hasRight('mailing', 'creer') && $object->status < $object::STATUS_SENTCOMPLETELY, 'string');
417 $email = CMailFile::getValidAddress($object->email_replyto, 2);
418 if ($action != 'editemail_replyto') {
419 if ($email && !isValidEmail($email)) {
420 $langs->load("errors");
421 print img_warning($langs->trans("ErrorBadEMail", $email));
422 } elseif ($email && !isValidMailDomain($email)) {
423 $langs->load("errors");
424 print img_warning($langs->trans("ErrorBadMXDomain", $email));
425 }
426 }
427 print '</td></tr>';
428 }
429
430 print '</table>';
431 print '</div>';
432
433
434 print '<div class="fichehalfright">';
435 print '<div class="underbanner clearboth"></div>';
436
437 print '<table class="border centpercent tableforfield">';
438
439 // Number of distinct emails
440 print '<tr><td>';
441 print $langs->trans("TotalNbOfDistinctRecipients");
442 print '</td><td>';
443 $nbemail = ($object->nbemail ? $object->nbemail : 0);
444 if (is_numeric($nbemail)) {
445 $htmltooltip = '';
446 if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') < $nbemail) && ($object->status == 1 || ($object->status == 2 && $nbtry < $nbemail))) {
447 if (getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') > 0) {
448 $htmltooltip .= $langs->trans('LimitSendingEmailing', getDolGlobalString('MAILING_LIMIT_SENDBYWEB'));
449 } else {
450 $htmltooltip .= $langs->trans('SendingFromWebInterfaceIsNotAllowed');
451 }
452 }
453 if (empty($nbemail)) {
454 $nbemail .= ' '.img_warning($langs->trans('ToAddRecipientsChooseHere'));//.' <span class="warning">'.$langs->trans("NoTargetYet").'</span>';
455 }
456 if ($htmltooltip) {
457 print $form->textwithpicto($nbemail, $htmltooltip, 1, 'info');
458 } else {
459 print $nbemail;
460 }
461 }
462 print '</td></tr>';
463
464 print '<tr><td>';
465 print $langs->trans("MAIN_MAIL_SENDMODE");
466 print '</td><td>';
467 if ($object->messtype != 'sms') {
468 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
469 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')];
470 } elseif (getDolGlobalString('MAIN_MAIL_SENDMODE')) {
471 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE')];
472 } else {
473 $text = $listofmethods['mail'];
474 }
475 print $text;
476 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
477 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'mail') {
478 print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER_EMAILING', getDolGlobalString('MAIN_MAIL_SMTP_SERVER')).')</span>';
479 }
480 } elseif (getDolGlobalString('MAIN_MAIL_SENDMODE') != 'mail' && getDolGlobalString('MAIN_MAIL_SMTP_SERVER')) {
481 print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER').')</span>';
482 }
483 } else {
484 print 'SMS ';
485 print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER').')</span>';
486 }
487 print '</td></tr>';
488
489 // Other attributes. Fields from hook formObjectOptions and Extrafields.
490 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
491
492 print '</table>';
493 print '</div>';
494 print '</div>';
495
496 print '<div class="clearboth"></div>';
497
498 print dol_get_fiche_end();
499
500 print '<br>';
501
502
503 $newcardbutton = '';
504 $allowaddtarget = ($object->status == $object::STATUS_DRAFT);
505 if (GETPOST('allowaddtarget')) {
506 $allowaddtarget = 1;
507 }
508 if (!$allowaddtarget) {
509 $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?id='.$object->id.'&allowaddtarget=1', '', $user->hasRight('mailing', 'creer'));
510 }
511
512 // Show email selectors
513 if ($allowaddtarget && $user->hasRight('mailing', 'creer')) {
514 print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere").'...', ($user->admin ? info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : ''), '');
515
516 print '<div class="div-table-responsive">';
517 print '<div class="tagtable centpercentwithout1imp liste_titre_bydiv borderbottom" id="tablelines">';
518
519 print '<div class="tagtr liste_titre">';
520 print '<div class="tagtd"></div>';
521 print '<div class="tagtd">'.$langs->trans("RecipientSelectionModules").'</div>';
522 print '<div class="tagtd center maxwidth150">';
523 if ($object->messtype != 'sms') {
524 print $langs->trans("NbOfUniqueEMails");
525 } else {
526 print $langs->trans("NbOfUniquePhones");
527 }
528 print '</div>';
529 print '<div class="tagtd left"><div class="inline-block">'.$langs->trans("Filters").'</div>';
530 if ($object->messtype != 'sms') {
531 print ' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class="inline-block valignmiddle">'.$langs->trans("EvenUnsubscribe").' ';
532 print ajax_object_onoff($object, 'evenunsubscribe', 'evenunsubscribe', 'EvenUnsubscribe:switch_on:warning', 'EvenUnsubscribe', array(), 'small valignmiddle reposition', '', 1);
533 print '</div>';
534 }
535 print '</div>';
536 print '<div class="tagtd">&nbsp;</div>';
537 print '</div>'; // End tr
538
539 clearstatcache();
540
541 foreach ($modulesdir as $dir) {
542 $modulenames = array();
543
544 // Load modules attributes in arrays (name, numero, orders) from dir directory
545 //print $dir."\n<br>";
546 dol_syslog("Scan directory ".$dir." for modules");
547 $handle = @opendir($dir);
548 if (is_resource($handle)) {
549 while (($file = readdir($handle)) !== false) {
550 if (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS') {
551 $reg = array();
552 if (preg_match("/(.*)\.modules\.php$/i", $file, $reg)) {
553 if ($reg[1] == 'example') {
554 continue;
555 }
556 $modulenames[] = $reg[1];
557 }
558 }
559 }
560 closedir($handle);
561 }
562
563 // Sort $modulenames
564 sort($modulenames);
565
566 $var = true;
567
568 // Loop on each submodule
569 foreach ($modulenames as $modulename) {
570 // Loading Class
571 $file = $dir.$modulename.".modules.php";
572 $classname = "mailing_".$modulename;
573 require_once $file;
574
575 $obj = new $classname($db);
576 '@phan-var-force MailingTargets $obj';
577
578 // Check if qualified
579 $qualified = (is_null($obj->enabled) ? 1 : (int) dol_eval((string) $obj->enabled, 1));
580
581 // Check dependencies
582 foreach ($obj->require_module as $key) {
583 if (empty($conf->$key->enabled) || (empty($user->admin) && $obj->require_admin)) {
584 $qualified = 0;
585 //print "Les prerequis d'activation du module mailing ne sont pas respectes. Il ne sera pas actif";
586 break;
587 }
588 }
589
590 // If module is qualified
591 if ($qualified) {
592 if ($allowaddtarget) {
593 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">';
594 print '<input type="hidden" name="token" value="'.newToken().'">';
595 print '<input type="hidden" name="action" value="add">';
596 print '<input type="hidden" name="page_y" value="'.newToken().'">';
597 } else {
598 print '<div class="oddeven trforbreakperms trforbreaknobg impair tagtr">';
599 }
600
601 print '<div class="tagtd paddingleftlarge marginleftonly paddingrightlarge marginrightonly valignmiddle center">';
602 if (empty($obj->picto)) {
603 $obj->picto = 'generic';
604 }
605 print img_object($langs->trans("EmailingTargetSelector").': '.get_class($obj), $obj->picto, 'class="valignmiddle width25 size15x"');
606 print '</div>';
607 print '<div class="tagtd valignmiddle">'; // style="height: 4em"
608 print $obj->getDesc();
609 print '</div>';
610
611 $nbofrecipient = -1;
612
613 try {
614 $obj->evenunsubscribe = $object->evenunsubscribe; // Set flag to include/exclude email that has opt-out.
615
616 $nbofrecipient = $obj->getNbOfRecipients('');
617 } catch (Exception $e) {
618 dol_syslog($e->getMessage(), LOG_ERR);
619 }
620
621 print '<div class="tagtd center valignmiddle">';
622 if ($nbofrecipient === '' || $nbofrecipient >= 0) {
623 print $nbofrecipient;
624 } else {
625 print $langs->trans("Error").' '.img_error($obj->error);
626 }
627 print '</div>';
628
629 print '<div class="tagtd left valignmiddle">';
630 if ($allowaddtarget) {
631 try {
632 $filter = $obj->formFilter();
633 } catch (Exception $e) {
634 dol_syslog($e->getMessage(), LOG_ERR);
635 }
636 if ($filter) {
637 print $filter;
638 } else {
639 print $langs->trans("None");
640 }
641 }
642 print '</div>';
643
644 print '<div class="tagtd right valignmiddle">';
645 if ($allowaddtarget) {
646 print '<input type="submit" class="button button-add small reposition" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
647 } else {
648 print '<input type="submit" class="button small disabled" disabled="disabled" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
649 //print $langs->trans("MailNoChangePossible");
650 print "&nbsp;";
651 }
652 print '</div>';
653
654 if ($allowaddtarget) {
655 print '</form>';
656 } else {
657 print '</div>';
658 }
659 }
660 }
661 } // End foreach dir
662
663 $parameters = array();
664 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
665 print $hookmanager->resPrint;
666
667 print '</div>'; // End table
668 print '</div>';
669
670 print '<br>';
671
672 if ($sqlmessage && $user->admin) {
673 print info_admin($langs->trans("SQLUsedForExport").':<br> '.$sqlmessage, 0, 0, '1', '', 'TechnicalInformation');
674 print '<br>';
675 }
676
677 print '<br><br>';
678 }
679
680
681
682 // List of selected targets
683 $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,";
684 $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text,";
685 $sql .= " COUNT(mu.rowid) as nb";
686 $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
687 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."mailing_unsubscribe as mu ON mu.email = mc.email";
688 $sql .= " WHERE mc.fk_mailing=".((int) $object->id);
689 $asearchcriteriahasbeenset = 0;
690 if ($search_lastname) {
691 $sql .= natural_search("mc.lastname", $search_lastname);
692 $asearchcriteriahasbeenset++;
693 }
694 if ($search_firstname) {
695 $sql .= natural_search("mc.firstname", $search_firstname);
696 $asearchcriteriahasbeenset++;
697 }
698 if ($search_email) {
699 $sql .= natural_search("mc.email", $search_email);
700 $asearchcriteriahasbeenset++;
701 }
702 if ($search_other) {
703 $sql .= natural_search("mc.other", $search_other);
704 $asearchcriteriahasbeenset++;
705 }
706 if ($search_dest_status != '' && (int) $search_dest_status >= -1) {
707 $sql .= " AND mc.statut = ".((int) $search_dest_status);
708 $asearchcriteriahasbeenset++;
709 }
710 $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';
711 $sql .= $db->order($sortfield, $sortorder);
712
713
714 // Count total nb of records
715 $nbtotalofrecords = '';
716 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
717 $result = $db->query($sql);
718 $nbtotalofrecords = $db->num_rows($result);
719 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
720 $page = 0;
721 $offset = 0;
722 }
723
724 // Fix/update nbemail on emailing record if it differs (may happen if user edit lines from database directly)
725 if (empty($asearchcriteriahasbeenset)) {
726 if ($nbtotalofrecords != $object->nbemail) {
727 dol_syslog("We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
728 //print "nbemail=".$object->nbemail." nbtotalofrecords=".$nbtotalofrecords;
729 $resultrefresh = $object->refreshNbOfTargets();
730 if ($resultrefresh < 0) {
731 dol_print_error($db, $object->error, $object->errors);
732 }
733 }
734 }
735 }
736
737 //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets
738 $sql .= $db->plimit($limit + 1, $offset);
739
740 $resql = $db->query($sql);
741 if ($resql) {
742 $num = $db->num_rows($resql);
743
744 $param = "&id=".$object->id;
745 //if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
746 if ($limit > 0 && $limit != $conf->liste_limit) {
747 $param .= '&limit='.((int) $limit);
748 }
749 if ($search_lastname) {
750 $param .= "&search_lastname=".urlencode($search_lastname);
751 }
752 if ($search_firstname) {
753 $param .= "&search_firstname=".urlencode($search_firstname);
754 }
755 if ($search_email) {
756 $param .= "&search_email=".urlencode($search_email);
757 }
758 if ($search_other) {
759 $param .= "&search_other=".urlencode($search_other);
760 }
761
762 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
763 print '<input type="hidden" name="token" value="'.newToken().'">';
764 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
765 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
766 print '<input type="hidden" name="page" value="'.$page.'">';
767 print '<input type="hidden" name="id" value="'.$object->id.'">';
768 print '<input type="hidden" name="page_y" value="">';
769
770 $morehtmlcenter = '';
771 $arrayofmassactions = array();
772 if ($permissiontocreate) {
773 $arrayofmassactions['reset_target'] = img_picto('', 'refresh', 'class="pictofixedwidth"').$langs->trans("ResetMailingTargetMassaction");
774 }
775 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
776 $morehtmlcenter .= $massactionbutton .'<br>';
777
778 if ($object->status == $object::STATUS_DRAFT) {
779 $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>';
780 }
781
782 $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;';
783
784 print '</form>';
785
786 print "\n<!-- List of selected targets -->\n";
787 print '<form method="POST" action="'.dolBuildUrl($_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, $morehtmlright);
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: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.
dol_print_email($email, $contactid=0, $socid=0, $addlink=0, $max=0, $showinvalid=2, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
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'.
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.