627 public function send($notifcode,
$object, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array())
635 if (!is_object($hookmanager)) {
636 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
639 $hookmanager->initHooks(array(
'notification'));
641 $parameters = array(
'notifcode' => $notifcode);
642 $reshook = $hookmanager->executeHooks(
'notifsupported', $parameters,
$object, $action);
643 if (empty($reshook)) {
644 if (!empty($hookmanager->resArray[
'arrayofnotifsupported'])) {
645 Notify::$arrayofnotifsupported = array_merge(Notify::$arrayofnotifsupported, $hookmanager->resArray[
'arrayofnotifsupported']);
650 if (!in_array($notifcode, Notify::$arrayofnotifsupported)) {
654 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
656 dol_syslog(get_class($this).
"::send notifcode=".$notifcode.
", object id=".
$object->id);
658 $langs->load(
"other");
662 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
666 $application = constant(
'DOL_APPLICATION_TITLE');
668 if ($applicationcustom) {
669 $application = (preg_match(
'/^\+/', $applicationcustom) ? $application :
'').$applicationcustom;
689 $sql .=
"SELECT 'tocontactid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,";
690 $sql .=
" a.rowid as adid, a.label, a.code, n.rowid, n.threshold, n.context, n.type";
691 $sql .=
" FROM ".$this->db->prefix().
"socpeople as c,";
692 $sql .=
" ".$this->db->prefix().
"c_action_trigger as a,";
693 $sql .=
" ".$this->db->prefix().
"notify_def as n,";
694 $sql .=
" ".$this->db->prefix().
"societe as s";
695 $sql .=
" WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
696 $sql .=
" AND n.fk_soc = s.rowid";
697 $sql .=
" AND c.statut = 1";
698 if (is_numeric($notifcode)) {
699 $sql .=
" AND n.fk_action = ".((int) $notifcode);
701 $sql .=
" AND a.code = '".$this->db->escape($notifcode).
"'";
704 $sql .=
" AND s.rowid = ".((int)
$object->socid);
710 $sql .=
"SELECT 'touserid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.lang as default_lang,";
711 $sql .=
" a.rowid as adid, a.label, a.code, n.rowid, n.threshold, n.context, n.type";
712 $sql .=
" FROM ".$this->db->prefix().
"user as c,";
713 $sql .=
" ".$this->db->prefix().
"c_action_trigger as a,";
714 $sql .=
" ".$this->db->prefix().
"notify_def as n";
715 $sql .=
" WHERE n.fk_user = c.rowid AND a.rowid = n.fk_action";
716 $sql .=
" AND c.statut = 1";
717 if (is_numeric($notifcode)) {
718 $sql .=
" AND n.fk_action = ".((int) $notifcode);
720 $sql .=
" AND a.code = '".$this->db->escape($notifcode).
"'";
728 $result = $this->db->query($sql);
730 $num = $this->db->num_rows($result);
733 $projtitle =
'('.$object->project->title.
')';
738 while ($i < $num && !$error) {
739 $obj = $this->db->fetch_object($result);
742 $notifcodedefid = $obj->adid;
744 if ($obj->type_target ==
'tocontactid') {
745 $trackid =
'ctc'.$obj->cid;
747 if ($obj->type_target ==
'touserid') {
748 $trackid =
'use'.$obj->cid;
753 $outputlangs = $langs;
754 if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) {
756 $outputlangs->setDefaultLang($obj->default_lang);
757 $outputlangs->loadLangs(array(
"main",
"other"));
762 $subject =
'['.$appli.
'] '.$outputlangs->transnoentitiesnoconv(
"DolibarrNotification").($projtitle ?
' '.$projtitle :
'');
764 switch ($notifcode) {
766 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
768 $object_type =
'facture';
769 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInvoiceCanceled", $link);
771 case 'BILL_VALIDATE':
772 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
774 $object_type =
'facture';
775 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInvoiceValidated", $link);
778 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
780 $object_type =
'facture';
781 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInvoicePayed", $link);
784 $link =
'<a href="'.$urlwithroot.
'/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
786 $object_type =
'order';
787 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextOrderCanceled", $link);
789 case 'ORDER_VALIDATE':
790 $link =
'<a href="'.$urlwithroot.
'/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
792 $object_type =
'order';
793 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextOrderValidated", $link);
796 $link =
'<a href="'.$urlwithroot.
'/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
798 $object_type =
'order';
800 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextOrderClose", $link);
802 case 'PROPAL_VALIDATE':
803 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
805 $object_type =
'propal';
806 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextProposalValidated", $link);
808 case 'PROPAL_CLOSE_REFUSED':
809 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
811 $object_type =
'propal';
813 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextProposalClosedRefused", $link);
814 if (!empty(
$object->context[
'closedfromonlinesignature'])) {
815 $mesg .=
' - From online page';
818 case 'PROPAL_CLOSE_SIGNED':
819 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
821 $object_type =
'propal';
822 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextProposalClosedSigned", $link);
823 if (!empty(
$object->context[
'closedfromonlinesignature'])) {
824 $mesg .=
' - From online page';
827 case 'FICHINTER_ADD_CONTACT':
828 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
829 $dir_output =
$conf->ficheinter->dir_output;
830 $object_type =
'fichinter';
831 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInterventionAddedContact", $link);
833 case 'FICHINTER_VALIDATE':
834 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
835 $dir_output =
$conf->ficheinter->dir_output;
836 $object_type =
'fichinter';
837 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInterventionValidated", $link);
839 case 'FICHINTER_MODIFY':
840 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
841 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
842 $dir_output =
$conf->ficheinter->dir_output;
843 $object_type =
'fichinter';
844 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInterventionModified", $link, $context_info);
846 case 'FICHINTER_CLOSE':
847 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
848 $dir_output =
$conf->ficheinter->dir_output;
849 $object_type =
'fichinter';
850 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInterventionClosed", $link);
852 case 'ORDER_SUPPLIER_VALIDATE':
853 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
855 $object_type =
'order_supplier';
857 $mesg = $outputlangs->transnoentitiesnoconv(
"Hello").
",\n\n";
858 $mesg .= $outputlangs->transnoentitiesnoconv(
"EMailTextSupplierOrderValidatedBy", $link, $user->getFullName($outputlangs));
859 $mesg .=
"\n\n".$outputlangs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
861 case 'ORDER_SUPPLIER_CANCEL':
862 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
864 $object_type =
'order_supplier';
865 $mesg = $outputlangs->transnoentitiesnoconv(
"Hello").
",\n\n";
866 $mesg .= $outputlangs->transnoentitiesnoconv(
"EMailTextSupplierOrderCanceledBy", $link, $user->getFullName($outputlangs));
867 $mesg .=
"\n\n".$outputlangs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
869 case 'ORDER_SUPPLIER_APPROVE':
870 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
872 $object_type =
'order_supplier';
874 $mesg = $outputlangs->transnoentitiesnoconv(
"Hello").
",\n\n";
875 $mesg .= $outputlangs->transnoentitiesnoconv(
"EMailTextSupplierOrderApprovedBy", $link, $user->getFullName($outputlangs));
876 $mesg .=
"\n\n".$outputlangs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
878 case 'ORDER_SUPPLIER_SUBMIT':
879 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
881 $object_type =
'order_supplier';
882 $mesg = $outputlangs->transnoentitiesnoconv(
"Hello").
",\n\n";
883 $mesg .= $outputlangs->transnoentitiesnoconv(
"EMailTextSupplierOrderSubmittedBy", $link, $user->getFullName($outputlangs));
884 $mesg .=
"\n\n".$outputlangs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
886 case 'ORDER_SUPPLIER_REFUSE':
887 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
889 $object_type =
'order_supplier';
891 $mesg = $outputlangs->transnoentitiesnoconv(
"Hello").
",\n\n";
892 $mesg .= $outputlangs->transnoentitiesnoconv(
"EMailTextSupplierOrderRefusedBy", $link, $user->getFullName($outputlangs));
893 $mesg .=
"\n\n".$outputlangs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
895 case 'SHIPPING_MODIFY':
896 $link =
'<a href="'.$urlwithroot.
'/expedition/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
897 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
899 $object_type =
'shipping';
900 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextExpeditionModified", $link, $context_info);
902 case 'SHIPPING_VALIDATE':
903 $link =
'<a href="'.$urlwithroot.
'/expedition/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
905 $object_type =
'shipping';
906 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextExpeditionValidated", $link);
908 case 'EXPENSE_REPORT_VALIDATE':
909 $link =
'<a href="'.$urlwithroot.
'/expensereport/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
910 $dir_output =
$conf->expensereport->dir_output;
911 $object_type =
'expensereport';
912 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextExpenseReportValidated", $link);
914 case 'EXPENSE_REPORT_APPROVE':
915 $link =
'<a href="'.$urlwithroot.
'/expensereport/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
916 $dir_output =
$conf->expensereport->dir_output;
917 $object_type =
'expensereport';
918 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextExpenseReportApproved", $link);
920 case 'HOLIDAY_VALIDATE':
921 $link =
'<a href="'.$urlwithroot.
'/holiday/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
922 $dir_output =
$conf->holiday->dir_output;
923 $object_type =
'holiday';
924 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextHolidayValidated", $link);
926 case 'HOLIDAY_APPROVE':
927 $link =
'<a href="'.$urlwithroot.
'/holiday/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
928 $dir_output =
$conf->holiday->dir_output;
929 $object_type =
'holiday';
930 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextHolidayApproved", $link);
932 case 'ACTION_CREATE':
933 $link =
'<a href="'.$urlwithroot.
'/comm/action/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
934 $dir_output =
$conf->agenda->dir_output;
935 $object_type =
'action';
936 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextActionAdded", $link);
938 case 'CONTRACT_MODIFY':
939 $link =
'<a href="'.$urlwithroot.
'/contrat/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
940 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
941 $dir_output =
$conf->contract->multidir_output;
942 $object_type =
'contract';
943 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextContractModified", $link, $context_info);
946 $object_type =
$object->element;
948 $template = $notifcode.
'_TEMPLATE';
949 $mesg = $outputlangs->transnoentitiesnoconv(
'Notify_'.$notifcode).
' '.$newref.
' '.$dir_output;
953 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
954 $formmail =
new FormMail($this->db);
955 $arraydefaultmessage =
null;
957 $template = $notifcode.
'_TEMPLATE';
959 if (!empty($labeltouse)) {
960 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $object_type, $user, $outputlangs, 0, 1, $labeltouse);
962 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
963 if (method_exists(
$object,
'fetch_thirdparty') && empty(
$object->thirdparty)) {
966 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null,
$object);
969 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
970 $message =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
972 $message = $outputlangs->transnoentities(
"YouReceiveMailBecauseOfNotification", $application,
$mysoc->name).
"\n";
973 $message .= $outputlangs->transnoentities(
"YouReceiveMailBecauseOfNotification2", $application,
$mysoc->name).
"\n";
979 $pdf_path = $dir_output.
"/".$ref.
".pdf";
980 if (!
dol_is_file($pdf_path) || (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0 && !$arraydefaultmessage->joinfiles)) {
984 $filepdf = $pdf_path;
985 $filename_list[] = $filepdf;
986 $mimetype_list[] = mime_content_type($filepdf);
987 $mimefilename_list[] = $ref.
".pdf";
990 $labeltouse = !empty($labeltouse) ? $labeltouse :
'';
995 $parameters = array(
'notifcode' => $notifcode,
'sendto' => $sendto,
'from' => $from,
'file' => $filename_list,
'mimefile' => $mimetype_list,
'filename' => $mimefilename_list,
'outputlangs' => $outputlangs,
'labeltouse' => $labeltouse);
996 if (!isset($action)) {
1000 $reshook = $hookmanager->executeHooks(
'formatNotificationMessage', $parameters,
$object, $action);
1001 if (empty($reshook)) {
1002 if (!empty($hookmanager->resArray[
'files'])) {
1003 $filename_list = $hookmanager->resArray[
'files'][
'file'];
1004 $mimetype_list = $hookmanager->resArray[
'files'][
'mimefile'];
1005 $mimefilename_list = $hookmanager->resArray[
'files'][
'filename'];
1007 if (!empty($hookmanager->resArray[
'subject'])) {
1008 $subject .= $hookmanager->resArray[
'subject'];
1010 if (!empty($hookmanager->resArray[
'message'])) {
1011 $message .= $hookmanager->resArray[
'message'];
1034 if (! empty($mailfile->error) || ! empty($mailfile->errors)) {
1035 $this->error = $mailfile->error;
1036 $this->errors = $mailfile->errors;
1040 if ($mailfile->sendfile()) {
1041 if ($obj->type_target ==
'touserid') {
1042 $sql =
"INSERT INTO ".$this->db->prefix().
"notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)";
1044 $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).
"')";
1046 $sql =
"INSERT INTO ".$this->db->prefix().
"notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)";
1048 $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).
"')";
1050 if (!$this->db->query($sql)) {
1055 $this->errors[] = $mailfile->error;
1058 dol_syslog(
"No notification sent for ".$sendto.
" because email is empty");
1064 dol_syslog(
"No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".(empty(
$object->socid) ?
'' :
$object->socid));
1068 $this->errors[] = $this->db->lasterror();
1069 dol_syslog(
"Failed to get list of notification to send ".$this->db->lasterror(), LOG_ERR);
1076 foreach (
$conf->global as $key => $val) {
1078 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.
'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
1084 $threshold = (float) $reg[1];
1085 if (!empty(
$object->total_ht) &&
$object->total_ht <= $threshold) {
1086 dol_syslog(
"A notification is requested for notifcode = ".$notifcode.
" but amount = ".
$object->total_ht.
" so lower than threshold = ".$threshold.
". We discard this notification");
1090 $notifcodedefid =
dol_getIdFromCode($this->db, $notifcode,
'c_action_trigger',
'code',
'rowid');
1091 if ($notifcodedefid <= 0) {
1102 $subject =
'['.$appli.
'] '.$langs->transnoentitiesnoconv(
"DolibarrNotification").($projtitle ?
' '.$projtitle :
'');
1104 switch ($notifcode) {
1105 case 'BILL_VALIDATE':
1106 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1108 $object_type =
'facture';
1109 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInvoiceValidated", $link);
1112 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1114 $object_type =
'facture';
1115 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInvoicePayed", $link);
1117 case 'ORDER_VALIDATE':
1118 $link =
'<a href="'.$urlwithroot.
'/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1120 $object_type =
'order';
1121 $mesg = $langs->transnoentitiesnoconv(
"EMailTextOrderValidated", $link);
1124 $link =
'<a href="'.$urlwithroot.
'/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1126 $object_type =
'order';
1127 $mesg = $langs->transnoentitiesnoconv(
"EMailTextOrderClose", $link);
1129 case 'PROPAL_VALIDATE':
1130 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1132 $object_type =
'propal';
1133 $mesg = $langs->transnoentitiesnoconv(
"EMailTextProposalValidated", $link);
1135 case 'PROPAL_CLOSE_SIGNED':
1136 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1138 $object_type =
'propal';
1139 $mesg = $langs->transnoentitiesnoconv(
"EMailTextProposalClosedSigned", $link);
1141 case 'FICHINTER_ADD_CONTACT':
1142 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1143 $dir_output =
$conf->ficheinter->dir_output;
1144 $object_type =
'fichinter';
1145 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInterventionAddedContact", $link);
1147 case 'FICHINTER_VALIDATE':
1148 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1149 $dir_output =
$conf->facture->dir_output;
1150 $object_type =
'fichinter';
1151 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInterventionValidated", $link);
1153 case 'FICHINTER_MODIFY':
1154 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1155 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
1156 $dir_output =
$conf->ficheinter->dir_output;
1157 $object_type =
'fichinter';
1158 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInterventionModified", $link, $context_info);
1160 case 'FICHINTER_CLOSE':
1161 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1162 $dir_output =
$conf->facture->dir_output;
1163 $object_type =
'fichinter';
1164 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInterventionClosed", $link);
1166 case 'ORDER_SUPPLIER_CANCEL':
1167 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1169 $object_type =
'order_supplier';
1170 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
1171 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextSupplierOrderCanceledBy", $link, $user->getFullName($langs));
1172 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1174 case 'ORDER_SUPPLIER_VALIDATE':
1175 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1177 $object_type =
'order_supplier';
1178 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
1179 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextSupplierOrderValidatedBy", $link, $user->getFullName($langs));
1180 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1182 case 'ORDER_SUPPLIER_APPROVE':
1183 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1185 $object_type =
'order_supplier';
1186 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
1187 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextSupplierOrderApprovedBy", $link, $user->getFullName($langs));
1188 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1190 case 'ORDER_SUPPLIER_SUBMIT':
1191 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1193 $object_type =
'order_supplier';
1194 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
1195 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextSupplierOrderSubmittedBy", $link, $user->getFullName($langs));
1196 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1198 case 'ORDER_SUPPLIER_REFUSE':
1199 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1201 $object_type =
'order_supplier';
1202 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
1203 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextSupplierOrderRefusedBy", $link, $user->getFullName($langs));
1204 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1206 case 'SHIPPING_MODIFY':
1207 $link =
'<a href="'.$urlwithroot.
'/expedition/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1208 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
1210 $object_type =
'order_supplier';
1211 $mesg = $langs->transnoentitiesnoconv(
"EMailTextExpeditionModified", $link, $context_info);
1213 case 'SHIPPING_VALIDATE':
1214 $link =
'<a href="'.$urlwithroot.
'/expedition/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1216 $object_type =
'order_supplier';
1217 $mesg = $langs->transnoentitiesnoconv(
"EMailTextExpeditionValidated", $link);
1219 case 'EXPENSE_REPORT_VALIDATE':
1220 $link =
'<a href="'.$urlwithroot.
'/expensereport/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1221 $dir_output =
$conf->expensereport->dir_output;
1222 $object_type =
'expensereport';
1223 $mesg = $langs->transnoentitiesnoconv(
"EMailTextExpenseReportValidated", $link);
1225 case 'EXPENSE_REPORT_APPROVE':
1226 $link =
'<a href="'.$urlwithroot.
'/expensereport/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1227 $dir_output =
$conf->expensereport->dir_output;
1228 $object_type =
'expensereport';
1229 $mesg = $langs->transnoentitiesnoconv(
"EMailTextExpenseReportApproved", $link);
1231 case 'HOLIDAY_VALIDATE':
1232 $link =
'<a href="'.$urlwithroot.
'/holiday/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1233 $dir_output =
$conf->holiday->dir_output;
1234 $object_type =
'holiday';
1235 $mesg = $langs->transnoentitiesnoconv(
"EMailTextHolidayValidated", $link);
1237 case 'HOLIDAY_APPROVE':
1238 $link =
'<a href="'.$urlwithroot.
'/holiday/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1239 $dir_output =
$conf->holiday->dir_output;
1240 $object_type =
'holiday';
1241 $mesg = $langs->transnoentitiesnoconv(
"EMailTextHolidayApproved", $link);
1243 case 'ACTION_CREATE':
1244 $link =
'<a href="'.$urlwithroot.
'/comm/action/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1245 $dir_output =
$conf->agenda->dir_output;
1246 $object_type =
'action';
1247 $mesg = $langs->transnoentitiesnoconv(
"EMailTextActionAdded", $link);
1249 case 'CONTRACT_MODIFY':
1250 $link =
'<a href="'.$urlwithroot.
'/contrat/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1251 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
1252 $dir_output =
$conf->contract->multidir_output;
1253 $object_type =
'contrat';
1254 $mesg = $langs->transnoentitiesnoconv(
"EMailTextContractModified", $link, $context_info);
1257 $object_type =
$object->element;
1259 $mesg = $langs->transnoentitiesnoconv(
'Notify_'.$notifcode).
' '.$newref;
1263 $pdf_path = $dir_output.
"/".$ref.
".pdf";
1268 $filepdf = $pdf_path;
1269 $filename_list[] = $pdf_path;
1270 $mimetype_list[] = mime_content_type($filepdf);
1271 $mimefilename_list[] = $ref.
".pdf";
1275 $outputlangs = $langs;
1280 $emailTemplate =
null;
1281 if (!empty($mailTemplateLabel)) {
1282 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1283 $formmail =
new FormMail($this->db);
1284 $emailTemplate = $formmail->getEMailTemplate($this->db, $object_type, $user, $outputlangs, 0, 1, $mailTemplateLabel);
1286 if (!empty($mailTemplateLabel) && is_object($emailTemplate) && $emailTemplate->id > 0) {
1287 if (property_exists(
$object,
'thirdparty')) {
1292 if (
$object->thirdparty instanceof
Societe &&
$object->thirdparty->default_lang &&
$object->thirdparty->default_lang != $langs->defaultlang) {
1294 $outputlangs->setDefaultLang(
$object->thirdparty->default_lang);
1295 $outputlangs->loadLangs(array(
'main',
'other'));
1299 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null,
$object);
1301 $subject =
make_substitutions($emailTemplate->topic, $substitutionarray, $outputlangs);
1302 $message =
make_substitutions($emailTemplate->content, $substitutionarray, $outputlangs);
1305 $message .= $outputlangs->transnoentities(
"YouReceiveMailBecauseOfNotification2", $application,
$mysoc->name).
"\n";
1309 $message = nl2br($message);
1316 $parameters = array(
'notifcode' => $notifcode,
'sendto' => $sendto,
'from' => $from,
'file' => $filename_list,
'mimefile' => $mimetype_list,
'filename' => $mimefilename_list,
'subject' => &$subject,
'message' => &$message);
1317 $reshook = $hookmanager->executeHooks(
'formatNotificationMessage', $parameters,
$object, $action);
1318 if (empty($reshook)) {
1319 if (!empty($hookmanager->resArray[
'files'])) {
1320 $filename_list = $hookmanager->resArray[
'files'][
'file'];
1321 $mimetype_list = $hookmanager->resArray[
'files'][
'mimefile'];
1322 $mimefilename_list = $hookmanager->resArray[
'files'][
'filename'];
1324 if (!empty($hookmanager->resArray[
'subject'])) {
1325 $subject .= $hookmanager->resArray[
'subject'];
1327 if (!empty($hookmanager->resArray[
'message'])) {
1328 $message .= $hookmanager->resArray[
'message'];
1350 if (! empty($mailfile->error) || ! empty($mailfile->errors)) {
1351 $this->error = $mailfile->error;
1352 $this->errors = $mailfile->errors;
1356 if ($mailfile->sendfile()) {
1357 $sql =
"INSERT INTO ".$this->db->prefix().
"notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)";
1359 $sql .=
" VALUES ('".$this->db->idate(
dol_now()).
"', ".((int) $notifcodedefid).
", ".((!empty(
$object->socid) &&
$object->socid > 0) ? ((
int)
$object->socid) :
'null').
", null, 'email', 'tofixedemail', '".$this->db->escape($object_type).
"', ".((int)
$object->id).
", '".$this->db->escape($sendto).
"')";
1360 if (!$this->db->query($sql)) {
1365 $this->errors[] = $mailfile->error;