From a4a89ef97b65684b03b9ffb0a15b7e0a6aebaf7a Mon Sep 17 00:00:00 2001 From: "d.lechner" <d.lechner@adito.de> Date: Thu, 25 Jul 2019 15:29:20 +0200 Subject: [PATCH] Remove logging.log --- .../recordcontainers/jdito/contentProcess.js | 2 - .../recordcontainers/jdito/onInsert.js | 2 - .../recordcontainers/jdito/contentProcess.js | 2 - .../entityfields/recipient/stateProcess.js | 2 - .../entityfields/value/contentTypeProcess.js | 2 - .../entityfields/condition/valueProcess.js | 3 - .../entityfields/parameter/valueProcess.js | 2 - .../entityfields/icon/valueProcess.js | 8 +- .../entityfields/contact_id/onValidation.js | 12 - .../entityfields/contact_id/onValueChange.js | 3 - .../entityfields/object_rowid/valueProcess.js | 2 - .../children/language_param/valueProcess.js | 3 +- .../filterConditionProcess.js | 2 - .../addtocampaignfromtable/onActionProcess.js | 42 ++-- .../filterConditionProcess.js | 2 - .../recordcontainers/db/onDBUpdate.js | 2 - .../recordcontainers/jdito/contentProcess.js | 2 - .../entityfields/state/onValueChange.js | 4 - .../DownloadReady/onResultOpen.js | 39 ++- process/Attribute_lib/process.js | 2 - process/Context_lib/process.js | 4 - process/Salesproject_lib/process.js | 230 +++++++++--------- 22 files changed, 154 insertions(+), 218 deletions(-) diff --git a/entity/360Degree_entity/recordcontainers/jdito/contentProcess.js b/entity/360Degree_entity/recordcontainers/jdito/contentProcess.js index 953a229acb..92fef480e5 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 c995f2f3bd..48de276e37 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 52a61eb71a..5a78999dea 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 756911b924..3e96a7bc47 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 44303ce0e6..f12ab2a78c 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 395c147d36..c1041366b8 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 7ac009f93f..9eab3ae2e0 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 71433b6fd1..73958ed988 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 98c4fef71d..e69de29bb2 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 c90065cca0..525a255e12 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 29bb85ddce..8682d1f41d 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 33d4d6d238..e157fccd57 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 eb15ffb9a9..c4a6ddac89 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 1d8b597ca6..5306ab46ad 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 e207f370e7..d74496a97c 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 243f0443fb..e94b093bae 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 549dd18c52..8bb7ef210a 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 9ec0f299aa..df560db282 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 36c2e4242a..eeb3fb5184 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 8ea4702b78..48311a0242 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 179cb9b793..f859d6b4f3 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 c2258732e3..cf89a78d1c 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 -- GitLab