dolibarr 20.0.0
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 $nbemail;
79
83 public $bgcolor;
84
88 public $bgimage;
89
94 public $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
95
99 public $status; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
100
104 public $email_from;
105
109 public $sendto;
110
114 public $email_replyto;
115
119 public $email_errorsto;
120
124 public $joined_file1;
125
129 public $joined_file2;
130
134 public $joined_file3;
135
139 public $joined_file4;
140
144 public $date_creation;
145
149 public $date_validation;
150
154 public $date_envoi;
155
159 public $extraparams = array();
160
164 public $statut_dest = array();
165
169 public $substitutionarray;
170
174 public $substitutionarrayfortest;
175
176 const STATUS_DRAFT = 0;
177 const STATUS_VALIDATED = 1;
178 const STATUS_SENTPARTIALY = 2;
179 const STATUS_SENTCOMPLETELY = 3;
180
181
187 public function __construct($db)
188 {
189 $this->db = $db;
190
191 // List of language codes for status
192 $this->labelStatus[0] = 'MailingStatusDraft';
193 $this->labelStatus[1] = 'MailingStatusValidated';
194 $this->labelStatus[2] = 'MailingStatusSentPartialy';
195 $this->labelStatus[3] = 'MailingStatusSentCompletely';
196
197 $this->statut_dest[0] = 'MailingStatusNotSent';
198 $this->statut_dest[1] = 'MailingStatusSent';
199 $this->statut_dest[2] = 'MailingStatusRead';
200 $this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore
201 $this->statut_dest[-1] = 'MailingStatusError';
202 }
203
211 public function create($user, $notrigger = 0)
212 {
213 global $conf, $langs;
214
215 // Check properties
216 if (preg_match('/^InvalidHTMLStringCantBeCleaned/', $this->body)) {
217 $this->error = 'InvalidHTMLStringCantBeCleaned';
218 return -1;
219 }
220
221 $this->title = trim($this->title);
222 $this->email_from = trim($this->email_from);
223
224 if (!$this->email_from) {
225 if ($this->messtype !== 'sms') {
226 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailFrom"));
227 } else {
228 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PhoneFrom"));
229 }
230 return -1;
231 }
232
233 $error = 0;
234 $now = dol_now();
235
236 $this->db->begin();
237
238 $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing";
239 $sql .= " (date_creat, fk_user_creat, entity)";
240 $sql .= " VALUES ('".$this->db->idate($now)."', ".((int) $user->id).", ".((int) $conf->entity).")";
241
242 if (!$this->title) {
243 $this->title = $langs->trans("NoTitle");
244 }
245
246 dol_syslog(__METHOD__, LOG_DEBUG);
247
248 $resql = $this->db->query($sql);
249 if ($resql) {
250 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing");
251
252 $result = $this->update($user, 1);
253 if ($result < 0) {
254 $error++;
255 }
256
257 if (!$error && !$notrigger) {
258 // Call trigger
259 $result = $this->call_trigger('MAILING_CREATE', $user);
260 if ($result < 0) {
261 $error++;
262 }
263 // End call triggers
264 }
265
266 if (!$error) {
267 $this->db->commit();
268 return $this->id;
269 } else {
270 $this->db->rollback();
271 dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
272 return -2;
273 }
274 } else {
275 $this->error = $this->db->lasterror();
276 $this->db->rollback();
277 return -1;
278 }
279 }
280
288 public function update($user, $notrigger = 0)
289 {
290 global $langs;
291
292 // Check properties
293 if (preg_match('/^InvalidHTMLStringCantBeCleaned/', $this->body)) {
294 $this->error = 'InvalidHTMLStringCantBeCleaned';
295 return -1;
296 }
297
298 $error = 0;
299 $this->db->begin();
300
301 $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
302 $sql .= " SET titre = '".$this->db->escape($this->title)."'";
303 $sql .= ", messtype = '".$this->db->escape($this->messtype)."'";
304 $sql .= ", sujet = '".$this->db->escape($this->sujet)."'";
305 $sql .= ", body = '".$this->db->escape($this->body)."'";
306 $sql .= ", email_from = '".$this->db->escape($this->email_from)."'";
307 $sql .= ", email_replyto = '".$this->db->escape($this->email_replyto)."'";
308 $sql .= ", email_errorsto = '".$this->db->escape($this->email_errorsto)."'";
309 $sql .= ", bgcolor = '".($this->bgcolor ? $this->db->escape($this->bgcolor) : null)."'";
310 $sql .= ", bgimage = '".($this->bgimage ? $this->db->escape($this->bgimage) : null)."'";
311 $sql .= ", evenunsubscribe = ".((int) $this->evenunsubscribe);
312 $sql .= " WHERE rowid = ".(int) $this->id;
313
314 dol_syslog(__METHOD__, LOG_DEBUG);
315 $resql = $this->db->query($sql);
316 if ($resql) {
317 if (!$error && !$notrigger) {
318 // Call trigger
319 $result = $this->call_trigger('MAILING_MODIFY', $user);
320 if ($result < 0) {
321 $error++;
322 }
323 // End call triggers
324 }
325
326 if (!$error) {
327 dol_syslog(__METHOD__ . ' success');
328 $this->db->commit();
329 return 1;
330 } else {
331 $this->db->rollback();
332 dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
333 return -2;
334 }
335 } else {
336 if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
337 $this->error = $langs->trans("ErrorTitleAlreadyExists", $this->title);
338 } else {
339 $this->error = $this->db->lasterror();
340 }
341 $this->db->rollback();
342 return -1;
343 }
344 }
345
353 public function fetch($rowid, $ref = '')
354 {
355 $sql = "SELECT m.rowid, m.messtype, m.titre as title, m.sujet, m.body, m.bgcolor, m.bgimage, m.evenunsubscribe";
356 $sql .= ", m.email_from, m.email_replyto, m.email_errorsto";
357 $sql .= ", m.statut as status, m.nbemail";
358 $sql .= ", m.fk_user_creat, m.fk_user_valid";
359 $sql .= ", m.date_creat";
360 $sql .= ", m.date_valid";
361 $sql .= ", m.date_envoi";
362 $sql .= ", m.extraparams";
363 $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
364 $sql .= " WHERE entity IN (".getEntity('mailing').")";
365 if ($ref) {
366 $sql .= " AND m.titre = '".$this->db->escape($ref)."'";
367 } else {
368 $sql .= " AND m.rowid = ".(int) $rowid;
369 }
370
371 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
372 $result = $this->db->query($sql);
373 if ($result) {
374 if ($this->db->num_rows($result)) {
375 $obj = $this->db->fetch_object($result);
376
377 $this->id = $obj->rowid;
378 $this->ref = $obj->rowid;
379 $this->title = $obj->title;
380 $this->messtype = $obj->messtype;
381
382 $this->statut = $obj->status; // deprecated
383 $this->status = $obj->status;
384
385 $this->nbemail = $obj->nbemail;
386
387 $this->sujet = $obj->sujet;
388 if (getDolGlobalString('FCKEDITOR_ENABLE_MAILING') && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5))) {
389 $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5);
390 } else {
391 $this->body = $obj->body;
392 }
393
394 $this->bgcolor = $obj->bgcolor;
395 $this->bgimage = $obj->bgimage;
396 $this->evenunsubscribe = $obj->evenunsubscribe;
397
398 $this->email_from = $obj->email_from;
399 $this->email_replyto = $obj->email_replyto;
400 $this->email_errorsto = $obj->email_errorsto;
401
402 $this->user_creation_id = $obj->fk_user_creat;
403 $this->user_validation_id = $obj->fk_user_valid;
404
405 $this->date_creation = $this->db->jdate($obj->date_creat);
406 $this->date_validation = $this->db->jdate($obj->date_valid);
407 $this->date_envoi = $this->db->jdate($obj->date_envoi);
408
409 $this->extraparams = (array) json_decode($obj->extraparams, true);
410
411 if ($this->messtype == 'sms') {
412 $this->picto = 'phone';
413 }
414
415 return 1;
416 } else {
417 dol_syslog(get_class($this)."::fetch Erreur -1");
418 return -1;
419 }
420 } else {
421 dol_syslog(get_class($this)."::fetch Erreur -2");
422 return -2;
423 }
424 }
425
426
436 public function createFromClone(User $user, $fromid, $option1, $option2)
437 {
438 global $langs;
439
440 $error = 0;
441
442 $object = new Mailing($this->db);
443
444 $this->db->begin();
445
446 // Load source object
447 $object->fetch($fromid);
448 $object->id = 0;
449 $object->status = 0;
450 $object->statut = 0;
451
452 // Clear fields
453 $object->title = $langs->trans("CopyOf").' '.$object->title.' '.dol_print_date(dol_now());
454
455 // If no option copy content
456 if (empty($option1)) {
457 // Clear values
458 $object->nbemail = 0;
459 $object->sujet = '';
460 $object->body = '';
461 $object->bgcolor = '';
462 $object->bgimage = '';
463 $object->evenunsubscribe = 0;
464
465 //$object->email_from = ''; // We do not reset from email because it is a mandatory value
466 $object->email_replyto = '';
467 $object->email_errorsto = '';
468
469 $object->user_creation_id = $user->id;
470 $object->user_validation_id = null;
471
472 $object->date_envoi = null;
473 }
474
475 // Create clone
476 $object->context['createfromclone'] = 'createfromclone';
477 $result = $object->create($user);
478
479 // Other options
480 if ($result < 0) {
481 $this->error = $object->error;
482 $this->errors = array_merge($this->errors, $object->errors);
483 $error++;
484 }
485
486 if (!$error) {
487 // Clone recipient targets
488 if (!empty($option2)) {
489 require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
490
491 $mailing_target = new MailingTargets($this->db);
492
493 $target_array = array();
494
495 $sql = "SELECT fk_contact,";
496 $sql .= " lastname,";
497 $sql .= " firstname,";
498 $sql .= " email,";
499 $sql .= " other,";
500 $sql .= " source_url,";
501 $sql .= " source_id ,";
502 $sql .= " source_type";
503 $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles";
504 $sql .= " WHERE fk_mailing = ".((int) $fromid);
505
506 $result = $this->db->query($sql);
507 if ($result) {
508 if ($this->db->num_rows($result)) {
509 while ($obj = $this->db->fetch_object($result)) {
510 $target_array[] = array(
511 'fk_contact'=>$obj->fk_contact,
512 'lastname'=>$obj->lastname,
513 'firstname'=>$obj->firstname,
514 'email'=>$obj->email,
515 'other'=>$obj->other,
516 'source_url'=>$obj->source_url,
517 'source_id'=>$obj->source_id,
518 'source_type'=>$obj->source_type
519 );
520 }
521 }
522 } else {
523 $this->error = $this->db->lasterror();
524 return -1;
525 }
526
527 $mailing_target->addTargetsToDatabase($object->id, $target_array);
528 }
529 }
530
531 unset($object->context['createfromclone']);
532
533 // End
534 if (!$error) {
535 $this->db->commit();
536 return $object->id;
537 } else {
538 $this->db->rollback();
539 return -1;
540 }
541 }
542
549 public function valid($user)
550 {
551 $now = dol_now();
552
553 $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
554 $sql .= " SET statut = 1, date_valid = '".$this->db->idate($now)."', fk_user_valid=".$user->id;
555 $sql .= " WHERE rowid = ".((int) $this->id);
556
557 dol_syslog("Mailing::valid", LOG_DEBUG);
558 if ($this->db->query($sql)) {
559 return 1;
560 } else {
561 $this->error = $this->db->lasterror();
562 return -1;
563 }
564 }
565
566
574 public function delete($user, $notrigger = 0)
575 {
576 $error = 0;
577
578 $this->db->begin();
579
580 if (!$notrigger) {
581 $result = $this->call_trigger('MAILING_DELETE', $user);
582 if ($result < 0) {
583 $error++;
584 }
585 }
586
587 if (!$error) {
588 $sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing";
589 $sql .= " WHERE rowid = " . ((int) $this->id);
590
591 dol_syslog(__METHOD__, LOG_DEBUG);
592 $resql = $this->db->query($sql);
593 if ($resql) {
594 $res = $this->delete_targets();
595 if ($res <= 0) {
596 $error++;
597 }
598
599 if (!$error) {
600 dol_syslog(__METHOD__ . ' success');
601 $this->db->commit();
602 return 1;
603 } else {
604 $this->db->rollback();
605 dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
606 return -2;
607 }
608 } else {
609 $this->db->rollback();
610 $this->error = $this->db->lasterror();
611 return -1;
612 }
613 } else {
614 $this->db->rollback();
615 return -1;
616 }
617 }
618
619 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
625 public function delete_targets()
626 {
627 // phpcs:enable
628 $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
629 $sql .= " WHERE fk_mailing = ".((int) $this->id);
630
631 dol_syslog("Mailing::delete_targets", LOG_DEBUG);
632 $resql = $this->db->query($sql);
633 if ($resql) {
634 $this->refreshNbOfTargets();
635
636 return 1;
637 } else {
638 $this->error = $this->db->lasterror();
639 return 0;
640 }
641 }
642
643
644 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
651 public function reset_targets_status($user)
652 {
653 // phpcs:enable
654 $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
655 $sql .= " SET statut = 0";
656 $sql .= " WHERE fk_mailing = ".((int) $this->id);
657
658 dol_syslog("Mailing::reset_targets_status", LOG_DEBUG);
659 $resql = $this->db->query($sql);
660 if ($resql) {
661 return 1;
662 } else {
663 $this->error = $this->db->lasterror();
664 return -1;
665 }
666 }
667
668
675 public function countNbOfTargets($mode)
676 {
677 $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
678 $sql .= " WHERE fk_mailing = ".((int) $this->id);
679 if ($mode == 'alreadysent') {
680 $sql .= " AND statut <> 0";
681 } elseif ($mode == 'alreadysentok') {
682 $sql .= " AND statut > 0";
683 } elseif ($mode == 'alreadysentko') {
684 $sql .= " AND statut = -1";
685 } else {
686 $this->error = 'BadValueForParameterMode';
687 return -2;
688 }
689
690 $resql = $this->db->query($sql);
691 if ($resql) {
692 $obj = $this->db->fetch_object($resql);
693 if ($obj) {
694 return $obj->nb;
695 }
696 } else {
697 $this->error = $this->db->lasterror();
698 return -1;
699 }
700 return 0;
701 }
702
709 public function refreshNbOfTargets()
710 {
711 $sql = "SELECT COUNT(rowid) as nb";
712 $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles";
713 $sql .= " WHERE fk_mailing = ".((int) $this->id);
714
715 $resql = $this->db->query($sql);
716 if ($resql) {
717 $obj = $this->db->fetch_object($resql);
718 if ($obj) {
719 $nbforupdate = $obj->nb;
720
721 $sql = 'UPDATE '.MAIN_DB_PREFIX.'mailing SET nbemail = '.((int) $nbforupdate);
722 $sql .= ' WHERE rowid = '.((int) $this->id);
723
724 $resqlupdate = $this->db->query($sql);
725 if (! $resqlupdate) {
726 $this->error = $this->db->lasterror();
727 return -1;
728 } else {
729 $this->nbemail = (int) $nbforupdate;
730 }
731 }
732 } else {
733 $this->error = $this->db->lasterror();
734 return -1;
735 }
736
737 return 1;
738 }
739
747 public function getTooltipContentArray($params)
748 {
749 global $langs;
750
751 //$nofetch = !empty($params['nofetch']);
752 $langs->load('mails');
753
754 $datas = array();
755 $datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ShowEMailing").'</u>';
756 if (isset($this->status)) {
757 $datas['picto'] .= ' '.$this->getLibStatut(5);
758 }
759 $datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
760 if (isset($this->title)) {
761 $datas['title'] = '<br><b>'.$langs->trans('MailTitle').':</b> '.$this->title;
762 }
763 if (isset($this->sujet)) {
764 $datas['subject'] = '<br><b>'.$langs->trans('MailTopic').':</b> '.$this->sujet;
765 }
766
767 return $datas;
768 }
769
780 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
781 {
782 global $conf, $langs, $hookmanager;
783
784 if (!empty($conf->dol_no_mouse_hover)) {
785 $notooltip = 1; // Force disable tooltips
786 }
787
788 $result = '';
789 $params = [
790 'id' => $this->id,
791 'objecttype' => $this->element,
792 'option' => $option,
793 'nofetch' => 1,
794 ];
795 $classfortooltip = 'classfortooltip';
796 $dataparams = '';
797 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
798 $classfortooltip = 'classforajaxtooltip';
799 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
800 $label = '';
801 } else {
802 $label = implode($this->getTooltipContentArray($params));
803 }
804
805 $url = DOL_URL_ROOT.'/comm/mailing/card.php?id='.$this->id;
806
807 if ($option != 'nolink') {
808 // Add param to save lastsearch_values or not
809 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
810 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
811 $add_save_lastsearch_values = 1;
812 }
813 if ($add_save_lastsearch_values) {
814 $url .= '&save_lastsearch_values=1';
815 }
816 }
817
818 $linkclose = '';
819 if (empty($notooltip)) {
820 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
821 $label = $langs->trans("ShowEMailing");
822 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
823 }
824 $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
825 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
826 } else {
827 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
828 }
829
830 $linkstart = '<a href="'.$url.'"';
831 $linkstart .= $linkclose.'>';
832 $linkend = '</a>';
833
834 $result .= $linkstart;
835 if ($withpicto) {
836 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
837 }
838 if ($withpicto != 2) {
839 $result .= $this->ref;
840 }
841 $result .= $linkend;
842 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
843
844 global $action;
845 $hookmanager->initHooks(array('emailingdao'));
846 $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
847 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
848 if ($reshook > 0) {
849 $result = $hookmanager->resPrint;
850 } else {
851 $result .= $hookmanager->resPrint;
852 }
853
854 return $result;
855 }
856
863 public function getLibStatut($mode = 0)
864 {
865 return $this->LibStatut($this->status, $mode);
866 }
867
868 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
876 public function LibStatut($status, $mode = 0)
877 {
878 // phpcs:enable
879 global $langs;
880 $langs->load("mailing");
881
882 $labelStatus = $langs->transnoentitiesnoconv($this->labelStatus[$status]);
883 $labelStatusShort = $langs->transnoentitiesnoconv($this->labelStatus[$status]);
884
885 $statusType = 'status'.$status;
886 if ($status == 2) {
887 $statusType = 'status3';
888 }
889 if ($status == 3) {
890 $statusType = 'status6';
891 }
892
893 return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
894 }
895
896
906 public static function libStatutDest($status, $mode = 0, $desc = '')
907 {
908 global $langs;
909 $langs->load("mails");
910
911 $labelStatus = array();
912 $labelStatusShort = array();
913
914 $labelStatus[-1] = $langs->transnoentitiesnoconv('MailingStatusError');
915 $labelStatus[0] = $langs->transnoentitiesnoconv('MailingStatusNotSent');
916 $labelStatus[1] = $langs->transnoentitiesnoconv('MailingStatusSent');
917 $labelStatus[2] = $langs->transnoentitiesnoconv('MailingStatusRead');
918 $labelStatus[3] = $langs->transnoentitiesnoconv('MailingStatusNotContact');
919 $labelStatusShort[-1] = $langs->transnoentitiesnoconv('MailingStatusError');
920 $labelStatusShort[0] = $langs->transnoentitiesnoconv('MailingStatusNotSent');
921 $labelStatusShort[1] = $langs->transnoentitiesnoconv('MailingStatusSent');
922 $labelStatusShort[2] = $langs->transnoentitiesnoconv('MailingStatusRead');
923 $labelStatusShort[3] = $langs->transnoentitiesnoconv('MailingStatusNotContact');
924
925 $statusType = 'status'.$status;
926 if ($status == -1) {
927 $statusType = 'status8';
928 }
929 if ($status == 1) {
930 $statusType = 'status6';
931 }
932 if ($status == 2) {
933 $statusType = 'status4';
934 }
935
936 $param = array();
937 if ($status == -1) {
938 $param = array('badgeParams' => array('attr' => array('title' => $desc)));
939 }
940
941 return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode, '', $param);
942 }
943}
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:636
$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:1991