dolibarr  20.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  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
27 
28 
32 class Mailing extends CommonObject
33 {
37  public $element = 'mailing';
38 
42  public $table_element = 'mailing';
43 
47  public $picto = 'email';
48 
52  public $messtype;
53 
57  public $title;
58 
62  public $sujet;
63 
67  public $body;
68 
72  public $evenunsubscribe;
73 
77  public $nbemail;
78 
82  public $bgcolor;
83 
87  public $bgimage;
88 
93  public $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
94 
98  public $status; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
99 
103  public $email_from;
104 
108  public $sendto;
109 
113  public $email_replyto;
114 
118  public $email_errorsto;
119 
123  public $joined_file1;
124 
128  public $joined_file2;
129 
133  public $joined_file3;
134 
138  public $joined_file4;
139 
143  public $date_creation;
144 
148  public $date_validation;
149 
153  public $date_envoi;
154 
158  public $extraparams = array();
159 
163  public $statut_dest = array();
164 
168  public $labelStatus = array();
169 
173  public $substitutionarray;
174 
178  public $substitutionarrayfortest;
179 
180  const STATUS_DRAFT = 0;
181  const STATUS_VALIDATED = 1;
182  const STATUS_SENTPARTIALY = 2;
183  const STATUS_SENTCOMPLETELY = 3;
184 
185 
191  public function __construct($db)
192  {
193  $this->db = $db;
194 
195  // List of language codes for status
196  $this->labelStatus[0] = 'MailingStatusDraft';
197  $this->labelStatus[1] = 'MailingStatusValidated';
198  $this->labelStatus[2] = 'MailingStatusSentPartialy';
199  $this->labelStatus[3] = 'MailingStatusSentCompletely';
200 
201  $this->statut_dest[0] = 'MailingStatusNotSent';
202  $this->statut_dest[1] = 'MailingStatusSent';
203  $this->statut_dest[2] = 'MailingStatusRead';
204  $this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore
205  $this->statut_dest[-1] = 'MailingStatusError';
206  }
207 
215  public function create($user, $notrigger = 0)
216  {
217  global $conf, $langs;
218 
219  // Check properties
220  if (preg_match('/^InvalidHTMLStringCantBeCleaned/', $this->body)) {
221  $this->error = 'InvalidHTMLStringCantBeCleaned';
222  return -1;
223  }
224 
225  $this->title = trim($this->title);
226  $this->email_from = trim($this->email_from);
227 
228  if (!$this->email_from) {
229  if ($this->messtype !== 'sms') {
230  $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailFrom"));
231  } else {
232  $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PhoneFrom"));
233  }
234  return -1;
235  }
236 
237  $error = 0;
238  $now = dol_now();
239 
240  $this->db->begin();
241 
242  $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing";
243  $sql .= " (date_creat, fk_user_creat, entity)";
244  $sql .= " VALUES ('".$this->db->idate($now)."', ".((int) $user->id).", ".((int) $conf->entity).")";
245 
246  if (!$this->title) {
247  $this->title = $langs->trans("NoTitle");
248  }
249 
250  dol_syslog(__METHOD__, LOG_DEBUG);
251 
252  $resql = $this->db->query($sql);
253  if ($resql) {
254  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing");
255 
256  $result = $this->update($user, 1);
257  if ($result < 0) {
258  $error++;
259  }
260 
261  if (!$error && !$notrigger) {
262  // Call trigger
263  $result = $this->call_trigger('MAILING_CREATE', $user);
264  if ($result < 0) {
265  $error++;
266  }
267  // End call triggers
268  }
269 
270  if (!$error) {
271  $this->db->commit();
272  return $this->id;
273  } else {
274  $this->db->rollback();
275  dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
276  return -2;
277  }
278  } else {
279  $this->error = $this->db->lasterror();
280  $this->db->rollback();
281  return -1;
282  }
283  }
284 
292  public function update($user, $notrigger = 0)
293  {
294  global $langs;
295 
296  // Check properties
297  if (preg_match('/^InvalidHTMLStringCantBeCleaned/', $this->body)) {
298  $this->error = 'InvalidHTMLStringCantBeCleaned';
299  return -1;
300  }
301 
302  $error = 0;
303  $this->db->begin();
304 
305  $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
306  $sql .= " SET titre = '".$this->db->escape($this->title)."'";
307  $sql .= ", messtype = '".$this->db->escape($this->messtype)."'";
308  $sql .= ", sujet = '".$this->db->escape($this->sujet)."'";
309  $sql .= ", body = '".$this->db->escape($this->body)."'";
310  $sql .= ", email_from = '".$this->db->escape($this->email_from)."'";
311  $sql .= ", email_replyto = '".$this->db->escape($this->email_replyto)."'";
312  $sql .= ", email_errorsto = '".$this->db->escape($this->email_errorsto)."'";
313  $sql .= ", bgcolor = '".($this->bgcolor ? $this->db->escape($this->bgcolor) : null)."'";
314  $sql .= ", bgimage = '".($this->bgimage ? $this->db->escape($this->bgimage) : null)."'";
315  $sql .= ", evenunsubscribe = ".((int) $this->evenunsubscribe);
316  $sql .= " WHERE rowid = ".(int) $this->id;
317 
318  dol_syslog(__METHOD__, LOG_DEBUG);
319  $resql = $this->db->query($sql);
320  if ($resql) {
321  if (!$error && !$notrigger) {
322  // Call trigger
323  $result = $this->call_trigger('MAILING_MODIFY', $user);
324  if ($result < 0) {
325  $error++;
326  }
327  // End call triggers
328  }
329 
330  if (!$error) {
331  dol_syslog(__METHOD__ . ' success');
332  $this->db->commit();
333  return 1;
334  } else {
335  $this->db->rollback();
336  dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
337  return -2;
338  }
339  } else {
340  if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
341  $this->error = $langs->trans("ErrorTitleAlreadyExists", $this->title);
342  } else {
343  $this->error = $this->db->lasterror();
344  }
345  $this->db->rollback();
346  return -1;
347  }
348  }
349 
357  public function fetch($rowid, $ref = '')
358  {
359  $sql = "SELECT m.rowid, m.messtype, m.titre as title, m.sujet, m.body, m.bgcolor, m.bgimage, m.evenunsubscribe";
360  $sql .= ", m.email_from, m.email_replyto, m.email_errorsto";
361  $sql .= ", m.statut as status, m.nbemail";
362  $sql .= ", m.fk_user_creat, m.fk_user_valid";
363  $sql .= ", m.date_creat";
364  $sql .= ", m.date_valid";
365  $sql .= ", m.date_envoi";
366  $sql .= ", m.extraparams";
367  $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
368  $sql .= " WHERE entity IN (".getEntity('mailing').")";
369  if ($ref) {
370  $sql .= " AND m.titre = '".$this->db->escape($ref)."'";
371  } else {
372  $sql .= " AND m.rowid = ".(int) $rowid;
373  }
374 
375  dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
376  $result = $this->db->query($sql);
377  if ($result) {
378  if ($this->db->num_rows($result)) {
379  $obj = $this->db->fetch_object($result);
380 
381  $this->id = $obj->rowid;
382  $this->ref = $obj->rowid;
383  $this->title = $obj->title;
384  $this->messtype = $obj->messtype;
385 
386  $this->statut = $obj->status; // deprecated
387  $this->status = $obj->status;
388 
389  $this->nbemail = $obj->nbemail;
390 
391  $this->sujet = $obj->sujet;
392  if (getDolGlobalString('FCKEDITOR_ENABLE_MAILING') && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5))) {
393  $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5);
394  } else {
395  $this->body = $obj->body;
396  }
397 
398  $this->bgcolor = $obj->bgcolor;
399  $this->bgimage = $obj->bgimage;
400  $this->evenunsubscribe = $obj->evenunsubscribe;
401 
402  $this->email_from = $obj->email_from;
403  $this->email_replyto = $obj->email_replyto;
404  $this->email_errorsto = $obj->email_errorsto;
405 
406  $this->user_creation_id = $obj->fk_user_creat;
407  $this->user_validation_id = $obj->fk_user_valid;
408 
409  $this->date_creation = $this->db->jdate($obj->date_creat);
410  $this->date_validation = $this->db->jdate($obj->date_valid);
411  $this->date_envoi = $this->db->jdate($obj->date_envoi);
412 
413  $this->extraparams = (array) json_decode($obj->extraparams, true);
414 
415  if ($this->messtype == 'sms') {
416  $this->picto = 'phone';
417  }
418 
419  return 1;
420  } else {
421  dol_syslog(get_class($this)."::fetch Erreur -1");
422  return -1;
423  }
424  } else {
425  dol_syslog(get_class($this)."::fetch Erreur -2");
426  return -2;
427  }
428  }
429 
430 
440  public function createFromClone(User $user, $fromid, $option1, $option2)
441  {
442  global $langs;
443 
444  $error = 0;
445 
446  $object = new Mailing($this->db);
447 
448  $this->db->begin();
449 
450  // Load source object
451  $object->fetch($fromid);
452  $object->id = 0;
453  $object->status = 0;
454  $object->statut = 0;
455 
456  // Clear fields
457  $object->title = $langs->trans("CopyOf").' '.$object->title.' '.dol_print_date(dol_now());
458 
459  // If no option copy content
460  if (empty($option1)) {
461  // Clear values
462  $object->nbemail = 0;
463  $object->sujet = '';
464  $object->body = '';
465  $object->bgcolor = '';
466  $object->bgimage = '';
467  $object->evenunsubscribe = 0;
468 
469  //$object->email_from = ''; // We do not reset from email because it is a mandatory value
470  $object->email_replyto = '';
471  $object->email_errorsto = '';
472 
473  $object->user_creation_id = $user->id;
474  $object->user_validation_id = null;
475 
476  $object->date_envoi = null;
477  }
478 
479  // Create clone
480  $object->context['createfromclone'] = 'createfromclone';
481  $result = $object->create($user);
482 
483  // Other options
484  if ($result < 0) {
485  $this->error = $object->error;
486  $this->errors = array_merge($this->errors, $object->errors);
487  $error++;
488  }
489 
490  if (!$error) {
491  // Clone recipient targets
492  if (!empty($option2)) {
493  require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
494 
495  $mailing_target = new MailingTargets($this->db);
496 
497  $target_array = array();
498 
499  $sql = "SELECT fk_contact,";
500  $sql .= " lastname,";
501  $sql .= " firstname,";
502  $sql .= " email,";
503  $sql .= " other,";
504  $sql .= " source_url,";
505  $sql .= " source_id ,";
506  $sql .= " source_type";
507  $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles";
508  $sql .= " WHERE fk_mailing = ".((int) $fromid);
509 
510  $result = $this->db->query($sql);
511  if ($result) {
512  if ($this->db->num_rows($result)) {
513  while ($obj = $this->db->fetch_object($result)) {
514  $target_array[] = array(
515  'fk_contact'=>$obj->fk_contact,
516  'lastname'=>$obj->lastname,
517  'firstname'=>$obj->firstname,
518  'email'=>$obj->email,
519  'other'=>$obj->other,
520  'source_url'=>$obj->source_url,
521  'source_id'=>$obj->source_id,
522  'source_type'=>$obj->source_type
523  );
524  }
525  }
526  } else {
527  $this->error = $this->db->lasterror();
528  return -1;
529  }
530 
531  $mailing_target->addTargetsToDatabase($object->id, $target_array);
532  }
533  }
534 
535  unset($object->context['createfromclone']);
536 
537  // End
538  if (!$error) {
539  $this->db->commit();
540  return $object->id;
541  } else {
542  $this->db->rollback();
543  return -1;
544  }
545  }
546 
553  public function valid($user)
554  {
555  $now = dol_now();
556 
557  $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
558  $sql .= " SET statut = 1, date_valid = '".$this->db->idate($now)."', fk_user_valid=".$user->id;
559  $sql .= " WHERE rowid = ".((int) $this->id);
560 
561  dol_syslog("Mailing::valid", LOG_DEBUG);
562  if ($this->db->query($sql)) {
563  return 1;
564  } else {
565  $this->error = $this->db->lasterror();
566  return -1;
567  }
568  }
569 
570 
578  public function delete($user, $notrigger = 0)
579  {
580  $error = 0;
581 
582  $this->db->begin();
583 
584  if (!$notrigger) {
585  $result = $this->call_trigger('MAILING_DELETE', $user);
586  if ($result < 0) {
587  $error++;
588  }
589  }
590 
591  if (!$error) {
592  $sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing";
593  $sql .= " WHERE rowid = " . ((int) $this->id);
594 
595  dol_syslog(__METHOD__, LOG_DEBUG);
596  $resql = $this->db->query($sql);
597  if ($resql) {
598  $res = $this->delete_targets();
599  if ($res <= 0) {
600  $error++;
601  }
602 
603  if (!$error) {
604  dol_syslog(__METHOD__ . ' success');
605  $this->db->commit();
606  return 1;
607  } else {
608  $this->db->rollback();
609  dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
610  return -2;
611  }
612  } else {
613  $this->db->rollback();
614  $this->error = $this->db->lasterror();
615  return -1;
616  }
617  } else {
618  $this->db->rollback();
619  return -1;
620  }
621  }
622 
623  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
629  public function delete_targets()
630  {
631  // phpcs:enable
632  $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
633  $sql .= " WHERE fk_mailing = ".((int) $this->id);
634 
635  dol_syslog("Mailing::delete_targets", LOG_DEBUG);
636  $resql = $this->db->query($sql);
637  if ($resql) {
638  $this->refreshNbOfTargets();
639 
640  return 1;
641  } else {
642  $this->error = $this->db->lasterror();
643  return 0;
644  }
645  }
646 
647 
648  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
655  public function reset_targets_status($user)
656  {
657  // phpcs:enable
658  $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
659  $sql .= " SET statut = 0";
660  $sql .= " WHERE fk_mailing = ".((int) $this->id);
661 
662  dol_syslog("Mailing::reset_targets_status", LOG_DEBUG);
663  $resql = $this->db->query($sql);
664  if ($resql) {
665  return 1;
666  } else {
667  $this->error = $this->db->lasterror();
668  return -1;
669  }
670  }
671 
672 
679  public function countNbOfTargets($mode)
680  {
681  $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
682  $sql .= " WHERE fk_mailing = ".((int) $this->id);
683  if ($mode == 'alreadysent') {
684  $sql .= " AND statut <> 0";
685  } elseif ($mode == 'alreadysentok') {
686  $sql .= " AND statut > 0";
687  } elseif ($mode == 'alreadysentko') {
688  $sql .= " AND statut = -1";
689  } else {
690  $this->error = 'BadValueForParameterMode';
691  return -2;
692  }
693 
694  $resql = $this->db->query($sql);
695  if ($resql) {
696  $obj = $this->db->fetch_object($resql);
697  if ($obj) {
698  return $obj->nb;
699  }
700  } else {
701  $this->error = $this->db->lasterror();
702  return -1;
703  }
704  return 0;
705  }
706 
713  public function refreshNbOfTargets()
714  {
715  $sql = "SELECT COUNT(rowid) as nb";
716  $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles";
717  $sql .= " WHERE fk_mailing = ".((int) $this->id);
718 
719  $resql = $this->db->query($sql);
720  if ($resql) {
721  $obj = $this->db->fetch_object($resql);
722  if ($obj) {
723  $nbforupdate = $obj->nb;
724 
725  $sql = 'UPDATE '.MAIN_DB_PREFIX.'mailing SET nbemail = '.((int) $nbforupdate);
726  $sql .= ' WHERE rowid = '.((int) $this->id);
727 
728  $resqlupdate = $this->db->query($sql);
729  if (! $resqlupdate) {
730  $this->error = $this->db->lasterror();
731  return -1;
732  } else {
733  $this->nbemail = (int) $nbforupdate;
734  }
735  }
736  } else {
737  $this->error = $this->db->lasterror();
738  return -1;
739  }
740 
741  return 1;
742  }
743 
751  public function getTooltipContentArray($params)
752  {
753  global $langs;
754 
755  //$nofetch = !empty($params['nofetch']);
756  $langs->load('mails');
757 
758  $datas = array();
759  $datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ShowEMailing").'</u>';
760  if (isset($this->status)) {
761  $datas['picto'] .= ' '.$this->getLibStatut(5);
762  }
763  $datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
764  if (isset($this->title)) {
765  $datas['title'] = '<br><b>'.$langs->trans('MailTitle').':</b> '.$this->title;
766  }
767  if (isset($this->sujet)) {
768  $datas['subject'] = '<br><b>'.$langs->trans('MailTopic').':</b> '.$this->sujet;
769  }
770 
771  return $datas;
772  }
773 
784  public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
785  {
786  global $conf, $langs, $hookmanager;
787 
788  if (!empty($conf->dol_no_mouse_hover)) {
789  $notooltip = 1; // Force disable tooltips
790  }
791 
792  $result = '';
793  $params = [
794  'id' => $this->id,
795  'objecttype' => $this->element,
796  'option' => $option,
797  'nofetch' => 1,
798  ];
799  $classfortooltip = 'classfortooltip';
800  $dataparams = '';
801  if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
802  $classfortooltip = 'classforajaxtooltip';
803  $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
804  $label = '';
805  } else {
806  $label = implode($this->getTooltipContentArray($params));
807  }
808 
809  $url = DOL_URL_ROOT.'/comm/mailing/card.php?id='.$this->id;
810 
811  if ($option != 'nolink') {
812  // Add param to save lastsearch_values or not
813  $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
814  if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
815  $add_save_lastsearch_values = 1;
816  }
817  if ($add_save_lastsearch_values) {
818  $url .= '&save_lastsearch_values=1';
819  }
820  }
821 
822  $linkclose = '';
823  if (empty($notooltip)) {
824  if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
825  $label = $langs->trans("ShowEMailing");
826  $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
827  }
828  $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
829  $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
830  } else {
831  $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
832  }
833 
834  $linkstart = '<a href="'.$url.'"';
835  $linkstart .= $linkclose.'>';
836  $linkend = '</a>';
837 
838  $result .= $linkstart;
839  if ($withpicto) {
840  $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
841  }
842  if ($withpicto != 2) {
843  $result .= $this->ref;
844  }
845  $result .= $linkend;
846  //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
847 
848  global $action;
849  $hookmanager->initHooks(array('emailingdao'));
850  $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
851  $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
852  if ($reshook > 0) {
853  $result = $hookmanager->resPrint;
854  } else {
855  $result .= $hookmanager->resPrint;
856  }
857 
858  return $result;
859  }
860 
867  public function getLibStatut($mode = 0)
868  {
869  return $this->LibStatut($this->status, $mode);
870  }
871 
872  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
880  public function LibStatut($status, $mode = 0)
881  {
882  // phpcs:enable
883  global $langs;
884  $langs->load("mailing");
885 
886  $labelStatus = $langs->transnoentitiesnoconv($this->labelStatus[$status]);
887  $labelStatusShort = $langs->transnoentitiesnoconv($this->labelStatus[$status]);
888 
889  $statusType = 'status'.$status;
890  if ($status == 2) {
891  $statusType = 'status3';
892  }
893  if ($status == 3) {
894  $statusType = 'status6';
895  }
896 
897  return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
898  }
899 
900 
910  public static function libStatutDest($status, $mode = 0, $desc = '')
911  {
912  global $langs;
913  $langs->load("mails");
914 
915  $labelStatus = array();
916  $labelStatusShort = array();
917 
918  $labelStatus[-1] = $langs->transnoentitiesnoconv('MailingStatusError');
919  $labelStatus[0] = $langs->transnoentitiesnoconv('MailingStatusNotSent');
920  $labelStatus[1] = $langs->transnoentitiesnoconv('MailingStatusSent');
921  $labelStatus[2] = $langs->transnoentitiesnoconv('MailingStatusRead');
922  $labelStatus[3] = $langs->transnoentitiesnoconv('MailingStatusNotContact');
923  $labelStatusShort[-1] = $langs->transnoentitiesnoconv('MailingStatusError');
924  $labelStatusShort[0] = $langs->transnoentitiesnoconv('MailingStatusNotSent');
925  $labelStatusShort[1] = $langs->transnoentitiesnoconv('MailingStatusSent');
926  $labelStatusShort[2] = $langs->transnoentitiesnoconv('MailingStatusRead');
927  $labelStatusShort[3] = $langs->transnoentitiesnoconv('MailingStatusNotContact');
928 
929  $statusType = 'status'.$status;
930  if ($status == -1) {
931  $statusType = 'status8';
932  }
933  if ($status == 1) {
934  $statusType = 'status6';
935  }
936  if ($status == 2) {
937  $statusType = 'status4';
938  }
939 
940  $param = array();
941  if ($status == - 1) {
942  $param = array('badgeParams'=>array('attr'=>array('title'=>$desc)));
943  }
944  return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode, '', $param);
945  }
946 }
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:604
$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.
Definition: user.class.php:50
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:744
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 dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.