From e1410cd4e4df6b76d24177524d0d6470667918c4 Mon Sep 17 00:00:00 2001 From: Vinzent Broens <v.broens@adito.de> Date: Thu, 26 Aug 2021 09:16:34 +0000 Subject: [PATCH] Marketing 1075546 notifications --- .../_____LANGUAGE_de/_____LANGUAGE_de.aod | 30 +++++++---- process/sendBulkMail_serverProcess/process.js | 13 ++++- .../process.js | 53 +++++++++++++++++-- 3 files changed, 80 insertions(+), 16 deletions(-) diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index b5ef0f8efa..2dc7d4f608 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -126,6 +126,10 @@ <key>This setting is overridden by the setting '%0'</key> <value>Diese Einstellung wird durch die Einstellung '%0' überschrieben</value> </entry> + <entry> + <key>was missed</key> + <value>wurde verpasst</value> + </entry> <entry> <key>Move down</key> <value>Nach unten verschieben</value> @@ -6301,6 +6305,10 @@ <key>Existing contact</key> <value>Bestehender Kontakt</value> </entry> + <entry> + <key>Mailing</key> + <value>Mailing</value> + </entry> <entry> <key>Recommendation</key> <value>Empfehlung</value> @@ -6309,6 +6317,10 @@ <key>Print media</key> <value>Printmedien</value> </entry> + <entry> + <key>Mailing missed</key> + <value>Mailing verpasst</value> + </entry> <entry> <key>Call back (WV)</key> <value>Rückruf (WV)</value> @@ -12211,15 +12223,6 @@ Bitte Datumseingabe prüfen</value> <entry> <key>During processing the e-mail an error has occurred.\n Please contact an administrator</key> </entry> - <entry> - <key>DSGVO-Anonymisierung</key> - </entry> - <entry> - <key>privat</key> - </entry> - <entry> - <key>During processing the e-mail an error has occurred.\n Please contact an administrator</key> - </entry> <entry> <key>Authorware Binary File</key> <value>Authorware Binärdatei</value> @@ -12550,6 +12553,15 @@ Bitte Datumseingabe prüfen</value> <key>Grouptask</key> <value>Guppenaufgabe</value> </entry> + <entry> + <key>DSGVO-Anonymisierung</key> + </entry> + <entry> + <key>privat</key> + </entry> + <entry> + <key>During processing the e-mail an error has occurred.\n Please contact an administrator</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/process/sendBulkMail_serverProcess/process.js b/process/sendBulkMail_serverProcess/process.js index acccd48561..6a6c074903 100644 --- a/process/sendBulkMail_serverProcess/process.js +++ b/process/sendBulkMail_serverProcess/process.js @@ -1,3 +1,5 @@ +import("system.logging"); +import("Employee_lib"); import("system.datetime"); import("Sql_lib"); import("system.db"); @@ -24,5 +26,12 @@ if (user && !testRun) var description = translate.withArguments("%0 mails sent sucessfully, %1 mails failed. Process took %2 s.", [res.sucessful, res.failed, Math.round((datetime.date() - startTime) / datetime.ONE_SECOND)]); notification.addNotification(util.getNewUUID(), null, null, null, "BulkMailSent", notification.PRIO_NORMAL, 2, notification.STATE_UNSEEN, [user], message, description); - -} \ No newline at end of file + + var responsibleUser = newSelect("BULKMAIL.EMPLOYEE_CONTACT_ID") + .from("BULKMAIL") + .whereIfSet("BULKMAIL.BULKMAILID", bulkMailId) + .cell(true); + var employee = EmployeeUtils.getUserByContactId(responsibleUser); + var employeeUser = employee.myRole; + notification.addNotification(util.getNewUUID(), null, null, null, "BulkMailSent", notification.PRIO_NORMAL, 2, notification.STATE_UNSEEN, [employeeUser], message, description); +} diff --git a/process/sendPlannedBulkmails_serverProcess/process.js b/process/sendPlannedBulkmails_serverProcess/process.js index 3f74ac7a52..45d573f8b3 100644 --- a/process/sendPlannedBulkmails_serverProcess/process.js +++ b/process/sendPlannedBulkmails_serverProcess/process.js @@ -1,4 +1,8 @@ -import("system.logging"); +import("Keyword_lib"); +import("system.tools"); +import("Employee_lib"); +import("system.translate"); +import("system.notification"); import("Bulkmail_lib"); import("system.project"); import("system.datetime"); @@ -16,13 +20,52 @@ var bulkMailData = newSelect("BULKMAIL.BULKMAILID") .and("BULKMAIL.DATE_TO_SEND", datetime.date(), SqlBuilder.LESS_OR_EQUAL()) .and("BULKMAIL.DATE_TO_SEND",eMath.subInt(datetime.date(), eMath.mulInt(dateToSendPassedAfter, datetime.ONE_HOUR)), SqlBuilder.GREATER()) .arrayColumn(); -for (let i = 0; i < bulkMailData.length; i++) + +bulkMailData.forEach(function (element) { - newWhere("BULKMAIL.BULKMAILID", bulkMailData[i]) + newWhere("BULKMAIL.BULKMAILID", element) .updateFields({"STATUS" : $KeywordRegistry.bulkMailStatus$beingSent()}); - BulkMailUtils.sendBulkMailOnServer(bulkMailData[i],null,null); -} + BulkMailUtils.sendBulkMailOnServer(element,null,null); +}); + +//find all missed bulkmails and send responsible notification + +var bulkMailMissed = newSelect("BULKMAIL.EMPLOYEE_CONTACT_ID, BULKMAIL.NAME, BULKMAIL.DATE_TO_SEND") + .from("BULKMAIL") + .where("BULKMAIL.STATUS", $KeywordRegistry.bulkMailStatus$planned()) + .and("BULKMAIL.DATE_TO_SEND", eMath.subInt(datetime.date(), eMath.mulInt(dateToSendPassedAfter, datetime.ONE_HOUR)), SqlBuilder.LESS_OR_EQUAL()) + .table(); + + + +bulkMailMissed.forEach(function([pEmployeeContactId, pName, pDateToSend]){ + var targetLocale = newSelect("CONTACT.ISOLANGUAGE") + .from("CONTACT") + .where("CONTACT.CONTACTID",pEmployeeContactId) + .cell(); + var langIso2 = LanguageKeywordUtils.Iso2FromIso3(targetLocale); + + let caption = translate.text("Mailing missed",langIso2); + let description = translate.text("Mailing",langIso2) + " " + pName + " " + + translate.text("was missed",langIso2) + +". " + translate.text("Send Date",langIso2) + ": " + +datetime.toDate(pDateToSend,"dd.MM.yyyy"); + + var employee = EmployeeUtils.getUserByContactId(pEmployeeContactId); + var employeeUser = employee.myRole; + + let notificationConfig = notification.createConfig() + .addUserWithId(employeeUser) + .forcedPriority(notification.PRIO_NORMAL) + .notificationType("BulkMailSent") + .initialState(notification.STATE_UNSEEN) + .caption(caption) + .description(description); + + notification.addNotificationWith(notificationConfig); +}); + //set all missed bulkmails to status missed newWhere("BULKMAIL.STATUS", $KeywordRegistry.bulkMailStatus$planned()) -- GitLab