633 public function send($notifcode,
$object, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array())
641 if (!is_object($hookmanager)) {
642 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
645 $hookmanager->initHooks(array(
'notification'));
647 $parameters = array(
'notifcode' => $notifcode);
648 $reshook = $hookmanager->executeHooks(
'notifsupported', $parameters,
$object, $action);
649 if (empty($reshook)) {
650 if (!empty($hookmanager->resArray[
'arrayofnotifsupported'])) {
651 Notify::$arrayofnotifsupported = array_merge(Notify::$arrayofnotifsupported, $hookmanager->resArray[
'arrayofnotifsupported']);
656 if (!in_array($notifcode, Notify::$arrayofnotifsupported)) {
660 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
662 dol_syslog(get_class($this).
"::send notifcode=".$notifcode.
", object id=".
$object->id);
664 $langs->load(
"other");
668 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
672 $application = constant(
'DOL_APPLICATION_TITLE');
674 if ($applicationcustom) {
675 $application = (preg_match(
'/^\+/', $applicationcustom) ? $application :
'').$applicationcustom;
695 $sql .=
"SELECT 'tocontactid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,";
696 $sql .=
" a.rowid as adid, a.label, a.code, n.rowid, n.threshold, n.context, n.type";
697 $sql .=
" FROM ".$this->db->prefix().
"socpeople as c,";
698 $sql .=
" ".$this->db->prefix().
"c_action_trigger as a,";
699 $sql .=
" ".$this->db->prefix().
"notify_def as n,";
700 $sql .=
" ".$this->db->prefix().
"societe as s";
701 $sql .=
" WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
702 $sql .=
" AND n.entity IN (".getEntity(
'notify_def').
")";
703 $sql .=
" AND n.fk_soc = s.rowid";
704 $sql .=
" AND c.statut = 1";
705 if (is_numeric($notifcode)) {
706 $sql .=
" AND n.fk_action = ".((int) $notifcode);
708 $sql .=
" AND a.code = '".$this->db->escape($notifcode).
"'";
711 $sql .=
" AND s.rowid = ".((int)
$object->socid);
717 $sql .=
"SELECT 'touserid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.lang as default_lang,";
718 $sql .=
" a.rowid as adid, a.label, a.code, n.rowid, n.threshold, n.context, n.type";
719 $sql .=
" FROM ".$this->db->prefix().
"user as c,";
720 $sql .=
" ".$this->db->prefix().
"c_action_trigger as a,";
721 $sql .=
" ".$this->db->prefix().
"notify_def as n";
722 $sql .=
" WHERE n.fk_user = c.rowid AND a.rowid = n.fk_action";
723 $sql .=
" AND n.entity IN (".getEntity(
'notify_def').
")";
724 $sql .=
" AND c.statut = 1";
725 if (is_numeric($notifcode)) {
726 $sql .=
" AND n.fk_action = ".((int) $notifcode);
728 $sql .=
" AND a.code = '".$this->db->escape($notifcode).
"'";
736 $result = $this->db->query($sql);
738 $num = $this->db->num_rows($result);
741 $projtitle =
'('.$object->project->title.
')';
746 while ($i < $num && !$error) {
747 $obj = $this->db->fetch_object($result);
750 $notifcodedefid = $obj->adid;
752 if ($obj->type_target ==
'tocontactid') {
753 $trackid =
'ctc'.$obj->cid;
755 if ($obj->type_target ==
'touserid') {
756 $trackid =
'use'.$obj->cid;
761 $outputlangs = $langs;
762 if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) {
764 $outputlangs->setDefaultLang($obj->default_lang);
765 $outputlangs->loadLangs(array(
"main",
"other"));
770 $subject =
'['.$appli.
'] '.$outputlangs->transnoentitiesnoconv(
"DolibarrNotification").($projtitle ?
' '.$projtitle :
'');
772 switch ($notifcode) {
774 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
776 $object_type =
'facture';
777 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInvoiceCanceled", $link);
779 case 'BILL_VALIDATE':
780 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
782 $object_type =
'facture';
783 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInvoiceValidated", $link);
786 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
788 $object_type =
'facture';
789 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInvoicePayed", $link);
792 $link =
'<a href="'.$urlwithroot.
'/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
794 $object_type =
'order';
795 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextOrderCanceled", $link);
797 case 'ORDER_VALIDATE':
798 $link =
'<a href="'.$urlwithroot.
'/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
800 $object_type =
'order';
801 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextOrderValidated", $link);
804 $link =
'<a href="'.$urlwithroot.
'/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
806 $object_type =
'order';
808 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextOrderClose", $link);
810 case 'PROPAL_VALIDATE':
811 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
813 $object_type =
'propal';
814 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextProposalValidated", $link);
816 case 'PROPAL_CLOSE_REFUSED':
817 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
819 $object_type =
'propal';
821 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextProposalClosedRefused", $link);
822 if (!empty(
$object->context[
'closedfromonlinesignature'])) {
823 $mesg .=
' - From online page';
826 case 'PROPAL_CLOSE_SIGNED':
827 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
829 $object_type =
'propal';
830 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextProposalClosedSigned", $link);
831 if (!empty(
$object->context[
'closedfromonlinesignature'])) {
832 $mesg .=
' - From online page';
835 case 'FICHINTER_ADD_CONTACT':
836 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
837 $dir_output =
$conf->ficheinter->dir_output;
838 $object_type =
'fichinter';
839 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInterventionAddedContact", $link);
841 case 'FICHINTER_VALIDATE':
842 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
843 $dir_output =
$conf->ficheinter->dir_output;
844 $object_type =
'fichinter';
845 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInterventionValidated", $link);
847 case 'FICHINTER_MODIFY':
848 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
849 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
850 $dir_output =
$conf->ficheinter->dir_output;
851 $object_type =
'fichinter';
852 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInterventionModified", $link, $context_info);
854 case 'FICHINTER_CLOSE':
855 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
856 $dir_output =
$conf->ficheinter->dir_output;
857 $object_type =
'fichinter';
858 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextInterventionClosed", $link);
860 case 'ORDER_SUPPLIER_VALIDATE':
861 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
863 $object_type =
'order_supplier';
865 $mesg = $outputlangs->transnoentitiesnoconv(
"Hello").
",\n\n";
866 $mesg .= $outputlangs->transnoentitiesnoconv(
"EMailTextSupplierOrderValidatedBy", $link, $user->getFullName($outputlangs));
867 $mesg .=
"\n\n".$outputlangs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
869 case 'ORDER_SUPPLIER_CANCEL':
870 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
872 $object_type =
'order_supplier';
873 $mesg = $outputlangs->transnoentitiesnoconv(
"Hello").
",\n\n";
874 $mesg .= $outputlangs->transnoentitiesnoconv(
"EMailTextSupplierOrderCanceledBy", $link, $user->getFullName($outputlangs));
875 $mesg .=
"\n\n".$outputlangs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
877 case 'ORDER_SUPPLIER_APPROVE':
878 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
880 $object_type =
'order_supplier';
882 $mesg = $outputlangs->transnoentitiesnoconv(
"Hello").
",\n\n";
883 $mesg .= $outputlangs->transnoentitiesnoconv(
"EMailTextSupplierOrderApprovedBy", $link, $user->getFullName($outputlangs));
884 $mesg .=
"\n\n".$outputlangs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
886 case 'ORDER_SUPPLIER_SUBMIT':
887 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
889 $object_type =
'order_supplier';
890 $mesg = $outputlangs->transnoentitiesnoconv(
"Hello").
",\n\n";
891 $mesg .= $outputlangs->transnoentitiesnoconv(
"EMailTextSupplierOrderSubmittedBy", $link, $user->getFullName($outputlangs));
892 $mesg .=
"\n\n".$outputlangs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
894 case 'ORDER_SUPPLIER_REFUSE':
895 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
897 $object_type =
'order_supplier';
899 $mesg = $outputlangs->transnoentitiesnoconv(
"Hello").
",\n\n";
900 $mesg .= $outputlangs->transnoentitiesnoconv(
"EMailTextSupplierOrderRefusedBy", $link, $user->getFullName($outputlangs));
901 $mesg .=
"\n\n".$outputlangs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
903 case 'SHIPPING_MODIFY':
904 $link =
'<a href="'.$urlwithroot.
'/expedition/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
905 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
907 $object_type =
'shipping';
908 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextExpeditionModified", $link, $context_info);
910 case 'SHIPPING_VALIDATE':
911 $link =
'<a href="'.$urlwithroot.
'/expedition/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
913 $object_type =
'shipping';
914 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextExpeditionValidated", $link);
916 case 'EXPENSE_REPORT_VALIDATE':
917 $link =
'<a href="'.$urlwithroot.
'/expensereport/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
918 $dir_output =
$conf->expensereport->dir_output;
919 $object_type =
'expensereport';
920 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextExpenseReportValidated", $link);
922 case 'EXPENSE_REPORT_APPROVE':
923 $link =
'<a href="'.$urlwithroot.
'/expensereport/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
924 $dir_output =
$conf->expensereport->dir_output;
925 $object_type =
'expensereport';
926 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextExpenseReportApproved", $link);
928 case 'HOLIDAY_VALIDATE':
929 $link =
'<a href="'.$urlwithroot.
'/holiday/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
930 $dir_output =
$conf->holiday->dir_output;
931 $object_type =
'holiday';
932 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextHolidayValidated", $link);
934 case 'HOLIDAY_APPROVE':
935 $link =
'<a href="'.$urlwithroot.
'/holiday/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
936 $dir_output =
$conf->holiday->dir_output;
937 $object_type =
'holiday';
938 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextHolidayApproved", $link);
940 case 'ACTION_CREATE':
941 $link =
'<a href="'.$urlwithroot.
'/comm/action/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
942 $dir_output =
$conf->agenda->dir_output;
943 $object_type =
'action';
944 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextActionAdded", $link);
946 case 'CONTRACT_MODIFY':
947 $link =
'<a href="'.$urlwithroot.
'/contrat/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
948 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
950 $object_type =
'contract';
951 $mesg = $outputlangs->transnoentitiesnoconv(
"EMailTextContractModified", $link, $context_info);
954 $object_type =
$object->element;
956 $template = $notifcode.
'_TEMPLATE';
957 $mesg = $outputlangs->transnoentitiesnoconv(
'Notify_'.$notifcode).
' '.$newref.
' '.$dir_output;
961 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
962 $formmail =
new FormMail($this->db);
963 $arraydefaultmessage =
null;
965 $template = $notifcode.
'_TEMPLATE';
967 if (!empty($labeltouse)) {
968 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $object_type, $user, $outputlangs, 0, 1, $labeltouse);
970 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
971 if (method_exists(
$object,
'fetch_thirdparty') && empty(
$object->thirdparty)) {
974 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null,
$object);
977 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
978 $message =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
980 $message = $outputlangs->transnoentities(
"YouReceiveMailBecauseOfNotification", $application,
$mysoc->name).
"\n";
981 $message .= $outputlangs->transnoentities(
"YouReceiveMailBecauseOfNotification2", $application,
$mysoc->name).
"\n";
987 $pdf_path = $dir_output.
"/".$ref.
".pdf";
988 if (!
dol_is_file($pdf_path) || (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0 && !$arraydefaultmessage->joinfiles)) {
992 $filepdf = $pdf_path;
993 $filename_list[] = $filepdf;
994 $mimetype_list[] = mime_content_type($filepdf);
995 $mimefilename_list[] = $ref.
".pdf";
998 $labeltouse = !empty($labeltouse) ? $labeltouse :
'';
1003 $parameters = array(
'notifcode' => $notifcode,
'sendto' => $sendto,
'from' => $from,
'file' => $filename_list,
'mimefile' => $mimetype_list,
'filename' => $mimefilename_list,
'outputlangs' => $outputlangs,
'labeltouse' => $labeltouse);
1004 if (!isset($action)) {
1008 $reshook = $hookmanager->executeHooks(
'formatNotificationMessage', $parameters,
$object, $action);
1009 if (empty($reshook)) {
1010 if (!empty($hookmanager->resArray[
'files'])) {
1011 $filename_list = $hookmanager->resArray[
'files'][
'file'];
1012 $mimetype_list = $hookmanager->resArray[
'files'][
'mimefile'];
1013 $mimefilename_list = $hookmanager->resArray[
'files'][
'filename'];
1015 if (!empty($hookmanager->resArray[
'subject'])) {
1016 $subject .= $hookmanager->resArray[
'subject'];
1018 if (!empty($hookmanager->resArray[
'message'])) {
1019 $message .= $hookmanager->resArray[
'message'];
1042 if (! empty($mailfile->error) || ! empty($mailfile->errors)) {
1043 $this->error = $mailfile->error;
1044 $this->errors = $mailfile->errors;
1048 if ($mailfile->sendfile()) {
1049 if ($obj->type_target ==
'touserid') {
1050 $sql =
"INSERT INTO ".$this->db->prefix().
"notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)";
1052 $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).
"')";
1054 $sql =
"INSERT INTO ".$this->db->prefix().
"notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)";
1056 $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).
"')";
1058 if (!$this->db->query($sql)) {
1059 dol_print_error($this->db);
1063 $this->errors[] = $mailfile->error;
1066 dol_syslog(
"No notification sent for ".$sendto.
" because email is empty");
1072 dol_syslog(
"No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".(empty(
$object->socid) ?
'' :
$object->socid));
1076 $this->errors[] = $this->db->lasterror();
1077 dol_syslog(
"Failed to get list of notification to send ".$this->db->lasterror(), LOG_ERR);
1084 foreach (
$conf->global as $key => $val) {
1086 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.
'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
1092 $threshold = (float) $reg[1];
1093 if (!empty(
$object->total_ht) &&
$object->total_ht <= $threshold) {
1094 dol_syslog(
"A notification is requested for notifcode = ".$notifcode.
" but amount = ".
$object->total_ht.
" so lower than threshold = ".$threshold.
". We discard this notification");
1098 $notifcodedefid =
dol_getIdFromCode($this->db, $notifcode,
'c_action_trigger',
'code',
'rowid');
1099 if ($notifcodedefid <= 0) {
1100 dol_print_error($this->db,
'Failed to get id from code');
1110 $subject =
'['.$appli.
'] '.$langs->transnoentitiesnoconv(
"DolibarrNotification").($projtitle ?
' '.$projtitle :
'');
1112 switch ($notifcode) {
1113 case 'BILL_VALIDATE':
1114 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1116 $object_type =
'facture';
1117 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInvoiceValidated", $link);
1120 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1122 $object_type =
'facture';
1123 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInvoicePayed", $link);
1125 case 'ORDER_VALIDATE':
1126 $link =
'<a href="'.$urlwithroot.
'/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1128 $object_type =
'order';
1129 $mesg = $langs->transnoentitiesnoconv(
"EMailTextOrderValidated", $link);
1132 $link =
'<a href="'.$urlwithroot.
'/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1134 $object_type =
'order';
1135 $mesg = $langs->transnoentitiesnoconv(
"EMailTextOrderClose", $link);
1137 case 'PROPAL_VALIDATE':
1138 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1140 $object_type =
'propal';
1141 $mesg = $langs->transnoentitiesnoconv(
"EMailTextProposalValidated", $link);
1143 case 'PROPAL_CLOSE_SIGNED':
1144 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1146 $object_type =
'propal';
1147 $mesg = $langs->transnoentitiesnoconv(
"EMailTextProposalClosedSigned", $link);
1149 case 'FICHINTER_ADD_CONTACT':
1150 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1151 $dir_output =
$conf->ficheinter->dir_output;
1152 $object_type =
'fichinter';
1153 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInterventionAddedContact", $link);
1155 case 'FICHINTER_VALIDATE':
1156 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1157 $dir_output =
$conf->facture->dir_output;
1158 $object_type =
'fichinter';
1159 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInterventionValidated", $link);
1161 case 'FICHINTER_MODIFY':
1162 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1163 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
1164 $dir_output =
$conf->ficheinter->dir_output;
1165 $object_type =
'fichinter';
1166 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInterventionModified", $link, $context_info);
1168 case 'FICHINTER_CLOSE':
1169 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1170 $dir_output =
$conf->facture->dir_output;
1171 $object_type =
'fichinter';
1172 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInterventionClosed", $link);
1174 case 'ORDER_SUPPLIER_CANCEL':
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(
"EMailTextSupplierOrderCanceledBy", $link, $user->getFullName($langs));
1180 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1182 case 'ORDER_SUPPLIER_VALIDATE':
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(
"EMailTextSupplierOrderValidatedBy", $link, $user->getFullName($langs));
1188 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1190 case 'ORDER_SUPPLIER_APPROVE':
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(
"EMailTextSupplierOrderApprovedBy", $link, $user->getFullName($langs));
1196 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1198 case 'ORDER_SUPPLIER_SUBMIT':
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(
"EMailTextSupplierOrderSubmittedBy", $link, $user->getFullName($langs));
1204 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1206 case 'ORDER_SUPPLIER_REFUSE':
1207 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1209 $object_type =
'order_supplier';
1210 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
1211 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextSupplierOrderRefusedBy", $link, $user->getFullName($langs));
1212 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1214 case 'SHIPPING_MODIFY':
1215 $link =
'<a href="'.$urlwithroot.
'/expedition/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1216 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
1218 $object_type =
'shipping';
1219 $mesg = $langs->transnoentitiesnoconv(
"EMailTextExpeditionModified", $link, $context_info);
1221 case 'SHIPPING_VALIDATE':
1222 $link =
'<a href="'.$urlwithroot.
'/expedition/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1224 $object_type =
'shipping';
1225 $mesg = $langs->transnoentitiesnoconv(
"EMailTextExpeditionValidated", $link);
1227 case 'EXPENSE_REPORT_VALIDATE':
1228 $link =
'<a href="'.$urlwithroot.
'/expensereport/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1229 $dir_output =
$conf->expensereport->dir_output;
1230 $object_type =
'expensereport';
1231 $mesg = $langs->transnoentitiesnoconv(
"EMailTextExpenseReportValidated", $link);
1233 case 'EXPENSE_REPORT_APPROVE':
1234 $link =
'<a href="'.$urlwithroot.
'/expensereport/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1235 $dir_output =
$conf->expensereport->dir_output;
1236 $object_type =
'expensereport';
1237 $mesg = $langs->transnoentitiesnoconv(
"EMailTextExpenseReportApproved", $link);
1239 case 'HOLIDAY_VALIDATE':
1240 $link =
'<a href="'.$urlwithroot.
'/holiday/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1241 $dir_output =
$conf->holiday->dir_output;
1242 $object_type =
'holiday';
1243 $mesg = $langs->transnoentitiesnoconv(
"EMailTextHolidayValidated", $link);
1245 case 'HOLIDAY_APPROVE':
1246 $link =
'<a href="'.$urlwithroot.
'/holiday/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1247 $dir_output =
$conf->holiday->dir_output;
1248 $object_type =
'holiday';
1249 $mesg = $langs->transnoentitiesnoconv(
"EMailTextHolidayApproved", $link);
1251 case 'ACTION_CREATE':
1252 $link =
'<a href="'.$urlwithroot.
'/comm/action/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1253 $dir_output =
$conf->agenda->dir_output;
1254 $object_type =
'action';
1255 $mesg = $langs->transnoentitiesnoconv(
"EMailTextActionAdded", $link);
1257 case 'CONTRACT_MODIFY':
1258 $link =
'<a href="'.$urlwithroot.
'/contrat/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1259 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
1261 $object_type =
'contract';
1262 $mesg = $langs->transnoentitiesnoconv(
"EMailTextContractModified", $link, $context_info);
1265 $object_type =
$object->element;
1267 $mesg = $langs->transnoentitiesnoconv(
'Notify_'.$notifcode).
' '.$newref;
1271 $pdf_path = $dir_output.
"/".$ref.
".pdf";
1276 $filepdf = $pdf_path;
1277 $filename_list[] = $pdf_path;
1278 $mimetype_list[] = mime_content_type($filepdf);
1279 $mimefilename_list[] = $ref.
".pdf";
1283 $outputlangs = $langs;
1288 $emailTemplate =
null;
1289 if (!empty($mailTemplateLabel)) {
1290 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1291 $formmail =
new FormMail($this->db);
1292 $emailTemplate = $formmail->getEMailTemplate($this->db, $object_type, $user, $outputlangs, 0, 1, $mailTemplateLabel);
1294 if (!empty($mailTemplateLabel) && is_object($emailTemplate) && $emailTemplate->id > 0) {
1295 if (property_exists(
$object,
'thirdparty')) {
1300 if (
$object->thirdparty instanceof
Societe &&
$object->thirdparty->default_lang &&
$object->thirdparty->default_lang != $langs->defaultlang) {
1302 $outputlangs->setDefaultLang(
$object->thirdparty->default_lang);
1303 $outputlangs->loadLangs(array(
'main',
'other'));
1307 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null,
$object);
1309 $subject =
make_substitutions($emailTemplate->topic, $substitutionarray, $outputlangs);
1310 $message =
make_substitutions($emailTemplate->content, $substitutionarray, $outputlangs);
1313 $message .= $outputlangs->transnoentities(
"YouReceiveMailBecauseOfNotification2", $application,
$mysoc->name).
"\n";
1317 $message = nl2br($message);
1324 $parameters = array(
'notifcode' => $notifcode,
'sendto' => $sendto,
'from' => $from,
'file' => $filename_list,
'mimefile' => $mimetype_list,
'filename' => $mimefilename_list,
'subject' => &$subject,
'message' => &$message);
1325 $reshook = $hookmanager->executeHooks(
'formatNotificationMessage', $parameters,
$object, $action);
1326 if (empty($reshook)) {
1327 if (!empty($hookmanager->resArray[
'files'])) {
1328 $filename_list = $hookmanager->resArray[
'files'][
'file'];
1329 $mimetype_list = $hookmanager->resArray[
'files'][
'mimefile'];
1330 $mimefilename_list = $hookmanager->resArray[
'files'][
'filename'];
1332 if (!empty($hookmanager->resArray[
'subject'])) {
1333 $subject .= $hookmanager->resArray[
'subject'];
1335 if (!empty($hookmanager->resArray[
'message'])) {
1336 $message .= $hookmanager->resArray[
'message'];
1358 if (! empty($mailfile->error) || ! empty($mailfile->errors)) {
1359 $this->error = $mailfile->error;
1360 $this->errors = $mailfile->errors;
1364 if ($mailfile->sendfile()) {
1365 $sql =
"INSERT INTO ".$this->db->prefix().
"notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)";
1367 $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).
"')";
1368 if (!$this->db->query($sql)) {
1369 dol_print_error($this->db);
1373 $this->errors[] = $mailfile->error;