dolibarr  19.0.0-dev
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 $title;
53 
57  public $sujet;
58 
62  public $body;
63 
67  public $evenunsubscribe;
68 
72  public $nbemail;
73 
77  public $bgcolor;
78 
82  public $bgimage;
83 
87  public $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
88 
92  public $email_from;
93 
97  public $sendto;
98 
102  public $email_replyto;
103 
107  public $email_errorsto;
108 
112  public $joined_file1;
113 
117  public $joined_file2;
118 
122  public $joined_file3;
123 
127  public $joined_file4;
128 
132  public $user_creation;
133 
138  public $user_creat;
139 
143  public $user_validation;
144 
149  public $user_valid;
150 
155  public $date_creat;
156 
160  public $date_creation;
161 
166  public $date_valid;
167 
171  public $date_validation;
172 
176  public $extraparams = array();
177 
181  public $statut_dest = array();
182 
186  public $statuts = array();
187 
191  public $substitutionarray;
192 
196  public $substitutionarrayfortest;
197 
198  const STATUS_DRAFT = 0;
199  const STATUS_VALIDATED = 1;
200  const STATUS_SENTPARTIALY = 2;
201  const STATUS_SENTCOMPLETELY = 3;
202 
203 
209  public function __construct($db)
210  {
211  global $langs;
212 
213  $this->db = $db;
214 
215  // List of language codes for status
216  $this->statuts[0] = 'MailingStatusDraft';
217  $this->statuts[1] = 'MailingStatusValidated';
218  $this->statuts[2] = 'MailingStatusSentPartialy';
219  $this->statuts[3] = 'MailingStatusSentCompletely';
220 
221  $this->statut_dest[-1] = 'MailingStatusError';
222  $this->statut_dest[0] = 'MailingStatusNotSent';
223  $this->statut_dest[1] = 'MailingStatusSent';
224  $this->statut_dest[2] = 'MailingStatusRead';
225  $this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore
226  }
227 
235  public function create($user, $notrigger = 0)
236  {
237  global $conf, $langs;
238 
239  // Check properties
240  if ($this->body === 'InvalidHTMLString') {
241  $this->error = 'InvalidHTMLString';
242  return -1;
243  }
244 
245  $this->title = trim($this->title);
246  $this->email_from = trim($this->email_from);
247 
248  if (!$this->email_from) {
249  $this->error = $langs->trans("ErrorMailFromRequired");
250  return -1;
251  }
252 
253  $error = 0;
254  $now = dol_now();
255  $this->db->begin();
256 
257  $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing";
258  $sql .= " (date_creat, fk_user_creat, entity)";
259  $sql .= " VALUES ('".$this->db->idate($now)."', ".((int) $user->id).", ".((int) $conf->entity).")";
260 
261  if (!$this->title) {
262  $this->title = $langs->trans("NoTitle");
263  }
264 
265  dol_syslog(__METHOD__, LOG_DEBUG);
266  $resql = $this->db->query($sql);
267  if ($resql) {
268  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing");
269 
270  $result = $this->update($user, 1);
271  if ($result < 0) {
272  $error++;
273  }
274 
275  if (!$error && !$notrigger) {
276  // Call trigger
277  $result = $this->call_trigger('MAILING_CREATE', $user);
278  if ($result < 0) {
279  $error++;
280  }
281  // End call triggers
282  }
283 
284  if (!$error) {
285  $this->db->commit();
286  return $this->id;
287  } else {
288  $this->db->rollback();
289  dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
290  return -2;
291  }
292  } else {
293  $this->error = $this->db->lasterror();
294  $this->db->rollback();
295  return -1;
296  }
297  }
298 
306  public function update($user, $notrigger = 0)
307  {
308  // Check properties
309  if ($this->body === 'InvalidHTMLString') {
310  $this->error = 'InvalidHTMLString';
311  return -1;
312  }
313 
314  $error = 0;
315  $this->db->begin();
316 
317  $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
318  $sql .= " SET titre = '".$this->db->escape($this->title)."'";
319  $sql .= ", sujet = '".$this->db->escape($this->sujet)."'";
320  $sql .= ", body = '".$this->db->escape($this->body)."'";
321  $sql .= ", email_from = '".$this->db->escape($this->email_from)."'";
322  $sql .= ", email_replyto = '".$this->db->escape($this->email_replyto)."'";
323  $sql .= ", email_errorsto = '".$this->db->escape($this->email_errorsto)."'";
324  $sql .= ", bgcolor = '".($this->bgcolor ? $this->db->escape($this->bgcolor) : null)."'";
325  $sql .= ", bgimage = '".($this->bgimage ? $this->db->escape($this->bgimage) : null)."'";
326  $sql .= ", evenunsubscribe = ".((int) $this->evenunsubscribe);
327  $sql .= " WHERE rowid = ".(int) $this->id;
328 
329  dol_syslog(__METHOD__, LOG_DEBUG);
330  $resql = $this->db->query($sql);
331  if ($resql) {
332  if (!$error && !$notrigger) {
333  // Call trigger
334  $result = $this->call_trigger('MAILING_MODIFY', $user);
335  if ($result < 0) {
336  $error++;
337  }
338  // End call triggers
339  }
340 
341  if (!$error) {
342  dol_syslog(__METHOD__ . ' success');
343  $this->db->commit();
344  return 1;
345  } else {
346  $this->db->rollback();
347  dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
348  return -2;
349  }
350  } else {
351  $this->error = $this->db->lasterror();
352  $this->db->rollback();
353  return -1;
354  }
355  }
356 
364  public function fetch($rowid, $ref = '')
365  {
366  global $conf;
367 
368  $sql = "SELECT m.rowid, m.titre as title, m.sujet, m.body, m.bgcolor, m.bgimage, m.evenunsubscribe";
369  $sql .= ", m.email_from, m.email_replyto, m.email_errorsto";
370  $sql .= ", m.statut, m.nbemail";
371  $sql .= ", m.fk_user_creat, m.fk_user_valid";
372  $sql .= ", m.date_creat";
373  $sql .= ", m.date_valid";
374  $sql .= ", m.date_envoi";
375  $sql .= ", m.extraparams";
376  $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
377  $sql .= " WHERE entity IN (".getEntity('mailing').")";
378  if ($ref) {
379  $sql .= " AND m.titre = '".$this->db->escape($ref)."'";
380  } else {
381  $sql .= " AND m.rowid = ".(int) $rowid;
382  }
383 
384  dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
385  $result = $this->db->query($sql);
386  if ($result) {
387  if ($this->db->num_rows($result)) {
388  $obj = $this->db->fetch_object($result);
389 
390  $this->id = $obj->rowid;
391  $this->ref = $obj->rowid;
392  $this->statut = $obj->statut;
393  $this->nbemail = $obj->nbemail;
394  $this->title = $obj->title;
395 
396  $this->sujet = $obj->sujet;
397  if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5))) {
398  $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5);
399  } else {
400  $this->body = $obj->body;
401  }
402 
403  $this->bgcolor = $obj->bgcolor;
404  $this->bgimage = $obj->bgimage;
405  $this->evenunsubscribe = $obj->evenunsubscribe;
406 
407  $this->email_from = $obj->email_from;
408  $this->email_replyto = $obj->email_replyto;
409  $this->email_errorsto = $obj->email_errorsto;
410 
411  $this->user_creat = $obj->fk_user_creat;
412  $this->user_creation = $obj->fk_user_creat;
413  $this->user_valid = $obj->fk_user_valid;
414  $this->user_validation = $obj->fk_user_valid;
415 
416  $this->date_creat = $this->db->jdate($obj->date_creat);
417  $this->date_creation = $this->db->jdate($obj->date_creat);
418  $this->date_valid = $this->db->jdate($obj->date_valid);
419  $this->date_validation = $this->db->jdate($obj->date_valid);
420  $this->date_envoi = $this->db->jdate($obj->date_envoi);
421 
422  $this->extraparams = (array) json_decode($obj->extraparams, true);
423 
424  return 1;
425  } else {
426  dol_syslog(get_class($this)."::fetch Erreur -1");
427  return -1;
428  }
429  } else {
430  dol_syslog(get_class($this)."::fetch Erreur -2");
431  return -2;
432  }
433  }
434 
435 
445  public function createFromClone(User $user, $fromid, $option1, $option2)
446  {
447  global $langs;
448 
449  $error = 0;
450 
451  $object = new Mailing($this->db);
452 
453  $this->db->begin();
454 
455  // Load source object
456  $object->fetch($fromid);
457  $object->id = 0;
458  $object->statut = 0;
459 
460  // Clear fields
461  $object->title = $langs->trans("CopyOf").' '.$object->title.' '.dol_print_date(dol_now());
462 
463  // If no option copy content
464  if (empty($option1)) {
465  // Clear values
466  $object->nbemail = 0;
467  $object->sujet = '';
468  $object->body = '';
469  $object->bgcolor = '';
470  $object->bgimage = '';
471  $object->evenunsubscribe = 0;
472 
473  //$object->email_from = ''; // We do not reset from email because it is a mandatory value
474  $object->email_replyto = '';
475  $object->email_errorsto = '';
476 
477  $object->user_creat = $user->id;
478  $object->user_valid = '';
479 
480  $object->date_creat = '';
481  $object->date_valid = '';
482  $object->date_envoi = '';
483  }
484 
485  // Create clone
486  $object->context['createfromclone'] = 'createfromclone';
487  $result = $object->create($user);
488 
489  // Other options
490  if ($result < 0) {
491  $this->error = $object->error;
492  $this->errors = array_merge($this->errors, $object->errors);
493  $error++;
494  }
495 
496  if (!$error) {
497  // Clone recipient targets
498  if (!empty($option2)) {
499  require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
500 
501  $mailing_target = new MailingTargets($this->db);
502 
503  $target_array = array();
504 
505  $sql = "SELECT fk_contact,";
506  $sql .= " lastname,";
507  $sql .= " firstname,";
508  $sql .= " email,";
509  $sql .= " other,";
510  $sql .= " source_url,";
511  $sql .= " source_id ,";
512  $sql .= " source_type";
513  $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles";
514  $sql .= " WHERE fk_mailing = ".((int) $fromid);
515 
516  $result = $this->db->query($sql);
517  if ($result) {
518  if ($this->db->num_rows($result)) {
519  while ($obj = $this->db->fetch_object($result)) {
520  $target_array[] = array(
521  'fk_contact'=>$obj->fk_contact,
522  'lastname'=>$obj->lastname,
523  'firstname'=>$obj->firstname,
524  'email'=>$obj->email,
525  'other'=>$obj->other,
526  'source_url'=>$obj->source_url,
527  'source_id'=>$obj->source_id,
528  'source_type'=>$obj->source_type
529  );
530  }
531  }
532  } else {
533  $this->error = $this->db->lasterror();
534  return -1;
535  }
536 
537  $mailing_target->addTargetsToDatabase($object->id, $target_array);
538  }
539  }
540 
541  unset($object->context['createfromclone']);
542 
543  // End
544  if (!$error) {
545  $this->db->commit();
546  return $object->id;
547  } else {
548  $this->db->rollback();
549  return -1;
550  }
551  }
552 
559  public function valid($user)
560  {
561  $now = dol_now();
562 
563  $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
564  $sql .= " SET statut = 1, date_valid = '".$this->db->idate($now)."', fk_user_valid=".$user->id;
565  $sql .= " WHERE rowid = ".((int) $this->id);
566 
567  dol_syslog("Mailing::valid", LOG_DEBUG);
568  if ($this->db->query($sql)) {
569  return 1;
570  } else {
571  $this->error = $this->db->lasterror();
572  return -1;
573  }
574  }
575 
576 
584  public function delete($user, $notrigger = 0)
585  {
586  $error = 0;
587 
588  $this->db->begin();
589 
590  if (!$notrigger) {
591  $result = $this->call_trigger('MAILING_DELETE', $user);
592  if ($result < 0) {
593  $error++;
594  }
595  }
596 
597  if (!$error) {
598  $sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing";
599  $sql .= " WHERE rowid = " . ((int) $this->id);
600 
601  dol_syslog(__METHOD__, LOG_DEBUG);
602  $resql = $this->db->query($sql);
603  if ($resql) {
604  $res = $this->delete_targets();
605  if ($res <= 0) {
606  $error++;
607  }
608 
609  if (!$error) {
610  dol_syslog(__METHOD__ . ' success');
611  $this->db->commit();
612  return 1;
613  } else {
614  $this->db->rollback();
615  dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
616  return -2;
617  }
618  } else {
619  $this->db->rollback();
620  $this->error = $this->db->lasterror();
621  return -1;
622  }
623  } else {
624  $this->db->rollback();
625  return -1;
626  }
627  }
628 
629  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
635  public function delete_targets()
636  {
637  // phpcs:enable
638  $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
639  $sql .= " WHERE fk_mailing = ".((int) $this->id);
640 
641  dol_syslog("Mailing::delete_targets", LOG_DEBUG);
642  $resql = $this->db->query($sql);
643  if ($resql) {
644  $this->refreshNbOfTargets();
645 
646  return 1;
647  } else {
648  $this->error = $this->db->lasterror();
649  return 0;
650  }
651  }
652 
653 
654  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
661  public function reset_targets_status($user)
662  {
663  // phpcs:enable
664  $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
665  $sql .= " SET statut = 0";
666  $sql .= " WHERE fk_mailing = ".((int) $this->id);
667 
668  dol_syslog("Mailing::reset_targets_status", LOG_DEBUG);
669  $resql = $this->db->query($sql);
670  if ($resql) {
671  return 1;
672  } else {
673  $this->error = $this->db->lasterror();
674  return -1;
675  }
676  }
677 
678 
685  public function countNbOfTargets($mode)
686  {
687  $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
688  $sql .= " WHERE fk_mailing = ".((int) $this->id);
689  if ($mode == 'alreadysent') {
690  $sql .= " AND statut <> 0";
691  } elseif ($mode == 'alreadysentok') {
692  $sql .= " AND statut > 0";
693  } elseif ($mode == 'alreadysentko') {
694  $sql .= " AND statut = -1";
695  } else {
696  $this->error = 'BadValueForParameterMode';
697  return -2;
698  }
699 
700  $resql = $this->db->query($sql);
701  if ($resql) {
702  $obj = $this->db->fetch_object($resql);
703  if ($obj) {
704  return $obj->nb;
705  }
706  } else {
707  $this->error = $this->db->lasterror();
708  return -1;
709  }
710  return 0;
711  }
712 
719  public function refreshNbOfTargets()
720  {
721  $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
722  $sql .= " WHERE fk_mailing = ".((int) $this->id);
723 
724  $resql = $this->db->query($sql);
725  if ($resql) {
726  $obj = $this->db->fetch_object($resql);
727  if ($obj) {
728  $nbforupdate = $obj->nb;
729 
730  $sql = 'UPDATE '.MAIN_DB_PREFIX.'mailing SET nbemail = '.((int) $nbforupdate);
731  $sql .= ' WHERE rowid = '.((int) $this->id);
732 
733  $resqlupdate = $this->db->query($sql);
734  if (! $resqlupdate) {
735  $this->error = $this->db->lasterror();
736  return -1;
737  } else {
738  $this->nbemail = (int) $nbforupdate;
739  }
740  }
741  } else {
742  $this->error = $this->db->lasterror();
743  return -1;
744  }
745 
746  return 1;
747  }
748 
756  public function getTooltipContentArray($params)
757  {
758  global $conf, $langs;
759 
760  $nofetch = !empty($params['nofetch']);
761  $langs->load('mails');
762 
763  $datas = array();
764  $datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ShowEMailing").'</u>';
765  if (isset($this->statut)) {
766  $datas['picto'] .= ' '.$this->getLibStatut(5);
767  }
768  $datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
769  if (isset($this->title)) {
770  $datas['title'] .= '<br><b>'.$langs->trans('MailTitle').':</b> '.$this->title;
771  }
772  if (isset($this->sujet)) {
773  $datas['subject'] .= '<br><b>'.$langs->trans('MailTopic').':</b> '.$this->sujet;
774  }
775 
776  return $datas;
777  }
778 
789  public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
790  {
791  global $db, $conf, $langs, $hookmanager;
792  global $dolibarr_main_authentication, $dolibarr_main_demo;
793  global $menumanager;
794 
795  if (!empty($conf->dol_no_mouse_hover)) {
796  $notooltip = 1; // Force disable tooltips
797  }
798 
799  $result = '';
800  $params = [
801  'id' => $this->id,
802  'objecttype' => $this->element,
803  'option' => $option,
804  'nofetch' => 1,
805  ];
806  $classfortooltip = 'classfortooltip';
807  $dataparams = '';
808  if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
809  $classfortooltip = 'classforajaxtooltip';
810  $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
811  $label = '';
812  } else {
813  $label = implode($this->getTooltipContentArray($params));
814  }
815 
816  $url = DOL_URL_ROOT.'/comm/mailing/card.php?id='.$this->id;
817 
818  if ($option != 'nolink') {
819  // Add param to save lastsearch_values or not
820  $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
821  if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
822  $add_save_lastsearch_values = 1;
823  }
824  if ($add_save_lastsearch_values) {
825  $url .= '&save_lastsearch_values=1';
826  }
827  }
828 
829  $linkclose = '';
830  if (empty($notooltip)) {
831  if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
832  $label = $langs->trans("ShowEMailing");
833  $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
834  }
835  $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
836  $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
837  } else {
838  $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
839  }
840 
841  $linkstart = '<a href="'.$url.'"';
842  $linkstart .= $linkclose.'>';
843  $linkend = '</a>';
844 
845  $result .= $linkstart;
846  if ($withpicto) {
847  $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
848  }
849  if ($withpicto != 2) {
850  $result .= $this->ref;
851  }
852  $result .= $linkend;
853  //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
854 
855  global $action;
856  $hookmanager->initHooks(array('emailingdao'));
857  $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
858  $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
859  if ($reshook > 0) {
860  $result = $hookmanager->resPrint;
861  } else {
862  $result .= $hookmanager->resPrint;
863  }
864 
865  return $result;
866  }
867 
874  public function getLibStatut($mode = 0)
875  {
876  return $this->LibStatut($this->statut, $mode);
877  }
878 
879  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
887  public function LibStatut($status, $mode = 0)
888  {
889  // phpcs:enable
890  global $langs;
891  $langs->load("mailing");
892 
893  $labelStatus = $langs->transnoentitiesnoconv($this->statuts[$status]);
894  $labelStatusShort = $langs->transnoentitiesnoconv($this->statuts[$status]);
895 
896  $statusType = 'status'.$status;
897  if ($status == 2) {
898  $statusType = 'status3';
899  }
900  if ($status == 3) {
901  $statusType = 'status6';
902  }
903 
904  return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
905  }
906 
907 
917  public static function libStatutDest($status, $mode = 0, $desc = '')
918  {
919  global $langs;
920  $langs->load("mails");
921 
922  $labelStatus = array();
923  $labelStatusShort = array();
924 
925  $labelStatus[-1] = $langs->transnoentitiesnoconv('MailingStatusError');
926  $labelStatus[0] = $langs->transnoentitiesnoconv('MailingStatusNotSent');
927  $labelStatus[1] = $langs->transnoentitiesnoconv('MailingStatusSent');
928  $labelStatus[2] = $langs->transnoentitiesnoconv('MailingStatusRead');
929  $labelStatus[3] = $langs->transnoentitiesnoconv('MailingStatusNotContact');
930  $labelStatusShort[-1] = $langs->transnoentitiesnoconv('MailingStatusError');
931  $labelStatusShort[0] = $langs->transnoentitiesnoconv('MailingStatusNotSent');
932  $labelStatusShort[1] = $langs->transnoentitiesnoconv('MailingStatusSent');
933  $labelStatusShort[2] = $langs->transnoentitiesnoconv('MailingStatusRead');
934  $labelStatusShort[3] = $langs->transnoentitiesnoconv('MailingStatusNotContact');
935 
936  $statusType = 'status'.$status;
937  if ($status == -1) {
938  $statusType = 'status8';
939  }
940  if ($status == 1) {
941  $statusType = 'status6';
942  }
943  if ($status == 2) {
944  $statusType = 'status4';
945  }
946 
947  $param = array();
948  if ($status == - 1) {
949  $param = array('badgeParams'=>array('attr'=>array('title'=>$desc)));
950  }
951  return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode, '', $param);
952  }
953 }
$object ref
Definition: info.php:78
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.
fetch($rowid, $ref='')
Get object from database.
getTooltipContentArray($params)
getTooltipContentArray
__construct($db)
Constructor.
update($user, $notrigger=0)
Update emailing record.
create($user, $notrigger=0)
Create an EMailing.
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:48
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->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') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
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=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.