diff --git a/entity/Leadimport_entity/Leadimport_entity.aod b/entity/Leadimport_entity/Leadimport_entity.aod index 1b7191a1c94613b19f876851d28c3e100ff91127..1820f57843b31f4a2228ed0d1c04a3fcc9849f64 100644 --- a/entity/Leadimport_entity/Leadimport_entity.aod +++ b/entity/Leadimport_entity/Leadimport_entity.aod @@ -338,6 +338,13 @@ </entityParameter> </children> </entityConsumer> + <entityActionField> + <name>LeadimportReset</name> + <title>Leadimport Reset</title> + <onActionProcess>%aditoprj%/entity/Leadimport_entity/entityfields/leadimportreset/onActionProcess.js</onActionProcess> + <state>INVISIBLE</state> + <stateProcess>%aditoprj%/entity/Leadimport_entity/entityfields/leadimportreset/stateProcess.js</stateProcess> + </entityActionField> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Leadimport_entity/entityfields/leadimportreset/onActionProcess.js b/entity/Leadimport_entity/entityfields/leadimportreset/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..65d82c07a29dd292246ce1db3ef69d31c0279ceb --- /dev/null +++ b/entity/Leadimport_entity/entityfields/leadimportreset/onActionProcess.js @@ -0,0 +1,53 @@ +import("Date_lib"); +import("system.logging"); +import("system.vars"); +import("KeywordRegistry_basic"); +import("Sql_lib"); +import("system.db"); + +let leadimportId = vars.get("$field.LEADIMPORTID"); + +var dateADayBefore = new Date(); +dateADayBefore.setDate(dateADayBefore.getDate()-1); + +// Delets all Data, which was created in the last 24 hours by the Leadimport +_deleteData("ORGANISATION", leadimportId, dateADayBefore); +_deleteData("PERSON", leadimportId, dateADayBefore); +_deleteData("ACTIVITY", leadimportId, dateADayBefore); +_deleteData("ACTIVITYLINK", leadimportId, dateADayBefore); +_deleteData("CONTACT", leadimportId, dateADayBefore); +_deleteData("ADDRESS", leadimportId, dateADayBefore); +_deleteData("COMMUNICATION", leadimportId, dateADayBefore); +_deleteData("AB_ATTRIBUTERELATION", leadimportId, dateADayBefore); + +newWhere("LEADLOG.LEADIMPORT_ID", leadimportId) +.and("LEADLOG.DATE_NEW", dateADayBefore.getTime(), "# >= ?") +.from("LEADLOG") +.deleteData(); + +newWhere("LEAD.LEADIMPORT_ID", leadimportId) +.and("LEAD.DATE_NEW", dateADayBefore.getTime(), "# >= ?") +.from("LEAD") +.deleteData(); +// Ändern des Status auf Created +newWhere("LEADIMPORT.LEADIMPORTID", leadimportId).updateData(true, "LEADIMPORT", ["Status"], null, [$KeywordRegistry.importStatus$created()]); + +/** + * Deletes the Data with was created by the Leadimport of the given table + * + * @param {String} pTableName the tabele of deleteing Data of the Date of the Leadimport + * @param {String} pleadimportId the ID of the current Leadimport + * @param {Date} pdateADayBefor 24 hours befor now + */ +function _deleteData (pTableName, pleadimportId, pdateADayBefor) +{ + newWhere(pTableName + "." + pTableName + "ID", + newSelect(pTableName + "." + pTableName + "ID") + .from(pTableName) + .join("LEADLOG", "LEADLOG.DATE_NEW = " + pTableName + ".DATE_NEW") + .where(pTableName + ".USER_NEW", "LEADLOG.USER_NEW") + .and("LEADLOG.LEADIMPORT_ID", pleadimportId) + .and("LEADLOG.DATE_NEW", pdateADayBefor.getTime(), "# >= ?"), SqlBuilder.IN()) + .from(pTableName) + .deleteData(); +} \ No newline at end of file diff --git a/entity/Leadimport_entity/entityfields/leadimportreset/stateProcess.js b/entity/Leadimport_entity/entityfields/leadimportreset/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..e017ead39335cf429f258a499852f864d6171ab3 --- /dev/null +++ b/entity/Leadimport_entity/entityfields/leadimportreset/stateProcess.js @@ -0,0 +1,14 @@ +import("system.logging"); +import("system.result"); +import("system.vars"); +import("Sql_lib"); + +var dateADayBefore = new Date(); +dateADayBefore.setDate(dateADayBefore.getDate()-1); + +let count = newSelect("count(*)").from("LEADLOG").where("LEADLOG.LEADIMPORT_ID", vars.get("$field.LEADIMPORTID")).and("LEADLOG.DATE_NEW", dateADayBefore.getTime(), "# >= ?").arrayColumn(); +if (count[0] > 0){ + result.string("EDITABLE"); +} else { + result.string("INVISIBLE"); +} \ No newline at end of file diff --git a/entity/Leadimport_entity/entityfields/transferdata/onActionProcess.js b/entity/Leadimport_entity/entityfields/transferdata/onActionProcess.js index 36a4c97ee12b64b63a0a6c6f3bb49c5d388a403e..a3e187a8b6de91fea68f89b06bc95b637c4368e1 100644 --- a/entity/Leadimport_entity/entityfields/transferdata/onActionProcess.js +++ b/entity/Leadimport_entity/entityfields/transferdata/onActionProcess.js @@ -22,7 +22,7 @@ if (binMetadatas.length > 0) var fieldSep = LeadImportUtils.getFieldSeparator(vars.get("$field.FIELDSEPARATOR")); var fieldLimit = LeadImportUtils.getFieldLimit(vars.get("$field.FIELDDELIMITERS")); var recordSep = LeadImportUtils.getRecordSeparator(vars.get("$field.SENTENCESEPARATOR")); - + var currDate = vars.get("$sys.date"); var params = { @@ -34,7 +34,7 @@ if (binMetadatas.length > 0) fieldLimit: fieldLimit, user: user, source: vars.getString("$field.IMPORTSOURCE"), - currDate: vars.get("$sys.date"), + currDate: currDate, userId: EmployeeUtils.getCurrentUserId(), importName: name } diff --git a/entity/Prod2prod_entity/Prod2prod_entity.aod b/entity/Prod2prod_entity/Prod2prod_entity.aod index 232bb1da69b8db5c39880e2a6f2b854d72c2d688..967049bcb5c724f02da4d0e0dc2cce9ebc9cd190 100644 --- a/entity/Prod2prod_entity/Prod2prod_entity.aod +++ b/entity/Prod2prod_entity/Prod2prod_entity.aod @@ -131,6 +131,7 @@ <name>jdito</name> <jDitoRecordAlias>Data_alias</jDitoRecordAlias> <isRequireContainerFiltering v="true" /> + <isSortable v="true" /> <contentProcess>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js</contentProcess> <hasDependentRecords v="true" /> <onInsert>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/onInsert.js</onInsert> diff --git a/process/ActivityTask_lib/process.js b/process/ActivityTask_lib/process.js index 4c80e2cc42953a6d459e17dba9764930b7cab1a3..d0536720851457d268c4621d4c2962e8ade47c45 100644 --- a/process/ActivityTask_lib/process.js +++ b/process/ActivityTask_lib/process.js @@ -50,20 +50,21 @@ function ActivityUtils() {} * for example: * <pre>[["number.txt", "MDExOCA5OTkgODgxIDk5OSAxMTkgNzI1IDM", true]]</pre> * @param {String} [pDbAlias=current db alias] database alias where the activity shall be inserted + * @param {Date} [pDateNew] The Date which one is in the DB the DATE_NEW * * @return {Object} js object where the following are filled: * <ul> * <li>activityId</li> * </ul> */ -ActivityUtils.insertNewActivity = function(pDataPreset, pActivityLinks, pDocuments, pDbAlias) +ActivityUtils.insertNewActivity = function(pDataPreset, pActivityLinks, pDocuments, pDbAlias, pDateNew) { var dataPreset = pDataPreset || {}; var dbAlias = pDbAlias || db.getCurrentAlias(); var insertStatements = []; var creationUser = dataPreset.userNew || vars.get("$sys.user"); - var creationDate = datetime.date(); + var creationDate = pDateNew || datetime.date(); var activityId = dataPreset.activityId || util.getNewUUID(); var entrydate = dataPreset.entrydate || creationDate; diff --git a/process/Leadimport_lib/process.js b/process/Leadimport_lib/process.js index 2d1f9d68d5556cbe84eec46c0f8f40c501d11515..74e6adc119bfdb7cb839be5fd767abb534830122 100644 --- a/process/Leadimport_lib/process.js +++ b/process/Leadimport_lib/process.js @@ -198,9 +198,9 @@ LeadImportUtils.importData = function(pDataFields, pDataTypes, pFieldDef, pField }; // History for organisation and person if (orgContactId != "" && orgRet[3]) - ActivityUtils.insertNewActivity(activityData, new Array(new Array(orgObjID, orgContactId)));//org + ActivityUtils.insertNewActivity(activityData, new Array(new Array(orgObjID, orgContactId)),undefined, undefined, pDate);//org if (persContactId != "") - ActivityUtils.insertNewActivity(activityData, new Array(new Array(persObjID, persContactId)));//pers + ActivityUtils.insertNewActivity(activityData, new Array(new Array(persObjID, persContactId)), undefined, undefined, pDate);//pers LeadValues["LEADIMPORT_ID"] = pImportDefID; LeadValues["ORGANISATION_ID"] = orgid;