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

[Projekt: Entwicklung - Neon][TicketNr.: 1032636][Vertrieb - Angebot - Wann...

[Projekt: Entwicklung - Neon][TicketNr.: 1032636][Vertrieb - Angebot - Wann ist das Feld "Vertriebsprojekt" verpflichtend]
parent 9b88b3e7
No related branches found
No related tags found
No related merge requests found
......@@ -73,7 +73,7 @@
<name>SALESPROJECT_ID</name>
<title>Salesproject</title>
<linkedContext>Salesproject_context</linkedContext>
<mandatory v="true" />
<mandatoryProcess>%aditoprj%/entity/Offer_entity/entityfields/salesproject_id/mandatoryProcess.js</mandatoryProcess>
<outgoingField>OfferSalesproject_dfo</outgoingField>
<state>INVISIBLE</state>
<stateProcess>%aditoprj%/entity/Offer_entity/entityfields/salesproject_id/stateProcess.js</stateProcess>
......@@ -254,6 +254,7 @@
<entityField>
<name>RELATION_ORG_ID</name>
<searchable v="false" />
<valueProcess>%aditoprj%/entity/Offer_entity/entityfields/relation_org_id/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>RELATION_PERS_ID</name>
......
import("system.vars");
import("system.result");
import("Relation_lib");
var type = RelationUtils.getRelationType(vars.get("$field.RELATION_ID"), vars.get("$field.RELATION_PERS_ID"), vars.get("$field.RELATION_ORG_ID"));
result.string(type != 2);
......@@ -23,5 +23,4 @@ if(oid != "")
db.updateData("OFFER", cols, null, vals, SqlCondition.equals("OFFER.OFFERID", oid, "1 = 2"));
neon.refresh();
}
\ No newline at end of file
......@@ -2,4 +2,4 @@ import("system.result");
import("system.vars");
import("Relation_lib")
result.object(RelationUtils.getRelationTypeByPersOrg(vars.get("$field.PERS_ID"), vars.get("$field.ORG_ID")));
\ No newline at end of file
result.object(RelationUtils.getRelationType(vars.get("$field.RELATIONID"), vars.get("$field.PERS_ID"), vars.get("$field.ORG_ID")));
\ No newline at end of file
import("system.neon");
import("system.vars");
import("system.result");
import("system.db");
......@@ -12,6 +13,43 @@ import("Context_lib");
*/
function RelationUtils() {}
/**
* Get the type of relation. <br>
* In recordstate NEW or EDIT it loads the pers- / orgid from the db.<br>
* But in the other states it uses the values pPersId, pOrgId directly (for performance).<br>
* <br>
* It only checks if pPersId / pOrgId are not empty. <br>
* Based on which parameter is empty / not empty it return s the type of the relation. <br>
* <br>
* !!It does not check if the pers / org ids really exist!! <br>
* !!And it does not check if really any relation with this pers / org ids exist!! <br>
* <br>
* <br>
* It is meant to be used by entitys, where you can load pers and org with the DataRecord. <br>
* This saves an extra select from RELATION. <br>
* <br>
* <br>
* @param {String} pRelationId
* @param {String} pPersId selected from the RELATION table
* @param {String} pOrgId selected from the RELATION table
* <br>
* @return {Integer} <br>0 if both ids are empty <br>
* 1 if organisation <br>
* 2 if privat person <br>
* 3 if person of an organisation <br>
*/
RelationUtils.getRelationType = function(pRelationId, pPersId, pOrgId)
{
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)
{
return RelationUtils.getRelationTypeByRelation(pRelationId);
}
else
{
return RelationUtils.getRelationTypeByPersOrg(pPersId, pOrgId);
}
}
/**
* get the type of relation for a relationId <br>
* If you already have persId and orgId from the RELATION table, use getRelationTypeByPersOrg() <br>
......
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