diff --git a/entity/Salesproject_entity/Salesproject_entity.aod b/entity/Salesproject_entity/Salesproject_entity.aod index 8332d804d923f14aec2e1822e5e2ee7dae0203ab..85832cea86543f8f073fe43dd2cce9e9cc788408 100644 --- a/entity/Salesproject_entity/Salesproject_entity.aod +++ b/entity/Salesproject_entity/Salesproject_entity.aod @@ -306,6 +306,7 @@ <entityField> <name>TIMETRACKINGSUM</name> <title>Time expenses</title> + <description>the total hours of all time trackings related to the salesproject</description> <state>READONLY</state> <valueProcess>%aditoprj%/entity/Salesproject_entity/entityfields/timetrackingsum/valueProcess.js</valueProcess> </entityField> @@ -362,6 +363,13 @@ </entityParameter> </children> </entityConsumer> + <entityActionField> + <name>newTimetracking</name> + <fieldType>ACTION</fieldType> + <title>New time tracking</title> + <description>Opens the time tracking context in new-mode for the selected salesproject</description> + <onActionProcess>%aditoprj%/entity/Salesproject_entity/entityfields/newtimetracking/onActionProcess.js</onActionProcess> + </entityActionField> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Salesproject_entity/entityfields/newtimetracking/onActionProcess.js b/entity/Salesproject_entity/entityfields/newtimetracking/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..2f991c1b2cde37a93ba1b2b0b3dfc70813449fd9 --- /dev/null +++ b/entity/Salesproject_entity/entityfields/newtimetracking/onActionProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("Timetracking_lib"); + +Timetracking.createNewTimeTracking(vars.getString("$field.SALESPROJECTID")); \ No newline at end of file diff --git a/entity/Salesproject_entity/entityfields/timetrackingsum/valueProcess.js b/entity/Salesproject_entity/entityfields/timetrackingsum/valueProcess.js index 91a3e076d0cc7c79921b286f3a29247efe27d23f..e3ef6877942e157abdbd49460716516416b058d0 100644 --- a/entity/Salesproject_entity/entityfields/timetrackingsum/valueProcess.js +++ b/entity/Salesproject_entity/entityfields/timetrackingsum/valueProcess.js @@ -1,13 +1,10 @@ -import("system.eMath"); +import("system.text"); import("system.translate"); import("system.result"); import("system.vars"); -import("Salesproject_lib"); +import("Timetracking_lib"); -var objectId = ContextUtils.getCurrentContextId(); -var rowId = vars.getString("$field.SALESPROJECTID"); - -var hrs = Salesproject.getTotalTrackingTime(objectId, rowId) / 60; -hrs = eMath.roundDec(hrs, 2, eMath.ROUND_HALF_UP); +var hrs = Timetracking.getTotalTrackingTime(vars.getString("$field.SALESPROJECTID")) / 60; +hrs = text.formatDouble(hrs, "0.00"); result.string(hrs + " " + translate.text("hrs")); \ No newline at end of file diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index 59cd2ccf51f5105582f56e82eb33da117adb99eb..9b057dd5bf9ad45a5ed3ccc749b324146e8eb9bc 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -58,6 +58,10 @@ <key>Austria</key> <value>Österreich</value> </entry> + <entry> + <key>New time tracking</key> + <value>Neuer Zeiteintrag</value> + </entry> <entry> <key>Customercode</key> <value>Kundennummer</value> @@ -1344,6 +1348,7 @@ </entry> <entry> <key>New receipt version</key> + <value></value> </entry> <entry> <key>Orderitems</key> diff --git a/process/Salesproject_lib/process.js b/process/Salesproject_lib/process.js index 393cc721882ce3815c532aa1309ce72c7e09f6be..acbb272a3e6cb68372a05e176884ef760b9402ce 100644 --- a/process/Salesproject_lib/process.js +++ b/process/Salesproject_lib/process.js @@ -1,3 +1,4 @@ +import("system.neon"); import("system.vars"); import("system.util"); import("system.translate"); @@ -82,21 +83,3 @@ Salesproject.getSalesProjectTitleById = function(pSalesProjectId) .andPrepare("SALESPROJECT.SALESPROJECTID", pSalesProjectId) .buildSql("select PROJECTTITLE from SALESPROJECT", "1=0")); } - -/** - * calculates the total time of all time trackings of the object - * - * @param {String} pObjectId the objectId - * @param {String} pRowId the rowId - * - * @return {Number} total time in minutes - */ -Salesproject.getTotalTrackingTime = function (pObjectId, pRowId) -{ - var totalMinutes = db.cell(SqlCondition.begin() - .andPrepare("TIMETRACKING.OBJECT_ID", pObjectId) - .andPrepare("TIMETRACKING.ROW_ID", pRowId) - .buildSql("select sum(MINUTES) from TIMETRACKING", "1=0")); - - return Number(totalMinutes); -} \ No newline at end of file diff --git a/process/Timetracking_lib/Timetracking_lib.aod b/process/Timetracking_lib/Timetracking_lib.aod new file mode 100644 index 0000000000000000000000000000000000000000..305c323c6ea8fa0daf6b27a061d0ba601bfa8db6 --- /dev/null +++ b/process/Timetracking_lib/Timetracking_lib.aod @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.7" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.1.7"> + <name>Timetracking_lib</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <process>%aditoprj%/process/Timetracking_lib/process.js</process> + <variants> + <element>LIBRARY</element> + </variants> +</process> diff --git a/process/Timetracking_lib/process.js b/process/Timetracking_lib/process.js new file mode 100644 index 0000000000000000000000000000000000000000..2a540245b62190ef1454d600cf1ab7000426913a --- /dev/null +++ b/process/Timetracking_lib/process.js @@ -0,0 +1,47 @@ +import("system.db"); +import("system.neon"); +import("Context_lib"); + +/** + * Methods used for time tracking. + * Do not create an instance of this! + * + * @class + */ +function Timetracking() {} + +/** + * calculates the total time of all time trackings of the object + * + * @param {String} pRowId the rowId + * + * @return {Number} total time in minutes + */ +Timetracking.getTotalTrackingTime = function (pRowId) +{ + var objectId = ContextUtils.getCurrentContextId(); + var totalMinutes = db.cell(SqlCondition.begin() + .andPrepare("TIMETRACKING.OBJECT_ID", objectId) + .andPrepare("TIMETRACKING.ROW_ID", pRowId) + .buildSql("select sum(MINUTES) from TIMETRACKING", "1=0")); + + return Number(totalMinutes); +} + +/** + * Create a new time tracking + * + * @param {String} pRowId the rowId + * + * @return {Number} total time in minutes + */ +Timetracking.createNewTimeTracking = function (pRowId) +{ + var objectId = ContextUtils.getCurrentContextId(); + var params = { + "ObjectId_param" : objectId, + "RowId_param" : pRowId + }; + + neon.openContext("Timetracking_context", null, null, neon.OPERATINGSTATE_NEW, params); +} \ No newline at end of file