Skip to content
Snippets Groups Projects
Commit 1cf831d7 authored by S.Listl's avatar S.Listl
Browse files

org report attributes

parent 75c454fa
No related branches found
No related tags found
No related merge requests found
import("system.logging");
import("system.util");
import("system.result");
import("system.neon");
import("system.vars");
logging.log("recordstate = " + vars.get("$sys.recordstate"))
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && !vars.get("$this.value"))
{
result.string("DE");
......
......@@ -609,7 +609,7 @@
<entityActionField>
<name>newAppointment</name>
<fieldType>ACTION</fieldType>
<title>new Appointment</title>
<title>New appointment</title>
<onActionProcess>%aditoprj%/entity/Organisation_entity/entityfields/newappointment/onActionProcess.js</onActionProcess>
<iconId>VAADIN:CALENDAR</iconId>
<tooltip>New Appointment</tooltip>
......
......@@ -707,7 +707,7 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
</entityField>
<entityField>
<name>POSITION</name>
<title>Posistion</title>
<title>Position</title>
</entityField>
<entityField>
<name>CONTACTROLE</name>
......
......@@ -2451,6 +2451,9 @@
<entry>
<key>New Appointment</key>
</entry>
<entry>
<key>New contact</key>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
<sqlModels>
......
......@@ -1740,6 +1740,10 @@
<key>Product_functionality</key>
<value>Produkt_Funktionalität</value>
</entry>
<entry>
<key>New appointment</key>
<value>Neuer Termin</value>
</entry>
<entry>
<key>Bulgaria</key>
<value>Bulgarien</value>
......@@ -3174,7 +3178,7 @@
<value>Funktion</value>
</entry>
<entry>
<key>new contact</key>
<key>New contact</key>
<value>Neuer Kontakt</value>
</entry>
<entry>
......@@ -3183,6 +3187,10 @@
<entry>
<key>Object tree</key>
</entry>
<entry>
<key>new contact</key>
<value>Neuer Kontakt</value>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
</language>
......@@ -2475,6 +2475,9 @@
<entry>
<key>New Appointment</key>
</entry>
<entry>
<key>New contact</key>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
</language>
import("system.datetime");
import("system.translate");
import("system.neon");
import("system.vars");
import("system.db");
import("Sql_lib");
import("Keyword_lib");
/**
* Provides functions for the work with attributes, like
......@@ -153,7 +155,7 @@ AttributeRelationUtils.getAttribute = function (pAttributeId, pObjectRowId, pObj
if (pObjectType != null)
attrCond.andPrepare("AB_ATTRIBUTERELATION.OBJECT_TYPE", pAttributeId);
var attributeSql = attrCond.buildSql("select ATTRIBUTE_TYPE, " + AttributeTypeUtil.getAllDatabaseFields()
var attributeSql = attrCond.buildSql("select ATTRIBUTE_TYPE, " + AttributeTypeUtil.getAllDatabaseFields().join(", ")
+ " from AB_ATTRIBUTERELATION join AB_ATTRIBUTE on AB_ATTRIBUTE_ID = AB_ATTRIBUTEID");
var attributeValues = db.array(db.ROW, attributeSql);
if (attributeValues.length == 0)
......@@ -163,6 +165,51 @@ AttributeRelationUtils.getAttribute = function (pAttributeId, pObjectRowId, pObj
return attributeValues[valueIndex];
}
/**
* gets all attributes for a dataset
*
* @param {String} pObjectRowId object rowid
* @param {String} [pObjectType=null] object-type
* @param {String} [pResolveNames=false] if true the full attribute names are used instead of the ids
*
* @return {String[][]} two-dimensional array a row is [attributeId|attributeName, value]
*/
AttributeRelationUtils.getAllAttributes = function (pObjectRowId, pObjectType, pResolveNames)
{
var attrCond = SqlCondition.begin()
.andPrepare("AB_ATTRIBUTERELATION.OBJECT_ROWID", pObjectRowId);
if (pObjectType != null)
attrCond.andPrepare("AB_ATTRIBUTERELATION.OBJECT_TYPE", pAttributeId);
var attributeSql = attrCond.buildSql("select AB_ATTRIBUTE_ID, AB_ATTRIBUTE.ATTRIBUTE_TYPE, AB_ATTRIBUTE.KEYWORD_CONTAINER, COMBOVAL.ATTRIBUTE_NAME, "
+ AttributeTypeUtil.getAllDatabaseFields().join(", ")
+ " from AB_ATTRIBUTERELATION join AB_ATTRIBUTE on AB_ATTRIBUTE_ID = AB_ATTRIBUTE.AB_ATTRIBUTEID"
+ " left join AB_ATTRIBUTE COMBOVAL on " + $AttributeTypes.COMBO.databaseField + " = COMBOVAL.AB_ATTRIBUTEID");
var attributeNameMap = {};
var attributeValues = db.table(attributeSql).map(function (row)
{
let attribute = row[0];
if (pResolveNames)
{
if (!(attribute in attributeNameMap))
attributeNameMap[attribute] = AttributeUtil.getFullAttributeName(attribute);
attribute = attributeNameMap[attribute];
}
let value;
if (row[1].trim() == $AttributeTypes.COMBO)
value = row[3];
else
{
value = row[AttributeTypeUtil.getTypeColumnIndex(row[1]) + 4];
value = AttributeTypeUtil.getAttributeViewValue(row[1].trim(), value, row[2]);
}
return [attribute, value];
});
return attributeValues;
}
AttributeRelationUtils.getAttributes = function ()
{
//TODO: implement maybe
......@@ -282,7 +329,11 @@ $AttributeTypes.DATE = {
keyword : "DATE",
contentType : "DATE",
databaseField : "DATE_VALUE",
entityField : "DATE_VALUE"
entityField : "DATE_VALUE",
getViewValue : function (pValue)
{
return datetime.toDate(pValue, translate.text("dd.MM.yyyy"));
}
};
$AttributeTypes.NUMBER = {
toString : function () {return this.keyword},
......@@ -296,7 +347,11 @@ $AttributeTypes.BOOLEAN = {
keyword : "BOOLEAN",
contentType : "BOOLEAN",
databaseField : "BOOL_VALUE",
entityField : "BOOL_VALUE"
entityField : "BOOL_VALUE",
getViewValue : function (pValue)
{
return pValue == "1" ? translate.text("Yes") : translate.text("No");
}
};
$AttributeTypes.COMBO = {
toString : function () {return this.keyword},
......@@ -324,7 +379,11 @@ $AttributeTypes.KEYWORD = {
keyword : "KEYWORD",
contentType : "UNKNOWN",
databaseField : "ID_VALUE",
entityField : "ID_VALUE"
entityField : "ID_VALUE",
getViewValue : function (pValue, pKeyword)
{
return KeywordUtils.getViewValue(pKeyword, pValue);
}
};
$AttributeTypes.MEMO = {
toString : function () {return this.keyword},
......@@ -380,18 +439,11 @@ AttributeTypeUtil.getDatabaseField = function (pAttributeType)
return null;
}
/**
* returns the name of the given attribute type
*
* @param {String} pAttributeType the attribute type
* (use the values of the AttributeTypes object, e. g. AttributeTypes.TEXT)
* @return {String} the name the attribute
*/
AttributeTypeUtil.getName = function (pAttributeType)
AttributeTypeUtil.getAttributeViewValue = function (pAttributeType, pValue, pKeyword)
{
if (pAttributeType in $AttributeTypes)
return translate.text($AttributeTypes[pAttributeType].displayName);
return null;
if (pAttributeType in $AttributeTypes && "getViewValue" in $AttributeTypes[pAttributeType])
return $AttributeTypes[pAttributeType].getViewValue(pValue, pKeyword);
return pValue;
}
AttributeTypeUtil._initTypeColumnData = function ()
......
......@@ -5,6 +5,7 @@ import("Binary_lib");
import("Report_lib");
import("Sql_lib");
import("Keyword_lib");
import("Attribute_lib");
import("PostalAddress_lib");
import("Communication_lib");
import("KeywordRegistry_basic");
......@@ -84,7 +85,7 @@ OrgUtils.openOrgReport = function(pOrgId)
//select people from the organization
var persSql = "select SALUTATION, TITLE, FIRSTNAME, LASTNAME "
+ ",'' as PERSFUNCITON, '' as PERSDEPARTMENT "//TODO: Position und Abteilung fehlen noch
+ ",CONTACTROLE as PERSFUNCITON, DEPARTMENT as PERSDEPARTMENT "
+ ",(" + CommUtil.getStandardSubSqlMail() + ")"
+ ",(" + CommUtil.getStandardSubSqlPhone() + ")"
+ ",ORGANISATION_ID, CONTACTID "
......@@ -120,8 +121,9 @@ OrgUtils.openOrgReport = function(pOrgId)
});
histData = ReportData.begin(["ENTRYDATE", "MEDIUM", "LOGIN", "INFO"]).add(histData);
var attr = ""; //TODO: this should be a string with the attributes
var attr = AttributeRelationUtils.getAllAttributes(pOrgId, null, true)
.map(function (row) {return row.join(": ")})
.join("\n");
//tasks
var taskSql = "select TASK.SUBJECT, TASK.DESCRIPTION, TASK.STATUS, FIRSTNAME, LASTNAME from TASK"
......
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