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);
981 $substitutionarray[
'__REF__'] =
$object->newref;
983 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
984 $message =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
986 $message = $outputlangs->transnoentities(
"YouReceiveMailBecauseOfNotification", $application,
$mysoc->name).
"\n";
987 $message .= $outputlangs->transnoentities(
"YouReceiveMailBecauseOfNotification2", $application,
$mysoc->name).
"\n";
993 $pdf_path = $dir_output.
"/".$ref.
".pdf";
994 if (!
dol_is_file($pdf_path) || (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0 && !$arraydefaultmessage->joinfiles)) {
998 $filepdf = $pdf_path;
999 $filename_list[] = $filepdf;
1000 $mimetype_list[] = mime_content_type($filepdf);
1001 $mimefilename_list[] = $ref.
".pdf";
1004 $labeltouse = !empty($labeltouse) ? $labeltouse :
'';
1009 $parameters = array(
'notifcode' => $notifcode,
'sendto' => $sendto,
'from' => $from,
'file' => $filename_list,
'mimefile' => $mimetype_list,
'filename' => $mimefilename_list,
'outputlangs' => $outputlangs,
'labeltouse' => $labeltouse);
1010 if (!isset($action)) {
1014 $reshook = $hookmanager->executeHooks(
'formatNotificationMessage', $parameters,
$object, $action);
1015 if (empty($reshook)) {
1016 if (!empty($hookmanager->resArray[
'files'])) {
1017 $filename_list = $hookmanager->resArray[
'files'][
'file'];
1018 $mimetype_list = $hookmanager->resArray[
'files'][
'mimefile'];
1019 $mimefilename_list = $hookmanager->resArray[
'files'][
'filename'];
1021 if (!empty($hookmanager->resArray[
'subject'])) {
1022 $subject .= $hookmanager->resArray[
'subject'];
1024 if (!empty($hookmanager->resArray[
'message'])) {
1025 $message .= $hookmanager->resArray[
'message'];
1048 if (! empty($mailfile->error) || ! empty($mailfile->errors)) {
1049 $this->error = $mailfile->error;
1050 $this->errors = $mailfile->errors;
1054 if ($mailfile->sendfile()) {
1055 if ($obj->type_target ==
'touserid') {
1056 $sql =
"INSERT INTO ".$this->db->prefix().
"notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)";
1058 $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).
"')";
1060 $sql =
"INSERT INTO ".$this->db->prefix().
"notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)";
1062 $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).
"')";
1064 if (!$this->db->query($sql)) {
1065 dol_print_error($this->db);
1069 $this->errors[] = $mailfile->error;
1072 dol_syslog(
"No notification sent for ".$sendto.
" because email is empty");
1078 dol_syslog(
"No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".(empty(
$object->socid) ?
'' :
$object->socid));
1082 $this->errors[] = $this->db->lasterror();
1083 dol_syslog(
"Failed to get list of notification to send ".$this->db->lasterror(), LOG_ERR);
1090 foreach (
$conf->global as $key => $val) {
1092 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.
'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
1098 $threshold = (float) $reg[1];
1099 if (!empty(
$object->total_ht) &&
$object->total_ht <= $threshold) {
1100 dol_syslog(
"A notification is requested for notifcode = ".$notifcode.
" but amount = ".
$object->total_ht.
" so lower than threshold = ".$threshold.
". We discard this notification");
1104 $notifcodedefid =
dol_getIdFromCode($this->db, $notifcode,
'c_action_trigger',
'code',
'rowid');
1105 if ($notifcodedefid <= 0) {
1106 dol_print_error($this->db,
'Failed to get id from code');
1116 $subject =
'['.$appli.
'] '.$langs->transnoentitiesnoconv(
"DolibarrNotification").($projtitle ?
' '.$projtitle :
'');
1118 switch ($notifcode) {
1119 case 'BILL_VALIDATE':
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(
"EMailTextInvoiceValidated", $link);
1126 $link =
'<a href="'.$urlwithroot.
'/compta/facture/card.php?facid='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1128 $object_type =
'facture';
1129 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInvoicePayed", $link);
1131 case 'ORDER_VALIDATE':
1132 $link =
'<a href="'.$urlwithroot.
'/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1134 $object_type =
'order';
1135 $mesg = $langs->transnoentitiesnoconv(
"EMailTextOrderValidated", $link);
1138 $link =
'<a href="'.$urlwithroot.
'/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1140 $object_type =
'order';
1141 $mesg = $langs->transnoentitiesnoconv(
"EMailTextOrderClose", $link);
1143 case 'PROPAL_VALIDATE':
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(
"EMailTextProposalValidated", $link);
1149 case 'PROPAL_CLOSE_SIGNED':
1150 $link =
'<a href="'.$urlwithroot.
'/comm/propal/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1152 $object_type =
'propal';
1153 $mesg = $langs->transnoentitiesnoconv(
"EMailTextProposalClosedSigned", $link);
1155 case 'FICHINTER_ADD_CONTACT':
1156 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1157 $dir_output =
$conf->ficheinter->dir_output;
1158 $object_type =
'fichinter';
1159 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInterventionAddedContact", $link);
1161 case 'FICHINTER_VALIDATE':
1162 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1163 $dir_output =
$conf->facture->dir_output;
1164 $object_type =
'fichinter';
1165 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInterventionValidated", $link);
1167 case 'FICHINTER_MODIFY':
1168 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1169 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
1170 $dir_output =
$conf->ficheinter->dir_output;
1171 $object_type =
'fichinter';
1172 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInterventionModified", $link, $context_info);
1174 case 'FICHINTER_CLOSE':
1175 $link =
'<a href="'.$urlwithroot.
'/fichinter/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1176 $dir_output =
$conf->facture->dir_output;
1177 $object_type =
'fichinter';
1178 $mesg = $langs->transnoentitiesnoconv(
"EMailTextInterventionClosed", $link);
1180 case 'ORDER_SUPPLIER_CANCEL':
1181 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1183 $object_type =
'order_supplier';
1184 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
1185 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextSupplierOrderCanceledBy", $link, $user->getFullName($langs));
1186 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1188 case 'ORDER_SUPPLIER_VALIDATE':
1189 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1191 $object_type =
'order_supplier';
1192 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
1193 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextSupplierOrderValidatedBy", $link, $user->getFullName($langs));
1194 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1196 case 'ORDER_SUPPLIER_APPROVE':
1197 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1199 $object_type =
'order_supplier';
1200 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
1201 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextSupplierOrderApprovedBy", $link, $user->getFullName($langs));
1202 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1204 case 'ORDER_SUPPLIER_SUBMIT':
1205 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1207 $object_type =
'order_supplier';
1208 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
1209 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextSupplierOrderSubmittedBy", $link, $user->getFullName($langs));
1210 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1212 case 'ORDER_SUPPLIER_REFUSE':
1213 $link =
'<a href="'.$urlwithroot.
'/fourn/commande/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1215 $object_type =
'order_supplier';
1216 $mesg = $langs->transnoentitiesnoconv(
"Hello").
",\n\n";
1217 $mesg .= $langs->transnoentitiesnoconv(
"EMailTextSupplierOrderRefusedBy", $link, $user->getFullName($langs));
1218 $mesg .=
"\n\n".$langs->transnoentitiesnoconv(
"Sincerely").
".\n\n";
1220 case 'SHIPPING_MODIFY':
1221 $link =
'<a href="'.$urlwithroot.
'/expedition/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1222 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
1224 $object_type =
'shipping';
1225 $mesg = $langs->transnoentitiesnoconv(
"EMailTextExpeditionModified", $link, $context_info);
1227 case 'SHIPPING_VALIDATE':
1228 $link =
'<a href="'.$urlwithroot.
'/expedition/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1230 $object_type =
'shipping';
1231 $mesg = $langs->transnoentitiesnoconv(
"EMailTextExpeditionValidated", $link);
1233 case 'EXPENSE_REPORT_VALIDATE':
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(
"EMailTextExpenseReportValidated", $link);
1239 case 'EXPENSE_REPORT_APPROVE':
1240 $link =
'<a href="'.$urlwithroot.
'/expensereport/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1241 $dir_output =
$conf->expensereport->dir_output;
1242 $object_type =
'expensereport';
1243 $mesg = $langs->transnoentitiesnoconv(
"EMailTextExpenseReportApproved", $link);
1245 case 'HOLIDAY_VALIDATE':
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(
"EMailTextHolidayValidated", $link);
1251 case 'HOLIDAY_APPROVE':
1252 $link =
'<a href="'.$urlwithroot.
'/holiday/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1253 $dir_output =
$conf->holiday->dir_output;
1254 $object_type =
'holiday';
1255 $mesg = $langs->transnoentitiesnoconv(
"EMailTextHolidayApproved", $link);
1257 case 'ACTION_CREATE':
1258 $link =
'<a href="'.$urlwithroot.
'/comm/action/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1259 $dir_output =
$conf->agenda->dir_output;
1260 $object_type =
'action';
1261 $mesg = $langs->transnoentitiesnoconv(
"EMailTextActionAdded", $link);
1263 case 'CONTRACT_MODIFY':
1264 $link =
'<a href="'.$urlwithroot.
'/contrat/card.php?id='.
$object->id.
'&entity='.
$object->entity.
'">'.$newref.
'</a>';
1265 $context_info = array_key_exists(
'signature',
$object->context) ?
$object->getLibSignedStatus() :
'';
1267 $object_type =
'contract';
1268 $mesg = $langs->transnoentitiesnoconv(
"EMailTextContractModified", $link, $context_info);
1271 $object_type =
$object->element;
1273 $mesg = $langs->transnoentitiesnoconv(
'Notify_'.$notifcode).
' '.$newref;
1277 $pdf_path = $dir_output.
"/".$ref.
".pdf";
1282 $filepdf = $pdf_path;
1283 $filename_list[] = $pdf_path;
1284 $mimetype_list[] = mime_content_type($filepdf);
1285 $mimefilename_list[] = $ref.
".pdf";
1289 $outputlangs = $langs;
1294 $emailTemplate =
null;
1295 if (!empty($mailTemplateLabel)) {
1296 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1297 $formmail =
new FormMail($this->db);
1298 $emailTemplate = $formmail->getEMailTemplate($this->db, $object_type, $user, $outputlangs, 0, 1, $mailTemplateLabel);
1300 if (!empty($mailTemplateLabel) && is_object($emailTemplate) && $emailTemplate->id > 0) {
1301 if (property_exists(
$object,
'thirdparty')) {
1306 if (
$object->thirdparty instanceof
Societe &&
$object->thirdparty->default_lang &&
$object->thirdparty->default_lang != $langs->defaultlang) {
1308 $outputlangs->setDefaultLang(
$object->thirdparty->default_lang);
1309 $outputlangs->loadLangs(array(
'main',
'other'));
1313 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null,
$object);
1318 if (!empty(
$object->newref)) {
1319 $substitutionarray[
'__REF__'] =
$object->newref;
1321 $subject =
make_substitutions($emailTemplate->topic, $substitutionarray, $outputlangs);
1322 $message =
make_substitutions($emailTemplate->content, $substitutionarray, $outputlangs);
1325 $message .= $outputlangs->transnoentities(
"YouReceiveMailBecauseOfNotification2", $application,
$mysoc->name).
"\n";
1329 $message = nl2br($message);
1336 $parameters = array(
'notifcode' => $notifcode,
'sendto' => $sendto,
'from' => $from,
'file' => $filename_list,
'mimefile' => $mimetype_list,
'filename' => $mimefilename_list,
'subject' => &$subject,
'message' => &$message);
1337 $reshook = $hookmanager->executeHooks(
'formatNotificationMessage', $parameters,
$object, $action);
1338 if (empty($reshook)) {
1339 if (!empty($hookmanager->resArray[
'files'])) {
1340 $filename_list = $hookmanager->resArray[
'files'][
'file'];
1341 $mimetype_list = $hookmanager->resArray[
'files'][
'mimefile'];
1342 $mimefilename_list = $hookmanager->resArray[
'files'][
'filename'];
1344 if (!empty($hookmanager->resArray[
'subject'])) {
1345 $subject .= $hookmanager->resArray[
'subject'];
1347 if (!empty($hookmanager->resArray[
'message'])) {
1348 $message .= $hookmanager->resArray[
'message'];
1370 if (! empty($mailfile->error) || ! empty($mailfile->errors)) {
1371 $this->error = $mailfile->error;
1372 $this->errors = $mailfile->errors;
1376 if ($mailfile->sendfile()) {
1377 $sql =
"INSERT INTO ".$this->db->prefix().
"notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)";
1379 $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).
"')";
1380 if (!$this->db->query($sql)) {
1381 dol_print_error($this->db);
1385 $this->errors[] = $mailfile->error;