Skip to content
Snippets Groups Projects
Commit f7f2d770 authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

fix object tree and salesproject

parent d8ca8647
No related branches found
No related tags found
No related merge requests found
...@@ -129,6 +129,9 @@ ...@@ -129,6 +129,9 @@
<valueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/objectrelationtypeid/valueProcess.js</valueProcess> <valueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/objectrelationtypeid/valueProcess.js</valueProcess>
<displayValueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/objectrelationtypeid/displayValueProcess.js</displayValueProcess> <displayValueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/objectrelationtypeid/displayValueProcess.js</displayValueProcess>
<onValueChange>%aditoprj%/entity/ObjectTree_entity/entityfields/objectrelationtypeid/onValueChange.js</onValueChange> <onValueChange>%aditoprj%/entity/ObjectTree_entity/entityfields/objectrelationtypeid/onValueChange.js</onValueChange>
<onValueChangeTypes>
<element>MASK</element>
</onValueChangeTypes>
</entityField> </entityField>
<entityConsumer> <entityConsumer>
<name>Objects</name> <name>Objects</name>
......
...@@ -101,6 +101,8 @@ ...@@ -101,6 +101,8 @@
<onValueChange>%aditoprj%/entity/Salesproject_entity/entityfields/state/onValueChange.js</onValueChange> <onValueChange>%aditoprj%/entity/Salesproject_entity/entityfields/state/onValueChange.js</onValueChange>
<onValueChangeTypes> <onValueChangeTypes>
<element>MASK</element> <element>MASK</element>
<element>PROCESS</element>
<element>PROCESS_SETVALUE</element>
</onValueChangeTypes> </onValueChangeTypes>
</entityField> </entityField>
<entityField> <entityField>
......
import("system.vars"); import("system.logging");
import("Sql_lib"); import("Sql_lib");
import("system.vars");
import("system.db"); import("system.db");
import("KeywordRegistry_basic");
import("Keyword_lib");
import("system.translate");
import("system.question");
import("system.neon");
if (vars.get("$sys.recordstate") != neon.OPERATINGSTATE_NEW)
{
var state = vars.get("local.value");
// Postponed
if (state == $KeywordRegistry.salesprojectState$postponed())
{
var stateName = KeywordUtils.getViewValue($KeywordRegistry.salesprojectState(), state);
var clearForecast = question.askYesNo(translate.withArguments("Clear forecast and set state to '%0'?", [stateName]), translate.withArguments("Would you really like to clear the forecast and set the state to '%0'?", [stateName]) + "\n" + translate.text("This cannot be undone!"), false);
if (!clearForecast) logging.log(JSON.stringify(db.cell(SqlCondition.begin()
{ .andPrepareVars("SALESPROJECT.SALESPROJECTID", "$field.SALESPROJECTID")
// reset to value from db .buildSql("select STATE from SALESPROJECT", "1=2")), null, "\t"))
neon.setFieldValue("$field.STATE", db.cell(SqlCondition.begin() vars.set("$context.statusBefore", db.cell(SqlCondition.begin()
.andPrepareVars("SALESPROJECT.SALESPROJECTID", "$field.SALESPROJECTID") .andPrepareVars("SALESPROJECT.SALESPROJECTID", "$field.SALESPROJECTID")
.buildSql("select STATE from SALESPROJECT", "1=2"))); .buildSql("select STATE from SALESPROJECT", "1=2")));
} \ No newline at end of file
}
}
import("system.logging");
import("Context_lib");
import("system.neon"); import("system.neon");
import("system.translate"); import("system.translate");
import("system.vars"); import("system.vars");
...@@ -31,7 +33,10 @@ vars.get("$local.changed").forEach(function(fieldName) { ...@@ -31,7 +33,10 @@ vars.get("$local.changed").forEach(function(fieldName) {
if (state == $KeywordRegistry.salesprojectState$lost()) if (state == $KeywordRegistry.salesprojectState$lost())
{ {
// set all offers of the salesproject to lost // set all offers of the salesproject to lost
db.updateData("OFFER", ["STATUS"], null, [$KeywordRegistry.offerStatus$lost()], SqlCondition.equals("OFFER.OBJECT_ROWID", vars.getString("$local.uid"), "1=2")); db.updateData("OFFER", ["STATUS"], null, [$KeywordRegistry.offerStatus$lost()], SqlCondition.begin()
.andPrepare("OFFER.OBJECT_ROWID", vars.getString("$local.uid"))
.andPrepare("OFFER.OBJECT_TYPE", ContextUtils.getCurrentContextId())
.build("1=2"));
_updateReasons(); _updateReasons();
clearReason = false; clearReason = false;
} }
...@@ -39,16 +44,31 @@ vars.get("$local.changed").forEach(function(fieldName) { ...@@ -39,16 +44,31 @@ vars.get("$local.changed").forEach(function(fieldName) {
else if (state == $KeywordRegistry.salesprojectState$order()) else if (state == $KeywordRegistry.salesprojectState$order())
{ {
// set all competitions of the salesproject to lost // set all competitions of the salesproject to lost
db.updateData("COMPETITION", ["STATUS"], null, [$KeywordRegistry.competitionState$lost()], SqlCondition.equals("COMPETITION.OBJECT_ROWID", vars.getString("$local.uid"), "1=2")); db.updateData("COMPETITION", ["STATUS"], null, [$KeywordRegistry.competitionState$lost()], SqlCondition.begin()
.andPrepare("COMPETITION.OBJECT_ROWID", vars.getString("$local.uid"))
.andPrepare("COMPETITION.OBJECT_TYPE", ContextUtils.getCurrentContextId())
.build("1=2"));
_updateReasons(); _updateReasons();
clearReason = false; clearReason = false;
} }
// Postponed // Postponed
else if (state == $KeywordRegistry.salesprojectState$postponed()) else if (state == $KeywordRegistry.salesprojectState$postponed())
{ {
// do not notify as the user just got a question, if he really would like to clear the forecast // ask if forecast should be cleared. Else reset to old value.
needToUpdateForecast = false; var stateName = KeywordUtils.getViewValue($KeywordRegistry.salesprojectState(), state);
db.deleteData("FORECAST", SqlCondition.equals("FORECAST.OBJECT_ROWID", vars.getString("$local.uid"), "1=2")); var clearForecast = question.askYesNo(translate.withArguments("Clear forecast and set state to '%0'?", [stateName]), translate.withArguments("Would you really like to clear the forecast and set the state to '%0'?", [stateName]) + "\n" + translate.text("This cannot be undone!"), false);
if (!clearForecast)
{
// reset to value from db
db.updateData("SALESPROJECT", ["STATE"], null, [vars.get("$context.statusBefore")], SqlCondition.begin()
.andPrepare("SALESPROJECT.SALESPROJECTID", vars.getString("$local.uid"))
.build("1=2"));
} else {
// do not notify as the user just got a question, if he really would like to clear the forecast
needToUpdateForecast = false;
db.deleteData("FORECAST", SqlCondition.equals("FORECAST.OBJECT_ROWID", vars.getString("$local.uid"), "1=2"));
}
} }
// if state changed, but not to one of the above states // if state changed, but not to one of the above states
else else
...@@ -58,7 +78,7 @@ vars.get("$local.changed").forEach(function(fieldName) { ...@@ -58,7 +78,7 @@ vars.get("$local.changed").forEach(function(fieldName) {
break; break;
} }
// It clearReason is undefined, it the state did not change. So do nothing // If clearReason is undefined, it the state did not change. So do nothing
if (clearReason != undefined) if (clearReason != undefined)
{ {
_clearReasons(clearReason); _clearReasons(clearReason);
...@@ -70,13 +90,15 @@ vars.get("$local.changed").forEach(function(fieldName) { ...@@ -70,13 +90,15 @@ vars.get("$local.changed").forEach(function(fieldName) {
if (needToUpdateForecast === null) if (needToUpdateForecast === null)
needToUpdateForecast = true; needToUpdateForecast = true;
Salesproject.insertMilestone(vars.getString("$local.uid"), typeValue, vars.getString(fieldVar)); Salesproject.insertMilestone(vars.getString("$local.uid"), typeValue, rowdata[fieldName]);
} }
}); });
if (needToUpdateForecast) if (needToUpdateForecast)
Salesproject.notifyToUpdateForecast(); Salesproject.notifyToUpdateForecast();
neon.refreshAll();
function _updateReasons() function _updateReasons()
{ {
var reasons = rowdata["SALESPROJECT.REASONS"]; var reasons = rowdata["SALESPROJECT.REASONS"];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment