dolibarr  18.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 $title;
53 
57  public $sujet;
58 
62  public $body;
63 
67  public $nbemail;
68 
72  public $bgcolor;
73 
77  public $bgimage;
78 
82  public $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
83 
87  public $email_from;
88 
92  public $sendto;
93 
97  public $email_replyto;
98 
102  public $email_errorsto;
103 
107  public $joined_file1;
108 
112  public $joined_file2;
113 
117  public $joined_file3;
118 
122  public $joined_file4;
123 
127  public $user_creation;
128 
133  public $user_creat;
134 
138  public $user_validation;
139 
144  public $user_valid;
145 
150  public $date_creat;
151 
155  public $date_creation;
156 
161  public $date_valid;
162 
166  public $date_validation;
167 
171  public $extraparams = array();
172 
176  public $statut_dest = array();
177 
181  public $statuts = array();
182 
186  public $substitutionarray;
187 
191  public $substitutionarrayfortest;
192 
193 
194  const STATUS_DRAFT = 0;
195  const STATUS_VALIDATED = 1;
196  const STATUS_SENTPARTIALY = 2;
197  const STATUS_SENTCOMPLETELY = 3;
198 
199 
205  public function __construct($db)
206  {
207  $this->db = $db;
208 
209  // List of language codes for status
210  $this->statuts[0] = 'MailingStatusDraft';
211  $this->statuts[1] = 'MailingStatusValidated';
212  $this->statuts[2] = 'MailingStatusSentPartialy';
213  $this->statuts[3] = 'MailingStatusSentCompletely';
214 
215  $this->statut_dest[-1] = 'MailingStatusError';
216  $this->statut_dest[0] = 'MailingStatusNotSent';
217  $this->statut_dest[1] = 'MailingStatusSent';
218  $this->statut_dest[2] = 'MailingStatusRead';
219  $this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore
220  }
221 
229  public function create($user, $notrigger = 0)
230  {
231  global $conf, $langs;
232 
233  // Check properties
234  if ($this->body === 'InvalidHTMLString') {
235  $this->error = 'InvalidHTMLString';
236  return -1;
237  }
238 
239  $this->title = trim($this->title);
240  $this->email_from = trim($this->email_from);
241 
242  if (!$this->email_from) {
243  $this->error = $langs->trans("ErrorMailFromRequired");
244  return -1;
245  }
246 
247  $error = 0;
248  $now = dol_now();
249  $this->db->begin();
250 
251  $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing";
252  $sql .= " (date_creat, fk_user_creat, entity)";
253  $sql .= " VALUES ('".$this->db->idate($now)."', ".((int) $user->id).", ".((int) $conf->entity).")";
254 
255  if (!$this->title) {
256  $this->title = $langs->trans("NoTitle");
257  }
258 
259  dol_syslog(__METHOD__, LOG_DEBUG);
260  $resql = $this->db->query($sql);
261  if ($resql) {
262  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing");
263 
264  $result = $this->update($user, 1);
265  if ($result < 0) {
266  $error++;
267  }
268 
269  if (!$error && !$notrigger) {
270  // Call trigger
271  $result = $this->call_trigger('MAILING_CREATE', $user);
272  if ($result < 0) {
273  $error++;
274  }
275  // End call triggers
276  }
277 
278  if (!$error) {
279  $this->db->commit();
280  return $this->id;
281  } else {
282  $this->db->rollback();
283  dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
284  return -2;
285  }
286  } else {
287  $this->error = $this->db->lasterror();
288  $this->db->rollback();
289  return -1;
290  }
291  }
292 
300  public function update($user, $notrigger = 0)
301  {
302  // Check properties
303  if ($this->body === 'InvalidHTMLString') {
304  $this->error = 'InvalidHTMLString';
305  return -1;
306  }
307 
308  $error = 0;
309  $this->db->begin();
310 
311  $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
312  $sql .= " SET titre = '".$this->db->escape($this->title)."'";
313  $sql .= ", sujet = '".$this->db->escape($this->sujet)."'";
314  $sql .= ", body = '".$this->db->escape($this->body)."'";
315  $sql .= ", email_from = '".$this->db->escape($this->email_from)."'";
316  $sql .= ", email_replyto = '".$this->db->escape($this->email_replyto)."'";
317  $sql .= ", email_errorsto = '".$this->db->escape($this->email_errorsto)."'";
318  $sql .= ", bgcolor = '".($this->bgcolor ? $this->db->escape($this->bgcolor) : null)."'";
319  $sql .= ", bgimage = '".($this->bgimage ? $this->db->escape($this->bgimage) : null)."'";
320  $sql .= " WHERE rowid = ".(int) $this->id;
321 
322  dol_syslog(__METHOD__, LOG_DEBUG);
323  $resql = $this->db->query($sql);
324  if ($resql) {
325  if (!$error && !$notrigger) {
326  // Call trigger
327  $result = $this->call_trigger('MAILING_MODIFY', $user);
328  if ($result < 0) {
329  $error++;
330  }
331  // End call triggers
332  }
333 
334  if (!$error) {
335  dol_syslog(__METHOD__ . ' success');
336  $this->db->commit();
337  return 1;
338  } else {
339  $this->db->rollback();
340  dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
341  return -2;
342  }
343  } else {
344  $this->error = $this->db->lasterror();
345  $this->db->rollback();
346  return -1;
347  }
348  }
349 
356  public function fetch($rowid)
357  {
358  global $conf;
359 
360  $sql = "SELECT m.rowid, m.titre as title, m.sujet, m.body, m.bgcolor, m.bgimage";
361  $sql .= ", m.email_from, m.email_replyto, m.email_errorsto";
362  $sql .= ", m.statut, m.nbemail";
363  $sql .= ", m.fk_user_creat, m.fk_user_valid";
364  $sql .= ", m.date_creat";
365  $sql .= ", m.date_valid";
366  $sql .= ", m.date_envoi";
367  $sql .= ", m.extraparams";
368  $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
369  $sql .= " WHERE m.rowid = ".(int) $rowid;
370 
371  dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
372  $result = $this->db->query($sql);
373  if ($result) {
374  if ($this->db->num_rows($result)) {
375  $obj = $this->db->fetch_object($result);
376 
377  $this->id = $obj->rowid;
378  $this->ref = $obj->rowid;
379  $this->statut = $obj->statut;
380  $this->nbemail = $obj->nbemail;
381  $this->title = $obj->title;
382 
383  $this->sujet = $obj->sujet;
384  if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5))) {
385  $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5);
386  } else {
387  $this->body = $obj->body;
388  }
389 
390  $this->bgcolor = $obj->bgcolor;
391  $this->bgimage = $obj->bgimage;
392 
393  $this->email_from = $obj->email_from;
394  $this->email_replyto = $obj->email_replyto;
395  $this->email_errorsto = $obj->email_errorsto;
396 
397  $this->user_creat = $obj->fk_user_creat;
398  $this->user_creation = $obj->fk_user_creat;
399  $this->user_valid = $obj->fk_user_valid;
400  $this->user_validation = $obj->fk_user_valid;
401 
402  $this->date_creat = $this->db->jdate($obj->date_creat);
403  $this->date_creation = $this->db->jdate($obj->date_creat);
404  $this->date_valid = $this->db->jdate($obj->date_valid);
405  $this->date_validation = $this->db->jdate($obj->date_valid);
406  $this->date_envoi = $this->db->jdate($obj->date_envoi);
407 
408  $this->extraparams = (array) json_decode($obj->extraparams, true);
409 
410  return 1;
411  } else {
412  dol_syslog(get_class($this)."::fetch Erreur -1");
413  return -1;
414  }
415  } else {
416  dol_syslog(get_class($this)."::fetch Erreur -2");
417  return -2;
418  }
419  }
420 
421 
431  public function createFromClone(User $user, $fromid, $option1, $option2)
432  {
433  global $langs;
434 
435  $error = 0;
436 
437  $object = new Mailing($this->db);
438 
439  $this->db->begin();
440 
441  // Load source object
442  $object->fetch($fromid);
443  $object->id = 0;
444  $object->statut = 0;
445 
446  // Clear fields
447  $object->title = $langs->trans("CopyOf").' '.$object->title.' '.dol_print_date(dol_now());
448 
449  // If no option copy content
450  if (empty($option1)) {
451  // Clear values
452  $object->nbemail = 0;
453  $object->sujet = '';
454  $object->body = '';
455  $object->bgcolor = '';
456  $object->bgimage = '';
457 
458  //$object->email_from = ''; // We do not reset from email because it is a mandatory value
459  $object->email_replyto = '';
460  $object->email_errorsto = '';
461 
462  $object->user_creat = $user->id;
463  $object->user_valid = '';
464 
465  $object->date_creat = '';
466  $object->date_valid = '';
467  $object->date_envoi = '';
468  }
469 
470  // Create clone
471  $object->context['createfromclone'] = 'createfromclone';
472  $result = $object->create($user);
473 
474  // Other options
475  if ($result < 0) {
476  $this->error = $object->error;
477  $this->errors = array_merge($this->errors, $object->errors);
478  $error++;
479  }
480 
481  if (!$error) {
482  // Clone recipient targets
483  if (!empty($option2)) {
484  require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
485 
486  $mailing_target = new MailingTargets($this->db);
487 
488  $target_array = array();
489 
490  $sql = "SELECT fk_contact,";
491  $sql .= " lastname,";
492  $sql .= " firstname,";
493  $sql .= " email,";
494  $sql .= " other,";
495  $sql .= " source_url,";
496  $sql .= " source_id ,";
497  $sql .= " source_type";
498  $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles";
499  $sql .= " WHERE fk_mailing = ".((int) $fromid);
500 
501  $result = $this->db->query($sql);
502  if ($result) {
503  if ($this->db->num_rows($result)) {
504  while ($obj = $this->db->fetch_object($result)) {
505  $target_array[] = array(
506  'fk_contact'=>$obj->fk_contact,
507  'lastname'=>$obj->lastname,
508  'firstname'=>$obj->firstname,
509  'email'=>$obj->email,
510  'other'=>$obj->other,
511  'source_url'=>$obj->source_url,
512  'source_id'=>$obj->source_id,
513  'source_type'=>$obj->source_type
514  );
515  }
516  }
517  } else {
518  $this->error = $this->db->lasterror();
519  return -1;
520  }
521 
522  $mailing_target->addTargetsToDatabase($object->id, $target_array);
523  }
524  }
525 
526  unset($object->context['createfromclone']);
527 
528  // End
529  if (!$error) {
530  $this->db->commit();
531  return $object->id;
532  } else {
533  $this->db->rollback();
534  return -1;
535  }
536  }
537 
544  public function valid($user)
545  {
546  $now = dol_now();
547 
548  $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
549  $sql .= " SET statut = 1, date_valid = '".$this->db->idate($now)."', fk_user_valid=".$user->id;
550  $sql .= " WHERE rowid = ".((int) $this->id);
551 
552  dol_syslog("Mailing::valid", LOG_DEBUG);
553  if ($this->db->query($sql)) {
554  return 1;
555  } else {
556  $this->error = $this->db->lasterror();
557  return -1;
558  }
559  }
560 
561 
569  public function delete($user, $notrigger = 0)
570  {
571  $error = 0;
572 
573  $this->db->begin();
574 
575  if (!$notrigger) {
576  $result = $this->call_trigger('MAILING_DELETE', $user);
577  if ($result < 0) {
578  $error++;
579  }
580  }
581 
582  if (!$error) {
583  $sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing";
584  $sql .= " WHERE rowid = " . ((int) $this->id);
585 
586  dol_syslog(__METHOD__, LOG_DEBUG);
587  $resql = $this->db->query($sql);
588  if ($resql) {
589  $res = $this->delete_targets();
590  if ($res <= 0) {
591  $error++;
592  }
593 
594  if (!$error) {
595  dol_syslog(__METHOD__ . ' success');
596  $this->db->commit();
597  return 1;
598  } else {
599  $this->db->rollback();
600  dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR);
601  return -2;
602  }
603  } else {
604  $this->db->rollback();
605  $this->error = $this->db->lasterror();
606  return -1;
607  }
608  } else {
609  $this->db->rollback();
610  return -1;
611  }
612  }
613 
614  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
620  public function delete_targets()
621  {
622  // phpcs:enable
623  $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
624  $sql .= " WHERE fk_mailing = ".((int) $this->id);
625 
626  dol_syslog("Mailing::delete_targets", LOG_DEBUG);
627  $resql = $this->db->query($sql);
628  if ($resql) {
629  $this->refreshNbOfTargets();
630 
631  return 1;
632  } else {
633  $this->error = $this->db->lasterror();
634  return 0;
635  }
636  }
637 
638 
639  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
646  public function reset_targets_status($user)
647  {
648  // phpcs:enable
649  $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
650  $sql .= " SET statut = 0";
651  $sql .= " WHERE fk_mailing = ".((int) $this->id);
652 
653  dol_syslog("Mailing::reset_targets_status", LOG_DEBUG);
654  $resql = $this->db->query($sql);
655  if ($resql) {
656  return 1;
657  } else {
658  $this->error = $this->db->lasterror();
659  return -1;
660  }
661  }
662 
663 
670  public function countNbOfTargets($mode)
671  {
672  $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
673  $sql .= " WHERE fk_mailing = ".((int) $this->id);
674  if ($mode == 'alreadysent') {
675  $sql .= " AND statut <> 0";
676  } elseif ($mode == 'alreadysentok') {
677  $sql .= " AND statut > 0";
678  } elseif ($mode == 'alreadysentko') {
679  $sql .= " AND statut = -1";
680  } else {
681  $this->error = 'BadValueForParameterMode';
682  return -2;
683  }
684 
685  $resql = $this->db->query($sql);
686  if ($resql) {
687  $obj = $this->db->fetch_object($resql);
688  if ($obj) {
689  return $obj->nb;
690  }
691  } else {
692  $this->error = $this->db->lasterror();
693  return -1;
694  }
695  return 0;
696  }
697 
704  public function refreshNbOfTargets()
705  {
706  $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
707  $sql .= " WHERE fk_mailing = ".((int) $this->id);
708 
709  $resql = $this->db->query($sql);
710  if ($resql) {
711  $obj = $this->db->fetch_object($resql);
712  if ($obj) {
713  $nbforupdate = $obj->nb;
714 
715  $sql = 'UPDATE '.MAIN_DB_PREFIX.'mailing SET nbemail = '.((int) $nbforupdate);
716  $sql .= ' WHERE rowid = '.((int) $this->id);
717 
718  $resqlupdate = $this->db->query($sql);
719  if (! $resqlupdate) {
720  $this->error = $this->db->lasterror();
721  return -1;
722  } else {
723  $this->nbemail = (int) $nbforupdate;
724  }
725  }
726  } else {
727  $this->error = $this->db->lasterror();
728  return -1;
729  }
730 
731  return 1;
732  }
733 
741  public function getTooltipContentArray($params)
742  {
743  global $conf, $langs;
744 
745  $nofetch = !empty($params['nofetch']);
746  $langs->load('mails');
747 
748  $datas = array();
749  $datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ShowEMailing").'</u>';
750  if (isset($this->statut)) {
751  $datas['picto'] .= ' '.$this->getLibStatut(5);
752  }
753  $datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
754  if (isset($this->title)) {
755  $datas['title'] .= '<br><b>'.$langs->trans('MailTitle').':</b> '.$this->title;
756  }
757  if (isset($this->sujet)) {
758  $datas['subject'] .= '<br><b>'.$langs->trans('MailTopic').':</b> '.$this->sujet;
759  }
760 
761  return $datas;
762  }
763 
774  public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
775  {
776  global $db, $conf, $langs, $hookmanager;
777  global $dolibarr_main_authentication, $dolibarr_main_demo;
778  global $menumanager;
779 
780  if (!empty($conf->dol_no_mouse_hover)) {
781  $notooltip = 1; // Force disable tooltips
782  }
783 
784  $result = '';
785  $params = [
786  'id' => $this->id,
787  'objecttype' => $this->element,
788  'option' => $option,
789  'nofetch' => 1,
790  ];
791  $classfortooltip = 'classfortooltip';
792  $dataparams = '';
793  if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
794  $classfortooltip = 'classforajaxtooltip';
795  $dataparams = ' data-params='.json_encode($params);
796  // $label = $langs->trans('Loading');
797  }
798  $label = implode($this->getTooltipContentArray($params));
799 
800  $url = DOL_URL_ROOT.'/comm/mailing/card.php?id='.$this->id;
801 
802  if ($option != 'nolink') {
803  // Add param to save lastsearch_values or not
804  $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
805  if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
806  $add_save_lastsearch_values = 1;
807  }
808  if ($add_save_lastsearch_values) {
809  $url .= '&save_lastsearch_values=1';
810  }
811  }
812 
813  $linkclose = '';
814  if (empty($notooltip)) {
815  if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
816  $label = $langs->trans("ShowEMailing");
817  $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
818  }
819  $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"';
820  $linkclose .= ' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
821  } else {
822  $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
823  }
824 
825  $linkstart = '<a href="'.$url.'"';
826  $linkstart .= $linkclose.'>';
827  $linkend = '</a>';
828 
829  $result .= $linkstart;
830  if ($withpicto) {
831  $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);
832  }
833  if ($withpicto != 2) {
834  $result .= $this->ref;
835  }
836  $result .= $linkend;
837  //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
838 
839  global $action;
840  $hookmanager->initHooks(array('emailingdao'));
841  $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
842  $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
843  if ($reshook > 0) {
844  $result = $hookmanager->resPrint;
845  } else {
846  $result .= $hookmanager->resPrint;
847  }
848 
849  return $result;
850  }
851 
858  public function getLibStatut($mode = 0)
859  {
860  return $this->LibStatut($this->statut, $mode);
861  }
862 
863  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
871  public function LibStatut($status, $mode = 0)
872  {
873  // phpcs:enable
874  global $langs;
875  $langs->load("mailing");
876 
877  $labelStatus = $langs->transnoentitiesnoconv($this->statuts[$status]);
878  $labelStatusShort = $langs->transnoentitiesnoconv($this->statuts[$status]);
879 
880  $statusType = 'status'.$status;
881  if ($status == 2) {
882  $statusType = 'status3';
883  }
884  if ($status == 3) {
885  $statusType = 'status6';
886  }
887 
888  return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
889  }
890 
891 
901  public static function libStatutDest($status, $mode = 0, $desc = '')
902  {
903  global $langs;
904  $langs->load("mails");
905 
906  $labelStatus = array();
907  $labelStatusShort = array();
908 
909  $labelStatus[-1] = $langs->transnoentitiesnoconv('MailingStatusError');
910  $labelStatus[0] = $langs->transnoentitiesnoconv('MailingStatusNotSent');
911  $labelStatus[1] = $langs->transnoentitiesnoconv('MailingStatusSent');
912  $labelStatus[2] = $langs->transnoentitiesnoconv('MailingStatusRead');
913  $labelStatus[3] = $langs->transnoentitiesnoconv('MailingStatusNotContact');
914  $labelStatusShort[-1] = $langs->transnoentitiesnoconv('MailingStatusError');
915  $labelStatusShort[0] = $langs->transnoentitiesnoconv('MailingStatusNotSent');
916  $labelStatusShort[1] = $langs->transnoentitiesnoconv('MailingStatusSent');
917  $labelStatusShort[2] = $langs->transnoentitiesnoconv('MailingStatusRead');
918  $labelStatusShort[3] = $langs->transnoentitiesnoconv('MailingStatusNotContact');
919 
920  $statusType = 'status'.$status;
921  if ($status == -1) {
922  $statusType = 'status8';
923  }
924  if ($status == 1) {
925  $statusType = 'status6';
926  }
927  if ($status == 2) {
928  $statusType = 'status4';
929  }
930 
931  $param = array();
932  if ($status == - 1) {
933  $param = array('badgeParams'=>array('attr'=>array('title'=>$desc)));
934  }
935  return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode, '', $param);
936  }
937 }
db
$conf db
API class for accounts.
Definition: inc.php:41
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1504
Mailing\update
update($user, $notrigger=0)
Update emailing record.
Definition: mailing.class.php:300
$sql
if(isModEnabled('facture') &&!empty($user->rights->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') &&!empty($user->rights->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:745
Mailing\delete_targets
delete_targets()
Delete targets emailing.
Definition: mailing.class.php:620
MailingTargets
Parent class of emailing target selectors modules.
Definition: modules_mailings.php:32
CommonObject
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Definition: commonobject.class.php:45
Mailing\countNbOfTargets
countNbOfTargets($mode)
Count number of target with status.
Definition: mailing.class.php:670
Mailing\LibStatut
LibStatut($status, $mode=0)
Return the label of a given status.
Definition: mailing.class.php:871
Mailing\getTooltipContentArray
getTooltipContentArray($params)
getTooltipContentArray
Definition: mailing.class.php:741
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2566
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:4025
Mailing\valid
valid($user)
Validate emailing.
Definition: mailing.class.php:544
Mailing
Class to manage emailings module.
Definition: mailing.class.php:32
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1639
Mailing\refreshNbOfTargets
refreshNbOfTargets()
Refresh denormalized value ->nbemail into emailing record Note: There is also the method update_nb in...
Definition: mailing.class.php:704
Mailing\getNomUrl
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
Definition: mailing.class.php:774
Mailing\reset_targets_status
reset_targets_status($user)
Change status of each recipient.
Definition: mailing.class.php:646
ref
$object ref
Definition: info.php:78
Mailing\create
create($user, $notrigger=0)
Create an EMailing.
Definition: mailing.class.php:229
User
Class to manage Dolibarr users.
Definition: user.class.php:44
Mailing\fetch
fetch($rowid)
Get object from database.
Definition: mailing.class.php:356
dol_html_entity_decode
dol_html_entity_decode($a, $b, $c='UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
Definition: functions.lib.php:7390
Mailing\__construct
__construct($db)
Constructor.
Definition: mailing.class.php:205
Mailing\libStatutDest
static libStatutDest($status, $mode=0, $desc='')
Return the label of a given status of a recipient TODO Add class mailin_target.class....
Definition: mailing.class.php:901
Mailing\getLibStatut
getLibStatut($mode=0)
Return label of status of emailing (draft, validated, ...)
Definition: mailing.class.php:858
Mailing\createFromClone
createFromClone(User $user, $fromid, $option1, $option2)
Load an object from its id and create a new one in database.
Definition: mailing.class.php:431
dolGetStatus
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
Definition: functions.lib.php:10767
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4361
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2947
CommonObject\call_trigger
call_trigger($triggerName, $user)
Call trigger based on this instance.
Definition: commonobject.class.php:5864
dol_textishtml
dol_textishtml($msg, $option=0)
Return if a text is a html content.
Definition: functions.lib.php:7523
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:96