26 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
52 public $errors = array();
69 public $arrayofnotifsupported = array(
74 'PROPAL_CLOSE_SIGNED',
76 'FICHINTER_ADD_CONTACT',
77 'ORDER_SUPPLIER_VALIDATE',
78 'ORDER_SUPPLIER_APPROVE',
79 'ORDER_SUPPLIER_REFUSE',
81 'EXPENSE_REPORT_VALIDATE',
82 'EXPENSE_REPORT_APPROVE',
111 $langs->load(
"mails");
117 if (is_array($listofnotiftodo)) {
118 $nb = count($listofnotiftodo);
121 $texte =
img_object($langs->trans(
"Notifications"),
'email').
' '.$langs->trans(
"ErrorFailedToGetListOfNotificationsToSend");
122 } elseif ($nb == 0) {
123 $texte =
img_object($langs->trans(
"Notifications"),
'email').
' '.$langs->trans(
"NoNotificationsWillBeSent");
124 } elseif ($nb == 1) {
125 $texte =
img_object($langs->trans(
"Notifications"),
'email').
' '.$langs->trans(
"ANotificationsWillBeSent");
126 } elseif ($nb >= 2) {
127 $texte =
img_object($langs->trans(
"Notifications"),
'email').
' '.$langs->trans(
"SomeNotificationsWillBeSent", $nb);
130 if (is_array($listofnotiftodo)) {
132 foreach ($listofnotiftodo as $val) {
138 if ($val[
'isemailvalid']) {
139 $texte .= $val[
'email'];
141 $texte .= $val[
'emaildesc'];
163 public function getNotificationsArray($notifcode, $socid = 0, $object = null, $userid = 0, $scope = array(
'thirdparty',
'user',
'global'))
170 $valueforthreshold = 0;
171 if (is_object($object)) {
172 $valueforthreshold = $object->total_ht;
177 if (is_numeric($notifcode)) {
178 $sqlnotifcode =
" AND n.fk_action = ".$notifcode;
180 $sqlnotifcode =
" AND a.code = '".$this->db->escape($notifcode).
"'";
185 if ($socid >= 0 && in_array(
'thirdparty', $scope)) {
186 $sql =
"SELECT a.code, c.email, c.rowid";
187 $sql .=
" FROM ".MAIN_DB_PREFIX.
"notify_def as n,";
188 $sql .=
" ".MAIN_DB_PREFIX.
"socpeople as c,";
189 $sql .=
" ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
190 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
191 $sql .=
" WHERE n.fk_contact = c.rowid";
192 $sql .=
" AND a.rowid = n.fk_action";
193 $sql .=
" AND n.fk_soc = s.rowid";
194 $sql .= $sqlnotifcode;
195 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
197 $sql .=
" AND s.rowid = ".$socid;
200 dol_syslog(__METHOD__.
" ".$notifcode.
", ".$socid.
"", LOG_DEBUG);
207 $obj = $this->
db->fetch_object(
$resql);
209 $newval2 = trim($obj->email);
211 if (empty($resarray[$newval2])) {
212 $resarray[$newval2] = array(
'type'=>
'tocontact',
'code'=>trim($obj->code),
'emaildesc'=>
'Contact id '.$obj->rowid,
'email'=>$newval2,
'contactid'=>$obj->rowid,
'isemailvalid'=>$isvalid);
219 $this->error = $this->
db->lasterror();
225 if ($userid >= 0 && in_array(
'user', $scope)) {
226 $sql =
"SELECT a.code, c.email, c.rowid";
227 $sql .=
" FROM ".MAIN_DB_PREFIX.
"notify_def as n,";
228 $sql .=
" ".MAIN_DB_PREFIX.
"user as c,";
229 $sql .=
" ".MAIN_DB_PREFIX.
"c_action_trigger as a";
230 $sql .=
" WHERE n.fk_user = c.rowid";
231 $sql .=
" AND a.rowid = n.fk_action";
232 $sql .= $sqlnotifcode;
233 $sql .=
" AND c.entity IN (".getEntity(
'user').
")";
235 $sql .=
" AND c.rowid = ".$userid;
238 dol_syslog(__METHOD__.
" ".$notifcode.
", ".$socid.
"", LOG_DEBUG);
245 $obj = $this->
db->fetch_object(
$resql);
247 $newval2 = trim($obj->email);
249 if (empty($resarray[$newval2])) {
250 $resarray[$newval2] = array(
'type'=>
'touser',
'code'=>trim($obj->code),
'emaildesc'=>
'User id '.$obj->rowid,
'email'=>$newval2,
'userid'=>$obj->rowid,
'isemailvalid'=>$isvalid);
257 $this->error = $this->
db->lasterror();
263 if (in_array(
'global', $scope)) {
265 foreach ($conf->global as $key => $val) {
267 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.
'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
271 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
276 $threshold = (
float) $reg[1];
277 if ($valueforthreshold < $threshold) {
281 $tmpemail = explode(
',', $val);
282 foreach ($tmpemail as $key2 => $val2) {
283 $newval2 = trim($val2);
284 if ($newval2 ==
'__SUPERVISOREMAIL__') {
285 if ($user->fk_user > 0) {
286 $tmpuser =
new User($this->
db);
287 $tmpuser->fetch($user->fk_user);
288 if ($tmpuser->email) {
289 $newval2 = trim($tmpuser->email);
299 if (empty($resarray[$newval2])) {
300 $resarray[$newval2] = array(
'type'=>
'tofixedemail',
'code'=>trim($key),
'emaildesc'=>trim($val2),
'email'=>$newval2,
'isemailvalid'=>$isvalid);
327 public function send($notifcode, $object, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array())
329 global $user, $conf, $langs, $mysoc;
331 global $dolibarr_main_url_root;
334 if (!in_array($notifcode, $this->arrayofnotifsupported)) {
338 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
339 if (!is_object($hookmanager)) {
340 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
343 $hookmanager->initHooks(array(
'notification'));
345 dol_syslog(get_class($this).
"::send notifcode=".$notifcode.
", object=".$object->id);
347 $langs->load(
"other");
350 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
351 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
355 $application =
'Dolibarr';
356 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
357 $application = $conf->global->MAIN_APPLICATION_TITLE;
359 $replyto = $conf->notification->email_from;
365 $oldref = (empty($object->oldref) ? $object->ref : $object->oldref);
366 $newref = (empty($object->newref) ? $object->ref : $object->newref);
371 if (!empty($object->socid) && $object->socid > 0) {
372 $sql .=
"SELECT 'tocontactid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,";
373 $sql .=
" a.rowid as adid, a.label, a.code, n.rowid, n.type";
374 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c,";
375 $sql .=
" ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
376 $sql .=
" ".MAIN_DB_PREFIX.
"notify_def as n,";
377 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
378 $sql .=
" WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
379 $sql .=
" AND n.fk_soc = s.rowid";
380 $sql .=
" AND c.statut = 1";
381 if (is_numeric($notifcode)) {
382 $sql .=
" AND n.fk_action = ".$notifcode;
384 $sql .=
" AND a.code = '".$this->db->escape($notifcode).
"'";
386 $sql .=
" AND s.rowid = ".$object->socid;
392 $sql .=
"SELECT 'touserid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.lang as default_lang,";
393 $sql .=
" a.rowid as adid, a.label, a.code, n.rowid, n.type";
394 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as c,";
395 $sql .=
" ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
396 $sql .=
" ".MAIN_DB_PREFIX.
"notify_def as n";
397 $sql .=
" WHERE n.fk_user = c.rowid AND a.rowid = n.fk_action";
398 $sql .=
" AND c.statut = 1";
399 if (is_numeric($notifcode)) {
400 $sql .=
" AND n.fk_action = ".$notifcode;
402 $sql .=
" AND a.code = '".$this->db->escape($notifcode).
"'";
405 $result = $this->
db->query($sql);
407 $num = $this->
db->num_rows($result);
409 if (!empty($object->fk_project)) {
410 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
412 $proj->fetch($object->fk_project);
413 $projtitle =
'('.$proj->title.
')';
418 while ($i < $num && !$error) {
419 $obj = $this->
db->fetch_object($result);
422 $notifcodedefid = $obj->adid;
424 if ($obj->type_target ==
'tocontactid') {
425 $trackid =
'con'.$obj->id;
427 if ($obj->type_target ==
'touserid') {
428 $trackid =
'use'.$obj->id;
433 $outputlangs = $langs;
434 if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) {
436 $outputlangs->setDefaultLang($obj->default_lang);
437 $outputlangs->loadLangs(array(
"main",
"other"));
440 $subject =
'['.$mysoc->name.
'] '.$outputlangs->transnoentitiesnoconv(
"DolibarrNotification").($projtitle ?
' '.$projtitle :
'');
442 switch ($notifcode) {
443 case 'BILL_VALIDATE':
444 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.$object->id.
'">'.$newref.
'</a>';
445 $dir_output = $conf->facture->dir_output;
446 $object_type =
'facture';
447 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInvoiceValidated", $link);
450 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.$object->id.
'">'.$newref.
'</a>';
451 $dir_output = $conf->facture->dir_output;
452 $object_type =
'facture';
453 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInvoicePayed", $link);
455 case 'ORDER_VALIDATE':
456 $link =
'<a href="'.$urlwithroot.
'/commande/card.php?id='.$object->id.
'">'.$newref.
'</a>';
457 $dir_output = $conf->commande->dir_output;
458 $object_type =
'order';
459 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextOrderValidated", $link);
461 case 'PROPAL_VALIDATE':
462 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.$object->id.
'">'.$newref.
'</a>';
463 $dir_output = $conf->propal->multidir_output[$object->entity];
464 $object_type =
'propal';
465 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextProposalValidated", $link);
467 case 'PROPAL_CLOSE_SIGNED':
468 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.$object->id.
'">'.$newref.
'</a>';
469 $dir_output = $conf->propal->multidir_output[$object->entity];
470 $object_type =
'propal';
471 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextProposalClosedSigned", $link);
473 case 'FICHINTER_ADD_CONTACT':
474 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.$object->id.
'">'.$newref.
'</a>';
475 $dir_output = $conf->ficheinter->dir_output;
476 $object_type =
'ficheinter';
477 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInterventionAddedContact", $link);
479 case 'FICHINTER_VALIDATE':
480 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.$object->id.
'">'.$newref.
'</a>';
481 $dir_output = $conf->ficheinter->dir_output;
482 $object_type =
'ficheinter';
483 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInterventionValidated", $link);
485 case 'ORDER_SUPPLIER_VALIDATE':
486 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.$object->id.
'">'.$newref.
'</a>';
487 $dir_output = $conf->fournisseur->commande->dir_output;
488 $object_type =
'order_supplier';
489 $mesg = $outputlangs->transnoentitiesnoconv(
"Hello").
",\n\n";
490 $mesg .= $outputlangs->transnoentitiesnoconv(
"EMailTextOrderValidatedBy", $link, $user->getFullName($outputlangs));
491 $mesg .=
"\n\n".$outputlangs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
493 case 'ORDER_SUPPLIER_APPROVE':
494 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.$object->id.
'">'.$newref.
'</a>';
495 $dir_output = $conf->fournisseur->commande->dir_output;
496 $object_type =
'order_supplier';
497 $mesg = $outputlangs->transnoentitiesnoconv(
"Hello").
",\n\n";
498 $mesg .= $outputlangs->transnoentitiesnoconv(
"EMailTextOrderApprovedBy", $link, $user->getFullName($outputlangs));
499 $mesg .=
"\n\n".$outputlangs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
501 case 'ORDER_SUPPLIER_REFUSE':
502 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.$object->id.
'">'.$newref.
'</a>';
503 $dir_output = $conf->fournisseur->commande->dir_output;
504 $object_type =
'order_supplier';
505 $mesg = $outputlangs->transnoentitiesnoconv(
"Hello").
",\n\n";
506 $mesg .= $outputlangs->transnoentitiesnoconv(
"EMailTextOrderRefusedBy", $link, $user->getFullName($outputlangs));
507 $mesg .=
"\n\n".$outputlangs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
509 case 'SHIPPING_VALIDATE':
510 $link =
'<a href="'.$urlwithroot.
'/expedition/card.php?id='.$object->id.
'">'.$newref.
'</a>';
511 $dir_output = $conf->expedition->dir_output.
'/sending/';
512 $object_type =
'expedition';
513 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextExpeditionValidated", $link);
515 case 'EXPENSE_REPORT_VALIDATE':
516 $link =
'<a href="'.$urlwithroot.
'/expensereport/card.php?id='.$object->id.
'">'.$newref.
'</a>';
517 $dir_output = $conf->expensereport->dir_output;
518 $object_type =
'expensereport';
519 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextExpenseReportValidated", $link);
521 case 'EXPENSE_REPORT_APPROVE':
522 $link =
'<a href="'.$urlwithroot.
'/expensereport/card.php?id='.$object->id.
'">'.$newref.
'</a>';
523 $dir_output = $conf->expensereport->dir_output;
524 $object_type =
'expensereport';
525 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextExpenseReportApproved", $link);
527 case 'HOLIDAY_VALIDATE':
528 $link =
'<a href="'.$urlwithroot.
'/holiday/card.php?id='.$object->id.
'">'.$newref.
'</a>';
529 $dir_output = $conf->holiday->dir_output;
530 $object_type =
'holiday';
531 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextHolidayValidated", $link);
533 case 'HOLIDAY_APPROVE':
534 $link =
'<a href="'.$urlwithroot.
'/holiday/card.php?id='.$object->id.
'">'.$newref.
'</a>';
535 $dir_output = $conf->holiday->dir_output;
536 $object_type =
'holiday';
537 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextHolidayApproved", $link);
541 $pdf_path = $dir_output.
"/".$ref.
"/".$ref.
".pdf";
546 $filepdf = $pdf_path;
549 $message = $outputlangs->transnoentities(
"YouReceiveMailBecauseOfNotification", $application, $mysoc->name).
"\n";
550 $message .= $outputlangs->transnoentities(
"YouReceiveMailBecauseOfNotification2", $application, $mysoc->name).
"\n";
554 $parameters = array(
'notifcode'=>$notifcode,
'sendto'=>$sendto,
'replyto'=>$replyto,
'file'=>$filename_list,
'mimefile'=>$mimetype_list,
'filename'=>$mimefilename_list);
555 if (!isset($action)) {
559 $reshook = $hookmanager->executeHooks(
'formatNotificationMessage', $parameters, $object, $action);
560 if (empty($reshook)) {
561 if (!empty($hookmanager->resArray[
'subject'])) {
562 $subject .= $hookmanager->resArray[
'subject'];
564 if (!empty($hookmanager->resArray[
'message'])) {
565 $message .= $hookmanager->resArray[
'message'];
588 if ($mailfile->sendfile()) {
589 if ($obj->type_target ==
'touserid') {
590 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)";
591 $sql .=
" VALUES ('".$this->db->idate(
dol_now()).
"', ".$notifcodedefid.
", ".($object->socid ? $object->socid :
'null').
", ".$obj->cid.
", '".$obj->type.
"', '".$object_type.
"', '".$obj->type_target.
"', ".$object->id.
", '".$this->db->escape($obj->email).
"')";
593 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)";
594 $sql .=
" VALUES ('".$this->db->idate(
dol_now()).
"', ".$notifcodedefid.
", ".($object->socid ? $object->socid :
'null').
", ".$obj->cid.
", '".$obj->type.
"', '".$object_type.
"', '".$obj->type_target.
"', ".$object->id.
", '".$this->db->escape($obj->email).
"')";
596 if (!$this->
db->query($sql)) {
601 $this->errors[] = $mailfile->error;
604 dol_syslog(
"No notification sent for ".$sendto.
" because email is empty");
609 dol_syslog(
"No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".(empty($object->socid) ?
'' : $object->socid));
613 $this->errors[] = $this->
db->lasterror();
614 dol_syslog(
"Failed to get list of notification to send ".$this->
db->lasterror(), LOG_ERR);
620 foreach ($conf->global as $key => $val) {
622 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.
'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
626 $threshold = (
float) $reg[1];
627 if (!empty($object->total_ht) && $object->total_ht <= $threshold) {
628 dol_syslog(
"A notification is requested for notifcode = ".$notifcode.
" but amount = ".$object->total_ht.
" so lower than threshold = ".$threshold.
". We discard this notification");
632 $param =
'NOTIFICATION_FIXEDEMAIL_'.$notifcode.
'_THRESHOLD_HIGHER_'.$reg[1];
634 $sendto = $conf->global->$param;
635 $notifcodedefid =
dol_getIdFromCode($this->
db, $notifcode,
'c_action_trigger',
'code',
'rowid');
636 if ($notifcodedefid <= 0) {
645 $subject =
'['.$mysoc->name.
'] '.$langs->transnoentitiesnoconv(
"DolibarrNotification").($projtitle ?
' '.$projtitle :
'');
647 switch ($notifcode) {
648 case 'BILL_VALIDATE':
649 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.$object->id.
'">'.$newref.
'</a>';
650 $dir_output = $conf->facture->dir_output;
651 $object_type =
'facture';
652 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInvoiceValidated", $link);
655 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.$object->id.
'">'.$newref.
'</a>';
656 $dir_output = $conf->facture->dir_output;
657 $object_type =
'facture';
658 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInvoicePayed", $link);
660 case 'ORDER_VALIDATE':
661 $link =
'<a href="'.$urlwithroot.
'/commande/card.php?id='.$object->id.
'">'.$newref.
'</a>';
662 $dir_output = $conf->commande->dir_output;
663 $object_type =
'order';
664 $mesg = $langs->transnoentitiesnoconv(
"EMailTextOrderValidated", $link);
666 case 'PROPAL_VALIDATE':
667 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.$object->id.
'">'.$newref.
'</a>';
668 $dir_output = $conf->propal->multidir_output[$object->entity];
669 $object_type =
'propal';
670 $mesg = $langs->transnoentitiesnoconv(
"EMailTextProposalValidated", $link);
672 case 'PROPAL_CLOSE_SIGNED':
673 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.$object->id.
'">'.$newref.
'</a>';
674 $dir_output = $conf->propal->multidir_output[$object->entity];
675 $object_type =
'propal';
676 $mesg = $langs->transnoentitiesnoconv(
"EMailTextProposalClosedSigned", $link);
678 case 'FICHINTER_ADD_CONTACT':
679 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.$object->id.
'">'.$newref.
'</a>';
680 $dir_output = $conf->ficheinter->dir_output;
681 $object_type =
'ficheinter';
682 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInterventionAddedContact", $link);
684 case 'FICHINTER_VALIDATE':
685 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.$object->id.
'">'.$newref.
'</a>';
686 $dir_output = $conf->facture->dir_output;
687 $object_type =
'ficheinter';
688 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInterventionValidated", $link);
690 case 'ORDER_SUPPLIER_VALIDATE':
691 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.$object->id.
'">'.$newref.
'</a>';
692 $dir_output = $conf->fournisseur->commande->dir_output;
693 $object_type =
'order_supplier';
694 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
695 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextOrderValidatedBy", $link, $user->getFullName($langs));
696 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
698 case 'ORDER_SUPPLIER_APPROVE':
699 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.$object->id.
'">'.$newref.
'</a>';
700 $dir_output = $conf->fournisseur->commande->dir_output;
701 $object_type =
'order_supplier';
702 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
703 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextOrderApprovedBy", $link, $user->getFullName($langs));
704 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
706 case 'ORDER_SUPPLIER_APPROVE2':
707 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.$object->id.
'">'.$newref.
'</a>';
708 $dir_output = $conf->fournisseur->commande->dir_output;
709 $object_type =
'order_supplier';
710 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
711 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextOrderApprovedBy", $link, $user->getFullName($langs));
712 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
714 case 'ORDER_SUPPLIER_REFUSE':
715 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.$object->id.
'">'.$newref.
'</a>';
716 $dir_output = $conf->fournisseur->dir_output.
'/commande/';
717 $object_type =
'order_supplier';
718 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
719 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextOrderRefusedBy", $link, $user->getFullName($langs));
720 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
722 case 'SHIPPING_VALIDATE':
723 $link =
'<a href="'.$urlwithroot.
'/expedition/card.php?id='.$object->id.
'">'.$newref.
'</a>';
724 $dir_output = $conf->expedition->dir_output.
'/sending/';
725 $object_type =
'order_supplier';
726 $mesg = $langs->transnoentitiesnoconv(
"EMailTextExpeditionValidated", $link);
728 case 'EXPENSE_REPORT_VALIDATE':
729 $link =
'<a href="'.$urlwithroot.
'/expensereport/card.php?id='.$object->id.
'">'.$newref.
'</a>';
730 $dir_output = $conf->expensereport->dir_output;
731 $object_type =
'expensereport';
732 $mesg = $langs->transnoentitiesnoconv(
"EMailTextExpenseReportValidated", $link);
734 case 'EXPENSE_REPORT_APPROVE':
735 $link =
'<a href="'.$urlwithroot.
'/expensereport/card.php?id='.$object->id.
'">'.$newref.
'</a>';
736 $dir_output = $conf->expensereport->dir_output;
737 $object_type =
'expensereport';
738 $mesg = $langs->transnoentitiesnoconv(
"EMailTextExpenseReportApproved", $link);
740 case 'HOLIDAY_VALIDATE':
741 $link =
'<a href="'.$urlwithroot.
'/holiday/card.php?id='.$object->id.
'">'.$newref.
'</a>';
742 $dir_output = $conf->holiday->dir_output;
743 $object_type =
'holiday';
744 $mesg = $langs->transnoentitiesnoconv(
"EMailTextHolidayValidated", $link);
746 case 'HOLIDAY_APPROVE':
747 $link =
'<a href="'.$urlwithroot.
'/holiday/card.php?id='.$object->id.
'">'.$newref.
'</a>';
748 $dir_output = $conf->holiday->dir_output;
749 $object_type =
'holiday';
750 $mesg = $langs->transnoentitiesnoconv(
"EMailTextHolidayApproved", $link);
754 $pdf_path = $dir_output.
"/".$ref.
"/".$ref.
".pdf";
759 $filepdf = $pdf_path;
762 $message .= $langs->transnoentities(
"YouReceiveMailBecauseOfNotification2", $application, $mysoc->name).
"\n";
766 $message = nl2br($message);
769 if (preg_match(
'/__SUPERVISOREMAIL__/', $sendto)) {
771 if ($user->fk_user > 0) {
772 $supervisoruser =
new User($this->
db);
773 $supervisoruser->fetch($user->fk_user);
774 if ($supervisoruser->email) {
775 $newval = trim(
dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).
' <'.$supervisoruser->email.
'>');
778 dol_syslog(
"Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval);
779 $sendto = preg_replace(
'/__SUPERVISOREMAIL__/', $newval, $sendto);
780 $sendto = preg_replace(
'/,\s*,/',
',', $sendto);
781 $sendto = preg_replace(
'/^[\s,]+/',
'', $sendto);
782 $sendto = preg_replace(
'/[\s,]+$/',
'', $sendto);
786 $parameters = array(
'notifcode'=>$notifcode,
'sendto'=>$sendto,
'replyto'=>$replyto,
'file'=>$filename_list,
'mimefile'=>$mimetype_list,
'filename'=>$mimefilename_list);
787 $reshook = $hookmanager->executeHooks(
'formatNotificationMessage', $parameters, $object, $action);
788 if (empty($reshook)) {
789 if (!empty($hookmanager->resArray[
'subject'])) {
790 $subject .= $hookmanager->resArray[
'subject'];
792 if (!empty($hookmanager->resArray[
'message'])) {
793 $message .= $hookmanager->resArray[
'message'];
815 if ($mailfile->sendfile()) {
816 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)";
817 $sql .=
" VALUES ('".$this->db->idate(
dol_now()).
"', ".$notifcodedefid.
", ".($object->socid ? $object->socid :
'null').
", null, 'email', 'tofixedemail', '".$object_type.
"', ".$object->id.
", '".$this->db->escape($conf->global->$param).
"')";
818 if (!$this->
db->query($sql)) {
823 $this->errors[] = $mailfile->error;
Class to manage notifications.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
getNotificationsArray($notifcode, $socid=0, $object=null, $userid=0, $scope=array('thirdparty', 'user', 'global'))
Return number of notifications activated for action code (and third party)
confirmMessage($action, $socid, $object)
Return message that say how many notification (and to which email) will occurs on requested event...
send($notifcode, $object, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array())
Check if notification are active for couple action/company.
$conf db
API class for accounts.
Class to manage projects.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto); $mailfile->sendfile();.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_is_file($pathoffile)
Return if path is a file.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
div float
Buy price without taxes.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
__construct($db)
Constructor.
isValidEmail($address, $acceptsupervisorkey=0)
Return true if email syntax is ok.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.