diff --git a/entity/CampaignStep_entity/CampaignStep_entity.aod b/entity/CampaignStep_entity/CampaignStep_entity.aod index 21312819fdaa875d9afcf2e45cc1d1c63a1634f3..8a97d786370d05ca32f97e362b2776406056cce6 100644 --- a/entity/CampaignStep_entity/CampaignStep_entity.aod +++ b/entity/CampaignStep_entity/CampaignStep_entity.aod @@ -23,6 +23,7 @@ <entityField> <name>NAME</name> <title>Name</title> + <mandatory v="true" /> </entityField> <entityField> <name>DATE_START</name> @@ -30,6 +31,7 @@ <contentType>DATE</contentType> <resolution>DAY</resolution> <outputFormat>dd.MM.yyyy</outputFormat> + <mandatory v="true" /> </entityField> <entityField> <name>DATE_END</name> @@ -37,14 +39,18 @@ <contentType>DATE</contentType> <resolution>DAY</resolution> <outputFormat>dd.MM.yyyy</outputFormat> + <mandatory v="true" /> </entityField> <entityField> <name>STATE</name> <title>Status</title> + <mandatory v="true" /> </entityField> <entityField> <name>SORTING</name> <title>Reihenfolge</title> + <contentType>NUMBER</contentType> + <mandatory v="true" /> </entityField> <entityField> <name>USER_NEW</name> @@ -89,6 +95,7 @@ </entityParameter> <entityConsumer> <name>CampaignParticipantsConsumer</name> + <title>Teilnehmer</title> <fieldType>DEPENDENCY_OUT</fieldType> <dependency> <name>dependency</name> @@ -99,15 +106,11 @@ <entityParameter> <name>CampaignIdParameter</name> <valueProcess>%aditoprj%/entity/CampaignStep_entity/entityfields/campaignparticipantsconsumer/children/campaignidparameter/valueProcess.js</valueProcess> - <expose v="false" /> - <mandatory v="true" /> </entityParameter> <entityParameter> <name>CampaignStepIdParameter</name> <title></title> <valueProcess>%aditoprj%/entity/CampaignStep_entity/entityfields/campaignparticipantsconsumer/children/campaignstepidparameter/valueProcess.js</valueProcess> - <expose v="false" /> - <mandatory v="true" /> </entityParameter> </children> </entityConsumer> @@ -117,6 +120,7 @@ <name>db</name> <alias>Data_alias</alias> <conditionProcess>%aditoprj%/entity/CampaignStep_entity/recordcontainers/db/conditionProcess.js</conditionProcess> + <orderClauseProcess>%aditoprj%/entity/CampaignStep_entity/recordcontainers/db/orderClauseProcess.js</orderClauseProcess> <linkInformation> <linkInformation> <name>0199eaa2-5fc5-4f91-a1ec-a9bc77117f69</name> diff --git a/entity/CampaignStep_entity/entityfields/campaign_id/valueProcess.js b/entity/CampaignStep_entity/entityfields/campaign_id/valueProcess.js index a75d01ab7d6fb2f12099a870fea61a3f25fa7c12..7ae7bfcabecdf73776a9fed9fe3cdb09f4485c28 100644 --- a/entity/CampaignStep_entity/entityfields/campaign_id/valueProcess.js +++ b/entity/CampaignStep_entity/entityfields/campaign_id/valueProcess.js @@ -1,6 +1,7 @@ +import("system.logging"); import("system.result"); import("system.vars"); -loggin.log("______CampaignStep_Campaign_ID_valueProcess: -> " + vars.get("$param.campaignId_param")); +logging.log("______CampaignStep_Campaign_ID_valueProcess: -> " + vars.get("$param.campaignId_param")); if(vars.exists("$param.campaignId_param") && vars.get("$param.campaignId_param")) result.string(vars.get("$param.campaignId_param")); \ No newline at end of file diff --git a/entity/CampaignStep_entity/entityfields/campaignparticipantsconsumer/children/campaignidparameter/valueProcess.js b/entity/CampaignStep_entity/entityfields/campaignparticipantsconsumer/children/campaignidparameter/valueProcess.js index 2322e402b175ab2f03738a164d047356484ac90a..ccbf0377ddbaff70e34757a7873b84dc41d7512d 100644 --- a/entity/CampaignStep_entity/entityfields/campaignparticipantsconsumer/children/campaignidparameter/valueProcess.js +++ b/entity/CampaignStep_entity/entityfields/campaignparticipantsconsumer/children/campaignidparameter/valueProcess.js @@ -2,5 +2,6 @@ import("system.logging"); import("system.result"); import("system.vars"); -logging.log("CampaignStep_ParameterValueProcess_CAMPAIGN_ID_" + vars.getString("$field.CAMPAIGN_ID")); -result.string(vars.getString("$field.CAMPAIGN_ID")); \ No newline at end of file +logging.log("CampaignStep_ParameterValueProcess_CAMPAIGN_ID_field_" + vars.getString("$field.CAMPAIGN_ID")); +logging.log("CampaignStep_ParameterValueProcess_CAMPAIGN_ID_param " + vars.get("$param.campaignId_param")); +result.string(vars.get("$param.campaignId_param")); \ No newline at end of file diff --git a/entity/CampaignStep_entity/recordcontainers/db/orderClauseProcess.js b/entity/CampaignStep_entity/recordcontainers/db/orderClauseProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..8538a702d13027d9d9739d9b6652105b87725638 --- /dev/null +++ b/entity/CampaignStep_entity/recordcontainers/db/orderClauseProcess.js @@ -0,0 +1,4 @@ +import("system.result"); +import("system.db"); + +result.object({"CAMPAIGNSTEP.SORTING": db.ASCENDING}); \ No newline at end of file diff --git a/entity/Campaign_entity/Campaign_entity.aod b/entity/Campaign_entity/Campaign_entity.aod index 46d8b59f81e2ae9c725322e2f4c5647a310ecc68..22a3d410de701e73cc1c6d496a074e3cde500fd6 100644 --- a/entity/Campaign_entity/Campaign_entity.aod +++ b/entity/Campaign_entity/Campaign_entity.aod @@ -16,23 +16,27 @@ <entityField> <name>NAME</name> <title>Name</title> + <mandatory v="true" /> </entityField> <entityField> <name>DATE_START</name> <title>Beginn</title> <contentType>DATE</contentType> <resolution>DAY</resolution> - <outputFormat>dd.MM.yyyy</outputFormat> + <outputFormat>dd.MM.YYYY</outputFormat> + <displayValueProcess>%aditoprj%/entity/Campaign_entity/entityfields/date_start/displayValueProcess.js</displayValueProcess> </entityField> <entityField> <name>DATE_END</name> <title>Ende</title> <contentType>DATE</contentType> <resolution>DAY</resolution> + <displayValueProcess>%aditoprj%/entity/Campaign_entity/entityfields/date_end/displayValueProcess.js</displayValueProcess> </entityField> <entityField> <name>EMPLOYEE_CONTACT_ID</name> <title>ZustÃĪndiger</title> + <mandatory v="true" /> <valueProcess>%aditoprj%/entity/Campaign_entity/entityfields/employee_contact_id/valueProcess.js</valueProcess> </entityField> <entityField> @@ -59,6 +63,7 @@ </entityField> <entityConsumer> <name>CampaignSteps</name> + <title>Schritte</title> <fieldType>DEPENDENCY_OUT</fieldType> <dependency> <name>dependency</name> @@ -82,10 +87,10 @@ <alias>Data_alias</alias> <linkInformation> <linkInformation> - <name>ca43f87d-8396-4ce2-bcd6-c0eac74359b3</name> + <name>10e20295-ac9e-4faf-bd30-fa560784e44e</name> <tableName>CAMPAIGN</tableName> <primaryKey>CAMPAIGNID</primaryKey> - <isUIDTable v="true" /> + <isUIDTable v="false" /> <readonly v="false" /> </linkInformation> </linkInformation> @@ -94,18 +99,10 @@ <name>DATE_EDIT.value</name> <recordfield>CAMPAIGN.DATE_EDIT</recordfield> </dbRecordFieldMapping> - <dbRecordFieldMapping> - <name>DATE_END.value</name> - <recordfield>CAMPAIGN.DATE_END</recordfield> - </dbRecordFieldMapping> <dbRecordFieldMapping> <name>DATE_NEW.value</name> <recordfield>CAMPAIGN.DATE_NEW</recordfield> </dbRecordFieldMapping> - <dbRecordFieldMapping> - <name>DATE_START.value</name> - <recordfield>CAMPAIGN.DATE_START</recordfield> - </dbRecordFieldMapping> <dbRecordFieldMapping> <name>DESCRIPTION.value</name> <recordfield>CAMPAIGN.DESCRIPTION</recordfield> diff --git a/entity/Campaign_entity/entityfields/date_end/displayValueProcess.js b/entity/Campaign_entity/entityfields/date_end/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..78fa42b279e02df00bf808a1b6b6ea12187446da --- /dev/null +++ b/entity/Campaign_entity/entityfields/date_end/displayValueProcess.js @@ -0,0 +1,12 @@ +import("system.result"); +import("system.vars"); +import("Campaign_lib"); + +if(vars.exists("$field.CAMPAIGN_ID") && + vars.get("$field.CAMPAIGN_ID") != "" && vars.get("$field.CAMPAIGN_ID") != null) +{ + var capmaignId = vars.get("$field.CAMPAIGN_ID"); + var campaignStepEndDate = getCampaignEndDate(capmaignId); + + result.string(campaignStepEndDate); +} \ No newline at end of file diff --git a/entity/Campaign_entity/entityfields/date_start/displayValueProcess.js b/entity/Campaign_entity/entityfields/date_start/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..ecfc54b8d912fff29ef29627d2170bba67363062 --- /dev/null +++ b/entity/Campaign_entity/entityfields/date_start/displayValueProcess.js @@ -0,0 +1,12 @@ +import("system.result"); +import("system.vars"); +import("Campaign_lib"); + +if(vars.exists("$field.CAMPAIGN_ID") && + vars.get("$field.CAMPAIGN_ID") != "" && vars.get("$field.CAMPAIGN_ID") != null) +{ + var capmaignId = vars.get("$field.CAMPAIGN_ID"); + var campaignStepStartDate = getCampaignStartDate(capmaignId); + + result.string(campaignStepStartDate); +} \ No newline at end of file diff --git a/neonView/CampaignEdit_view/CampaignEdit_view.aod b/neonView/CampaignEdit_view/CampaignEdit_view.aod index 4ee7a5c8e2c08cc8f74a4e500d1a3d987b02cf34..3e68616f45ca5fcbc9e363c9920971d6fdbbfb01 100644 --- a/neonView/CampaignEdit_view/CampaignEdit_view.aod +++ b/neonView/CampaignEdit_view/CampaignEdit_view.aod @@ -22,14 +22,6 @@ <name>8471feb0-7688-4c69-96b0-f731bb87718a</name> <entityField>NAME</entityField> </entityFieldLink> - <entityFieldLink> - <name>337a6bbd-8e1f-443c-991d-8c4ac44c928a</name> - <entityField>DATE_START</entityField> - </entityFieldLink> - <entityFieldLink> - <name>6097ccbb-e0a5-43c0-af3f-258b03b35149</name> - <entityField>DATE_END</entityField> - </entityFieldLink> <entityFieldLink> <name>83a486a0-3297-4d6d-85bd-77f0f42b80d6</name> <entityField>EMPLOYEE_CONTACT_ID</entityField> diff --git a/others/db_changes/data_alias/basic/2019.2/CampaignManagement/create_campaign.xml b/others/db_changes/data_alias/basic/2019.2/CampaignManagement/create_campaign.xml index 5512dd24667b7d5c1ff80eafa68ef751f0334c56..0dcbf0ab91610036e463d16655d1deba78450157 100644 --- a/others/db_changes/data_alias/basic/2019.2/CampaignManagement/create_campaign.xml +++ b/others/db_changes/data_alias/basic/2019.2/CampaignManagement/create_campaign.xml @@ -8,12 +8,6 @@ <column name="NAME" type="NVARCHAR(50)"> <constraints nullable="false"/> </column> - <column name="DATE_START" type="DATE"> - <constraints nullable="false"/> - </column> - <column name="DATE_END" type="DATE"> - <constraints nullable="false"/> - </column> <column name="EMPLOYEE_CONTACT_ID" type="CHAR(36)"> <constraints nullable="false"/> </column> diff --git a/process/Campaign_lib/Campaign_lib.aod b/process/Campaign_lib/Campaign_lib.aod new file mode 100644 index 0000000000000000000000000000000000000000..e32f63d60bb1890dffcfb25a7c250d7cb280b7ac --- /dev/null +++ b/process/Campaign_lib/Campaign_lib.aod @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.0"> + <name>Campaign_lib</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <process>%aditoprj%/process/Campaign_lib/process.js</process> + <variants> + <element>LIBRARY</element> + </variants> +</process> diff --git a/process/Campaign_lib/process.js b/process/Campaign_lib/process.js new file mode 100644 index 0000000000000000000000000000000000000000..b1029d5075be3fd03f2055f74b04890878dbd206 --- /dev/null +++ b/process/Campaign_lib/process.js @@ -0,0 +1,72 @@ +import("system.db"); +/* +* FÞgt Mitglieder zu einer Kampagne hinzu. +* +* @param {String []} pParticipants req die RELATIONID +* @param {String} pCampaignID opt die ID der Kampagne +* @param {String} pStepID opt ID des Schritts +* +* @return {integer} Anzahl keine Email vorhanden +*/ +function addParticipants( pParticipants, pCampaignID, pStepID ) +{ + if ( pStepID == undefined ) + pStepID = selectCampaignStep(pCampaignID); + + if ( pCampaignID == "" || pStepID == null) + return 0; + + var count = 0; + + // aktuelle Anzahl - maximale Anzahl + var iscount = Number(db.cell("select count(*) from campaignparticipant where campaign_id = '" + pCampaignID + "'")); + var maxcount = db.cell("select max_participants from campaign where campaignid = '" + pCampaignID + "'"); + if ( maxcount != "") maxcount = Number(maxcount); else maxcount = 9999999; + + var actdate = vars.getString("$sys.date"); + var user = vars.getString("$sys.user"); + var spalten = new Array("CAMPAIGNPARTICIPANTID", "RELATION_ID", "USER_NEW", "DATE_NEW", "CAMPAIGNSTEP_ID", "CAMPAIGN_ID"); + var typen = db.getColumnTypes("CAMPAIGNPARTICIPANT", spalten); + var logcol = new Array("CAMPAIGN_ID", "STEP_ID", "RELATION_ID", "CAMPAIGNPARTICIPANT_ID", "DATE_NEW", "USER_NEW"); + var logtyp = db.getColumnTypes("CAMPAIGNLOG", logcol); + var logvalue = new Array(pCampaignID, pStepID, 0, 0, actdate, user ); + + for ( var i = 0; i < pParticipants.length; i++ ) + { + if ( iscount < maxcount ) + { + var newID = util.getNewUUID() + var werte = [ newID, pParticipants[i] , user, actdate, pStepID, pCampaignID ]; + count += db.insertData("CAMPAIGNPARTICIPANT", spalten, typen, werte); + logvalue[2] = pParticipants[i]; + logvalue[3] = newID; + db.insertData("CAMPAIGNLOG", logcol, logtyp, logvalue); + iscount++; + } + else + { + question.showMessage(translate.text("Die maximale Anzahl Teilnehmer ist erreicht!")); + break; + } + } + + return count; +} + +/** + * todo + */ +function getCampaignStartDate(pCapmaignId) +{ + var dateStartQuery = "SELECT DATE_START, SORTING FROM ADITO.CAMPAIGNSTEP where CAMPAIGN_ID = '"+ pCapmaignId +"' order by SORTING ASC FETCH FIRST 1 ROWS ONLY"; + return db.cell(dateStartQuery); +} + +/** + * todo + */ +function getCampaignEndDate(pCapmaignId) +{ + var dateEndQuery = "SELECT DATE_END, SORTING FROM ADITO.CAMPAIGNSTEP where CAMPAIGN_ID = '"+ pCapmaignId +"' order by SORTING DESC FETCH FIRST 1 ROWS ONLY"; + return db.cell(dateEndQuery); +} \ No newline at end of file