dolibarr 20.0.5
mailing.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
28
29
33class Mailing extends CommonObject
34{
38 public $element = 'mailing';
39
43 public $table_element = 'mailing';
44
48 public $picto = 'email';
49
53 public $messtype;
54
58 public $title;
59
63 public $sujet;
64
68 public $body;
69
73 public $evenunsubscribe;
74
78 public $note_public;
79
83 public $note_private;
84
88 public $nbemail;
89
93 public $bgcolor;
94
98 public $bgimage;
99
104 public $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
105
109 public $status; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
110
114 public $email_from;
115
119 public $sendto;
120
124 public $email_replyto;
125
129 public $email_errorsto;
130
134 public $joined_file1;
135
139 public $joined_file2;
140
144 public $joined_file3;
145
149 public $joined_file4;
150
154 public $date_creation;
155
159 public $date_validation;
160
164 public $date_envoi;
165
169 public $extraparams = array();
170
174 public $statut_dest = array();
175
179 public $substitutionarray;
180
184 public $substitutionarrayfortest;
185
186 const STATUS_DRAFT = 0;
187 const STATUS_VALIDATED = 1;
188 const STATUS_SENTPARTIALY = 2;
189 const STATUS_SENTCOMPLETELY = 3;
190
191
197 public function __construct($db)
198 {
199 $this->db = $db;
200
201 // List of language codes for status
202 $this->labelStatus[0] = 'MailingStatusDraft';
203 $this->labelStatus[1] = 'MailingStatusValidated';
204 $this->labelStatus[2] = 'MailingStatusSentPartialy';
205 $this->labelStatus[3] = 'MailingStatusSentCompletely';
206
207 $this->statut_dest[0] = 'MailingStatusNotSent';
208 $this->statut_dest[1] = 'MailingStatusSent';
209 $this->statut_dest[2] = 'MailingStatusRead';
210 $this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore
211 $this->statut_dest[-1] = 'MailingStatusError';
212 }
213
221 public function create($user, $notrigger = 0)
222 {
223 global $conf, $langs;
224
225 // Check properties
226 if (preg_match('/^InvalidHTMLStringCantBeCleaned/', $this->body)) {
227 $this->error = 'InvalidHTMLStringCantBeCleaned';
228 return -1;
229 }
230
231 $this->title = trim($this->title);
232 $this->email_from = trim($this->email_from);
233
234 if (!$this->email_from) {
235 if ($this->messtype !== 'sms') {
236 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailFrom"));
237 } else {
238 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PhoneFrom"));
239 }
240 return -1;
241 }
242
243 $error = 0;
244 $now = dol_now();
245
246 $this->db->begin();
247
248 $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing";
249 $sql .= " (date_creat, fk_user_creat, entity)";
250 $sql .= " VALUES ('".$this->db->idate($now)."', ".((int) $user->id).", ".((int) $conf->entity).")";
251
252 if (!$this->title) {
253 $this->title = $langs->trans("NoTitle");
254 }
255
256 dol_syslog(__METHOD__, LOG_DEBUG);
257
258 $resql = $this->db->query($sql);
259 if ($resql) {
260 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing");
261
262 $result = $this->update($user, 1);
263 if ($result < 0) {
264 $error++;
265 }
266
267 if (!$error && !$notrigger) {
268 // Call trigger
269 $result = $this->call_trigger('MAILING_CREATE', $user);
270 if ($result < 0) {
271 $error++;
272 }
273 // End call triggers
274 }
275
276 if (!$error) {
277 $this->db->commit();
278 return $this->id;
279 } else {
280 $this->db->rollback();
281 dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
282 return -2;
283 }
284 } else {
285 $this->error = $this->db->lasterror();
286 $this->db->rollback();
287 return -1;
288 }
289 }
290
298 public function update($user, $notrigger = 0)
299 {
300 global $langs;
301
302 // Check properties
303 if (preg_match('/^InvalidHTMLStringCantBeCleaned/', $this->body)) {
304 $this->error = 'InvalidHTMLStringCantBeCleaned';
305 return -1;
306 }
307
308 $error = 0;
309 $this->db->begin();
310
311 $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
312 $sql .= " SET titre = '".$this->db->escape($this->title)."'";
313 $sql .= ", messtype = '".$this->db->escape($this->messtype)."'";
314 $sql .= ", sujet = '".$this->db->escape($this->sujet)."'";
315 $sql .= ", body = '".$this->db->escape($this->body)."'";
316 $sql .= ", email_from = '".$this->db->escape($this->email_from)."'";
317 $sql .= ", email_replyto = '".$this->db->escape($this->email_replyto)."'";
318 $sql .= ", email_errorsto = '".$this->db->escape($this->email_errorsto)."'";
319 $sql .= ", bgcolor = '".($this->bgcolor ? $this->db->escape($this->bgcolor) : null)."'";
320 $sql .= ", bgimage = '".($this->bgimage ? $this->db->escape($this->bgimage) : null)."'";
321 $sql .= ", evenunsubscribe = ".((int) $this->evenunsubscribe);
322 $sql .= ", note_public = '".$this->db->escape($this->note_public)."'";
323 $sql .= ", note_private = '".$this->db->escape($this->note_private)."'";
324 $sql .= " WHERE rowid = ".(int) $this->id;
325
326 dol_syslog(__METHOD__, LOG_DEBUG);
327 $resql = $this->db->query($sql);
328 if ($resql) {
329 if (!$error && !$notrigger) {
330 // Call trigger
331 $result = $this->call_trigger('MAILING_MODIFY', $user);
332 if ($result < 0) {
333 $error++;
334 }
335 // End call triggers
336 }
337
338 if (!$error) {
339 dol_syslog(__METHOD__ . ' success');
340 $this->db->commit();
341 return 1;
342 } else {
343 $this->db->rollback();
344 dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
345 return -2;
346 }
347 } else {
348 if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
349 $this->error = $langs->trans("ErrorTitleAlreadyExists", $this->title);
350 } else {
351 $this->error = $this->db->lasterror();
352 }
353 $this->db->rollback();
354 return -1;
355 }
356 }
357
365 public function fetch($rowid, $ref = '')
366 {
367 $sql = "SELECT m.rowid, m.messtype, m.titre as title, m.sujet, m.body, m.bgcolor, m.bgimage, m.evenunsubscribe";
368 $sql .= ", m.note_public, m.note_private";
369 $sql .= ", m.email_from, m.email_replyto, m.email_errorsto";
370 $sql .= ", m.statut as status, m.nbemail";
371 $sql .= ", m.fk_user_creat, m.fk_user_valid";
372 $sql .= ", m.date_creat";
373 $sql .= ", m.date_valid";
374 $sql .= ", m.date_envoi";
375 $sql .= ", m.extraparams";
376 $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
377 $sql .= " WHERE entity IN (".getEntity('mailing').")";
378 if ($ref) {
379 $sql .= " AND m.titre = '".$this->db->escape($ref)."'";
380 } else {
381 $sql .= " AND m.rowid = ".(int) $rowid;
382 }
383
384 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
385 $result = $this->db->query($sql);
386 if ($result) {
387 if ($this->db->num_rows($result)) {
388 $obj = $this->db->fetch_object($result);
389
390 $this->id = $obj->rowid;
391 $this->ref = $obj->rowid;
392 $this->title = $obj->title;
393 $this->messtype = $obj->messtype;
394
395 $this->statut = $obj->status; // deprecated
396 $this->status = $obj->status;
397
398 $this->nbemail = $obj->nbemail;
399
400 $this->sujet = $obj->sujet;
401 if (getDolGlobalString('FCKEDITOR_ENABLE_MAILING') && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5))) {
402 $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5);
403 } else {
404 $this->body = $obj->body;
405 }
406
407 $this->bgcolor = $obj->bgcolor;
408 $this->bgimage = $obj->bgimage;
409 $this->evenunsubscribe = $obj->evenunsubscribe;
410 $this->note_public = $obj->note_public;
411 $this->note_private = $obj->note_private;
412
413 $this->email_from = $obj->email_from;
414 $this->email_replyto = $obj->email_replyto;
415 $this->email_errorsto = $obj->email_errorsto;
416
417 $this->user_creation_id = $obj->fk_user_creat;
418 $this->user_validation_id = $obj->fk_user_valid;
419
420 $this->date_creation = $this->db->jdate($obj->date_creat);
421 $this->date_validation = $this->db->jdate($obj->date_valid);
422 $this->date_envoi = $this->db->jdate($obj->date_envoi);
423
424 $this->extraparams = (array) json_decode($obj->extraparams, true);
425
426 if ($this->messtype == 'sms') {
427 $this->picto = 'phone';
428 }
429
430 return 1;
431 } else {
432 dol_syslog(get_class($this)."::fetch Erreur -1");
433 return -1;
434 }
435 } else {
436 dol_syslog(get_class($this)."::fetch Erreur -2");
437 return -2;
438 }
439 }
440
441
451 public function createFromClone(User $user, $fromid, $option1, $option2)
452 {
453 global $langs;
454
455 $error = 0;
456
457 $object = new Mailing($this->db);
458
459 $this->db->begin();
460
461 // Load source object
462 $object->fetch($fromid);
463 $object->id = 0;
464 $object->status = 0;
465 $object->statut = 0;
466
467 // Clear fields
468 $object->title = $langs->trans("CopyOf").' '.$object->title.' '.dol_print_date(dol_now());
469
470 // If no option copy content
471 if (empty($option1)) {
472 // Clear values
473 $object->nbemail = 0;
474 $object->sujet = '';
475 $object->body = '';
476 $object->bgcolor = '';
477 $object->bgimage = '';
478 $object->evenunsubscribe = 0;
479 $object->note_public = '';
480 $object->note_private = '';
481
482 //$object->email_from = ''; // We do not reset from email because it is a mandatory value
483 $object->email_replyto = '';
484 $object->email_errorsto = '';
485
486 $object->user_creation_id = $user->id;
487 $object->user_validation_id = null;
488
489 $object->date_envoi = null;
490 }
491
492 // Create clone
493 $object->context['createfromclone'] = 'createfromclone';
494 $result = $object->create($user);
495
496 // Other options
497 if ($result < 0) {
498 $this->error = $object->error;
499 $this->errors = array_merge($this->errors, $object->errors);
500 $error++;
501 }
502
503 if (!$error) {
504 // Clone recipient targets
505 if (!empty($option2)) {
506 require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
507
508 $mailing_target = new MailingTargets($this->db);
509
510 $target_array = array();
511
512 $sql = "SELECT fk_contact,";
513 $sql .= " lastname,";
514 $sql .= " firstname,";
515 $sql .= " email,";
516 $sql .= " other,";
517 $sql .= " source_url,";
518 $sql .= " source_id ,";
519 $sql .= " source_type";
520 $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles";
521 $sql .= " WHERE fk_mailing = ".((int) $fromid);
522
523 $result = $this->db->query($sql);
524 if ($result) {
525 if ($this->db->num_rows($result)) {
526 while ($obj = $this->db->fetch_object($result)) {
527 $target_array[] = array(
528 'fk_contact'=>$obj->fk_contact,
529 'lastname'=>$obj->lastname,
530 'firstname'=>$obj->firstname,
531 'email'=>$obj->email,
532 'other'=>$obj->other,
533 'source_url'=>$obj->source_url,
534 'source_id'=>$obj->source_id,
535 'source_type'=>$obj->source_type
536 );
537 }
538 }
539 } else {
540 $this->error = $this->db->lasterror();
541 return -1;
542 }
543
544 $mailing_target->addTargetsToDatabase($object->id, $target_array);
545 }
546 }
547
548 unset($object->context['createfromclone']);
549
550 // End
551 if (!$error) {
552 $this->db->commit();
553 return $object->id;
554 } else {
555 $this->db->rollback();
556 return -1;
557 }
558 }
559
566 public function valid($user)
567 {
568 $now = dol_now();
569
570 $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
571 $sql .= " SET statut = 1, date_valid = '".$this->db->idate($now)."', fk_user_valid=".$user->id;
572 $sql .= " WHERE rowid = ".((int) $this->id);
573
574 dol_syslog("Mailing::valid", LOG_DEBUG);
575 if ($this->db->query($sql)) {
576 return 1;
577 } else {
578 $this->error = $this->db->lasterror();
579 return -1;
580 }
581 }
582
583
591 public function delete($user, $notrigger = 0)
592 {
593 $error = 0;
594
595 $this->db->begin();
596
597 if (!$notrigger) {
598 $result = $this->call_trigger('MAILING_DELETE', $user);
599 if ($result < 0) {
600 $error++;
601 }
602 }
603
604 if (!$error) {
605 $sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing";
606 $sql .= " WHERE rowid = " . ((int) $this->id);
607
608 dol_syslog(__METHOD__, LOG_DEBUG);
609 $resql = $this->db->query($sql);
610 if ($resql) {
611 $res = $this->delete_targets();
612 if ($res <= 0) {
613 $error++;
614 }
615
616 if (!$error) {
617 dol_syslog(__METHOD__ . ' success');
618 $this->db->commit();
619 return 1;
620 } else {
621 $this->db->rollback();
622 dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
623 return -2;
624 }
625 } else {
626 $this->db->rollback();
627 $this->error = $this->db->lasterror();
628 return -1;
629 }
630 } else {
631 $this->db->rollback();
632 return -1;
633 }
634 }
635
636 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
642 public function delete_targets()
643 {
644 // phpcs:enable
645 $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
646 $sql .= " WHERE fk_mailing = ".((int) $this->id);
647
648 dol_syslog("Mailing::delete_targets", LOG_DEBUG);
649 $resql = $this->db->query($sql);
650 if ($resql) {
651 $this->refreshNbOfTargets();
652
653 return 1;
654 } else {
655 $this->error = $this->db->lasterror();
656 return 0;
657 }
658 }
659
660
661 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
668 public function reset_targets_status($user)
669 {
670 // phpcs:enable
671 $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
672 $sql .= " SET statut = 0";
673 $sql .= " WHERE fk_mailing = ".((int) $this->id);
674
675 dol_syslog("Mailing::reset_targets_status", LOG_DEBUG);
676 $resql = $this->db->query($sql);
677 if ($resql) {
678 return 1;
679 } else {
680 $this->error = $this->db->lasterror();
681 return -1;
682 }
683 }
684
685
692 public function countNbOfTargets($mode)
693 {
694 $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
695 $sql .= " WHERE fk_mailing = ".((int) $this->id);
696 if ($mode == 'alreadysent') {
697 $sql .= " AND statut <> 0";
698 } elseif ($mode == 'alreadysentok') {
699 $sql .= " AND statut > 0";
700 } elseif ($mode == 'alreadysentko') {
701 $sql .= " AND statut = -1";
702 } else {
703 $this->error = 'BadValueForParameterMode';
704 return -2;
705 }
706
707 $resql = $this->db->query($sql);
708 if ($resql) {
709 $obj = $this->db->fetch_object($resql);
710 if ($obj) {
711 return $obj->nb;
712 }
713 } else {
714 $this->error = $this->db->lasterror();
715 return -1;
716 }
717 return 0;
718 }
719
726 public function refreshNbOfTargets()
727 {
728 $sql = "SELECT COUNT(rowid) as nb";
729 $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles";
730 $sql .= " WHERE fk_mailing = ".((int) $this->id);
731
732 $resql = $this->db->query($sql);
733 if ($resql) {
734 $obj = $this->db->fetch_object($resql);
735 if ($obj) {
736 $nbforupdate = $obj->nb;
737
738 $sql = 'UPDATE '.MAIN_DB_PREFIX.'mailing SET nbemail = '.((int) $nbforupdate);
739 $sql .= ' WHERE rowid = '.((int) $this->id);
740
741 $resqlupdate = $this->db->query($sql);
742 if (! $resqlupdate) {
743 $this->error = $this->db->lasterror();
744 return -1;
745 } else {
746 $this->nbemail = (int) $nbforupdate;
747 }
748 }
749 } else {
750 $this->error = $this->db->lasterror();
751 return -1;
752 }
753
754 return 1;
755 }
756
764 public function getTooltipContentArray($params)
765 {
766 global $langs;
767
768 //$nofetch = !empty($params['nofetch']);
769 $langs->load('mails');
770
771 $datas = array();
772 $datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ShowEMailing").'</u>';
773 if (isset($this->status)) {
774 $datas['picto'] .= ' '.$this->getLibStatut(5);
775 }
776 $datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
777 if (isset($this->title)) {
778 $datas['title'] = '<br><b>'.$langs->trans('MailTitle').':</b> '.$this->title;
779 }
780 if (isset($this->sujet)) {
781 $datas['subject'] = '<br><b>'.$langs->trans('MailTopic').':</b> '.$this->sujet;
782 }
783
784 return $datas;
785 }
786
797 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
798 {
799 global $conf, $langs, $hookmanager;
800
801 if (!empty($conf->dol_no_mouse_hover)) {
802 $notooltip = 1; // Force disable tooltips
803 }
804
805 $result = '';
806 $params = [
807 'id' => $this->id,
808 'objecttype' => $this->element,
809 'option' => $option,
810 'nofetch' => 1,
811 ];
812 $classfortooltip = 'classfortooltip';
813 $dataparams = '';
814 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
815 $classfortooltip = 'classforajaxtooltip';
816 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
817 $label = '';
818 } else {
819 $label = implode($this->getTooltipContentArray($params));
820 }
821
822 $url = DOL_URL_ROOT.'/comm/mailing/card.php?id='.$this->id;
823
824 if ($option != 'nolink') {
825 // Add param to save lastsearch_values or not
826 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
827 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
828 $add_save_lastsearch_values = 1;
829 }
830 if ($add_save_lastsearch_values) {
831 $url .= '&save_lastsearch_values=1';
832 }
833 }
834
835 $linkclose = '';
836 if (empty($notooltip)) {
837 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
838 $label = $langs->trans("ShowEMailing");
839 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
840 }
841 $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
842 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
843 } else {
844 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
845 }
846
847 $linkstart = '<a href="'.$url.'"';
848 $linkstart .= $linkclose.'>';
849 $linkend = '</a>';
850
851 $result .= $linkstart;
852 if ($withpicto) {
853 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
854 }
855 if ($withpicto != 2) {
856 $result .= $this->ref;
857 }
858 $result .= $linkend;
859 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
860
861 global $action;
862 $hookmanager->initHooks(array('emailingdao'));
863 $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
864 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
865 if ($reshook > 0) {
866 $result = $hookmanager->resPrint;
867 } else {
868 $result .= $hookmanager->resPrint;
869 }
870
871 return $result;
872 }
873
880 public function getLibStatut($mode = 0)
881 {
882 return $this->LibStatut($this->status, $mode);
883 }
884
885 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
893 public function LibStatut($status, $mode = 0)
894 {
895 // phpcs:enable
896 global $langs;
897 $langs->load("mailing");
898
899 $labelStatus = $langs->transnoentitiesnoconv($this->labelStatus[$status]);
900 $labelStatusShort = $langs->transnoentitiesnoconv($this->labelStatus[$status]);
901
902 $statusType = 'status'.$status;
903 if ($status == 2) {
904 $statusType = 'status3';
905 }
906 if ($status == 3) {
907 $statusType = 'status6';
908 }
909
910 return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
911 }
912
913
923 public static function libStatutDest($status, $mode = 0, $desc = '')
924 {
925 global $langs;
926 $langs->load("mails");
927
928 $labelStatus = array();
929 $labelStatusShort = array();
930
931 $labelStatus[-1] = $langs->transnoentitiesnoconv('MailingStatusError');
932 $labelStatus[0] = $langs->transnoentitiesnoconv('MailingStatusNotSent');
933 $labelStatus[1] = $langs->transnoentitiesnoconv('MailingStatusSent');
934 $labelStatus[2] = $langs->transnoentitiesnoconv('MailingStatusRead');
935 $labelStatus[3] = $langs->transnoentitiesnoconv('MailingStatusNotContact');
936 $labelStatusShort[-1] = $langs->transnoentitiesnoconv('MailingStatusError');
937 $labelStatusShort[0] = $langs->transnoentitiesnoconv('MailingStatusNotSent');
938 $labelStatusShort[1] = $langs->transnoentitiesnoconv('MailingStatusSent');
939 $labelStatusShort[2] = $langs->transnoentitiesnoconv('MailingStatusRead');
940 $labelStatusShort[3] = $langs->transnoentitiesnoconv('MailingStatusNotContact');
941
942 $statusType = 'status'.$status;
943 if ($status == -1) {
944 $statusType = 'status8';
945 }
946 if ($status == 1) {
947 $statusType = 'status6';
948 }
949 if ($status == 2) {
950 $statusType = 'status4';
951 }
952
953 $param = array();
954 if ($status == -1) {
955 $param = array('badgeParams' => array('attr' => array('title' => $desc)));
956 }
957
958 return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode, '', $param);
959 }
960}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition security.php:637
$object ref
Definition info.php:79
Parent class of all other business classes (invoices, contracts, proposals, orders,...
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage emailings module.
static libStatutDest($status, $mode=0, $desc='')
Return the label of a given status of a recipient TODO Add class mailin_target.class....
getLibStatut($mode=0)
Return label of status of emailing (draft, validated, ...)
delete_targets()
Delete targets emailing.
valid($user)
Validate emailing.
countNbOfTargets($mode)
Count number of target with status.
create($user, $notrigger=0)
Create an EMailing.
fetch($rowid, $ref='')
Get object from database.
getTooltipContentArray($params)
getTooltipContentArray
__construct($db)
Constructor.
update($user, $notrigger=0)
Update emailing record.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
createFromClone(User $user, $fromid, $option1, $option2)
Load an object from its id and create a new one in database.
refreshNbOfTargets()
Refresh denormalized value ->nbemail into emailing record Note: There is also the method update_nb in...
reset_targets_status($user)
Change status of each recipient.
LibStatut($status, $mode=0)
Return the label of a given status.
Parent class of emailing target selectors modules.
Class to manage Dolibarr users.
dol_html_entity_decode($a, $b, $c='UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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).
dol_textishtml($msg, $option=0)
Return if a text is a html content.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e e e e e statut
Definition invoice.php:2010