diff --git a/entity/360Degree_entity/recordcontainers/jdito/contentProcess.js b/entity/360Degree_entity/recordcontainers/jdito/contentProcess.js index 953a229acb9dc610df8b3fb5cfec1bda71aa0b20..92fef480e511705c8f175b3190c3bbb40303a32d 100644 --- a/entity/360Degree_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/360Degree_entity/recordcontainers/jdito/contentProcess.js @@ -1,4 +1,3 @@ -import("system.logging"); import("system.util"); import("system.db"); import("system.vars"); @@ -97,7 +96,6 @@ function _get360Data(pSelectMap, pBaseContextId, pContactId, pContextList, pActi subContextContactIds.forEach(function(pId) { // V-- do not add subcontexts deeper than one layer var subcontextRes = _get360Data(pSelectMap, pBaseContextId, pId, subContexts[subContextId][1], pActive, pExcludedObjectIds, false); - logging.log(subcontextRes.toSource()) resultList = resultList.concat(subcontextRes); }); } diff --git a/entity/Appointment_entity/recordcontainers/jdito/onInsert.js b/entity/Appointment_entity/recordcontainers/jdito/onInsert.js index c995f2f3bdbb6abd8627f27d33e9f3c0103fee7a..48de276e373ecf0609caaa3afddb841660a3fc38 100644 --- a/entity/Appointment_entity/recordcontainers/jdito/onInsert.js +++ b/entity/Appointment_entity/recordcontainers/jdito/onInsert.js @@ -1,4 +1,3 @@ -import("system.logging"); import("system.neon"); import("system.calendars"); import("system.vars"); @@ -13,7 +12,6 @@ import("system.tools"); var event = JSON.parse(vars.getString("$param.Entry_param")); var fields = vars.get("$local.rowdata"); -logging.log(JSON.stringify(fields)); event[calendars.TYPE] = calendars.VEVENT; event[calendars.ID] = ""; //wenn hier neue id erstellt und mitgegeben wird, wird versucht einen termin mit dieser id zu finden, den es nicht gibt. also leer. diff --git a/entity/ClassificationAdmin_entity/recordcontainers/jdito/contentProcess.js b/entity/ClassificationAdmin_entity/recordcontainers/jdito/contentProcess.js index 52a61eb71abaeb31c3468bf91027f2167d1f47a1..5a78999dea25b300de3f031341e56276f932906e 100644 --- a/entity/ClassificationAdmin_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/ClassificationAdmin_entity/recordcontainers/jdito/contentProcess.js @@ -1,4 +1,3 @@ -import("system.logging"); import("JditoFilter_lib"); import("Classification_lib"); import("system.vars"); @@ -12,7 +11,6 @@ var classificationTypeId; if (vars.exists("$local.idvalues") && vars.get("$local.idvalues") && vars.get("$local.idvalues").length > 0) { var selected = vars.get("$local.idvalues")[0]; - logging.log(selected.toSource()) classificationTypeId = selected; } diff --git a/entity/DSGVOInfo_entity/entityfields/recipient/stateProcess.js b/entity/DSGVOInfo_entity/entityfields/recipient/stateProcess.js index 756911b924bab101ee9dfab8743ab1b990c82b33..3e96a7bc47dbb2ffacabaeaa9aa42851c7c06a03 100644 --- a/entity/DSGVOInfo_entity/entityfields/recipient/stateProcess.js +++ b/entity/DSGVOInfo_entity/entityfields/recipient/stateProcess.js @@ -1,4 +1,3 @@ -import("system.logging"); import("system.result"); import("system.vars"); import("system.neon"); @@ -10,6 +9,5 @@ if (vars.get("$field.TRANSMISSION") && vars.get("$field.TRANSMISSION") != $Keywo } else { - logging.log("DISABLE res"); result.string(neon.COMPONENTSTATE_DISABLED); } \ No newline at end of file diff --git a/entity/DSGVO_entity/entityfields/value/contentTypeProcess.js b/entity/DSGVO_entity/entityfields/value/contentTypeProcess.js index 44303ce0e65c86bb9393acd43a152fd9c7abc6c5..f12ab2a78c8f353a32df4fa08af7411d4dae9550 100644 --- a/entity/DSGVO_entity/entityfields/value/contentTypeProcess.js +++ b/entity/DSGVO_entity/entityfields/value/contentTypeProcess.js @@ -1,11 +1,9 @@ -import("system.logging"); import("system.result"); import("KeywordRegistry_basic"); import("system.vars"); import("system.neon"); // NOTE: If there are more cases added, consider adding this to DSGVOType keyword as attribute or adding it to DataPrivacy_lib to the Types. -logging.log(vars.get("$field.DSGVOTYPE")); switch (vars.get("$field.DSGVOTYPE").trim()) { case $KeywordRegistry.dsgvoType$birth().trim(): diff --git a/entity/DuplicateScanConditionConfig_entity/entityfields/condition/valueProcess.js b/entity/DuplicateScanConditionConfig_entity/entityfields/condition/valueProcess.js index 395c147d364228f1d667e1f37b5637d0fa71989d..c1041366b81d28135ca08820e00ae1c66d7c1609 100644 --- a/entity/DuplicateScanConditionConfig_entity/entityfields/condition/valueProcess.js +++ b/entity/DuplicateScanConditionConfig_entity/entityfields/condition/valueProcess.js @@ -1,12 +1,9 @@ -import("system.logging"); import("system.vars"); import("system.result"); -logging.log("condition -> " + JSON.stringify(vars.get("$this.value"))); if(vars.get("$this.value") == "") { let entityToScan = vars.get("$param.EntityToFilter_param"); - logging.log("condition leer neu rein schreiben -> " + entityToScan); let defaultFilterJson = JSON.stringify({entity: entityToScan, filter: {type: "group", operator: "AND", childs: []}}); result.string(defaultFilterJson); diff --git a/entity/DuplicateScanConditionConfig_entity/entityfields/parameter/valueProcess.js b/entity/DuplicateScanConditionConfig_entity/entityfields/parameter/valueProcess.js index 7ac009f93f24d9697f6eea6c7d11ac93df584ceb..9eab3ae2e01d4d2eae9cd972788b3ba035e8b5f5 100644 --- a/entity/DuplicateScanConditionConfig_entity/entityfields/parameter/valueProcess.js +++ b/entity/DuplicateScanConditionConfig_entity/entityfields/parameter/valueProcess.js @@ -1,6 +1,4 @@ -import("system.logging"); import("system.result"); import("system.vars"); -logging.log("EntityToFilter_param -> " + vars.get("$param.EntityToFilter_param")); result.string(vars.get("$param.EntityToFilter_param")); \ No newline at end of file diff --git a/entity/Member_entity/entityfields/icon/valueProcess.js b/entity/Member_entity/entityfields/icon/valueProcess.js index 71433b6fd1101334fd669ae6d666c248db6ec555..73958ed988bcd4b2fedafe9a1d903e419af75db0 100644 --- a/entity/Member_entity/entityfields/icon/valueProcess.js +++ b/entity/Member_entity/entityfields/icon/valueProcess.js @@ -16,10 +16,4 @@ if(role) if(isIntern) result.string("VAADIN:STAR"); -else result.string("VAADIN:AIRPLANE"); - -//var keywordAttributes = KeywordUtils.getAttributeRelationsByKey(role, $KeywordRegistry.MemberRole()); -// -//logging.log(keywordAttributes); -// -//result.string("VAADIN:AIRPLANE"); \ No newline at end of file +else result.string("VAADIN:AIRPLANE"); \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/contact_id/onValidation.js b/entity/Offer_entity/entityfields/contact_id/onValidation.js index 98c4fef71d31b5027c234773c7223421117a54a6..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/entity/Offer_entity/entityfields/contact_id/onValidation.js +++ b/entity/Offer_entity/entityfields/contact_id/onValidation.js @@ -1,12 +0,0 @@ -//import("system.logging"); -//import("system.result"); -//import("system.translate"); -//import("system.vars"); -//import("Context_lib"); -//import("Entity_lib"); -//import("Contact_lib"); -// -//if (ContactUtils.getContactTypeByContactId(vars.get("$local.value")) != 2 && ContextUtils.getCountByContactId(vars.get("$field.OBJECT_TYPE"), vars.get("$local.value")) == 0) { -// logging.log(ContextUtils.getCountByContactId(vars.get("$field.OBJECT_TYPE"), vars.get("local.value"))); -// result.string(translate.text("This contact has no possible link.")) -//} \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/contact_id/onValueChange.js b/entity/Offer_entity/entityfields/contact_id/onValueChange.js index c90065cca07269ff73a623755b297c7f4531b442..525a255e1284f6e34990521302341ba54e4e368d 100644 --- a/entity/Offer_entity/entityfields/contact_id/onValueChange.js +++ b/entity/Offer_entity/entityfields/contact_id/onValueChange.js @@ -1,4 +1,3 @@ -import("system.logging"); import("system.neon"); import("system.vars"); import("system.db"); @@ -26,7 +25,5 @@ else if(!vars.get("$param.ObjectRowId_param")) { - // logging.log(JSON.stringify(vars.get("$local.type"), null, "\t")) - // logging.log(JSON.stringify(vars.get("$local.typevalue"), null, "\t")) neon.setFieldValue("$field.OBJECT_ROWID", ""); } \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/object_rowid/valueProcess.js b/entity/Offer_entity/entityfields/object_rowid/valueProcess.js index 29bb85ddce909faec7a1d90bb521f3d129b4b495..8682d1f41d4023e8e347ad32eb1c0760af54f0fb 100644 --- a/entity/Offer_entity/entityfields/object_rowid/valueProcess.js +++ b/entity/Offer_entity/entityfields/object_rowid/valueProcess.js @@ -1,8 +1,6 @@ -import("system.logging"); import("system.neon"); import("system.vars"); import("system.result"); -logging.log("--- " + JSON.stringify(vars.get("$sys.recordstate"), vars.exists("$param.ObjectRowId_param"), null, "\t")) if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.ObjectRowId_param") && vars.get("$param.ObjectRowId_param")) result.string(vars.get("$param.ObjectRowId_param")); \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/offeritems/children/language_param/valueProcess.js b/entity/Offer_entity/entityfields/offeritems/children/language_param/valueProcess.js index 33d4d6d238c6273767dcb38ba121c6edd66acbea..e157fccd57ad345bc2a47fffdced80dda626cd80 100644 --- a/entity/Offer_entity/entityfields/offeritems/children/language_param/valueProcess.js +++ b/entity/Offer_entity/entityfields/offeritems/children/language_param/valueProcess.js @@ -1,5 +1,4 @@ -import("system.logging"); import("system.vars"); import("system.result"); -logging.log("offer " + vars.get("$field.LANGUAGE")) + result.string(vars.get("$field.LANGUAGE")); diff --git a/entity/Organisation_entity/recordcontainers/db/filterextensions/attribute_filter/filterConditionProcess.js b/entity/Organisation_entity/recordcontainers/db/filterextensions/attribute_filter/filterConditionProcess.js index eb15ffb9a993d391a37488ee099068d97aa656ac..c4a6ddac89829a46dc0bf86b8ab943090f6af753 100644 --- a/entity/Organisation_entity/recordcontainers/db/filterextensions/attribute_filter/filterConditionProcess.js +++ b/entity/Organisation_entity/recordcontainers/db/filterextensions/attribute_filter/filterConditionProcess.js @@ -2,7 +2,6 @@ import("system.db"); import("Context_lib"); import("Sql_lib"); import("Attribute_lib"); -import("system.logging"); import("system.vars"); import("system.result"); @@ -28,5 +27,4 @@ var resSql = "CONTACTID in (select CONTACT.CONTACTID \n\ resSql = db.translateCondition([resSql, preparedValues]); -logging.log("resSql>>" + resSql); result.string(resSql); \ No newline at end of file diff --git a/entity/Person_entity/entityfields/campaignactiongroup/children/addtocampaignfromtable/onActionProcess.js b/entity/Person_entity/entityfields/campaignactiongroup/children/addtocampaignfromtable/onActionProcess.js index 1d8b597ca6f299e1a9f82b72682eef6a35187449..5306ab46adf627dedf15b3c578162ed6720f8fed 100644 --- a/entity/Person_entity/entityfields/campaignactiongroup/children/addtocampaignfromtable/onActionProcess.js +++ b/entity/Person_entity/entityfields/campaignactiongroup/children/addtocampaignfromtable/onActionProcess.js @@ -1,23 +1,21 @@ -import("system.logging"); -import("system.vars"); -import("system.neon"); -import("Campaign_lib"); - -/* - * If there's a selection only those are ought to be added. - * Otherwise the filter gets checked, if a filter has beed set, the condition - * is used to determine the objects to be added. - * If no selection has been set, all objects will be added. - */ -var sysSelection = vars.get("$sys.selection"); - -if(sysSelection.length > 0) //selektierte IDs als Array -{ - CampaignUtils.addParticipantsByRowIds(JSON.stringify(sysSelection), "PERSON"); -} -else -{ - let sysFilter = vars.get("$sys.filter");//todo change name - logging.log("filter -> " + JSON.stringify(sysFilter)); - CampaignUtils.addParticipantsByCondition(JSON.stringify(sysFilter), "PERSON"); +import("system.vars"); +import("system.neon"); +import("Campaign_lib"); + +/* + * If there's a selection only those are ought to be added. + * Otherwise the filter gets checked, if a filter has beed set, the condition + * is used to determine the objects to be added. + * If no selection has been set, all objects will be added. + */ +var sysSelection = vars.get("$sys.selection"); + +if(sysSelection.length > 0) //selektierte IDs als Array +{ + CampaignUtils.addParticipantsByRowIds(JSON.stringify(sysSelection), "PERSON"); +} +else +{ + let sysFilter = vars.get("$sys.filter");//todo change name + CampaignUtils.addParticipantsByCondition(JSON.stringify(sysFilter), "PERSON"); } \ No newline at end of file diff --git a/entity/Person_entity/recordcontainers/db/filterextensions/attribute_filter/filterConditionProcess.js b/entity/Person_entity/recordcontainers/db/filterextensions/attribute_filter/filterConditionProcess.js index e207f370e74536ffc82c512eea7e22ac682b29b2..d74496a97c6722e71e00a96b70234c30f5e76b89 100644 --- a/entity/Person_entity/recordcontainers/db/filterextensions/attribute_filter/filterConditionProcess.js +++ b/entity/Person_entity/recordcontainers/db/filterextensions/attribute_filter/filterConditionProcess.js @@ -3,7 +3,6 @@ import("system.db"); import("Context_lib"); import("Sql_lib"); import("Attribute_lib"); -import("system.logging"); import("system.vars"); import("system.result"); @@ -28,5 +27,4 @@ var resSql = "CONTACTID in (select CONTACT.CONTACTID \n\ resSql = db.translateCondition([resSql, preparedValues]); -logging.log("resSql>>" + resSql); result.string(resSql); \ No newline at end of file diff --git a/entity/Person_entity/recordcontainers/db/onDBUpdate.js b/entity/Person_entity/recordcontainers/db/onDBUpdate.js index 243f0443fb13fbf4db44de0800dbf415e2e973da..e94b093bae13bbb9a87f8344ed4786ff99f5b123 100644 --- a/entity/Person_entity/recordcontainers/db/onDBUpdate.js +++ b/entity/Person_entity/recordcontainers/db/onDBUpdate.js @@ -1,4 +1,3 @@ -import("system.logging"); import("DataPrivacy_lib"); import("system.tools"); import("system.vars"); @@ -8,7 +7,6 @@ import("Entity_lib"); import("StandardObject_lib"); var rowdata = vars.get("$local.rowdata"); -logging.log(JSON.stringify(rowdata, null, "\t")) // TODO: this is a workaround for missing possibility to react on changes of fields not connected to record Contqainer #1030023 var uid = rowdata["CONTACT.CONTACTID"]; FieldChanges.assimilateChangeAndDispose("$field.STANDARD_EMAIL_COMMUNICATION", function(state, value){ diff --git a/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js b/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js index 549dd18c52b622b1419a23e002b166558d30623c..8bb7ef210a16a0ec02600971d745d6ce9b6db042 100644 --- a/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js @@ -1,4 +1,3 @@ -import("system.logging"); import("system.neon"); import("system.result"); import("system.vars"); @@ -140,6 +139,5 @@ if(prodid != "") graphData.forEach(function (gd) { allData.push(gd); }) }) - logging.log(JSON.stringify(allData, null, "\t")) result.object(allData); } \ No newline at end of file diff --git a/entity/Salesproject_entity/entityfields/state/onValueChange.js b/entity/Salesproject_entity/entityfields/state/onValueChange.js index 9ec0f299aac9b97194c4b256ef8cc920ac036a46..df560db2824a9415367216c513b42e7d26131bbd 100644 --- a/entity/Salesproject_entity/entityfields/state/onValueChange.js +++ b/entity/Salesproject_entity/entityfields/state/onValueChange.js @@ -1,11 +1,7 @@ -import("system.logging"); import("Sql_lib"); import("system.vars"); import("system.db"); -logging.log(JSON.stringify(db.cell(SqlCondition.begin() - .andPrepareVars("SALESPROJECT.SALESPROJECTID", "$field.SALESPROJECTID") - .buildSql("select STATE from SALESPROJECT", "1=2")), null, "\t")) vars.set("$context.statusBefore", db.cell(SqlCondition.begin() .andPrepareVars("SALESPROJECT.SALESPROJECTID", "$field.SALESPROJECTID") .buildSql("select STATE from SALESPROJECT", "1=2"))); \ No newline at end of file diff --git a/neonNotificationType/DownloadReady/onResultOpen.js b/neonNotificationType/DownloadReady/onResultOpen.js index 36c2e4242a33907fbc3744b4776675dd74b58459..eeb3fb518402c487ce24684d38dc2ba296b03249 100644 --- a/neonNotificationType/DownloadReady/onResultOpen.js +++ b/neonNotificationType/DownloadReady/onResultOpen.js @@ -1,21 +1,18 @@ -import("system.logging"); -import("system.vars"); - -var varses = [ - "$local.content", - "$local.data", - "$local.description", - "$local.idvalue", - "$local.idvalues", - "$local.row", - "$local.row_id", - "$local.rowdata", - "$local.uid", - "$local.binId", -]; -var existses = {}; -varses.forEach(function (v) { - this[v] = vars.exists(v); -}, existses); - -logging.log(JSON.stringify(existses, null, "\t")) \ No newline at end of file +import("system.vars"); + +var varses = [ + "$local.content", + "$local.data", + "$local.description", + "$local.idvalue", + "$local.idvalues", + "$local.row", + "$local.row_id", + "$local.rowdata", + "$local.uid", + "$local.binId", +]; +var existses = {}; +varses.forEach(function (v) { + this[v] = vars.exists(v); +}, existses); \ No newline at end of file diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js index 8ea4702b786e90b31e378581787e1e4b2cd0bdde..48311a024265ef1f7b72004b450fd0c3de399559 100644 --- a/process/Attribute_lib/process.js +++ b/process/Attribute_lib/process.js @@ -1,4 +1,3 @@ -import("system.logging"); import("Context_lib"); import("system.util"); import("system.datetime"); @@ -868,7 +867,6 @@ AttributeUsageUtil.updateChildrenUsages = function (pAttributeId, pOldObjectType .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", pAttributeId); var query = sqlSelect.where(condition); var attributes = db.table(query.build()); - logging.log(JSON.stringify(attributes, null, "\t")) attributes.forEach(function (row) { diff --git a/process/Context_lib/process.js b/process/Context_lib/process.js index 179cb9b79349b7cb53a988ddf70736b9e22ef544..f859d6b4f33109c9429b039619ece912870306fb 100644 --- a/process/Context_lib/process.js +++ b/process/Context_lib/process.js @@ -537,7 +537,6 @@ ContextUtils.getContextDataSql = function(pContextId, pContactId, pWithDate, pAc var cond = SqlCondition.begin(); if (pContactId) { - logging.log(JSON.stringify(ownContextSelector, null, "\t")) cond.andPrepare(ownContextSelector.getFullField(ownContextSelector.contactIdField), pContactId) } @@ -592,13 +591,10 @@ ContextUtils.getCountByContactId = function(pContextId, pContactId) var tableName = contextObject.tableName; var contactField = contextObject.getFullField(contextObject.contactIdField) var join = contextObject.joinExpression; - logging.log(tableName + " " + contactField) if (tableName && contactField) { var sql = "select count(*) from " + tableName + (join ? join : ""); - logging.log(sql + " " + pContactId); var count = db.cell(SqlCondition.begin().andPrepare(contactField, pContactId).buildSql(sql, "1=2")); - logging.log(count); return count; } return 0; diff --git a/process/Salesproject_lib/process.js b/process/Salesproject_lib/process.js index c2258732e3551f554af14495792969ae98735cdc..cf89a78d1c5461a5d6bff5c8adf6e91e2568d172 100644 --- a/process/Salesproject_lib/process.js +++ b/process/Salesproject_lib/process.js @@ -1,117 +1,115 @@ -import("system.logging"); -import("Sql_lib"); -import("system.neon"); -import("system.vars"); -import("system.util"); -import("system.translate"); -import("system.db"); -import("system.eMath"); -import("system.question"); -import("Util_lib"); -import("Keyword_lib"); -import("system.neonTools"); -/** - * Methods used by the Salesproject. - * Do not create an instance of this! - * - * @class - */ -function Salesproject() {} - -/** - * Delivers the next valid project number (has to be unique) - * - * @result {String} next valid project number - */ -Salesproject.getNextProjectNumber = function() { - return NumberSequencingUtils.getNextUniqueNumber("PROJECTCODE", "SALESPROJECT"); -} - -/** - * Checks if the passed project number is valid (has to be unique) - * - * @param {String} projectNumber project number to check - * - * @result {Boolean} passed number is valid - */ -Salesproject.validateProjectNumber = function(projectNumber) { - return NumberSequencingUtils.validateUniqueNumber(projectNumber, "PROJECTCODE", "SALESPROJECT"); -} - -/** - * Insert a new milestone. - * - * @param {String} salesprojectId of the salesproject - * @param {Integer} type can be any value of the keyword SALESPROJECT.MILESTONE.TYPE - * @param {Integer} value value of the phase or state - * @param {Boolean} [notifyForecast=false] if true, notify user to update the forecast - * - * @result {Boolean} true if inserted, else false - */ -Salesproject.insertMilestone = function(salesprojectId, type, value, notifyForecast) { - if (KeywordUtils.exists(value, type)) { - var id= db.cell(SqlCondition.begin() - .andPrepare("SALESPROJECT_MILESTONE.SALESPROJECT_ID", salesprojectId) - .andPrepare("SALESPROJECT_MILESTONE.TYPE", type) - .and("SALESPROJECT_MILESTONE.DATE_END is null") - .buildSql("select SALESPROJECT_MILESTONE.SALESPROJECT_MILESTONEID from SALESPROJECT_MILESTONE ")); - - logging.log("id = " + id) - - db.updateData( - "SALESPROJECT_MILESTONE", - ["DATE_END"], - null, - [vars.get("$sys.date")], - SqlCondition.begin() - .andPrepare("SALESPROJECT_MILESTONE.SALESPROJECT_ID", salesprojectId) - .andPrepare("SALESPROJECT_MILESTONE.TYPE", type) - .and("SALESPROJECT_MILESTONE.DATE_END is null") - .build("1=2")); - - db.insertData( - "SALESPROJECT_MILESTONE", - ["SALESPROJECT_MILESTONEID", "SALESPROJECT_ID", "TYPE", "VALUE", "DATE_START", "PARENT_ID"], - null, - [util.getNewUUID(), salesprojectId, type, value, vars.get("$sys.date"), id]); - if (notifyForecast) { - Salesproject.notifyToUpdateForecast() - } - return true; - } - return false; -} - -/** - * Notify the user to update the forecast - */ -Salesproject.notifyToUpdateForecast = function() { - if (vars.get("$sys.recordstate") != neon.OPERATINGSTATE_NEW) - question.showMessage(translate.text("Please update the ${FORECAST_ENGLISH}."), question.INFORMATION, translate.text("${FORECAST_ENGLISH}")); -} - -/** - * get the title of a salesproject by id - * @param {String} pSalesProjectId - * <br> - * @return {String} title of the salesproject - */ -Salesproject.getSalesProjectTitleById = function(pSalesProjectId) -{ - return db.cell( SqlCondition.begin() - .andPrepare("SALESPROJECT.SALESPROJECTID", pSalesProjectId) - .buildSql("select PROJECTTITLE from SALESPROJECT", "1=0")); -} - -/** - * Create a new Salesproject and open the Salesproject context in NEW-mode - */ -Salesproject.createNewSalesproject= function(pRelationId) -{ - var params = {}; - - if (pRelationId) - params["ContactId_param"] = pRelationId; - - neon.openContext("Salesproject", null, null, neon.OPERATINGSTATE_NEW, params); +import("Sql_lib"); +import("system.neon"); +import("system.vars"); +import("system.util"); +import("system.translate"); +import("system.db"); +import("system.eMath"); +import("system.question"); +import("Util_lib"); +import("Keyword_lib"); +import("system.neonTools"); +/** + * Methods used by the Salesproject. + * Do not create an instance of this! + * + * @class + */ +function Salesproject() {} + +/** + * Delivers the next valid project number (has to be unique) + * + * @result {String} next valid project number + */ +Salesproject.getNextProjectNumber = function() { + return NumberSequencingUtils.getNextUniqueNumber("PROJECTCODE", "SALESPROJECT"); +} + +/** + * Checks if the passed project number is valid (has to be unique) + * + * @param {String} projectNumber project number to check + * + * @result {Boolean} passed number is valid + */ +Salesproject.validateProjectNumber = function(projectNumber) { + return NumberSequencingUtils.validateUniqueNumber(projectNumber, "PROJECTCODE", "SALESPROJECT"); +} + +/** + * Insert a new milestone. + * + * @param {String} salesprojectId of the salesproject + * @param {Integer} type can be any value of the keyword SALESPROJECT.MILESTONE.TYPE + * @param {Integer} value value of the phase or state + * @param {Boolean} [notifyForecast=false] if true, notify user to update the forecast + * + * @result {Boolean} true if inserted, else false + */ +Salesproject.insertMilestone = function(salesprojectId, type, value, notifyForecast) { + if (KeywordUtils.exists(value, type)) { + var id= db.cell(SqlCondition.begin() + .andPrepare("SALESPROJECT_MILESTONE.SALESPROJECT_ID", salesprojectId) + .andPrepare("SALESPROJECT_MILESTONE.TYPE", type) + .and("SALESPROJECT_MILESTONE.DATE_END is null") + .buildSql("select SALESPROJECT_MILESTONE.SALESPROJECT_MILESTONEID from SALESPROJECT_MILESTONE ")); + + + db.updateData( + "SALESPROJECT_MILESTONE", + ["DATE_END"], + null, + [vars.get("$sys.date")], + SqlCondition.begin() + .andPrepare("SALESPROJECT_MILESTONE.SALESPROJECT_ID", salesprojectId) + .andPrepare("SALESPROJECT_MILESTONE.TYPE", type) + .and("SALESPROJECT_MILESTONE.DATE_END is null") + .build("1=2")); + + db.insertData( + "SALESPROJECT_MILESTONE", + ["SALESPROJECT_MILESTONEID", "SALESPROJECT_ID", "TYPE", "VALUE", "DATE_START", "PARENT_ID"], + null, + [util.getNewUUID(), salesprojectId, type, value, vars.get("$sys.date"), id]); + if (notifyForecast) { + Salesproject.notifyToUpdateForecast() + } + return true; + } + return false; +} + +/** + * Notify the user to update the forecast + */ +Salesproject.notifyToUpdateForecast = function() { + if (vars.get("$sys.recordstate") != neon.OPERATINGSTATE_NEW) + question.showMessage(translate.text("Please update the ${FORECAST_ENGLISH}."), question.INFORMATION, translate.text("${FORECAST_ENGLISH}")); +} + +/** + * get the title of a salesproject by id + * @param {String} pSalesProjectId + * <br> + * @return {String} title of the salesproject + */ +Salesproject.getSalesProjectTitleById = function(pSalesProjectId) +{ + return db.cell( SqlCondition.begin() + .andPrepare("SALESPROJECT.SALESPROJECTID", pSalesProjectId) + .buildSql("select PROJECTTITLE from SALESPROJECT", "1=0")); +} + +/** + * Create a new Salesproject and open the Salesproject context in NEW-mode + */ +Salesproject.createNewSalesproject= function(pRelationId) +{ + var params = {}; + + if (pRelationId) + params["ContactId_param"] = pRelationId; + + neon.openContext("Salesproject", null, null, neon.OPERATINGSTATE_NEW, params); } \ No newline at end of file