dolibarr  x.y.z
notify.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
5  * Copyright (C) 2018 Philippe Grand <philippe.grand@atoo-net.com>
6  * Copyright (C) 2021 Thibault FOUCART <support@ptibogxiv.net>
7  * Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
28 require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
29 
33 class Notify
34 {
38  public $id;
39 
43  public $db;
44 
48  public $error = '';
49 
53  public $errors = array();
54 
55  public $author;
56  public $ref;
57  public $date;
58  public $duree;
59  public $note;
60 
64  public $fk_project;
65 
66  // This codes actions are defined into table llx_notify_def
67  static public $arrayofnotifsupported = array(
68  'BILL_VALIDATE',
69  'BILL_PAYED',
70  'ORDER_CREATE',
71  'ORDER_VALIDATE',
72  'PROPAL_VALIDATE',
73  'PROPAL_CLOSE_SIGNED',
74  'PROPAL_CLOSE_SIGNED_WEB',
75  'PROPAL_CLOSE_REFUSED',
76  'PROPAL_CLOSE_REFUSED_WEB',
77  'FICHINTER_VALIDATE',
78  'FICHINTER_ADD_CONTACT',
79  'ORDER_SUPPLIER_VALIDATE',
80  'ORDER_SUPPLIER_APPROVE',
81  'ORDER_SUPPLIER_REFUSE',
82  'SHIPPING_VALIDATE',
83  'EXPENSE_REPORT_VALIDATE',
84  'EXPENSE_REPORT_APPROVE',
85  'HOLIDAY_VALIDATE',
86  'HOLIDAY_APPROVE',
87  'ACTION_CREATE'
88  );
89 
95  public function __construct($db)
96  {
97  $this->db = $db;
98  }
99 
100 
110  public function confirmMessage($action, $socid, $object)
111  {
112  global $conf, $langs;
113  $langs->load("mails");
114 
115  // Get full list of all notifications subscribed for $action, $socid and $object
116  $listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0);
117 
118  if (!empty($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER)) {
119  foreach ($listofnotiftodo as $val) {
120  if ($val['type'] == 'touser') {
121  unset($listofnotiftodo[$val['email']]);
122  //$listofnotiftodo = array_merge($listofnotiftodo);
123  }
124  }
125  }
126  if (!empty($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT)) {
127  foreach ($listofnotiftodo as $val) {
128  if ($val['type'] == 'tocontact') {
129  unset($listofnotiftodo[$val['email']]);
130  //$listofnotiftodo = array_merge($listofnotiftodo);
131  }
132  }
133  }
134  if (!empty($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX)) {
135  foreach ($listofnotiftodo as $val) {
136  if ($val['type'] == 'tofixedemail') {
137  unset($listofnotiftodo[$val['email']]);
138  //$listofnotiftodo = array_merge($listofnotiftodo);
139  }
140  }
141  }
142 
143  $texte = '';
144  $nb = -1;
145  if (is_array($listofnotiftodo)) {
146  $nb = count($listofnotiftodo);
147  }
148  if ($nb < 0) {
149  $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend");
150  } elseif ($nb == 0) {
151  $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent");
152  } elseif ($nb == 1) {
153  $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent");
154  } elseif ($nb >= 2) {
155  $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb);
156  }
157 
158  if (is_array($listofnotiftodo)) {
159  $i = 0;
160  foreach ($listofnotiftodo as $val) {
161  if ($i) {
162  $texte .= ', ';
163  } else {
164  $texte .= ' (';
165  }
166  if ($val['isemailvalid']) {
167  $texte .= $val['email'];
168  } else {
169  $texte .= $val['emaildesc'];
170  }
171  $i++;
172  }
173  if ($i) {
174  $texte .= ')';
175  }
176  }
177 
178  return $texte;
179  }
180 
191  public function getNotificationsArray($notifcode, $socid = 0, $object = null, $userid = 0, $scope = array('thirdparty', 'user', 'global'))
192  {
193  global $conf, $user;
194 
195  $error = 0;
196  $resarray = array();
197 
198  $valueforthreshold = 0;
199  if (is_object($object)) {
200  $valueforthreshold = $object->total_ht;
201  }
202 
203  $sqlnotifcode = '';
204  if ($notifcode) {
205  if (is_numeric($notifcode)) {
206  $sqlnotifcode = " AND n.fk_action = ".((int) $notifcode); // Old usage
207  } else {
208  $sqlnotifcode = " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
209  }
210  }
211 
212  if (!$error) {
213  if ($socid >= 0 && in_array('thirdparty', $scope)) {
214  $sql = "SELECT a.code, c.email, c.rowid";
215  $sql .= " FROM ".$this->db->prefix()."notify_def as n,";
216  $sql .= " ".$this->db->prefix()."socpeople as c,";
217  $sql .= " ".$this->db->prefix()."c_action_trigger as a,";
218  $sql .= " ".$this->db->prefix()."societe as s";
219  $sql .= " WHERE n.fk_contact = c.rowid";
220  $sql .= " AND a.rowid = n.fk_action";
221  $sql .= " AND n.fk_soc = s.rowid";
222  $sql .= $sqlnotifcode;
223  $sql .= " AND s.entity IN (".getEntity('societe').")";
224  if ($socid > 0) {
225  $sql .= " AND s.rowid = ".((int) $socid);
226  }
227 
228  dol_syslog(__METHOD__." ".$notifcode.", ".$socid, LOG_DEBUG);
229 
230  $resql = $this->db->query($sql);
231  if ($resql) {
232  $num = $this->db->num_rows($resql);
233  $i = 0;
234  while ($i < $num) {
235  $obj = $this->db->fetch_object($resql);
236  if ($obj) {
237  $newval2 = trim($obj->email);
238  $isvalid = isValidEmail($newval2);
239  if (empty($resarray[$newval2])) {
240  $resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
241  }
242  }
243  $i++;
244  }
245  } else {
246  $error++;
247  $this->error = $this->db->lasterror();
248  }
249  }
250  }
251 
252  if (!$error) {
253  if ($userid >= 0 && in_array('user', $scope)) {
254  $sql = "SELECT a.code, c.email, c.rowid";
255  $sql .= " FROM ".$this->db->prefix()."notify_def as n,";
256  $sql .= " ".$this->db->prefix()."user as c,";
257  $sql .= " ".$this->db->prefix()."c_action_trigger as a";
258  $sql .= " WHERE n.fk_user = c.rowid";
259  $sql .= " AND a.rowid = n.fk_action";
260  $sql .= $sqlnotifcode;
261  $sql .= " AND c.entity IN (".getEntity('user').")";
262  if ($userid > 0) {
263  $sql .= " AND c.rowid = ".((int) $userid);
264  }
265 
266  dol_syslog(__METHOD__." ".$notifcode.", ".$socid, LOG_DEBUG);
267 
268  $resql = $this->db->query($sql);
269  if ($resql) {
270  $num = $this->db->num_rows($resql);
271  $i = 0;
272  while ($i < $num) {
273  $obj = $this->db->fetch_object($resql);
274  if ($obj) {
275  $newval2 = trim($obj->email);
276  $isvalid = isValidEmail($newval2);
277  if (empty($resarray[$newval2])) {
278  $resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
279  }
280  }
281  $i++;
282  }
283  } else {
284  $error++;
285  $this->error = $this->db->lasterror();
286  }
287  }
288  }
289 
290  if (!$error) {
291  if (in_array('global', $scope)) {
292  // List of notifications enabled for fixed email
293  foreach ($conf->global as $key => $val) {
294  if ($notifcode) {
295  if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
296  continue;
297  }
298  } else {
299  if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
300  continue;
301  }
302  }
303 
304  $threshold = (float) $reg[1];
305  if ($valueforthreshold < $threshold) {
306  continue;
307  }
308 
309  $tmpemail = explode(',', $val);
310  foreach ($tmpemail as $key2 => $val2) {
311  $newval2 = trim($val2);
312  if ($newval2 == '__SUPERVISOREMAIL__') {
313  if ($user->fk_user > 0) {
314  $tmpuser = new User($this->db);
315  $tmpuser->fetch($user->fk_user);
316  if ($tmpuser->email) {
317  $newval2 = trim($tmpuser->email);
318  } else {
319  $newval2 = '';
320  }
321  } else {
322  $newval2 = '';
323  }
324  }
325  if ($newval2) {
326  $isvalid = isValidEmail($newval2, 0);
327  if (empty($resarray[$newval2])) {
328  $resarray[$newval2] = array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid);
329  }
330  }
331  }
332  }
333  }
334  }
335 
336  if ($error) {
337  return -1;
338  }
339 
340  //var_dump($resarray);
341  return $resarray;
342  }
343 
355  public function send($notifcode, $object, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array())
356  {
357  global $user, $conf, $langs, $mysoc;
358  global $hookmanager;
359  global $dolibarr_main_url_root;
360  global $action;
361 
362  if (!is_object($hookmanager)) {
363  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
364  $hookmanager = new HookManager($this->db);
365  }
366  $hookmanager->initHooks(array('notification'));
367 
368  $parameters = array('notifcode' => $notifcode);
369  $reshook = $hookmanager->executeHooks('notifsupported', $parameters, $object, $action);
370  if (empty($reshook)) {
371  if (!empty($hookmanager->resArray['arrayofnotifsupported'])) {
372  Notify::$arrayofnotifsupported = array_merge(Notify::$arrayofnotifsupported, $hookmanager->resArray['arrayofnotifsupported']);
373  }
374  }
375 
376  if (!in_array($notifcode, Notify::$arrayofnotifsupported)) {
377  return 0;
378  }
379 
380  include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
381 
382  dol_syslog(get_class($this)."::send notifcode=".$notifcode.", object=".$object->id);
383 
384  $langs->load("other");
385 
386  // Define $urlwithroot
387  $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
388  $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
389  //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
390 
391  // Define some vars
392  $application = 'Dolibarr';
393  if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
394  $application = $conf->global->MAIN_APPLICATION_TITLE;
395  }
396  $replyto = $conf->notification->email_from;
397  $object_type = '';
398  $link = '';
399  $num = 0;
400  $error = 0;
401 
402  $oldref = (empty($object->oldref) ? $object->ref : $object->oldref);
403  $newref = (empty($object->newref) ? $object->ref : $object->newref);
404 
405  $sql = '';
406 
407  // Check notification per third party
408  if (!empty($object->socid) && $object->socid > 0) {
409  $sql .= "SELECT 'tocontactid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,";
410  $sql .= " a.rowid as adid, a.label, a.code, n.rowid, n.type";
411  $sql .= " FROM ".$this->db->prefix()."socpeople as c,";
412  $sql .= " ".$this->db->prefix()."c_action_trigger as a,";
413  $sql .= " ".$this->db->prefix()."notify_def as n,";
414  $sql .= " ".$this->db->prefix()."societe as s";
415  $sql .= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
416  $sql .= " AND n.fk_soc = s.rowid";
417  $sql .= " AND c.statut = 1";
418  if (is_numeric($notifcode)) {
419  $sql .= " AND n.fk_action = ".((int) $notifcode); // Old usage
420  } else {
421  $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
422  }
423  $sql .= " AND s.rowid = ".((int) $object->socid);
424 
425  $sql .= "\nUNION\n";
426  }
427 
428  // Check notification per user
429  $sql .= "SELECT 'touserid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.lang as default_lang,";
430  $sql .= " a.rowid as adid, a.label, a.code, n.rowid, n.type";
431  $sql .= " FROM ".$this->db->prefix()."user as c,";
432  $sql .= " ".$this->db->prefix()."c_action_trigger as a,";
433  $sql .= " ".$this->db->prefix()."notify_def as n";
434  $sql .= " WHERE n.fk_user = c.rowid AND a.rowid = n.fk_action";
435  $sql .= " AND c.statut = 1";
436  if (is_numeric($notifcode)) {
437  $sql .= " AND n.fk_action = ".((int) $notifcode); // Old usage
438  } else {
439  $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
440  }
441 
442  $result = $this->db->query($sql);
443  if ($result) {
444  $num = $this->db->num_rows($result);
445  $projtitle = '';
446  if (!empty($object->fk_project)) {
447  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
448  $proj = new Project($this->db);
449  $proj->fetch($object->fk_project);
450  $projtitle = '('.$proj->title.')';
451  }
452 
453  if ($num > 0) {
454  $i = 0;
455  while ($i < $num && !$error) { // For each notification couple defined (third party/actioncode)
456  $obj = $this->db->fetch_object($result);
457 
458  $sendto = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">";
459  $notifcodedefid = $obj->adid;
460  $trackid = '';
461  if ($obj->type_target == 'tocontactid') {
462  $trackid = 'ctc'.$obj->cid;
463  }
464  if ($obj->type_target == 'touserid') {
465  $trackid = 'use'.$obj->cid;
466  }
467 
468  if (dol_strlen($obj->email)) {
469  // Set output language
470  $outputlangs = $langs;
471  if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) {
472  $outputlangs = new Translate('', $conf);
473  $outputlangs->setDefaultLang($obj->default_lang);
474  $outputlangs->loadLangs(array("main", "other"));
475  }
476 
477  $subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification").($projtitle ? ' '.$projtitle : '');
478 
479  switch ($notifcode) {
480  case 'BILL_VALIDATE':
481  $link = '<a href="'.$urlwithroot.'/compta/facture/card.php?facid='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
482  $dir_output = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice');
483  $object_type = 'facture';
484  $labeltouse = $conf->global->BILL_VALIDATE_TEMPLATE;
485  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoiceValidated", $link);
486  break;
487  case 'BILL_PAYED':
488  $link = '<a href="'.$urlwithroot.'/compta/facture/card.php?facid='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
489  $dir_output = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice');
490  $object_type = 'facture';
491  $labeltouse = $conf->global->BILL_PAYED_TEMPLATE;
492  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoicePayed", $link);
493  break;
494  case 'ORDER_VALIDATE':
495  $link = '<a href="'.$urlwithroot.'/commande/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
496  $dir_output = $conf->commande->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'commande');
497  $object_type = 'order';
498  $labeltouse = $conf->global->ORDER_VALIDATE_TEMPLATE;
499  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextOrderValidated", $link);
500  break;
501  case 'PROPAL_VALIDATE':
502  $link = '<a href="'.$urlwithroot.'/comm/propal/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
503  $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal');
504  $object_type = 'propal';
505  $labeltouse = $conf->global->PROPAL_VALIDATE_TEMPLATE;
506  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalValidated", $link);
507  break;
508  case 'PROPAL_CLOSE_REFUSED':
509  $link = '<a href="'.$urlwithroot.'/comm/propal/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
510  $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal');
511  $object_type = 'propal';
512  $labeltouse = $conf->global->PROPAL_CLOSE_REFUSED_TEMPLATE;
513  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedRefused", $link);
514  break;
515  case 'PROPAL_CLOSE_REFUSED_WEB':
516  $link = '<a href="'.$urlwithroot.'/comm/propal/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
517  $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal');
518  $object_type = 'propal';
519  $labeltouse = $conf->global->PROPAL_CLOSE_REFUSED_TEMPLATE;
520  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedRefusedWeb", $link);
521  break;
522  case 'PROPAL_CLOSE_SIGNED':
523  $link = '<a href="'.$urlwithroot.'/comm/propal/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
524  $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal');
525  $object_type = 'propal';
526  $labeltouse = $conf->global->PROPAL_CLOSE_SIGNED_TEMPLATE;
527  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $link);
528  break;
529  case 'PROPAL_CLOSE_SIGNED_WEB':
530  $link = '<a href="'.$urlwithroot.'/comm/propal/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
531  $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal');
532  $object_type = 'propal';
533  $labeltouse = $conf->global->PROPAL_CLOSE_SIGNED_TEMPLATE;
534  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $link);
535  break;
536  case 'FICHINTER_ADD_CONTACT':
537  $link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
538  $dir_output = $conf->ficheinter->dir_output;
539  $object_type = 'ficheinter';
540  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $link);
541  break;
542  case 'FICHINTER_VALIDATE':
543  $link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
544  $dir_output = $conf->ficheinter->dir_output;
545  $object_type = 'ficheinter';
546  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionValidated", $link);
547  break;
548  case 'ORDER_SUPPLIER_VALIDATE':
549  $link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
550  $dir_output = $conf->fournisseur->commande->dir_output;
551  $object_type = 'order_supplier';
552  $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n";
553  $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $link, $user->getFullName($outputlangs));
554  $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n";
555  break;
556  case 'ORDER_SUPPLIER_APPROVE':
557  $link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
558  $dir_output = $conf->fournisseur->commande->dir_output;
559  $object_type = 'order_supplier';
560  $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n";
561  $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($outputlangs));
562  $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n";
563  break;
564  case 'ORDER_SUPPLIER_REFUSE':
565  $link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
566  $dir_output = $conf->fournisseur->commande->dir_output;
567  $object_type = 'order_supplier';
568  $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n";
569  $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $link, $user->getFullName($outputlangs));
570  $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n";
571  break;
572  case 'SHIPPING_VALIDATE':
573  $link = '<a href="'.$urlwithroot.'/expedition/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
574  $dir_output = $conf->expedition->dir_output."/sending/".get_exdir(0, 0, 0, 1, $object, 'shipment');
575  $object_type = 'shipping';
576  $labeltouse = $conf->global->SHIPPING_VALIDATE_TEMPLATE;
577  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpeditionValidated", $link);
578  break;
579  case 'EXPENSE_REPORT_VALIDATE':
580  $link = '<a href="'.$urlwithroot.'/expensereport/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
581  $dir_output = $conf->expensereport->dir_output;
582  $object_type = 'expensereport';
583  $labeltouse = $conf->global->EXPENSE_REPORT_VALIDATE_TEMPLATE;
584  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpenseReportValidated", $link);
585  break;
586  case 'EXPENSE_REPORT_APPROVE':
587  $link = '<a href="'.$urlwithroot.'/expensereport/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
588  $dir_output = $conf->expensereport->dir_output;
589  $object_type = 'expensereport';
590  $labeltouse = $conf->global->EXPENSE_REPORT_APPROVE_TEMPLATE;
591  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpenseReportApproved", $link);
592  break;
593  case 'HOLIDAY_VALIDATE':
594  $link = '<a href="'.$urlwithroot.'/holiday/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
595  $dir_output = $conf->holiday->dir_output;
596  $object_type = 'holiday';
597  $labeltouse = $conf->global->HOLIDAY_VALIDATE_TEMPLATE;
598  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextHolidayValidated", $link);
599  break;
600  case 'HOLIDAY_APPROVE':
601  $link = '<a href="'.$urlwithroot.'/holiday/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
602  $dir_output = $conf->holiday->dir_output;
603  $object_type = 'holiday';
604  $labeltouse = $conf->global->HOLIDAY_APPROVE_TEMPLATE;
605  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextHolidayApproved", $link);
606  break;
607  case 'ACTION_CREATE':
608  $link = '<a href="'.$urlwithroot.'/comm/action/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
609  $dir_output = $conf->agenda->dir_output;
610  $object_type = 'action';
611  $labeltouse = $conf->global->ACTION_CREATE_TEMPLATE;
612  $mesg = $outputlangs->transnoentitiesnoconv("EMailTextActionAdded", $link);
613  break;
614  default:
615  $object_type = $object->element;
616  $dir_output = $conf->$object_type->multidir_output[$object->entity ? $object->entity : $conf->entity]."/".get_exdir(0, 0, 0, 1, $object, $object_type);
617  $template = $notifcode.'_TEMPLATE';
618  $labeltouse = $conf->global->$template;
619  $mesg = $outputlangs->transnoentitiesnoconv('Notify_'.$notifcode).' '.$newref.' '.$dir_output;
620  break;
621  }
622 
623  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
624  $formmail = new FormMail($this->db);
625  $arraydefaultmessage = null;
626 
627  if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $object_type.'_send', $user, $outputlangs, 0, 1, $labeltouse);
628  if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
629  $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
630  complete_substitutions_array($substitutionarray, $outputlangs, $object);
631  $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
632  $message = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
633  } else {
634  $message = $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name)."\n";
635  $message .= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n";
636  $message .= "\n";
637  $message .= $mesg;
638  }
639 
640  $ref = dol_sanitizeFileName($newref);
641  $pdf_path = $dir_output."/".$ref.".pdf";
642  if (!dol_is_file($pdf_path)||(is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0 && !$arraydefaultmessage->joinfiles)) {
643  // We can't add PDF as it is not generated yet.
644  $filepdf = '';
645  } else {
646  $filepdf = $pdf_path;
647  $filename_list[] = $filepdf;
648  $mimetype_list[] = mime_content_type($filepdf);
649  $mimefilename_list[] = $ref.".pdf";
650  }
651 
652  $labeltouse = !empty($labeltouse) ? $labeltouse : '';
653 
654  $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list, 'outputlangs'=>$outputlangs, 'labeltouse'=>$labeltouse);
655  if (!isset($action)) {
656  $action = '';
657  }
658 
659  $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
660  if (empty($reshook)) {
661  if (!empty($hookmanager->resArray['files'])) {
662  $filename_list = $hookmanager->resArray['files']['file'];
663  $mimetype_list = $hookmanager->resArray['files']['mimefile'];
664  $mimefilename_list = $hookmanager->resArray['files']['filename'];
665  }
666  if (!empty($hookmanager->resArray['subject'])) {
667  $subject .= $hookmanager->resArray['subject'];
668  }
669  if (!empty($hookmanager->resArray['message'])) {
670  $message .= $hookmanager->resArray['message'];
671  }
672  }
673 
674  $mailfile = new CMailFile(
675  $subject,
676  $sendto,
677  $replyto,
678  $message,
679  $filename_list,
680  $mimetype_list,
681  $mimefilename_list,
682  '',
683  '',
684  0,
685  -1,
686  '',
687  '',
688  $trackid,
689  '',
690  'notification'
691  );
692 
693  if ($mailfile->sendfile()) {
694  if ($obj->type_target == 'touserid') {
695  $sql = "INSERT INTO ".$this->db->prefix()."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)";
696  $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".((int) $notifcodedefid).", ".($object->socid > 0 ? ((int) $object->socid) : 'null').", ".((int) $obj->cid).", '".$this->db->escape($obj->type)."', '".$this->db->escape($object_type)."', '".$this->db->escape($obj->type_target)."', ".((int) $object->id).", '".$this->db->escape($obj->email)."')";
697  } else {
698  $sql = "INSERT INTO ".$this->db->prefix()."notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)";
699  $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".((int) $notifcodedefid).", ".($object->socid > 0 ? ((int) $object->socid) : 'null').", ".((int) $obj->cid).", '".$this->db->escape($obj->type)."', '".$this->db->escape($object_type)."', '".$this->db->escape($obj->type_target)."', ".((int) $object->id).", '".$this->db->escape($obj->email)."')";
700  }
701  if (!$this->db->query($sql)) {
702  dol_print_error($this->db);
703  }
704  } else {
705  $error++;
706  $this->errors[] = $mailfile->error;
707  }
708  } else {
709  dol_syslog("No notification sent for ".$sendto." because email is empty");
710  }
711  $i++;
712  }
713  } else {
714  dol_syslog("No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".(empty($object->socid) ? '' : $object->socid));
715  }
716  } else {
717  $error++;
718  $this->errors[] = $this->db->lasterror();
719  dol_syslog("Failed to get list of notification to send ".$this->db->lasterror(), LOG_ERR);
720  return -1;
721  }
722 
723  // Check notification using fixed email
724  if (!$error) {
725  foreach ($conf->global as $key => $val) {
726  $reg = array();
727  if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
728  continue;
729  }
730 
731  $threshold = (float) $reg[1];
732  if (!empty($object->total_ht) && $object->total_ht <= $threshold) {
733  dol_syslog("A notification is requested for notifcode = ".$notifcode." but amount = ".$object->total_ht." so lower than threshold = ".$threshold.". We discard this notification");
734  continue;
735  }
736 
737  $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_'.$reg[1];
738 
739  $sendto = $conf->global->$param;
740  $notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid');
741  if ($notifcodedefid <= 0) {
742  dol_print_error($this->db, 'Failed to get id from code');
743  }
744  $trackid = '';
745 
746  $object_type = '';
747  $link = '';
748  $num++;
749 
750  $subject = '['.$mysoc->name.'] '.$langs->transnoentitiesnoconv("DolibarrNotification").($projtitle ? ' '.$projtitle : '');
751 
752  switch ($notifcode) {
753  case 'BILL_VALIDATE':
754  $link = '<a href="'.$urlwithroot.'/compta/facture/card.php?facid='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
755  $dir_output = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice');
756  $object_type = 'facture';
757  $mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated", $link);
758  break;
759  case 'BILL_PAYED':
760  $link = '<a href="'.$urlwithroot.'/compta/facture/card.php?facid='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
761  $dir_output = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice');
762  $object_type = 'facture';
763  $mesg = $langs->transnoentitiesnoconv("EMailTextInvoicePayed", $link);
764  break;
765  case 'ORDER_VALIDATE':
766  $link = '<a href="'.$urlwithroot.'/commande/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
767  $dir_output = $conf->commande->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'commande');
768  $object_type = 'order';
769  $mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated", $link);
770  break;
771  case 'PROPAL_VALIDATE':
772  $link = '<a href="'.$urlwithroot.'/comm/propal/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
773  $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal');
774  $object_type = 'propal';
775  $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated", $link);
776  break;
777  case 'PROPAL_CLOSE_SIGNED':
778  $link = '<a href="'.$urlwithroot.'/comm/propal/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
779  $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal');
780  $object_type = 'propal';
781  $mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $link);
782  break;
783  case 'FICHINTER_ADD_CONTACT':
784  $link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
785  $dir_output = $conf->ficheinter->dir_output;
786  $object_type = 'ficheinter';
787  $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $link);
788  break;
789  case 'FICHINTER_VALIDATE':
790  $link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
791  $dir_output = $conf->facture->dir_output;
792  $object_type = 'ficheinter';
793  $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated", $link);
794  break;
795  case 'ORDER_SUPPLIER_VALIDATE':
796  $link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
797  $dir_output = $conf->fournisseur->commande->dir_output;
798  $object_type = 'order_supplier';
799  $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
800  $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $link, $user->getFullName($langs));
801  $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
802  break;
803  case 'ORDER_SUPPLIER_APPROVE':
804  $link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
805  $dir_output = $conf->fournisseur->commande->dir_output;
806  $object_type = 'order_supplier';
807  $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
808  $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs));
809  $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
810  break;
811  case 'ORDER_SUPPLIER_APPROVE2':
812  $link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
813  $dir_output = $conf->fournisseur->commande->dir_output;
814  $object_type = 'order_supplier';
815  $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
816  $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs));
817  $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
818  break;
819  case 'ORDER_SUPPLIER_REFUSE':
820  $link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
821  $dir_output = $conf->fournisseur->dir_output.'/commande/';
822  $object_type = 'order_supplier';
823  $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
824  $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $link, $user->getFullName($langs));
825  $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
826  break;
827  case 'SHIPPING_VALIDATE':
828  $link = '<a href="'.$urlwithroot.'/expedition/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
829  $dir_output = $conf->expedition->dir_output."/sending/".get_exdir(0, 0, 0, 1, $object, 'shipment');
830  $object_type = 'order_supplier';
831  $mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated", $link);
832  break;
833  case 'EXPENSE_REPORT_VALIDATE':
834  $link = '<a href="'.$urlwithroot.'/expensereport/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
835  $dir_output = $conf->expensereport->dir_output;
836  $object_type = 'expensereport';
837  $mesg = $langs->transnoentitiesnoconv("EMailTextExpenseReportValidated", $link);
838  break;
839  case 'EXPENSE_REPORT_APPROVE':
840  $link = '<a href="'.$urlwithroot.'/expensereport/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
841  $dir_output = $conf->expensereport->dir_output;
842  $object_type = 'expensereport';
843  $mesg = $langs->transnoentitiesnoconv("EMailTextExpenseReportApproved", $link);
844  break;
845  case 'HOLIDAY_VALIDATE':
846  $link = '<a href="'.$urlwithroot.'/holiday/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
847  $dir_output = $conf->holiday->dir_output;
848  $object_type = 'holiday';
849  $mesg = $langs->transnoentitiesnoconv("EMailTextHolidayValidated", $link);
850  break;
851  case 'HOLIDAY_APPROVE':
852  $link = '<a href="'.$urlwithroot.'/holiday/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
853  $dir_output = $conf->holiday->dir_output;
854  $object_type = 'holiday';
855  $mesg = $langs->transnoentitiesnoconv("EMailTextHolidayApproved", $link);
856  break;
857  case 'ACTION_CREATE':
858  $link = '<a href="'.$urlwithroot.'/comm/action/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
859  $dir_output = $conf->agenda->dir_output;
860  $object_type = 'action';
861  $mesg = $langs->transnoentitiesnoconv("EMailTextActionAdded", $link);
862  break;
863  default:
864  $object_type = $object->element;
865  $dir_output = $conf->$object_type->multidir_output[$object->entity ? $object->entity : $conf->entity]."/".get_exdir(0, 0, 0, 1, $object, $object_type);
866  $mesg = $langs->transnoentitiesnoconv('Notify_'.$notifcode).' '.$newref;
867  break;
868  }
869  $ref = dol_sanitizeFileName($newref);
870  $pdf_path = $dir_output."/".$ref."/".$ref.".pdf";
871  if (!dol_is_file($pdf_path)) {
872  // We can't add PDF as it is not generated yet.
873  $filepdf = '';
874  } else {
875  $filepdf = $pdf_path;
876  $filename_list[] = $pdf_path;
877  $mimetype_list[] = mime_content_type($filepdf);
878  $mimefilename_list[] = $ref.".pdf";
879  }
880 
881  $message = '';
882  $message .= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n";
883  $message .= "\n";
884  $message .= $mesg;
885 
886  $message = nl2br($message);
887 
888  // Replace keyword __SUPERVISOREMAIL__
889  if (preg_match('/__SUPERVISOREMAIL__/', $sendto)) {
890  $newval = '';
891  if ($user->fk_user > 0) {
892  $supervisoruser = new User($this->db);
893  $supervisoruser->fetch($user->fk_user);
894  if ($supervisoruser->email) {
895  $newval = trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>');
896  }
897  }
898  dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval);
899  $sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto);
900  $sendto = preg_replace('/,\s*,/', ',', $sendto); // in some case you can have $sendto like "email, __SUPERVISOREMAIL__ , otheremail" then you have "email, , othermail" and it's not valid
901  $sendto = preg_replace('/^[\s,]+/', '', $sendto); // Clean start of string
902  $sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string
903  }
904 
905  if ($sendto) {
906  $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
907  $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
908  if (empty($reshook)) {
909  if (!empty($hookmanager->resArray['files'])) {
910  $filename_list = $hookmanager->resArray['files']['file'];
911  $mimetype_list = $hookmanager->resArray['files']['mimefile'];
912  $mimefilename_list = $hookmanager->resArray['files']['filename'];
913  }
914  if (!empty($hookmanager->resArray['subject'])) {
915  $subject .= $hookmanager->resArray['subject'];
916  }
917  if (!empty($hookmanager->resArray['message'])) {
918  $message .= $hookmanager->resArray['message'];
919  }
920  }
921  $mailfile = new CMailFile(
922  $subject,
923  $sendto,
924  $replyto,
925  $message,
926  $filename_list,
927  $mimetype_list,
928  $mimefilename_list,
929  '',
930  '',
931  0,
932  1,
933  '',
934  $trackid,
935  '',
936  '',
937  'notification'
938  );
939 
940  if ($mailfile->sendfile()) {
941  $sql = "INSERT INTO ".$this->db->prefix()."notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)";
942  $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".((int) $notifcodedefid).", ".($object->socid > 0 ? ((int) $object->socid) : 'null').", null, 'email', 'tofixedemail', '".$this->db->escape($object_type)."', ".((int) $object->id).", '".$this->db->escape($conf->global->$param)."')";
943  if (!$this->db->query($sql)) {
944  dol_print_error($this->db);
945  }
946  } else {
947  $error++;
948  $this->errors[] = $mailfile->error;
949  }
950  }
951  }
952  }
953 
954  if (!$error) {
955  return $num;
956  } else {
957  return -1 * $error;
958  }
959  }
960 }
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Class to manage hooks.
Class to manage notifications.
confirmMessage($action, $socid, $object)
Return message that say how many notification (and to which email) will occurs on requested event.
getNotificationsArray($notifcode, $socid=0, $object=null, $userid=0, $scope=array('thirdparty', 'user', 'global'))
Return number of notifications activated for action code (and third party)
send($notifcode, $object, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array())
Check if notification are active for couple action/company.
__construct($db)
Constructor.
Class to manage projects.
Class to manage translations.
Class to manage Dolibarr users.
Definition: user.class.php:45
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)) $resql
Social contributions to pay.
Definition: index.php:745
dol_is_file($pathoffile)
Return if path is a file.
Definition: files.lib.php:480
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
div float
Buy price without taxes.
Definition: style.css.php:913
$conf db
API class for accounts.
Definition: inc.php:41