dolibarr 21.0.0-beta
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
29
30
34class Mailing extends CommonObject
35{
39 public $element = 'mailing';
40
44 public $table_element = 'mailing';
45
49 public $picto = 'email';
50
54 public $messtype;
55
59 public $title;
60
64 public $sujet;
65
69 public $body;
70
74 public $evenunsubscribe;
75
79 public $nbemail;
80
84 public $bgcolor;
85
89 public $bgimage;
90
95 public $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
96
100 public $status; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
101
105 public $email_from;
106
110 public $sendto;
111
115 public $email_replyto;
116
120 public $email_errorsto;
121
125 public $joined_file1;
126
130 public $joined_file2;
131
135 public $joined_file3;
136
140 public $joined_file4;
141
145 public $date_envoi;
146
150 public $extraparams = array();
151
155 public $statut_dest = array();
156
160 public $substitutionarray;
161
165 public $substitutionarrayfortest;
166
167 const STATUS_DRAFT = 0;
168 const STATUS_VALIDATED = 1;
169 const STATUS_SENTPARTIALY = 2;
170 const STATUS_SENTCOMPLETELY = 3;
171
172
178 public function __construct($db)
179 {
180 $this->db = $db;
181
182 // List of language codes for status
183 $this->labelStatus[0] = 'MailingStatusDraft';
184 $this->labelStatus[1] = 'MailingStatusValidated';
185 $this->labelStatus[2] = 'MailingStatusSentPartialy';
186 $this->labelStatus[3] = 'MailingStatusSentCompletely';
187
188 $this->statut_dest[0] = 'MailingStatusNotSent';
189 $this->statut_dest[1] = 'MailingStatusSent';
190 $this->statut_dest[2] = 'MailingStatusRead';
191 $this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore
192 $this->statut_dest[-1] = 'MailingStatusError';
193 }
194
202 public function create($user, $notrigger = 0)
203 {
204 global $conf, $langs;
205
206 // Check properties
207 if (preg_match('/^InvalidHTMLStringCantBeCleaned/', $this->body)) {
208 $this->error = 'InvalidHTMLStringCantBeCleaned';
209 return -1;
210 }
211
212 $this->title = trim($this->title);
213 $this->email_from = trim($this->email_from);
214
215 if (!$this->email_from) {
216 if ($this->messtype !== 'sms') {
217 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailFrom"));
218 } else {
219 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PhoneFrom"));
220 }
221 return -1;
222 }
223
224 $error = 0;
225 $now = dol_now();
226
227 $this->db->begin();
228
229 $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing";
230 $sql .= " (date_creat, fk_user_creat, entity)";
231 $sql .= " VALUES ('".$this->db->idate($now)."', ".((int) $user->id).", ".((int) $conf->entity).")";
232
233 if (!$this->title) {
234 $this->title = $langs->trans("NoTitle");
235 }
236
237 dol_syslog(__METHOD__, LOG_DEBUG);
238
239 $resql = $this->db->query($sql);
240 if ($resql) {
241 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing");
242
243 $result = $this->update($user, 1);
244 if ($result < 0) {
245 $error++;
246 }
247
248 if (!$error && !$notrigger) {
249 // Call trigger
250 $result = $this->call_trigger('MAILING_CREATE', $user);
251 if ($result < 0) {
252 $error++;
253 }
254 // End call triggers
255 }
256
257 if (!$error) {
258 $this->db->commit();
259 return $this->id;
260 } else {
261 $this->db->rollback();
262 dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
263 return -2;
264 }
265 } else {
266 $this->error = $this->db->lasterror();
267 $this->db->rollback();
268 return -1;
269 }
270 }
271
279 public function update($user, $notrigger = 0)
280 {
281 global $langs;
282
283 // Check properties
284 if (preg_match('/^InvalidHTMLStringCantBeCleaned/', $this->body)) {
285 $this->error = 'InvalidHTMLStringCantBeCleaned';
286 return -1;
287 }
288
289 $error = 0;
290 $this->db->begin();
291
292 $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
293 $sql .= " SET titre = '".$this->db->escape($this->title)."'";
294 $sql .= ", messtype = '".$this->db->escape($this->messtype)."'";
295 $sql .= ", sujet = '".$this->db->escape($this->sujet)."'";
296 $sql .= ", body = '".$this->db->escape($this->body)."'";
297 $sql .= ", email_from = '".$this->db->escape($this->email_from)."'";
298 $sql .= ", email_replyto = '".$this->db->escape($this->email_replyto)."'";
299 $sql .= ", email_errorsto = '".$this->db->escape($this->email_errorsto)."'";
300 $sql .= ", bgcolor = '".($this->bgcolor ? $this->db->escape($this->bgcolor) : null)."'";
301 $sql .= ", bgimage = '".($this->bgimage ? $this->db->escape($this->bgimage) : null)."'";
302 $sql .= ", evenunsubscribe = ".((int) $this->evenunsubscribe);
303 $sql .= " WHERE rowid = ".(int) $this->id;
304
305 dol_syslog(__METHOD__, LOG_DEBUG);
306 $resql = $this->db->query($sql);
307 if ($resql) {
308 if (!$error && !$notrigger) {
309 // Call trigger
310 $result = $this->call_trigger('MAILING_MODIFY', $user);
311 if ($result < 0) {
312 $error++;
313 }
314 // End call triggers
315 }
316
317 if (!$error) {
318 dol_syslog(__METHOD__ . ' success');
319 $this->db->commit();
320 return 1;
321 } else {
322 $this->db->rollback();
323 dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
324 return -2;
325 }
326 } else {
327 if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
328 $this->error = $langs->trans("ErrorTitleAlreadyExists", $this->title);
329 } else {
330 $this->error = $this->db->lasterror();
331 }
332 $this->db->rollback();
333 return -1;
334 }
335 }
336
344 public function fetch($rowid, $ref = '')
345 {
346 $sql = "SELECT m.rowid, m.messtype, m.titre as title, m.sujet, m.body, m.bgcolor, m.bgimage, m.evenunsubscribe";
347 $sql .= ", m.email_from, m.email_replyto, m.email_errorsto";
348 $sql .= ", m.statut as status, m.nbemail";
349 $sql .= ", m.fk_user_creat, m.fk_user_valid";
350 $sql .= ", m.date_creat";
351 $sql .= ", m.date_valid";
352 $sql .= ", m.date_envoi";
353 $sql .= ", m.extraparams";
354 $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
355 $sql .= " WHERE entity IN (".getEntity('mailing').")";
356 if ($ref) {
357 $sql .= " AND m.titre = '".$this->db->escape($ref)."'";
358 } else {
359 $sql .= " AND m.rowid = ".(int) $rowid;
360 }
361
362 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
363 $result = $this->db->query($sql);
364 if ($result) {
365 if ($this->db->num_rows($result)) {
366 $obj = $this->db->fetch_object($result);
367
368 $this->id = $obj->rowid;
369 $this->ref = $obj->rowid;
370 $this->title = $obj->title;
371 $this->messtype = $obj->messtype;
372
373 $this->statut = $obj->status; // deprecated
374 $this->status = $obj->status;
375
376 $this->nbemail = $obj->nbemail;
377
378 $this->sujet = $obj->sujet;
379 if (getDolGlobalString('FCKEDITOR_ENABLE_MAILING') && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5))) {
380 $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5);
381 } else {
382 $this->body = $obj->body;
383 }
384
385 $this->bgcolor = $obj->bgcolor;
386 $this->bgimage = $obj->bgimage;
387 $this->evenunsubscribe = $obj->evenunsubscribe;
388
389 $this->email_from = $obj->email_from;
390 $this->email_replyto = $obj->email_replyto;
391 $this->email_errorsto = $obj->email_errorsto;
392
393 $this->user_creation_id = $obj->fk_user_creat;
394 $this->user_validation_id = $obj->fk_user_valid;
395
396 $this->date_creation = $this->db->jdate($obj->date_creat);
397 $this->date_validation = $this->db->jdate($obj->date_valid);
398 $this->date_envoi = $this->db->jdate($obj->date_envoi);
399
400 $this->extraparams = (array) json_decode($obj->extraparams, true);
401
402 if ($this->messtype == 'sms') {
403 $this->picto = 'phone';
404 }
405
406 return 1;
407 } else {
408 dol_syslog(get_class($this)."::fetch Erreur -1");
409 return -1;
410 }
411 } else {
412 dol_syslog(get_class($this)."::fetch Erreur -2");
413 return -2;
414 }
415 }
416
417
427 public function createFromClone(User $user, $fromid, $option1, $option2)
428 {
429 global $langs;
430
431 $error = 0;
432
433 $object = new Mailing($this->db);
434
435 $this->db->begin();
436
437 // Load source object
438 $object->fetch($fromid);
439 $object->id = 0;
440 $object->status = 0;
441 $object->statut = 0;
442
443 // Clear fields
444 $object->title = $langs->trans("CopyOf").' '.$object->title.' '.dol_print_date(dol_now());
445
446 // If no option copy content
447 if (empty($option1)) {
448 // Clear values
449 $object->nbemail = 0;
450 $object->sujet = '';
451 $object->body = '';
452 $object->bgcolor = '';
453 $object->bgimage = '';
454 $object->evenunsubscribe = 0;
455
456 //$object->email_from = ''; // We do not reset from email because it is a mandatory value
457 $object->email_replyto = '';
458 $object->email_errorsto = '';
459
460 $object->user_creation_id = $user->id;
461 $object->user_validation_id = null;
462
463 $object->date_envoi = null;
464 }
465
466 // Create clone
467 $object->context['createfromclone'] = 'createfromclone';
468 $result = $object->create($user);
469
470 // Other options
471 if ($result < 0) {
472 $this->error = $object->error;
473 $this->errors = array_merge($this->errors, $object->errors);
474 $error++;
475 }
476
477 if (!$error) {
478 // Clone recipient targets
479 if (!empty($option2)) {
480 require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
481
482 $mailing_target = new MailingTargets($this->db);
483
484 $target_array = array();
485
486 $sql = "SELECT fk_contact,";
487 $sql .= " lastname,";
488 $sql .= " firstname,";
489 $sql .= " email,";
490 $sql .= " other,";
491 $sql .= " source_url,";
492 $sql .= " source_id ,";
493 $sql .= " source_type";
494 $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles";
495 $sql .= " WHERE fk_mailing = ".((int) $fromid);
496
497 $result = $this->db->query($sql);
498 if ($result) {
499 if ($this->db->num_rows($result)) {
500 while ($obj = $this->db->fetch_object($result)) {
501 $target_array[] = array(
502 'fk_contact' => $obj->fk_contact,
503 'lastname' => $obj->lastname,
504 'firstname' => $obj->firstname,
505 'email' => $obj->email,
506 'other' => $obj->other,
507 'source_url' => $obj->source_url,
508 'source_id' => $obj->source_id,
509 'source_type' => $obj->source_type
510 );
511 }
512 }
513 } else {
514 $this->error = $this->db->lasterror();
515 return -1;
516 }
517
518 $mailing_target->addTargetsToDatabase($object->id, $target_array);
519 }
520 }
521
522 unset($object->context['createfromclone']);
523
524 // End
525 if (!$error) {
526 $this->db->commit();
527 return $object->id;
528 } else {
529 $this->db->rollback();
530 return -1;
531 }
532 }
533
540 public function valid($user)
541 {
542 $now = dol_now();
543
544 $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
545 $sql .= " SET statut = 1, date_valid = '".$this->db->idate($now)."', fk_user_valid=".$user->id;
546 $sql .= " WHERE rowid = ".((int) $this->id);
547
548 dol_syslog("Mailing::valid", LOG_DEBUG);
549 if ($this->db->query($sql)) {
550 return 1;
551 } else {
552 $this->error = $this->db->lasterror();
553 return -1;
554 }
555 }
556
557
565 public function delete($user, $notrigger = 0)
566 {
567 $error = 0;
568
569 $this->db->begin();
570
571 if (!$notrigger) {
572 $result = $this->call_trigger('MAILING_DELETE', $user);
573 if ($result < 0) {
574 $error++;
575 }
576 }
577
578 if (!$error) {
579 $sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing";
580 $sql .= " WHERE rowid = " . ((int) $this->id);
581
582 dol_syslog(__METHOD__, LOG_DEBUG);
583 $resql = $this->db->query($sql);
584 if ($resql) {
585 $res = $this->delete_targets();
586 if ($res <= 0) {
587 $error++;
588 }
589
590 if (!$error) {
591 dol_syslog(__METHOD__ . ' success');
592 $this->db->commit();
593 return 1;
594 } else {
595 $this->db->rollback();
596 dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
597 return -2;
598 }
599 } else {
600 $this->db->rollback();
601 $this->error = $this->db->lasterror();
602 return -1;
603 }
604 } else {
605 $this->db->rollback();
606 return -1;
607 }
608 }
609
610 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
616 public function delete_targets()
617 {
618 // phpcs:enable
619 $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
620 $sql .= " WHERE fk_mailing = ".((int) $this->id);
621
622 dol_syslog("Mailing::delete_targets", LOG_DEBUG);
623 $resql = $this->db->query($sql);
624 if ($resql) {
625 $this->refreshNbOfTargets();
626
627 return 1;
628 } else {
629 $this->error = $this->db->lasterror();
630 return 0;
631 }
632 }
633
634
635 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
642 public function reset_targets_status($user)
643 {
644 // phpcs:enable
645 $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
646 $sql .= " SET statut = 0";
647 $sql .= " WHERE fk_mailing = ".((int) $this->id);
648
649 dol_syslog("Mailing::reset_targets_status", LOG_DEBUG);
650 $resql = $this->db->query($sql);
651 if ($resql) {
652 return 1;
653 } else {
654 $this->error = $this->db->lasterror();
655 return -1;
656 }
657 }
658
666 public function resetTargetErrorStatus($user, $id)
667 {
668 // phpcs:enable
669 global $langs;
670
671 $sql = "SELECT email, statut FROM ".MAIN_DB_PREFIX."mailing_cibles";
672 $sql .= " WHERE fk_mailing = ".((int) $this->id);
673 $sql .= " AND rowid = ".((int) $id);
674 $resql = $this->db->query($sql);
675 if ($resql) {
676 $nb = $this->db->num_rows($resql);
677 $obj = $this->db->fetch_object($resql);
678 if ($obj->statut != -1) {
679 $langs->load("errors");
680 $this->error = $langs->trans('ErrorIsNotInError', $obj->email);
681 return 0;
682 }
683 } else {
684 $this->error = $this->db->lasterror();
685 }
686
687 $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
688 $sql .= " SET statut = 0";
689 $sql .= " WHERE fk_mailing = ".((int) $this->id);
690 $sql .= " AND rowid = ".((int) $id);
691 $sql .= " AND statut = -1";
692
693 dol_syslog("Mailing::reset_targets_status", LOG_DEBUG);
694 $resql = $this->db->query($sql);
695 if ($resql) {
696 return 1;
697 } else {
698 $this->error = $this->db->lasterror();
699 return -1;
700 }
701 }
702
709 public function countNbOfTargets($mode)
710 {
711 $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
712 $sql .= " WHERE fk_mailing = ".((int) $this->id);
713 if ($mode == 'alreadysent') {
714 $sql .= " AND statut <> 0";
715 } elseif ($mode == 'alreadysentok') {
716 $sql .= " AND statut > 0";
717 } elseif ($mode == 'alreadysentko') {
718 $sql .= " AND statut = -1";
719 } else {
720 $this->error = 'BadValueForParameterMode';
721 return -2;
722 }
723
724 $resql = $this->db->query($sql);
725 if ($resql) {
726 $obj = $this->db->fetch_object($resql);
727 if ($obj) {
728 return $obj->nb;
729 }
730 } else {
731 $this->error = $this->db->lasterror();
732 return -1;
733 }
734 return 0;
735 }
736
743 public function refreshNbOfTargets()
744 {
745 $sql = "SELECT COUNT(rowid) as nb";
746 $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles";
747 $sql .= " WHERE fk_mailing = ".((int) $this->id);
748
749 $resql = $this->db->query($sql);
750 if ($resql) {
751 $obj = $this->db->fetch_object($resql);
752 if ($obj) {
753 $nbforupdate = $obj->nb;
754
755 $sql = 'UPDATE '.MAIN_DB_PREFIX.'mailing SET nbemail = '.((int) $nbforupdate);
756 $sql .= ' WHERE rowid = '.((int) $this->id);
757
758 $resqlupdate = $this->db->query($sql);
759 if (! $resqlupdate) {
760 $this->error = $this->db->lasterror();
761 return -1;
762 } else {
763 $this->nbemail = (int) $nbforupdate;
764 }
765 }
766 } else {
767 $this->error = $this->db->lasterror();
768 return -1;
769 }
770
771 return 1;
772 }
773
780 public function getTooltipContentArray($params)
781 {
782 global $langs;
783
784 //$nofetch = !empty($params['nofetch']);
785 $langs->load('mails');
786
787 $datas = array();
788 $datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ShowEMailing").'</u>';
789 if (isset($this->status)) {
790 $datas['picto'] .= ' '.$this->getLibStatut(5);
791 }
792 $datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
793 if (isset($this->title)) {
794 $datas['title'] = '<br><b>'.$langs->trans('MailTitle').':</b> '.$this->title;
795 }
796 if (isset($this->sujet)) {
797 $datas['subject'] = '<br><b>'.$langs->trans('MailTopic').':</b> '.$this->sujet;
798 }
799
800 return $datas;
801 }
802
813 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
814 {
815 global $conf, $langs, $hookmanager;
816
817 if (!empty($conf->dol_no_mouse_hover)) {
818 $notooltip = 1; // Force disable tooltips
819 }
820
821 $result = '';
822 $params = [
823 'id' => $this->id,
824 'objecttype' => $this->element,
825 'option' => $option,
826 'nofetch' => 1,
827 ];
828 $classfortooltip = 'classfortooltip';
829 $dataparams = '';
830 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
831 $classfortooltip = 'classforajaxtooltip';
832 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
833 $label = '';
834 } else {
835 $label = implode($this->getTooltipContentArray($params));
836 }
837
838 $url = DOL_URL_ROOT.'/comm/mailing/card.php?id='.$this->id;
839
840 if ($option != 'nolink') {
841 // Add param to save lastsearch_values or not
842 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
843 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
844 $add_save_lastsearch_values = 1;
845 }
846 if ($add_save_lastsearch_values) {
847 $url .= '&save_lastsearch_values=1';
848 }
849 }
850
851 $linkclose = '';
852 if (empty($notooltip)) {
853 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
854 $label = $langs->trans("ShowEMailing");
855 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
856 }
857 $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
858 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
859 } else {
860 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
861 }
862
863 $linkstart = '<a href="'.$url.'"';
864 $linkstart .= $linkclose.'>';
865 $linkend = '</a>';
866
867 $result .= $linkstart;
868 if ($withpicto) {
869 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
870 }
871 if ($withpicto != 2) {
872 $result .= $this->ref;
873 }
874 $result .= $linkend;
875 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
876
877 global $action;
878 $hookmanager->initHooks(array('emailingdao'));
879 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
880 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
881 if ($reshook > 0) {
882 $result = $hookmanager->resPrint;
883 } else {
884 $result .= $hookmanager->resPrint;
885 }
886
887 return $result;
888 }
889
896 public function getLibStatut($mode = 0)
897 {
898 return $this->LibStatut($this->status, $mode);
899 }
900
901 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
909 public function LibStatut($status, $mode = 0)
910 {
911 // phpcs:enable
912 global $langs;
913 $langs->load("mailing");
914
915 $labelStatus = $langs->transnoentitiesnoconv($this->labelStatus[$status]);
916 $labelStatusShort = $langs->transnoentitiesnoconv($this->labelStatus[$status]);
917
918 $statusType = 'status'.$status;
919 if ($status == 2) {
920 $statusType = 'status3';
921 }
922 if ($status == 3) {
923 $statusType = 'status6';
924 }
925
926 return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
927 }
928
929
939 public static function libStatutDest($status, $mode = 0, $desc = '')
940 {
941 global $langs;
942 $langs->load("mails");
943
944 $labelStatus = array();
945 $labelStatusShort = array();
946
947 $labelStatus[-1] = $langs->transnoentitiesnoconv('MailingStatusError');
948 $labelStatus[0] = $langs->transnoentitiesnoconv('MailingStatusNotSent');
949 $labelStatus[1] = $langs->transnoentitiesnoconv('MailingStatusSent');
950 $labelStatus[2] = $langs->transnoentitiesnoconv('MailingStatusRead');
951 $labelStatus[3] = $langs->transnoentitiesnoconv('MailingStatusNotContact');
952 $labelStatusShort[-1] = $langs->transnoentitiesnoconv('MailingStatusError');
953 $labelStatusShort[0] = $langs->transnoentitiesnoconv('MailingStatusNotSent');
954 $labelStatusShort[1] = $langs->transnoentitiesnoconv('MailingStatusSent');
955 $labelStatusShort[2] = $langs->transnoentitiesnoconv('MailingStatusRead');
956 $labelStatusShort[3] = $langs->transnoentitiesnoconv('MailingStatusNotContact');
957
958 $statusType = 'status'.$status;
959 if ($status == -1) {
960 $statusType = 'status8';
961 }
962 if ($status == 1) {
963 $statusType = 'status6';
964 }
965 if ($status == 2) {
966 $statusType = 'status4';
967 }
968
969 $param = array();
970 if ($status == -1) {
971 $param = array('badgeParams' => array('attr' => array('title' => $desc)));
972 }
973
974 return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode, '', $param);
975 }
976}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
$object ref
Definition info.php:89
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.
resetTargetErrorStatus($user, $id)
Reset status of a specific recipient in error.
LibStatut($status, $mode=0)
Return the label of a given status.
Parent class of emailing target selectors modules.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:171
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).
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79