From 5046ea5e7510f5da6c06eb90d21142a8d0ca8741 Mon Sep 17 00:00:00 2001 From: "c.wimmer" <c.wimmer@cwimmer-nb.aditosoftware.local> Date: Wed, 4 Nov 2020 19:40:42 +0100 Subject: [PATCH] Anpassungen VisitplanEntry --- .../VisitPlanEntry_entity.aod | 2 +- .../children/newappointment/stateProcess.js | 10 ++-- entity/VisitPlanEntry_entity/onValidation.js | 11 ----- .../recordcontainers/jdito/onUpdate.js | 48 +++++++++++++++++-- .../recordcontainers/jdito/contentProcess.js | 8 ++-- .../_____LANGUAGE_de/_____LANGUAGE_de.aod | 2 +- 6 files changed, 57 insertions(+), 24 deletions(-) diff --git a/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod b/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod index e5cc41bb60..b54657f204 100644 --- a/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod +++ b/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod @@ -100,7 +100,7 @@ <title>New Appointment</title> <onActionProcess>%aditoprj%/entity/VisitPlanEntry_entity/entityfields/entityactiongroup/children/newappointment/onActionProcess.js</onActionProcess> <iconId>VAADIN:CALENDAR</iconId> - <state>AUTO</state> + <state>EDITABLE</state> <stateProcess>%aditoprj%/entity/VisitPlanEntry_entity/entityfields/entityactiongroup/children/newappointment/stateProcess.js</stateProcess> <tooltip>Create new Appointment</tooltip> <tooltipProcess>%aditoprj%/entity/VisitPlanEntry_entity/entityfields/entityactiongroup/children/newappointment/tooltipProcess.js</tooltipProcess> diff --git a/entity/VisitPlanEntry_entity/entityfields/entityactiongroup/children/newappointment/stateProcess.js b/entity/VisitPlanEntry_entity/entityfields/entityactiongroup/children/newappointment/stateProcess.js index 00cae70329..3f986eb99c 100644 --- a/entity/VisitPlanEntry_entity/entityfields/entityactiongroup/children/newappointment/stateProcess.js +++ b/entity/VisitPlanEntry_entity/entityfields/entityactiongroup/children/newappointment/stateProcess.js @@ -1,8 +1,10 @@ +import("system.logging"); import("system.result"); import("system.vars"); import("system.neon"); -var state = neon.COMPONENTSTATE_DISABLED; -if (vars.get("$field.ISGROUP") == "false" && vars.get("$sys.selectionRows") != "") - state = neon.COMPONENTSTATE_EDITABLE; -result.string(state); +if (vars.get("$field.ISGROUP") == "false" && vars.get("$sys.selectionRows") != "" + && (vars.get("$field.STATUS") == "VISITSTATUSAPPPLANED" + || vars.get("$field.STATUS_APPOINTMENT") == "VISITSTATUSAPPOINTMENTCONFIRMED ")) + result.string(neon.COMPONENTSTATE_DISABLED); + diff --git a/entity/VisitPlanEntry_entity/onValidation.js b/entity/VisitPlanEntry_entity/onValidation.js index 15c1007b0a..0cdee16cc3 100644 --- a/entity/VisitPlanEntry_entity/onValidation.js +++ b/entity/VisitPlanEntry_entity/onValidation.js @@ -13,14 +13,3 @@ var begin_time = eMath.absInt(vars.get("$field.BEGIN_TIME")); if (endTime != "" && begin_time != "" && endTime < begin_time) result.string(translate.text("The endtime can't be before begintime!")); -if(vars.get("$param.NoVisitPlanEmployeeWeek_param") != "true") -{ - var week = newSelect("VISITPLAN_WEEK") - .from("VISITPLANEMPLOYEEWEEK") - .where("VISITPLANEMPLOYEEWEEK.VISITPLANEMPLOYEEWEEKID", vars.get("$field.VISITPLANEMPLOYEEWEEK_ID")) - .cell(); - weekEntrydate = eMath.absInt(datetime.toDate(vars.get("$field.ENTRYDATE"), "w")) - - if(week != weekEntrydate) - result.string(translate.text("Entrydate has to be in the selected calendar week!")); -} diff --git a/entity/VisitPlanEntry_entity/recordcontainers/jdito/onUpdate.js b/entity/VisitPlanEntry_entity/recordcontainers/jdito/onUpdate.js index 4c84ba65c5..29f1c3c50f 100644 --- a/entity/VisitPlanEntry_entity/recordcontainers/jdito/onUpdate.js +++ b/entity/VisitPlanEntry_entity/recordcontainers/jdito/onUpdate.js @@ -1,3 +1,5 @@ +import("Employee_lib"); +import("system.util"); import("system.datetime"); import("Sql_lib"); import("system.logging"); @@ -6,6 +8,44 @@ import("system.db"); import("system.vars"); var rowData = vars.get("$local.rowdata"); +var user = EmployeeUtils.getCurrentContactId() +var calendarWeek = datetime.toDate(rowData["ENTRYDATE.value"], "w"); +var calendarYear = datetime.toDate(rowData["ENTRYDATE.value"], "yyyy"); +var weekId = newSelect("VISITPLANEMPLOYEEWEEKID") + .from("VISITPLANEMPLOYEEWEEK") + .where("VISITPLANEMPLOYEEWEEK.VISITPLAN_WEEK", calendarWeek) + .and("VISITPLANEMPLOYEEWEEK.VISITPLAN_YEAR", calendarYear) + .and("VISITPLANEMPLOYEEWEEK.CONTACT_ID", user) + .cell(); + +logging.log(rowData["ENTRYDATE.value"]) +logging.log(datetime.toDate(rowData["ENTRYDATE.value"], "w")) +logging.log(datetime.toDate(rowData["ENTRYDATE.value"], "yyyy")) + +if(weekId) + visitPlanEmployeeWeekID = weekId; +else +{ + var newWeekId = util.getNewUUID(); + + var valuesWeek = [ + newWeekId, + calendarWeek, + calendarYear, + user + ]; + + var columnsWeek = [ + "VISITPLANEMPLOYEEWEEKID", + "VISITPLAN_WEEK", + "VISITPLAN_YEAR", + "CONTACT_ID", + ]; + + db.insertData("VISITPLANEMPLOYEEWEEK", columnsWeek, null, valuesWeek); + + visitPlanEmployeeWeekID = newWeekId; +} var values = [ rowData["ENTRYDATE.value"], @@ -13,7 +53,8 @@ var values = [ rowData["END_TIME.value"], rowData["ORGANISATION_CONTACT_ID.value"], rowData["STATUS.value"], - rowData["STATUS_APPOINTMENT.value"] + rowData["STATUS_APPOINTMENT.value"], + visitPlanEmployeeWeekID ]; var columns = [ @@ -22,9 +63,10 @@ var columns = [ "END_TIME", "ORGANISATION_CONTACT_ID", "STATUS", - "STATUS_APPOINTMENT" + "STATUS_APPOINTMENT", + "VISITPLANEMPLOYEEWEEK_ID" ]; - +logging.log(visitPlanEmployeeWeekID) var cond = newWhere("VISITPLANENTRY.VISITPLANENTRYID", vars.get("$field.UID")).toString(); db.updateData("VISITPLANENTRY", columns, null, values, cond); diff --git a/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js b/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js index c2499cbaaf..d2235a8b31 100644 --- a/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js @@ -147,15 +147,16 @@ if(idValues == false) tmpData[13] = ""; //USER_NEW.displayValue tmpData[14] = ""; //USER_NEW.value tmpData[15] = ContactUtils.getFullTitleByContactId(visitFrequencyData[i][1], false); //CONTACT_PERSON_ID.displayValue - tmpData[16] = ""; //CONTACT_PERSON_ID.value + tmpData[16] = visitFrequencyData[i][1]; //CONTACT_PERSON_ID.value tmpData[17] = ""; //RESPONSIBLE.displayValue tmpData[18] = ""; //RESPONSIBLE.value var dueDate = ""; var lastVisitDate = ""; + var today = datetime.date(); if((visitFrequencyData[i][8]).length == 0) { - dueDate = datetime.date(); + dueDate = today; } else { @@ -181,8 +182,7 @@ if(idValues == false) tmpData[6] = getPrioByDueDate(dueDate); //PRIORITY.value tmpData[8] = KeywordUtils.getViewValue($KeywordRegistry.visitRecommendationPriority(), tmpData[6]) //PRIORITY.displayValue tmpData[9] = dueDate; //DUE_DATE.value - - recommendationData.push(tmpData); + } } diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index 88b858ace4..9fecd319d4 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -8159,7 +8159,7 @@ Bitte Datumseingabe prüfen</value> </entry> <entry> <key>Appointment Confirmed</key> - <value>Bestätigt</value> + <value>Termin bestätigt</value> </entry> <entry> <key>critical</key> -- GitLab