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