From 201beca8faeadc49fc2f8ef4adc6f5b27b59e9c8 Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 7 May 2015 11:22:52 +0300 Subject: [PATCH] audited change --- .../Resources/metadata/entityDefs/Call.json | 6 ++++-- .../Resources/metadata/entityDefs/Case.json | 3 ++- .../Resources/metadata/entityDefs/Lead.json | 3 ++- .../metadata/entityDefs/Meeting.json | 6 ++++-- .../metadata/entityDefs/Opportunity.json | 3 ++- .../Resources/metadata/entityDefs/Task.json | 9 ++++++--- application/Espo/Services/Stream.php | 19 ++++++++++++------- 7 files changed, 32 insertions(+), 17 deletions(-) diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json index 90a4e23df7..eeabe3a145 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json @@ -11,12 +11,14 @@ "view": "Fields.EnumStyled", "style": { "Held": "success" - } + }, + "audited": true }, "dateStart": { "type": "datetime", "required": true, - "default": "javascript: return this.dateTime.getNow(15);" + "default": "javascript: return this.dateTime.getNow(15);", + "audited": true }, "dateEnd": { "type": "datetime", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json index b9b5f21453..2998e9ac0f 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json @@ -17,7 +17,8 @@ "Closed": "success", "Duplicate": "danger", "Rejected": "danger" - } + }, + "audited": true }, "priority": { "type": "enum", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json index d08793c78e..6f63fea871 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json @@ -31,7 +31,8 @@ "Converted": "success", "Recycled": "danger", "Dead": "danger" - } + }, + "audited": true }, "source": { "type": "enum", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json index 1b4a690921..5b743dcdde 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json @@ -11,12 +11,14 @@ "view": "Fields.EnumStyled", "style": { "Held": "success" - } + }, + "audited": true }, "dateStart": { "type": "datetime", "required": true, - "default": "javascript: return this.dateTime.getNow(15);" + "default": "javascript: return this.dateTime.getNow(15);", + "audited": true }, "dateEnd": { "type": "datetime", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json index a040914f20..d29c64f1a6 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json @@ -43,7 +43,8 @@ "type": "enum", "options": ["Prospecting", "Qualification", "Needs Analysis", "Value Proposition", "Id. Decision Makers", "Perception Analysis", "Proposal/Price Quote", "Negotiation/Review", "Closed Won", "Closed Lost"], "view": "Crm:Opportunity.Fields.Stage", - "default": "Prospecting" + "default": "Prospecting", + "audited": true }, "probability": { "type": "int", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json index 2fada2c29f..e77c7a9eb8 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json @@ -11,12 +11,14 @@ "style": { "Completed": "success" }, - "default": "Not Started" + "default": "Not Started", + "audited": true }, "priority": { "type": "enum", "options": ["Low", "Normal", "High", "Urgent"], - "default": "Normal" + "default": "Normal", + "audited": true }, "dateStart": { "type": "datetime", @@ -26,7 +28,8 @@ "dateEnd": { "type": "datetime", "after": "dateStart", - "view": "Crm:Task.Fields.DateEnd" + "view": "Crm:Task.Fields.DateEnd", + "audited": true }, "dateStartDate": { "type": "date", diff --git a/application/Espo/Services/Stream.php b/application/Espo/Services/Stream.php index 025944a995..84728e6f5d 100644 --- a/application/Espo/Services/Stream.php +++ b/application/Espo/Services/Stream.php @@ -678,14 +678,20 @@ class Stream extends \Espo\Core\Services\Base protected function getAuditedFields(Entity $entity) { - $entityName = $entity->getEntityName(); + $entityType = $entity->getEntityType(); - if (!array_key_exists($entityName, $this->auditedFieldsCache)) { - $fields = $this->getMetadata()->get('entityDefs.' . $entityName . '.fields'); + $statusFields = $this->getStatusFields(); + + if (!array_key_exists($entityType, $this->auditedFieldsCache)) { + $fields = $this->getMetadata()->get('entityDefs.' . $entityType . '.fields'); $auditedFields = array(); foreach ($fields as $field => $d) { if (!empty($d['audited'])) { - $attributes = array(); + if (!empty($statusFields[$entityType]) && $statusFields[$entityType] === $field) { + continue; + } + + $attributes = []; $fieldsDefs = $this->getMetadata()->get('fields.' . $d['type']); if (empty($fieldsDefs['actualFields'])) { @@ -703,10 +709,10 @@ class Stream extends \Espo\Core\Services\Base $auditedFields[$field] = $attributes; } } - $this->auditedFieldsCache[$entityName] = $auditedFields; + $this->auditedFieldsCache[$entityType] = $auditedFields; } - return $this->auditedFieldsCache[$entityName]; + return $this->auditedFieldsCache[$entityType]; } public function handleAudited($entity) @@ -721,7 +727,6 @@ class Stream extends \Espo\Core\Services\Base $updated = false; foreach ($attrs as $attr) { if ($entity->get($attr) != $entity->getFetched($attr)) { - $updated = true; } }