dolibarr 21.0.0-alpha
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_envoi;
145
149 public $extraparams = array();
150
154 public $statut_dest = array();
155
159 public $substitutionarray;
160
164 public $substitutionarrayfortest;
165
166 const STATUS_DRAFT = 0;
167 const STATUS_VALIDATED = 1;
168 const STATUS_SENTPARTIALY = 2;
169 const STATUS_SENTCOMPLETELY = 3;
170
171
177 public function __construct($db)
178 {
179 $this->db = $db;
180
181 // List of language codes for status
182 $this->labelStatus[0] = 'MailingStatusDraft';
183 $this->labelStatus[1] = 'MailingStatusValidated';
184 $this->labelStatus[2] = 'MailingStatusSentPartialy';
185 $this->labelStatus[3] = 'MailingStatusSentCompletely';
186
187 $this->statut_dest[0] = 'MailingStatusNotSent';
188 $this->statut_dest[1] = 'MailingStatusSent';
189 $this->statut_dest[2] = 'MailingStatusRead';
190 $this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore
191 $this->statut_dest[-1] = 'MailingStatusError';
192 }
193
201 public function create($user, $notrigger = 0)
202 {
203 global $conf, $langs;
204
205 // Check properties
206 if (preg_match('/^InvalidHTMLStringCantBeCleaned/', $this->body)) {
207 $this->error = 'InvalidHTMLStringCantBeCleaned';
208 return -1;
209 }
210
211 $this->title = trim($this->title);
212 $this->email_from = trim($this->email_from);
213
214 if (!$this->email_from) {
215 if ($this->messtype !== 'sms') {
216 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailFrom"));
217 } else {
218 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PhoneFrom"));
219 }
220 return -1;
221 }
222
223 $error = 0;
224 $now = dol_now();
225
226 $this->db->begin();
227
228 $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing";
229 $sql .= " (date_creat, fk_user_creat, entity)";
230 $sql .= " VALUES ('".$this->db->idate($now)."', ".((int) $user->id).", ".((int) $conf->entity).")";
231
232 if (!$this->title) {
233 $this->title = $langs->trans("NoTitle");
234 }
235
236 dol_syslog(__METHOD__, LOG_DEBUG);
237
238 $resql = $this->db->query($sql);
239 if ($resql) {
240 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing");
241
242 $result = $this->update($user, 1);
243 if ($result < 0) {
244 $error++;
245 }
246
247 if (!$error && !$notrigger) {
248 // Call trigger
249 $result = $this->call_trigger('MAILING_CREATE', $user);
250 if ($result < 0) {
251 $error++;
252 }
253 // End call triggers
254 }
255
256 if (!$error) {
257 $this->db->commit();
258 return $this->id;
259 } else {
260 $this->db->rollback();
261 dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
262 return -2;
263 }
264 } else {
265 $this->error = $this->db->lasterror();
266 $this->db->rollback();
267 return -1;
268 }
269 }
270
278 public function update($user, $notrigger = 0)
279 {
280 global $langs;
281
282 // Check properties
283 if (preg_match('/^InvalidHTMLStringCantBeCleaned/', $this->body)) {
284 $this->error = 'InvalidHTMLStringCantBeCleaned';
285 return -1;
286 }
287
288 $error = 0;
289 $this->db->begin();
290
291 $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
292 $sql .= " SET titre = '".$this->db->escape($this->title)."'";
293 $sql .= ", messtype = '".$this->db->escape($this->messtype)."'";
294 $sql .= ", sujet = '".$this->db->escape($this->sujet)."'";
295 $sql .= ", body = '".$this->db->escape($this->body)."'";
296 $sql .= ", email_from = '".$this->db->escape($this->email_from)."'";
297 $sql .= ", email_replyto = '".$this->db->escape($this->email_replyto)."'";
298 $sql .= ", email_errorsto = '".$this->db->escape($this->email_errorsto)."'";
299 $sql .= ", bgcolor = '".($this->bgcolor ? $this->db->escape($this->bgcolor) : null)."'";
300 $sql .= ", bgimage = '".($this->bgimage ? $this->db->escape($this->bgimage) : null)."'";
301 $sql .= ", evenunsubscribe = ".((int) $this->evenunsubscribe);
302 $sql .= " WHERE rowid = ".(int) $this->id;
303
304 dol_syslog(__METHOD__, LOG_DEBUG);
305 $resql = $this->db->query($sql);
306 if ($resql) {
307 if (!$error && !$notrigger) {
308 // Call trigger
309 $result = $this->call_trigger('MAILING_MODIFY', $user);
310 if ($result < 0) {
311 $error++;
312 }
313 // End call triggers
314 }
315
316 if (!$error) {
317 dol_syslog(__METHOD__ . ' success');
318 $this->db->commit();
319 return 1;
320 } else {
321 $this->db->rollback();
322 dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
323 return -2;
324 }
325 } else {
326 if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
327 $this->error = $langs->trans("ErrorTitleAlreadyExists", $this->title);
328 } else {
329 $this->error = $this->db->lasterror();
330 }
331 $this->db->rollback();
332 return -1;
333 }
334 }
335
343 public function fetch($rowid, $ref = '')
344 {
345 $sql = "SELECT m.rowid, m.messtype, m.titre as title, m.sujet, m.body, m.bgcolor, m.bgimage, m.evenunsubscribe";
346 $sql .= ", m.email_from, m.email_replyto, m.email_errorsto";
347 $sql .= ", m.statut as status, m.nbemail";
348 $sql .= ", m.fk_user_creat, m.fk_user_valid";
349 $sql .= ", m.date_creat";
350 $sql .= ", m.date_valid";
351 $sql .= ", m.date_envoi";
352 $sql .= ", m.extraparams";
353 $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
354 $sql .= " WHERE entity IN (".getEntity('mailing').")";
355 if ($ref) {
356 $sql .= " AND m.titre = '".$this->db->escape($ref)."'";
357 } else {
358 $sql .= " AND m.rowid = ".(int) $rowid;
359 }
360
361 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
362 $result = $this->db->query($sql);
363 if ($result) {
364 if ($this->db->num_rows($result)) {
365 $obj = $this->db->fetch_object($result);
366
367 $this->id = $obj->rowid;
368 $this->ref = $obj->rowid;
369 $this->title = $obj->title;
370 $this->messtype = $obj->messtype;
371
372 $this->statut = $obj->status; // deprecated
373 $this->status = $obj->status;
374
375 $this->nbemail = $obj->nbemail;
376
377 $this->sujet = $obj->sujet;
378 if (getDolGlobalString('FCKEDITOR_ENABLE_MAILING') && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5))) {
379 $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5);
380 } else {
381 $this->body = $obj->body;
382 }
383
384 $this->bgcolor = $obj->bgcolor;
385 $this->bgimage = $obj->bgimage;
386 $this->evenunsubscribe = $obj->evenunsubscribe;
387
388 $this->email_from = $obj->email_from;
389 $this->email_replyto = $obj->email_replyto;
390 $this->email_errorsto = $obj->email_errorsto;
391
392 $this->user_creation_id = $obj->fk_user_creat;
393 $this->user_validation_id = $obj->fk_user_valid;
394
395 $this->date_creation = $this->db->jdate($obj->date_creat);
396 $this->date_validation = $this->db->jdate($obj->date_valid);
397 $this->date_envoi = $this->db->jdate($obj->date_envoi);
398
399 $this->extraparams = (array) json_decode($obj->extraparams, true);
400
401 if ($this->messtype == 'sms') {
402 $this->picto = 'phone';
403 }
404
405 return 1;
406 } else {
407 dol_syslog(get_class($this)."::fetch Erreur -1");
408 return -1;
409 }
410 } else {
411 dol_syslog(get_class($this)."::fetch Erreur -2");
412 return -2;
413 }
414 }
415
416
426 public function createFromClone(User $user, $fromid, $option1, $option2)
427 {
428 global $langs;
429
430 $error = 0;
431
432 $object = new Mailing($this->db);
433
434 $this->db->begin();
435
436 // Load source object
437 $object->fetch($fromid);
438 $object->id = 0;
439 $object->status = 0;
440 $object->statut = 0;
441
442 // Clear fields
443 $object->title = $langs->trans("CopyOf").' '.$object->title.' '.dol_print_date(dol_now());
444
445 // If no option copy content
446 if (empty($option1)) {
447 // Clear values
448 $object->nbemail = 0;
449 $object->sujet = '';
450 $object->body = '';
451 $object->bgcolor = '';
452 $object->bgimage = '';
453 $object->evenunsubscribe = 0;
454
455 //$object->email_from = ''; // We do not reset from email because it is a mandatory value
456 $object->email_replyto = '';
457 $object->email_errorsto = '';
458
459 $object->user_creation_id = $user->id;
460 $object->user_validation_id = null;
461
462 $object->date_envoi = null;
463 }
464
465 // Create clone
466 $object->context['createfromclone'] = 'createfromclone';
467 $result = $object->create($user);
468
469 // Other options
470 if ($result < 0) {
471 $this->error = $object->error;
472 $this->errors = array_merge($this->errors, $object->errors);
473 $error++;
474 }
475
476 if (!$error) {
477 // Clone recipient targets
478 if (!empty($option2)) {
479 require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
480
481 $mailing_target = new MailingTargets($this->db);
482
483 $target_array = array();
484
485 $sql = "SELECT fk_contact,";
486 $sql .= " lastname,";
487 $sql .= " firstname,";
488 $sql .= " email,";
489 $sql .= " other,";
490 $sql .= " source_url,";
491 $sql .= " source_id ,";
492 $sql .= " source_type";
493 $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles";
494 $sql .= " WHERE fk_mailing = ".((int) $fromid);
495
496 $result = $this->db->query($sql);
497 if ($result) {
498 if ($this->db->num_rows($result)) {
499 while ($obj = $this->db->fetch_object($result)) {
500 $target_array[] = array(
501 'fk_contact'=>$obj->fk_contact,
502 'lastname'=>$obj->lastname,
503 'firstname'=>$obj->firstname,
504 'email'=>$obj->email,
505 'other'=>$obj->other,
506 'source_url'=>$obj->source_url,
507 'source_id'=>$obj->source_id,
508 'source_type'=>$obj->source_type
509 );
510 }
511 }
512 } else {
513 $this->error = $this->db->lasterror();
514 return -1;
515 }
516
517 $mailing_target->addTargetsToDatabase($object->id, $target_array);
518 }
519 }
520
521 unset($object->context['createfromclone']);
522
523 // End
524 if (!$error) {
525 $this->db->commit();
526 return $object->id;
527 } else {
528 $this->db->rollback();
529 return -1;
530 }
531 }
532
539 public function valid($user)
540 {
541 $now = dol_now();
542
543 $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
544 $sql .= " SET statut = 1, date_valid = '".$this->db->idate($now)."', fk_user_valid=".$user->id;
545 $sql .= " WHERE rowid = ".((int) $this->id);
546
547 dol_syslog("Mailing::valid", LOG_DEBUG);
548 if ($this->db->query($sql)) {
549 return 1;
550 } else {
551 $this->error = $this->db->lasterror();
552 return -1;
553 }
554 }
555
556
564 public function delete($user, $notrigger = 0)
565 {
566 $error = 0;
567
568 $this->db->begin();
569
570 if (!$notrigger) {
571 $result = $this->call_trigger('MAILING_DELETE', $user);
572 if ($result < 0) {
573 $error++;
574 }
575 }
576
577 if (!$error) {
578 $sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing";
579 $sql .= " WHERE rowid = " . ((int) $this->id);
580
581 dol_syslog(__METHOD__, LOG_DEBUG);
582 $resql = $this->db->query($sql);
583 if ($resql) {
584 $res = $this->delete_targets();
585 if ($res <= 0) {
586 $error++;
587 }
588
589 if (!$error) {
590 dol_syslog(__METHOD__ . ' success');
591 $this->db->commit();
592 return 1;
593 } else {
594 $this->db->rollback();
595 dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
596 return -2;
597 }
598 } else {
599 $this->db->rollback();
600 $this->error = $this->db->lasterror();
601 return -1;
602 }
603 } else {
604 $this->db->rollback();
605 return -1;
606 }
607 }
608
609 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
615 public function delete_targets()
616 {
617 // phpcs:enable
618 $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
619 $sql .= " WHERE fk_mailing = ".((int) $this->id);
620
621 dol_syslog("Mailing::delete_targets", LOG_DEBUG);
622 $resql = $this->db->query($sql);
623 if ($resql) {
624 $this->refreshNbOfTargets();
625
626 return 1;
627 } else {
628 $this->error = $this->db->lasterror();
629 return 0;
630 }
631 }
632
633
634 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
641 public function reset_targets_status($user)
642 {
643 // phpcs:enable
644 $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
645 $sql .= " SET statut = 0";
646 $sql .= " WHERE fk_mailing = ".((int) $this->id);
647
648 dol_syslog("Mailing::reset_targets_status", LOG_DEBUG);
649 $resql = $this->db->query($sql);
650 if ($resql) {
651 return 1;
652 } else {
653 $this->error = $this->db->lasterror();
654 return -1;
655 }
656 }
657
658
665 public function countNbOfTargets($mode)
666 {
667 $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
668 $sql .= " WHERE fk_mailing = ".((int) $this->id);
669 if ($mode == 'alreadysent') {
670 $sql .= " AND statut <> 0";
671 } elseif ($mode == 'alreadysentok') {
672 $sql .= " AND statut > 0";
673 } elseif ($mode == 'alreadysentko') {
674 $sql .= " AND statut = -1";
675 } else {
676 $this->error = 'BadValueForParameterMode';
677 return -2;
678 }
679
680 $resql = $this->db->query($sql);
681 if ($resql) {
682 $obj = $this->db->fetch_object($resql);
683 if ($obj) {
684 return $obj->nb;
685 }
686 } else {
687 $this->error = $this->db->lasterror();
688 return -1;
689 }
690 return 0;
691 }
692
699 public function refreshNbOfTargets()
700 {
701 $sql = "SELECT COUNT(rowid) as nb";
702 $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles";
703 $sql .= " WHERE fk_mailing = ".((int) $this->id);
704
705 $resql = $this->db->query($sql);
706 if ($resql) {
707 $obj = $this->db->fetch_object($resql);
708 if ($obj) {
709 $nbforupdate = $obj->nb;
710
711 $sql = 'UPDATE '.MAIN_DB_PREFIX.'mailing SET nbemail = '.((int) $nbforupdate);
712 $sql .= ' WHERE rowid = '.((int) $this->id);
713
714 $resqlupdate = $this->db->query($sql);
715 if (! $resqlupdate) {
716 $this->error = $this->db->lasterror();
717 return -1;
718 } else {
719 $this->nbemail = (int) $nbforupdate;
720 }
721 }
722 } else {
723 $this->error = $this->db->lasterror();
724 return -1;
725 }
726
727 return 1;
728 }
729
737 public function getTooltipContentArray($params)
738 {
739 global $langs;
740
741 //$nofetch = !empty($params['nofetch']);
742 $langs->load('mails');
743
744 $datas = array();
745 $datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ShowEMailing").'</u>';
746 if (isset($this->status)) {
747 $datas['picto'] .= ' '.$this->getLibStatut(5);
748 }
749 $datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
750 if (isset($this->title)) {
751 $datas['title'] = '<br><b>'.$langs->trans('MailTitle').':</b> '.$this->title;
752 }
753 if (isset($this->sujet)) {
754 $datas['subject'] = '<br><b>'.$langs->trans('MailTopic').':</b> '.$this->sujet;
755 }
756
757 return $datas;
758 }
759
770 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
771 {
772 global $conf, $langs, $hookmanager;
773
774 if (!empty($conf->dol_no_mouse_hover)) {
775 $notooltip = 1; // Force disable tooltips
776 }
777
778 $result = '';
779 $params = [
780 'id' => $this->id,
781 'objecttype' => $this->element,
782 'option' => $option,
783 'nofetch' => 1,
784 ];
785 $classfortooltip = 'classfortooltip';
786 $dataparams = '';
787 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
788 $classfortooltip = 'classforajaxtooltip';
789 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
790 $label = '';
791 } else {
792 $label = implode($this->getTooltipContentArray($params));
793 }
794
795 $url = DOL_URL_ROOT.'/comm/mailing/card.php?id='.$this->id;
796
797 if ($option != 'nolink') {
798 // Add param to save lastsearch_values or not
799 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
800 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
801 $add_save_lastsearch_values = 1;
802 }
803 if ($add_save_lastsearch_values) {
804 $url .= '&save_lastsearch_values=1';
805 }
806 }
807
808 $linkclose = '';
809 if (empty($notooltip)) {
810 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
811 $label = $langs->trans("ShowEMailing");
812 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
813 }
814 $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
815 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
816 } else {
817 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
818 }
819
820 $linkstart = '<a href="'.$url.'"';
821 $linkstart .= $linkclose.'>';
822 $linkend = '</a>';
823
824 $result .= $linkstart;
825 if ($withpicto) {
826 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
827 }
828 if ($withpicto != 2) {
829 $result .= $this->ref;
830 }
831 $result .= $linkend;
832 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
833
834 global $action;
835 $hookmanager->initHooks(array('emailingdao'));
836 $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
837 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
838 if ($reshook > 0) {
839 $result = $hookmanager->resPrint;
840 } else {
841 $result .= $hookmanager->resPrint;
842 }
843
844 return $result;
845 }
846
853 public function getLibStatut($mode = 0)
854 {
855 return $this->LibStatut($this->status, $mode);
856 }
857
858 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
866 public function LibStatut($status, $mode = 0)
867 {
868 // phpcs:enable
869 global $langs;
870 $langs->load("mailing");
871
872 $labelStatus = $langs->transnoentitiesnoconv($this->labelStatus[$status]);
873 $labelStatusShort = $langs->transnoentitiesnoconv($this->labelStatus[$status]);
874
875 $statusType = 'status'.$status;
876 if ($status == 2) {
877 $statusType = 'status3';
878 }
879 if ($status == 3) {
880 $statusType = 'status6';
881 }
882
883 return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
884 }
885
886
896 public static function libStatutDest($status, $mode = 0, $desc = '')
897 {
898 global $langs;
899 $langs->load("mails");
900
901 $labelStatus = array();
902 $labelStatusShort = array();
903
904 $labelStatus[-1] = $langs->transnoentitiesnoconv('MailingStatusError');
905 $labelStatus[0] = $langs->transnoentitiesnoconv('MailingStatusNotSent');
906 $labelStatus[1] = $langs->transnoentitiesnoconv('MailingStatusSent');
907 $labelStatus[2] = $langs->transnoentitiesnoconv('MailingStatusRead');
908 $labelStatus[3] = $langs->transnoentitiesnoconv('MailingStatusNotContact');
909 $labelStatusShort[-1] = $langs->transnoentitiesnoconv('MailingStatusError');
910 $labelStatusShort[0] = $langs->transnoentitiesnoconv('MailingStatusNotSent');
911 $labelStatusShort[1] = $langs->transnoentitiesnoconv('MailingStatusSent');
912 $labelStatusShort[2] = $langs->transnoentitiesnoconv('MailingStatusRead');
913 $labelStatusShort[3] = $langs->transnoentitiesnoconv('MailingStatusNotContact');
914
915 $statusType = 'status'.$status;
916 if ($status == -1) {
917 $statusType = 'status8';
918 }
919 if ($status == 1) {
920 $statusType = 'status6';
921 }
922 if ($status == 2) {
923 $statusType = 'status4';
924 }
925
926 $param = array();
927 if ($status == -1) {
928 $param = array('badgeParams' => array('attr' => array('title' => $desc)));
929 }
930
931 return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode, '', $param);
932 }
933}
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:626
$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:1929