From 972615c8e6a30f3056f6aeb90882192da99d4dc9 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 24 Feb 2015 15:57:34 +0200 Subject: [PATCH 01/22] Added Campaigns and Target Lists --- .../Espo/Modules/Crm/Controllers/Campaign.php | 28 +++++ .../Modules/Crm/Controllers/TargetList.php | 28 +++++ .../Espo/Modules/Crm/Entities/Campaign.php | 28 +++++ .../Espo/Modules/Crm/Entities/TargetList.php | 28 +++++ .../Crm/Resources/i18n/en_US/Account.json | 6 +- .../Crm/Resources/i18n/en_US/Campaign.json | 39 +++++++ .../Crm/Resources/i18n/en_US/Contact.json | 6 +- .../Crm/Resources/i18n/en_US/Global.json | 8 +- .../Crm/Resources/i18n/en_US/Lead.json | 4 +- .../Crm/Resources/i18n/en_US/Opportunity.json | 5 +- .../Crm/Resources/i18n/en_US/TargetList.json | 28 +++++ .../Crm/Resources/i18n/en_US/User.json | 5 + .../Resources/layouts/Campaign/detail.json | 11 ++ .../layouts/Campaign/detailSmall.json | 11 ++ .../Resources/layouts/Campaign/filters.json | 5 + .../Crm/Resources/layouts/Campaign/list.json | 6 + .../Resources/layouts/Campaign/listSmall.json | 5 + .../layouts/Campaign/relationships.json | 3 + .../Resources/layouts/TargetList/detail.json | 9 ++ .../layouts/TargetList/detailSmall.json | 8 ++ .../Resources/layouts/TargetList/filters.json | 2 + .../Resources/layouts/TargetList/list.json | 5 + .../layouts/TargetList/listSmall.json | 5 + .../layouts/TargetList/relationships.json | 7 ++ .../metadata/clientDefs/Campaign.json | 29 +++++ .../metadata/clientDefs/TargetList.json | 4 + .../metadata/entityDefs/Account.json | 10 ++ .../metadata/entityDefs/Campaign.json | 103 ++++++++++++++++++ .../metadata/entityDefs/Contact.json | 10 ++ .../Resources/metadata/entityDefs/Lead.json | 10 ++ .../metadata/entityDefs/Opportunity.json | 9 ++ .../metadata/entityDefs/TargetList.json | 96 ++++++++++++++++ .../Resources/metadata/entityDefs/User.json | 9 ++ .../Resources/metadata/scopes/Campaign.json | 10 ++ .../Resources/metadata/scopes/TargetList.json | 10 ++ 35 files changed, 581 insertions(+), 9 deletions(-) create mode 100644 application/Espo/Modules/Crm/Controllers/Campaign.php create mode 100644 application/Espo/Modules/Crm/Controllers/TargetList.php create mode 100644 application/Espo/Modules/Crm/Entities/Campaign.php create mode 100644 application/Espo/Modules/Crm/Entities/TargetList.php create mode 100644 application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json create mode 100644 application/Espo/Modules/Crm/Resources/i18n/en_US/TargetList.json create mode 100644 application/Espo/Modules/Crm/Resources/i18n/en_US/User.json create mode 100644 application/Espo/Modules/Crm/Resources/layouts/Campaign/detail.json create mode 100644 application/Espo/Modules/Crm/Resources/layouts/Campaign/detailSmall.json create mode 100644 application/Espo/Modules/Crm/Resources/layouts/Campaign/filters.json create mode 100644 application/Espo/Modules/Crm/Resources/layouts/Campaign/list.json create mode 100644 application/Espo/Modules/Crm/Resources/layouts/Campaign/listSmall.json create mode 100644 application/Espo/Modules/Crm/Resources/layouts/Campaign/relationships.json create mode 100644 application/Espo/Modules/Crm/Resources/layouts/TargetList/detail.json create mode 100644 application/Espo/Modules/Crm/Resources/layouts/TargetList/detailSmall.json create mode 100644 application/Espo/Modules/Crm/Resources/layouts/TargetList/filters.json create mode 100644 application/Espo/Modules/Crm/Resources/layouts/TargetList/list.json create mode 100644 application/Espo/Modules/Crm/Resources/layouts/TargetList/listSmall.json create mode 100644 application/Espo/Modules/Crm/Resources/layouts/TargetList/relationships.json create mode 100644 application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json create mode 100644 application/Espo/Modules/Crm/Resources/metadata/clientDefs/TargetList.json create mode 100644 application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json create mode 100644 application/Espo/Modules/Crm/Resources/metadata/entityDefs/TargetList.json create mode 100644 application/Espo/Modules/Crm/Resources/metadata/entityDefs/User.json create mode 100644 application/Espo/Modules/Crm/Resources/metadata/scopes/Campaign.json create mode 100644 application/Espo/Modules/Crm/Resources/metadata/scopes/TargetList.json diff --git a/application/Espo/Modules/Crm/Controllers/Campaign.php b/application/Espo/Modules/Crm/Controllers/Campaign.php new file mode 100644 index 0000000000..0e363c4d95 --- /dev/null +++ b/application/Espo/Modules/Crm/Controllers/Campaign.php @@ -0,0 +1,28 @@ + Date: Thu, 26 Feb 2015 11:52:27 +0200 Subject: [PATCH 02/22] fix relationship --- .../Modules/Crm/Resources/metadata/entityDefs/Account.json | 5 +++++ .../Modules/Crm/Resources/metadata/entityDefs/Contact.json | 5 +++++ .../Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json index 6570ee090b..ad34d1650f 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json @@ -218,6 +218,11 @@ "entity": "Campaign", "foreign": "accounts", "noJoin": true + }, + "targetLists": { + "type": "hasMany", + "entity": "TargetList", + "foreign": "accounts" } }, "collection": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json index 86fea37c7a..63b54dcfaa 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json @@ -202,6 +202,11 @@ "entity": "Campaign", "foreign": "contacts", "noJoin": true + }, + "targetLists": { + "type": "hasMany", + "entity": "TargetList", + "foreign": "users" } }, "collection": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json index ba9496bce7..4dd3ac8834 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json @@ -201,6 +201,11 @@ "entity": "Campaign", "foreign": "leads", "noJoin": true + }, + "targetLists": { + "type": "hasMany", + "entity": "TargetList", + "foreign": "leads" } }, "convertFields": { From 5acf253a98d04f53c10ea082e80c9a9ac8dfdb8b Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 27 Feb 2015 15:10:06 +0200 Subject: [PATCH 03/22] campaign --- .../Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json | 1 + .../Espo/Modules/Crm/Resources/layouts/Campaign/detail.json | 4 ++-- .../Modules/Crm/Resources/metadata/entityDefs/Campaign.json | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json index b3756fa182..40f6db9859 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json @@ -4,6 +4,7 @@ "description": "Description", "status": "Status", "type": "Type", + "startDate": "Start Date", "endDate": "End Date", "targetLists": "Target Lists" }, diff --git a/application/Espo/Modules/Crm/Resources/layouts/Campaign/detail.json b/application/Espo/Modules/Crm/Resources/layouts/Campaign/detail.json index 222bd88511..936e654d70 100644 --- a/application/Espo/Modules/Crm/Resources/layouts/Campaign/detail.json +++ b/application/Espo/Modules/Crm/Resources/layouts/Campaign/detail.json @@ -3,8 +3,8 @@ "label":"Overview", "rows":[ [{"name":"name"}, {"name":"status"}], - [{"name":"type"}, false], - [{"name":"endDate"}, false], + [{"name":"type"}, {"name":"startDate"}], + [{"name":"targetLists"}, {"name":"endDate"}], [{"name":"description", "fullWidth": true}] ] } diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json index 332216dc00..60c8c13e42 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json @@ -13,6 +13,9 @@ "type": "enum", "options": ["Email", "Web", "Television", "Radio", "Newsletter"] }, + "startDate": { + "type": "date" + }, "endDate": { "type": "date" }, @@ -43,7 +46,7 @@ "type": "linkMultiple" }, "targetLists": { - "type": "link" + "type": "linkMultiple" } }, "links": { From 811db09a1d0f2c018ad56893e3d185b47f24847a Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 27 Feb 2015 15:24:27 +0200 Subject: [PATCH 04/22] calculate entryCount --- .../Espo/Modules/Crm/Services/TargetList.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 application/Espo/Modules/Crm/Services/TargetList.php diff --git a/application/Espo/Modules/Crm/Services/TargetList.php b/application/Espo/Modules/Crm/Services/TargetList.php new file mode 100644 index 0000000000..2f7b979567 --- /dev/null +++ b/application/Espo/Modules/Crm/Services/TargetList.php @@ -0,0 +1,51 @@ +loadEntryCountField($entity); + } + + protected function loadAdditionalFieldsForList(Entity $entity) + { + parent::loadAdditionalFields($entity); + $this->loadEntryCountField($entity); + } + + protected function loadEntryCountField(Entity $entity) + { + $count = 0; + $count += $this->getEntityManager()->getRepository('TargetList')->countRelated($entity, 'contacts'); + $count += $this->getEntityManager()->getRepository('TargetList')->countRelated($entity, 'leads'); + $count += $this->getEntityManager()->getRepository('TargetList')->countRelated($entity, 'users'); + $count += $this->getEntityManager()->getRepository('TargetList')->countRelated($entity, 'accounts'); + $entity->set('entryCount', $count); + } +} + From 639c52d1d694456fec603fe15e19c379d8a069c0 Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 27 Feb 2015 15:36:46 +0200 Subject: [PATCH 05/22] fix relation --- .../Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json index 63b54dcfaa..6721a6362f 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json @@ -206,7 +206,7 @@ "targetLists": { "type": "hasMany", "entity": "TargetList", - "foreign": "users" + "foreign": "contacts" } }, "collection": { From 09801201846e8a873cd73806dc810bf0d93a85c0 Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 27 Feb 2015 15:49:48 +0200 Subject: [PATCH 06/22] fix taget list service --- application/Espo/Modules/Crm/Services/TargetList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/Espo/Modules/Crm/Services/TargetList.php b/application/Espo/Modules/Crm/Services/TargetList.php index 2f7b979567..c0cfc86eed 100644 --- a/application/Espo/Modules/Crm/Services/TargetList.php +++ b/application/Espo/Modules/Crm/Services/TargetList.php @@ -32,7 +32,7 @@ class TargetList extends \Espo\Services\Record $this->loadEntryCountField($entity); } - protected function loadAdditionalFieldsForList(Entity $entity) + public function loadAdditionalFieldsForList(Entity $entity) { parent::loadAdditionalFields($entity); $this->loadEntryCountField($entity); From d4a3eb102600d464ffd1a9b64301ce09d844881d Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 27 Feb 2015 17:18:24 +0200 Subject: [PATCH 07/22] change target list layout --- .../Crm/Resources/layouts/TargetList/relationships.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/application/Espo/Modules/Crm/Resources/layouts/TargetList/relationships.json b/application/Espo/Modules/Crm/Resources/layouts/TargetList/relationships.json index 8268ccee27..8717eacd49 100644 --- a/application/Espo/Modules/Crm/Resources/layouts/TargetList/relationships.json +++ b/application/Espo/Modules/Crm/Resources/layouts/TargetList/relationships.json @@ -2,6 +2,5 @@ "contacts", "leads", "users", - "accounts", - "campaigns" + "accounts" ] From be3dabe5a753d20fd6b0a285a40d8d59a267bedc Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 2 Mar 2015 11:55:43 +0200 Subject: [PATCH 08/22] campaign dev --- .../Crm/Resources/i18n/en_US/Campaign.json | 3 +- .../Crm/Resources/i18n/en_US/CampaignLog.json | 10 +++ .../metadata/clientDefs/Campaign.json | 5 +- .../metadata/entityDefs/Campaign.json | 5 ++ .../metadata/entityDefs/CampaignLog.json | 70 +++++++++++++++++++ .../metadata/scopes/CampaignLog.json | 10 +++ .../src/views/campaign/record/detail-side.js | 38 ++++++++++ .../crm/src/views/campaign/record/detail.js | 32 +++++++++ 8 files changed, 171 insertions(+), 2 deletions(-) create mode 100644 application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLog.json create mode 100644 application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLog.json create mode 100644 application/Espo/Modules/Crm/Resources/metadata/scopes/CampaignLog.json create mode 100644 frontend/client/modules/crm/src/views/campaign/record/detail-side.js create mode 100644 frontend/client/modules/crm/src/views/campaign/record/detail.js diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json index 40f6db9859..355ac04544 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json @@ -13,7 +13,8 @@ "accounts": "Accounts", "contacts": "Contacts", "leads": "Leads", - "opportunities": "Opportunities" + "opportunities": "Opportunities", + "campaignLogs": "Log" }, "options": { "type": { diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLog.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLog.json new file mode 100644 index 0000000000..d89157b361 --- /dev/null +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLog.json @@ -0,0 +1,10 @@ +{ + "fields": { + "action": "Action", + "actionDate": "Action Date", + "data": "Data", + "campaign": "Campaign", + "parent": "Parent", + "object": "Object" + } +} diff --git a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json index c54a226283..20bc56ad43 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json @@ -1,5 +1,5 @@ { - "controller": "Controllers.Record", + "controller": "Controllers.Record", "menu": { "list": { "buttons": [ @@ -13,6 +13,9 @@ ] } }, + "recordViews": { + "detail": "Crm:Campaign.Record.Detail" + }, "presetFilters": [ { "name":"active", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json index 60c8c13e42..5c25d3d14a 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json @@ -92,6 +92,11 @@ "type": "hasMany", "entity": "Opportunity", "foreign": "campaign" + }, + "campaignLogs": { + "type": "hasMany", + "entity": "CampaignLog", + "foreign": "campaign" } }, "collection": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLog.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLog.json new file mode 100644 index 0000000000..f2772ce92b --- /dev/null +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLog.json @@ -0,0 +1,70 @@ +{ + "fields": { + "action": { + "type": "varchar", + "required": true, + "maxLength": 50 + }, + "actionDate": { + "type": "datetime", + "required": true + }, + "data": { + "type": "jsonObject" + }, + "application": { + "type": "varchar", + "required": true, + "maxLength": 36, + "default": "EspoCRM" + }, + "createdAt": { + "type": "datetime", + "readOnly": true + }, + "createdBy": { + "type": "link", + "readOnly": true + }, + "campaign": { + "type": "link" + }, + "parent": { + "type": "linkParent" + }, + "object": { + "type": "linkParent" + } + }, + "links": { + "createdBy": { + "type": "belongsTo", + "entity": "User" + }, + "campaign": { + "type": "belongsTo", + "entity": "Campaign", + "foreign": "campaignLogs" + }, + "parent": { + "type": "belongsToParent", + "entityList": ["Account", "Contact", "Lead", "Opportunity", "User"] + }, + "object": { + "type": "belongsToParent", + "entityList": ["Email"] + } + }, + "collection": { + "sortBy": "actionDate", + "asc": false + }, + "indexes": { + "actionDate": { + "columns": ["actionDate", "deleted"] + }, + "action": { + "columns": ["action", "deleted"] + } + } +} diff --git a/application/Espo/Modules/Crm/Resources/metadata/scopes/CampaignLog.json b/application/Espo/Modules/Crm/Resources/metadata/scopes/CampaignLog.json new file mode 100644 index 0000000000..40723c50f9 --- /dev/null +++ b/application/Espo/Modules/Crm/Resources/metadata/scopes/CampaignLog.json @@ -0,0 +1,10 @@ +{ + "entity": true, + "layouts": false, + "tab": false, + "acl": false, + "module": "Crm", + "customizable": false, + "stream": false, + "importable": false +} diff --git a/frontend/client/modules/crm/src/views/campaign/record/detail-side.js b/frontend/client/modules/crm/src/views/campaign/record/detail-side.js new file mode 100644 index 0000000000..12b8995956 --- /dev/null +++ b/frontend/client/modules/crm/src/views/campaign/record/detail-side.js @@ -0,0 +1,38 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://www.espocrm.com + * + * EspoCRM is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * EspoCRM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with EspoCRM. If not, see http://www.gnu.org/licenses/. + ************************************************************************/ + + +Espo.define('Crm:Views.Campaign.Record.DetailBottom', 'Views.Record.DetailBottom', function (Dep) { + + return Dep.extend({ + + setup: function () { + Dep.prototype.setup.call(this); + + this.panels.unshift({ + + }); + } + + }); +}); + + diff --git a/frontend/client/modules/crm/src/views/campaign/record/detail.js b/frontend/client/modules/crm/src/views/campaign/record/detail.js new file mode 100644 index 0000000000..644a91753f --- /dev/null +++ b/frontend/client/modules/crm/src/views/campaign/record/detail.js @@ -0,0 +1,32 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://www.espocrm.com + * + * EspoCRM is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * EspoCRM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with EspoCRM. If not, see http://www.gnu.org/licenses/. + ************************************************************************/ + + +Espo.define('Crm:Views.Campaign.Record.Detail', 'Views.Record.Detail', function (Dep) { + + return Dep.extend({ + + bottomView: 'Crm:Campaign.Record.DetailSide', + + }); +}); + + From 16ce5385f4e806bfb49ff6a264c00b03a4612f72 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 2 Mar 2015 12:24:57 +0200 Subject: [PATCH 09/22] campaign dev --- .../Crm/Entities/CampaignLogRecord.php | 28 +++++++++++++++++ .../Crm/Resources/i18n/en_US/Campaign.json | 2 +- ...ampaignLog.json => CampaignLogRecord.json} | 0 .../layouts/Campaign/relationships.json | 2 +- .../metadata/clientDefs/Campaign.json | 9 +++++- .../metadata/entityDefs/Campaign.json | 4 +-- ...ampaignLog.json => CampaignLogRecord.json} | 2 +- ...ampaignLog.json => CampaignLogRecord.json} | 0 .../{detail-side.js => detail-bottom.js} | 7 ----- .../crm/src/views/campaign/record/detail.js | 2 +- .../record/panels/campaign-log-records.js | 31 +++++++++++++++++++ 11 files changed, 73 insertions(+), 14 deletions(-) create mode 100644 application/Espo/Modules/Crm/Entities/CampaignLogRecord.php rename application/Espo/Modules/Crm/Resources/i18n/en_US/{CampaignLog.json => CampaignLogRecord.json} (100%) rename application/Espo/Modules/Crm/Resources/metadata/entityDefs/{CampaignLog.json => CampaignLogRecord.json} (97%) rename application/Espo/Modules/Crm/Resources/metadata/scopes/{CampaignLog.json => CampaignLogRecord.json} (100%) rename frontend/client/modules/crm/src/views/campaign/record/{detail-side.js => detail-bottom.js} (89%) create mode 100644 frontend/client/modules/crm/src/views/campaign/record/panels/campaign-log-records.js diff --git a/application/Espo/Modules/Crm/Entities/CampaignLogRecord.php b/application/Espo/Modules/Crm/Entities/CampaignLogRecord.php new file mode 100644 index 0000000000..6b9e3924de --- /dev/null +++ b/application/Espo/Modules/Crm/Entities/CampaignLogRecord.php @@ -0,0 +1,28 @@ + Date: Mon, 2 Mar 2015 17:52:23 +0200 Subject: [PATCH 10/22] campaign dev --- .../Modules/Crm/Resources/layouts/Campaign/relationships.json | 4 +++- .../Espo/Modules/Crm/Resources/layouts/Lead/filters.json | 1 + .../Modules/Crm/Resources/layouts/Opportunity/filters.json | 1 + .../Modules/Crm/Resources/metadata/entityDefs/Campaign.json | 2 +- .../Espo/Modules/Crm/Resources/metadata/scopes/Campaign.json | 4 ++-- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/application/Espo/Modules/Crm/Resources/layouts/Campaign/relationships.json b/application/Espo/Modules/Crm/Resources/layouts/Campaign/relationships.json index a0ca8ee9e9..da08eeee57 100644 --- a/application/Espo/Modules/Crm/Resources/layouts/Campaign/relationships.json +++ b/application/Espo/Modules/Crm/Resources/layouts/Campaign/relationships.json @@ -1,3 +1,5 @@ [ - "campaignLogRecords" + "campaignLogRecords", + "opportunities", + "leads" ] diff --git a/application/Espo/Modules/Crm/Resources/layouts/Lead/filters.json b/application/Espo/Modules/Crm/Resources/layouts/Lead/filters.json index c97dc2570a..cf65e2651b 100644 --- a/application/Espo/Modules/Crm/Resources/layouts/Lead/filters.json +++ b/application/Espo/Modules/Crm/Resources/layouts/Lead/filters.json @@ -1,6 +1,7 @@ [ "assignedUser", "address", + "campaign", "status", "source", "opportunityAmountConverted", diff --git a/application/Espo/Modules/Crm/Resources/layouts/Opportunity/filters.json b/application/Espo/Modules/Crm/Resources/layouts/Opportunity/filters.json index b3cbf8861d..dac67478f4 100644 --- a/application/Espo/Modules/Crm/Resources/layouts/Opportunity/filters.json +++ b/application/Espo/Modules/Crm/Resources/layouts/Opportunity/filters.json @@ -2,6 +2,7 @@ "account", "amountConverted", "assignedUser", + "campaign", "closeDate", "contacts", "leadSource", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json index f9214048a8..90d6128e76 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json @@ -86,7 +86,7 @@ "leads": { "type": "hasMany", "entity": "Lead", - "foreign": "campaigns" + "foreign": "campaign" }, "opportunities": { "type": "hasMany", diff --git a/application/Espo/Modules/Crm/Resources/metadata/scopes/Campaign.json b/application/Espo/Modules/Crm/Resources/metadata/scopes/Campaign.json index b6ee9905d4..1b8f7311ca 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/scopes/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/metadata/scopes/Campaign.json @@ -1,10 +1,10 @@ { "entity": true, - "layouts": false, + "layouts": true, "tab": true, "acl": true, "module": "Crm", - "customizable": false, + "customizable": true, "stream": false, "importable": false } From f10dd1944606c06c598177585643847044da7901 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 3 Mar 2015 11:20:56 +0200 Subject: [PATCH 11/22] campaign --- .../Resources/metadata/entityDefs/CampaignLogRecord.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json index 0aac3853d6..48888ca104 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json @@ -1,9 +1,10 @@ { "fields": { "action": { - "type": "varchar", + "type": "enum", "required": true, - "maxLength": 50 + "maxLength": 50, + "options": ["Sent", "Viewed", "Opted Out", "Bounced", "Link Clicked", "Lead Created"] }, "actionDate": { "type": "datetime", @@ -12,6 +13,10 @@ "data": { "type": "jsonObject" }, + "stringData": { + "type": "varchar", + "maxLength": 100 + }, "application": { "type": "varchar", "required": true, From c074423f0bc48254e9b742b9d264e70e4bf03c61 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 3 Mar 2015 12:24:18 +0200 Subject: [PATCH 12/22] campaign dev --- .../i18n/en_US/CampaignLogRecord.json | 7 +++- .../CampaignLogRecord/listForCampaign.json | 8 ++-- .../metadata/clientDefs/Campaign.json | 2 + .../entityDefs/CampaignLogRecord.json | 5 ++- .../views/campaign-log-record/fields/data.js | 42 +++++++++++++++++++ 5 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 frontend/client/modules/crm/src/views/campaign-log-record/fields/data.js diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json index d89157b361..a531cac918 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json @@ -5,6 +5,11 @@ "data": "Data", "campaign": "Campaign", "parent": "Parent", - "object": "Object" + "object": "Object", + "application": "Application" + }, + "options": { + "action": { + } } } diff --git a/application/Espo/Modules/Crm/Resources/layouts/CampaignLogRecord/listForCampaign.json b/application/Espo/Modules/Crm/Resources/layouts/CampaignLogRecord/listForCampaign.json index 42040316ac..6658440ae1 100644 --- a/application/Espo/Modules/Crm/Resources/layouts/CampaignLogRecord/listForCampaign.json +++ b/application/Espo/Modules/Crm/Resources/layouts/CampaignLogRecord/listForCampaign.json @@ -1,6 +1,6 @@ [ - {"name": "parent", "width": 30}, - {"name": "action", "width": 30}, - {"name": "actionDate"}, - {"name": "application"} + {"name": "action", "notSortable": true, "width": 14}, + {"name": "parent", "notSortable": true}, + {"name": "actionDate", "width": 18}, + {"name": "data", "notSortable": true, "customLabel": ""} ] diff --git a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json index 79999e7878..c2e48c0d69 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json @@ -19,6 +19,8 @@ "relationshipPanels": { "campaignLogRecords": { "view": "Crm:Campaign.Record.Panels.CampaignLogRecords", + "layout": "listForCampaign", + "rowActionsView": "Record.RowActions.RelationshipRemoveOnly", "select": false, "create": false } diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json index 48888ca104..a58c199f4d 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json @@ -4,14 +4,15 @@ "type": "enum", "required": true, "maxLength": 50, - "options": ["Sent", "Viewed", "Opted Out", "Bounced", "Link Clicked", "Lead Created"] + "options": ["Sent", "Viewed", "Opted Out", "Bounced", "Clicked", "Lead Created"] }, "actionDate": { "type": "datetime", "required": true }, "data": { - "type": "jsonObject" + "type": "jsonObject", + "view": "Crm:CampaignLogRecord.Fields.Data" }, "stringData": { "type": "varchar", diff --git a/frontend/client/modules/crm/src/views/campaign-log-record/fields/data.js b/frontend/client/modules/crm/src/views/campaign-log-record/fields/data.js new file mode 100644 index 0000000000..b6b8a0fc4a --- /dev/null +++ b/frontend/client/modules/crm/src/views/campaign-log-record/fields/data.js @@ -0,0 +1,42 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://www.espocrm.com + * + * EspoCRM is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * EspoCRM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with EspoCRM. If not, see http://www.gnu.org/licenses/. + ************************************************************************/ + + +Espo.define('Crm:Views.CampaignLogRecord.Fields.Data', 'Views.Fields.Base', function (Dep) { + + return Dep.extend({ + + getValueForDisplay: function () { + var action = this.model.get('action'); + + switch (action) { + case 'Sent': + return this.model.get('stringData'); + case 'Clicked': + return this.model.get('stringData'); + } + return ''; + } + + }); +}); + + From 0f582c59ab23e93c64112d7cd3f3ff344015940a Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 3 Mar 2015 12:31:10 +0200 Subject: [PATCH 13/22] dev --- .../Modules/Crm/Resources/metadata/clientDefs/Campaign.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json index c2e48c0d69..00a100295c 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json @@ -20,7 +20,7 @@ "campaignLogRecords": { "view": "Crm:Campaign.Record.Panels.CampaignLogRecords", "layout": "listForCampaign", - "rowActionsView": "Record.RowActions.RelationshipRemoveOnly", + "rowActionsView": false, "select": false, "create": false } From 75d220e74d426ff6dae518ecde056a3086012b21 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 3 Mar 2015 13:38:15 +0200 Subject: [PATCH 14/22] dev --- application/Espo/Core/defaults/config.php | 2 +- .../Modules/Crm/Resources/i18n/en_US/Account.json | 3 ++- .../Modules/Crm/Resources/i18n/en_US/Campaign.json | 4 +++- .../Crm/Resources/i18n/en_US/CampaignLogRecord.json | 4 ++-- .../Modules/Crm/Resources/i18n/en_US/Contact.json | 3 ++- .../Espo/Modules/Crm/Resources/i18n/en_US/Lead.json | 3 ++- .../layouts/CampaignLogRecord/listForCampaign.json | 6 +++--- .../layouts/CampaignLogRecord/listSmall.json | 7 ++++--- .../Crm/Resources/metadata/clientDefs/Account.json | 5 +++++ .../Crm/Resources/metadata/clientDefs/Campaign.json | 2 +- .../Crm/Resources/metadata/clientDefs/Contact.json | 9 ++++++++- .../Crm/Resources/metadata/clientDefs/Lead.json | 9 ++++++++- .../Crm/Resources/metadata/entityDefs/Account.json | 5 +++++ .../metadata/entityDefs/CampaignLogRecord.json | 4 ++++ .../Crm/Resources/metadata/entityDefs/Contact.json | 5 +++++ .../Crm/Resources/metadata/entityDefs/Lead.json | 5 +++++ .../campaign-log-record/fields/data/detail.tpl | 1 + .../crm/src/views/campaign-log-record/fields/data.js | 12 ++++++++++++ 18 files changed, 73 insertions(+), 16 deletions(-) create mode 100644 frontend/client/modules/crm/res/templates/campaign-log-record/fields/data/detail.tpl diff --git a/application/Espo/Core/defaults/config.php b/application/Espo/Core/defaults/config.php index c067e864af..4d8e0353c2 100644 --- a/application/Espo/Core/defaults/config.php +++ b/application/Espo/Core/defaults/config.php @@ -87,7 +87,7 @@ return array ( 'Lead', 'Opportunity', ), - "tabList" => array("Account", "Contact", "Lead", "Opportunity", "Calendar", "Meeting", "Call", "Task", "Case", "Email"), + "tabList" => array("Account", "Contact", "Lead", "Opportunity", "Calendar", "Meeting", "Call", "Task", "Case", "Email", "Campaign"), "quickCreateList" => array("Account", "Contact", "Lead", "Opportunity", "Meeting", "Call", "Task", "Case"), 'calendarDefaultEntity' => 'Meeting', 'disableExport' => false, diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/Account.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/Account.json index 1a96f3ecd4..a4df8eb23c 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/Account.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/Account.json @@ -21,7 +21,8 @@ "meetingsPrimary": "Meetings (Internal)", "callsPrimary": "Calls (Internal)", "tasksPrimary": "Tasks (Internal)", - "targetLists": "Target Lists" + "targetLists": "Target Lists", + "campaignLogRecords": "Campaign Log" }, "options": { "type": { diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json index 28cec9b58b..1118dc666d 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json @@ -33,7 +33,9 @@ }, "labels": { "Create Campaign": "Create Campaign", - "Target Lists": "Target Lists" + "Target Lists": "Target Lists", + "hard": "hard", + "soft": "soft" }, "presetFilters": { "active": "Active" diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json index a531cac918..1358090b15 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json @@ -1,10 +1,10 @@ { "fields": { "action": "Action", - "actionDate": "Action Date", + "actionDate": "Date", "data": "Data", "campaign": "Campaign", - "parent": "Parent", + "parent": "Target", "object": "Object", "application": "Application" }, diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/Contact.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/Contact.json index 0cee568b47..47752d1ad0 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/Contact.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/Contact.json @@ -17,7 +17,8 @@ "links": { "opportunities": "Opportunities", "cases": "Cases", - "targetLists": "Target Lists" + "targetLists": "Target Lists", + "campaignLogRecords": "Campaign Log" }, "labels": { "Create Contact": "Create Contact" diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/Lead.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/Lead.json index 7bdc3b4dce..eb6bb4c65b 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/Lead.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/Lead.json @@ -24,7 +24,8 @@ "campaign": "Campaign" }, "links": { - "targetLists": "Target Lists" + "targetLists": "Target Lists", + "campaignLogRecords": "Campaign Log" }, "options": { "status": { diff --git a/application/Espo/Modules/Crm/Resources/layouts/CampaignLogRecord/listForCampaign.json b/application/Espo/Modules/Crm/Resources/layouts/CampaignLogRecord/listForCampaign.json index 6658440ae1..17e049a7da 100644 --- a/application/Espo/Modules/Crm/Resources/layouts/CampaignLogRecord/listForCampaign.json +++ b/application/Espo/Modules/Crm/Resources/layouts/CampaignLogRecord/listForCampaign.json @@ -1,6 +1,6 @@ [ - {"name": "action", "notSortable": true, "width": 14}, + {"name": "action", "notSortable": true, "width": 15}, {"name": "parent", "notSortable": true}, - {"name": "actionDate", "width": 18}, - {"name": "data", "notSortable": true, "customLabel": ""} + {"name": "data", "notSortable": true, "customLabel": ""}, + {"name": "actionDate", "width": 18} ] diff --git a/application/Espo/Modules/Crm/Resources/layouts/CampaignLogRecord/listSmall.json b/application/Espo/Modules/Crm/Resources/layouts/CampaignLogRecord/listSmall.json index 0140b5823b..46770b2e3d 100644 --- a/application/Espo/Modules/Crm/Resources/layouts/CampaignLogRecord/listSmall.json +++ b/application/Espo/Modules/Crm/Resources/layouts/CampaignLogRecord/listSmall.json @@ -1,5 +1,6 @@ [ - {"name": "action", "width": 40}, - {"name": "actionDate"}, - {"name": "campaign"} + {"name": "action", "notSortable": true, "width": 15}, + {"name": "data", "notSortable": true, "customLabel": ""}, + {"name": "campaign", "notSortable": true}, + {"name": "actionDate", "width": 18} ] diff --git a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Account.json b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Account.json index e544768c5d..53a3acabc4 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Account.json +++ b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Account.json @@ -28,6 +28,11 @@ ], "layout":"listForAccount" + }, + "campaignLogRecords": { + "rowActionsView": "Record.RowActions.Empty", + "select": false, + "create": false } }, "boolFilters": ["onlyMy"] diff --git a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json index 00a100295c..73f1aa0348 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json @@ -20,7 +20,7 @@ "campaignLogRecords": { "view": "Crm:Campaign.Record.Panels.CampaignLogRecords", "layout": "listForCampaign", - "rowActionsView": false, + "rowActionsView": "Record.RowActions.Empty", "select": false, "create": false } diff --git a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Contact.json b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Contact.json index 2e53aa5d20..90b25eff0e 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Contact.json +++ b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Contact.json @@ -22,5 +22,12 @@ } ] }, - "boolFilters": ["onlyMy"] + "relationshipPanels": { + "campaignLogRecords": { + "rowActionsView": "Record.RowActions.Empty", + "select": false, + "create": false + } + }, + "boolFilters": ["onlyMy"] } diff --git a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Lead.json b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Lead.json index 43cb5bb27e..9cd77fce6d 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Lead.json +++ b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Lead.json @@ -25,6 +25,13 @@ } ] }, + "relationshipPanels": { + "campaignLogRecords": { + "rowActionsView": "Record.RowActions.Empty", + "select": false, + "create": false + } + }, "presetFilters": [ { "name":"active", @@ -35,7 +42,7 @@ "value": ["New", "Assigned", "In Process"] } } - } + } ], "boolFilters": ["onlyMy"] } diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json index ad34d1650f..0c3e67b23a 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json @@ -219,6 +219,11 @@ "foreign": "accounts", "noJoin": true }, + "campaignLogRecords": { + "type": "hasChildren", + "entity": "CampaignLogRecord", + "foreign": "parent" + }, "targetLists": { "type": "hasMany", "entity": "TargetList", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json index a58c199f4d..73b4e04ae8 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json @@ -18,6 +18,10 @@ "type": "varchar", "maxLength": 100 }, + "stringAdditionalData": { + "type": "varchar", + "maxLength": 100 + }, "application": { "type": "varchar", "required": true, diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json index 6fab1a10a8..821506a5b5 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json @@ -203,6 +203,11 @@ "foreign": "contacts", "noJoin": true }, + "campaignLogRecords": { + "type": "hasChildren", + "entity": "CampaignLogRecord", + "foreign": "parent" + }, "targetLists": { "type": "hasMany", "entity": "TargetList", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json index bc2278f0e2..57d03c0702 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json @@ -202,6 +202,11 @@ "foreign": "leads", "noJoin": true }, + "campaignLogRecords": { + "type": "hasChildren", + "entity": "CampaignLogRecord", + "foreign": "parent" + }, "targetLists": { "type": "hasMany", "entity": "TargetList", diff --git a/frontend/client/modules/crm/res/templates/campaign-log-record/fields/data/detail.tpl b/frontend/client/modules/crm/res/templates/campaign-log-record/fields/data/detail.tpl new file mode 100644 index 0000000000..d7c3887ed3 --- /dev/null +++ b/frontend/client/modules/crm/res/templates/campaign-log-record/fields/data/detail.tpl @@ -0,0 +1 @@ +{{{value}}} \ No newline at end of file diff --git a/frontend/client/modules/crm/src/views/campaign-log-record/fields/data.js b/frontend/client/modules/crm/src/views/campaign-log-record/fields/data.js index b6b8a0fc4a..17a3bd97aa 100644 --- a/frontend/client/modules/crm/src/views/campaign-log-record/fields/data.js +++ b/frontend/client/modules/crm/src/views/campaign-log-record/fields/data.js @@ -24,6 +24,8 @@ Espo.define('Crm:Views.CampaignLogRecord.Fields.Data', 'Views.Fields.Base', func return Dep.extend({ + listTemplate: 'crm:campaign-log-record.fields.data.detail', + getValueForDisplay: function () { var action = this.model.get('action'); @@ -32,6 +34,16 @@ Espo.define('Crm:Views.CampaignLogRecord.Fields.Data', 'Views.Fields.Base', func return this.model.get('stringData'); case 'Clicked': return this.model.get('stringData'); + case 'Opted Out': + return '' + this.model.get('stringData') + ''; + case 'Bounced': + var emailAddress = this.model.get('stringData'); + var type = this.model.get('stringAdditionalData'); + if (type == 'Hard') { + return '' + emailAddress + ''; + } else { + return '' + emailAddress + ''; + } } return ''; } From b150aad9770f4d3be6c468b3bd93a27b2bbf9737 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 3 Mar 2015 15:45:20 +0200 Subject: [PATCH 15/22] dev --- .../i18n/en_US/CampaignLogRecord.json | 9 ++++++++ .../record/panels/campaign-log-records.tpl | 8 +++++++ .../record/panels/campaign-log-records.js | 23 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 frontend/client/modules/crm/res/templates/campaign/record/panels/campaign-log-records.tpl diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json index 1358090b15..643deadc30 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json @@ -10,6 +10,15 @@ }, "options": { "action": { + "Sent": "Sent", + "Viewed": "Viewed", + "Opted Out": "Opted Out", + "Bounced": "Bounced", + "Clicked": "Clicked", + "Lead Created": "Lead Created" } + }, + "labels": { + "All": "All" } } diff --git a/frontend/client/modules/crm/res/templates/campaign/record/panels/campaign-log-records.tpl b/frontend/client/modules/crm/res/templates/campaign/record/panels/campaign-log-records.tpl new file mode 100644 index 0000000000..88149a4c8a --- /dev/null +++ b/frontend/client/modules/crm/res/templates/campaign/record/panels/campaign-log-records.tpl @@ -0,0 +1,8 @@ +
+
+ +
+
+
{{{list}}}
diff --git a/frontend/client/modules/crm/src/views/campaign/record/panels/campaign-log-records.js b/frontend/client/modules/crm/src/views/campaign/record/panels/campaign-log-records.js index cb11d450eb..00b9fab737 100644 --- a/frontend/client/modules/crm/src/views/campaign/record/panels/campaign-log-records.js +++ b/frontend/client/modules/crm/src/views/campaign/record/panels/campaign-log-records.js @@ -24,6 +24,29 @@ Espo.define('Crm:Views.Campaign.Record.Panels.CampaignLogRecords', 'Views.Record return Dep.extend({ + template: 'crm:campaign.record.panels.campaign-log-records', + + filterList: ["All", "Sent", "Viewed", "Opted Out", "Bounced", "Clicked", "Lead Created"], + + data: function () { + return _.extend({ + filterList: this.filterList, + filterValue: this.filterValue, + filterTranslatedOptions: this.getFilterTranslatedOptions() + }, Dep.prototype.data.call(this)); + }, + + getFilterTranslatedOptions: function () { + var o = Espo.Utils.clone(this.getLanguage().get('CampaignLogRecord', 'options', 'action')); + o['All'] = this.translate('All', 'labels', 'CampaignLogRecord'); + + return o; + }, + + setup: function () { + this.addEvent(); + + } }); }); From 5a7f3ed101357f5a8eedb528ae3965329e6fdb79 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 3 Mar 2015 15:58:17 +0200 Subject: [PATCH 16/22] dev --- .../record/panels/campaign-log-records.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/frontend/client/modules/crm/src/views/campaign/record/panels/campaign-log-records.js b/frontend/client/modules/crm/src/views/campaign/record/panels/campaign-log-records.js index 00b9fab737..6552d51fa8 100644 --- a/frontend/client/modules/crm/src/views/campaign/record/panels/campaign-log-records.js +++ b/frontend/client/modules/crm/src/views/campaign/record/panels/campaign-log-records.js @@ -44,7 +44,27 @@ Espo.define('Crm:Views.Campaign.Record.Panels.CampaignLogRecords', 'Views.Record }, setup: function () { - this.addEvent(); + Dep.prototype.setup.call(this); + this.events = Espo.Utils.clone(this.events || {}); + + this.events['change select[name="filter"]'] = function (e) { + var value = $(e.currentTarget).val(); + this.setFilter(value); + }; + }, + + setFilter: function (value) { + this.filterValue = value; + if (value && value != 'All') { + this.collection.where = [{ + field: 'action', + type: 'equals', + value: value + }]; + } else { + this.collection.where = []; + } + this.collection.fetch(); } From 6aa012891dca70629d94c3418ef78b6f7ef3a471 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 3 Mar 2015 17:26:00 +0200 Subject: [PATCH 17/22] dev --- .../Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json | 2 +- .../Crm/Resources/metadata/entityDefs/CampaignLogRecord.json | 2 +- .../modules/crm/src/views/campaign-log-record/fields/data.js | 2 +- .../src/views/campaign/record/panels/campaign-log-records.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json index 643deadc30..67f75dbc6a 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/CampaignLogRecord.json @@ -11,7 +11,7 @@ "options": { "action": { "Sent": "Sent", - "Viewed": "Viewed", + "Opened": "Opened", "Opted Out": "Opted Out", "Bounced": "Bounced", "Clicked": "Clicked", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json index 73b4e04ae8..2796d6e54c 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/CampaignLogRecord.json @@ -4,7 +4,7 @@ "type": "enum", "required": true, "maxLength": 50, - "options": ["Sent", "Viewed", "Opted Out", "Bounced", "Clicked", "Lead Created"] + "options": ["Sent", "Opened", "Opted Out", "Bounced", "Clicked", "Lead Created"] }, "actionDate": { "type": "datetime", diff --git a/frontend/client/modules/crm/src/views/campaign-log-record/fields/data.js b/frontend/client/modules/crm/src/views/campaign-log-record/fields/data.js index 17a3bd97aa..84dc82b665 100644 --- a/frontend/client/modules/crm/src/views/campaign-log-record/fields/data.js +++ b/frontend/client/modules/crm/src/views/campaign-log-record/fields/data.js @@ -33,7 +33,7 @@ Espo.define('Crm:Views.CampaignLogRecord.Fields.Data', 'Views.Fields.Base', func case 'Sent': return this.model.get('stringData'); case 'Clicked': - return this.model.get('stringData'); + return '' + this.model.get('stringData') + ''; case 'Opted Out': return '' + this.model.get('stringData') + ''; case 'Bounced': diff --git a/frontend/client/modules/crm/src/views/campaign/record/panels/campaign-log-records.js b/frontend/client/modules/crm/src/views/campaign/record/panels/campaign-log-records.js index 6552d51fa8..d07818acf5 100644 --- a/frontend/client/modules/crm/src/views/campaign/record/panels/campaign-log-records.js +++ b/frontend/client/modules/crm/src/views/campaign/record/panels/campaign-log-records.js @@ -26,7 +26,7 @@ Espo.define('Crm:Views.Campaign.Record.Panels.CampaignLogRecords', 'Views.Record template: 'crm:campaign.record.panels.campaign-log-records', - filterList: ["All", "Sent", "Viewed", "Opted Out", "Bounced", "Clicked", "Lead Created"], + filterList: ["All", "Sent", "Opened", "Opted Out", "Bounced", "Clicked", "Lead Created"], data: function () { return _.extend({ From caa659020eecbbc547266fdf64401d42f8369036 Mon Sep 17 00:00:00 2001 From: yuri Date: Wed, 4 Mar 2015 12:13:47 +0200 Subject: [PATCH 18/22] dev --- .../Crm/Resources/i18n/en_US/Campaign.json | 1 + .../metadata/clientDefs/Campaign.json | 9 ++++ .../campaign/record/panels/statistics.tpl | 1 + .../crm/src/views/campaign/record/detail.js | 17 ++++++++ .../campaign/record/panels/statistics.js | 41 +++++++++++++++++++ 5 files changed, 69 insertions(+) create mode 100644 frontend/client/modules/crm/res/templates/campaign/record/panels/statistics.tpl create mode 100644 frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json index 1118dc666d..68c32d34c3 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json @@ -34,6 +34,7 @@ "labels": { "Create Campaign": "Create Campaign", "Target Lists": "Target Lists", + "Statistics": "Statistics", "hard": "hard", "soft": "soft" }, diff --git a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json index 73f1aa0348..458c5b2e4b 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json @@ -16,6 +16,15 @@ "recordViews": { "detail": "Crm:Campaign.Record.Detail" }, + "sidePanels":{ + "detail":[ + { + "name":"statistics", + "label":"Statistics", + "view":"Crm:Campaign.Record.Panels.Statistics" + } + ] + }, "relationshipPanels": { "campaignLogRecords": { "view": "Crm:Campaign.Record.Panels.CampaignLogRecords", diff --git a/frontend/client/modules/crm/res/templates/campaign/record/panels/statistics.tpl b/frontend/client/modules/crm/res/templates/campaign/record/panels/statistics.tpl new file mode 100644 index 0000000000..30d74d2584 --- /dev/null +++ b/frontend/client/modules/crm/res/templates/campaign/record/panels/statistics.tpl @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/frontend/client/modules/crm/src/views/campaign/record/detail.js b/frontend/client/modules/crm/src/views/campaign/record/detail.js index 92ba40c115..bf7dff6fcd 100644 --- a/frontend/client/modules/crm/src/views/campaign/record/detail.js +++ b/frontend/client/modules/crm/src/views/campaign/record/detail.js @@ -26,6 +26,23 @@ Espo.define('Crm:Views.Campaign.Record.Detail', 'Views.Record.Detail', function bottomView: 'Crm:Campaign.Record.DetailBottom', + handleStatisticsPanelAppearance: function() { + if (this.model.get('status') == 'Planning') { + this.hidePanel('statistics'); + } else { + this.showPanel('statistics'); + } + }, + + afterRender: function () { + Dep.prototype.afterRender.call(this); + + this.handleStatisticsPanelAppearance(); + this.listenTo(this.model, 'change:status', function () { + this.handleStatisticsPanelAppearance(); + }, this); + }, + }); }); diff --git a/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js b/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js new file mode 100644 index 0000000000..01629d586c --- /dev/null +++ b/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js @@ -0,0 +1,41 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://www.espocrm.com + * + * EspoCRM is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * EspoCRM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with EspoCRM. If not, see http://www.gnu.org/licenses/. + ************************************************************************/ + + +Espo.define('Crm:Views.Campaign.Record.Panels.Statistics', 'Views.Record.Panels.Side', function (Dep) { + + return Dep.extend({ + + template: 'crm:campaign.record.panels.statistics', + + data: function () { + return {}; + }, + + setup: function () { + Dep.prototype.setup.call(this); + } + + + }); +}); + + From 2ff6946b9155cbc846b6f7724d63faeb7f0920a8 Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 5 Mar 2015 11:14:02 +0200 Subject: [PATCH 19/22] dev --- .../Crm/Resources/i18n/en_US/Campaign.json | 14 +++- .../metadata/entityDefs/Campaign.json | 74 ++++++++++++++++++- .../campaign/record/panels/statistics.js | 33 ++++++++- 3 files changed, 116 insertions(+), 5 deletions(-) diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json index 68c32d34c3..ffa1892b7a 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/Campaign.json @@ -6,7 +6,16 @@ "type": "Type", "startDate": "Start Date", "endDate": "End Date", - "targetLists": "Target Lists" + "targetLists": "Target Lists", + "sentCount": "Sent", + "openedCount": "Opened", + "clickedCount": "Clicked", + "optedOutCount": "Opted Out", + "bouncedCount": "Bounced", + "hardBouncedCount": "Hard Bounced", + "softBouncedCount": "Soft Bounced", + "leadCreatedCount": "Leads Created", + "revenue": "Revenue" }, "links": { "targetLists": "Target Lists", @@ -22,7 +31,8 @@ "Web": "Web", "Television": "Television", "Radio": "Radio", - "Newsletter": "Newsletter" + "Newsletter": "Newsletter", + "Mail": "Mail" }, "status": { "Planning": "Planning", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json index 90d6128e76..a99375488d 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json @@ -11,7 +11,7 @@ }, "type": { "type": "enum", - "options": ["Email", "Web", "Television", "Radio", "Newsletter"] + "options": ["Email", "Newsletter", "Web", "Television", "Radio", "Mail"] }, "startDate": { "type": "date" @@ -47,6 +47,78 @@ }, "targetLists": { "type": "linkMultiple" + }, + "sentCount": { + "type": "int", + "notStorable": true, + "readOnly": true, + "layoutDetailDisabled": true, + "layoutListDisabled": true, + "layoutSearchDisabled": true + }, + "openedCount": { + "type": "int", + "notStorable": true, + "readOnly": true, + "layoutDetailDisabled": true, + "layoutListDisabled": true, + "layoutSearchDisabled": true + }, + "clickedCount": { + "type": "int", + "notStorable": true, + "readOnly": true, + "layoutDetailDisabled": true, + "layoutListDisabled": true, + "layoutSearchDisabled": true + }, + "optedOutCount": { + "type": "int", + "notStorable": true, + "readOnly": true, + "layoutDetailDisabled": true, + "layoutListDisabled": true, + "layoutSearchDisabled": true + }, + "bouncedCount": { + "type": "int", + "notStorable": true, + "readOnly": true, + "layoutDetailDisabled": true, + "layoutListDisabled": true, + "layoutSearchDisabled": true + }, + "hardBouncedCount": { + "type": "int", + "notStorable": true, + "readOnly": true, + "layoutDetailDisabled": true, + "layoutListDisabled": true, + "layoutSearchDisabled": true + }, + "softBouncedCount": { + "type": "int", + "notStorable": true, + "readOnly": true, + "layoutDetailDisabled": true, + "layoutListDisabled": true, + "layoutSearchDisabled": true + }, + "leadCreatedCount": { + "type": "int", + "notStorable": true, + "readOnly": true, + "layoutDetailDisabled": true, + "layoutListDisabled": true, + "layoutSearchDisabled": true + }, + "revenue": { + "type": "currency", + "notStorable": true, + "readOnly": true, + "layoutDetailDisabled": true, + "layoutListDisabled": true, + "layoutSearchDisabled": true } }, "links": { diff --git a/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js b/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js index 01629d586c..dab13c449d 100644 --- a/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js +++ b/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js @@ -24,17 +24,46 @@ Espo.define('Crm:Views.Campaign.Record.Panels.Statistics', 'Views.Record.Panels. return Dep.extend({ - template: 'crm:campaign.record.panels.statistics', - data: function () { + /*data: function () { return {}; + },*/ + + setupFieldList: function () { + var type = this.model.get('type'); + switch (type) { + case 'Email': + case 'Newsletter': + this.fields = ['sentCount', 'openedCount', 'clickedCount', 'optedOutCount', 'bouncedCount', 'revenue']; + break; + case 'Web': + case 'Television': + case 'Radio': + this.fields = ['leadCreatedCount', 'revenue']; + break; + case 'Mail': + this.fields = ['sentCount', 'leadCreatedCount', 'revenue']; + break; + default: + this.fields = ['leadCreatedCount', 'revenue']; + } }, setup: function () { + this.fields = ['sentCount', 'openedCount', 'clickedCount', 'optedOutCount', 'bouncedCount', 'leadCreatedCount', 'revenue']; Dep.prototype.setup.call(this); + this.setupFieldList(); + + this.listenTo(this.model, 'change:type', function () { + this.setupFieldList(); + if (this.isRendered()) { + this.render(); + } + }, this); } + }); }); From 4e0d570f903135596bbcdbb80330310a7c70293b Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 5 Mar 2015 12:26:11 +0200 Subject: [PATCH 20/22] dev --- .../Espo/Modules/Crm/Services/Campaign.php | 100 ++++++++++++++++++ .../campaign/record/panels/statistics.js | 9 +- 2 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 application/Espo/Modules/Crm/Services/Campaign.php diff --git a/application/Espo/Modules/Crm/Services/Campaign.php b/application/Espo/Modules/Crm/Services/Campaign.php new file mode 100644 index 0000000000..2bf174ac9b --- /dev/null +++ b/application/Espo/Modules/Crm/Services/Campaign.php @@ -0,0 +1,100 @@ +getEntityManager()->getRepository('CampaignLogRecord')->where(array( + 'campaignId' => $entity->id, + 'action' => 'Clicked' + ))->count(); + $entity->set('sentCount', $sentCount); + + $openedCount = $this->getEntityManager()->getRepository('CampaignLogRecord')->where(array( + 'campaignId' => $entity->id, + 'action' => 'Opened' + ))->count(); + $entity->set('openedCount', $openedCount); + + $clickedCount = $this->getEntityManager()->getRepository('CampaignLogRecord')->where(array( + 'campaignId' => $entity->id, + 'action' => 'Clicked' + ))->count(); + $entity->set('clickedCount', $clickedCount); + + $optedOutCount = $this->getEntityManager()->getRepository('CampaignLogRecord')->where(array( + 'campaignId' => $entity->id, + 'action' => 'Opted Out' + ))->count(); + $entity->set('optedOutCount', $optedOutCount); + + $bouncedCount = $this->getEntityManager()->getRepository('CampaignLogRecord')->where(array( + 'campaignId' => $entity->id, + 'action' => 'Bounced' + ))->count(); + $entity->set('bouncedCount', $bouncedCount); + + $leadCreatedCount = $this->getEntityManager()->getRepository('CampaignLogRecord')->where(array( + 'campaignId' => $entity->id, + 'action' => 'Lead Created' + ))->count(); + $entity->set('leadCreatedCount', $leadCreatedCount); + + $entity->set('revenueCurrency', $this->getConfig()->get('defaultCurrency')); + + $params = array( + 'select' => array('SUM:amountConverted'), + 'whereClause' => array( + 'status' => 'Closed Won', + 'campaignId' => $entity->id + ), + 'groupBy' => array('opportunity.campaignId') + ); + + $this->getEntityManager()->getRepository('Opportunity')->handleSelectParams($params); + + + $sql = $this->getEntityManager()->getQuery()->createSelectQuery('Opportunity', $params); + + + $pdo = $this->getEntityManager()->getPDO(); + $sth = $pdo->prepare($sql); + $sth->execute(); + + if ($row = $sth->fetch(\PDO::FETCH_ASSOC)) { + $revenue = floatval($row['SUM:amountConverted']); + if ($revenue > 0) { + $entity->set('revenue', $revenue); + } + } + } + +} + diff --git a/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js b/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js index dab13c449d..2fbdea2299 100644 --- a/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js +++ b/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js @@ -25,10 +25,6 @@ Espo.define('Crm:Views.Campaign.Record.Panels.Statistics', 'Views.Record.Panels. return Dep.extend({ - /*data: function () { - return {}; - },*/ - setupFieldList: function () { var type = this.model.get('type'); switch (type) { @@ -60,8 +56,11 @@ Espo.define('Crm:Views.Campaign.Record.Panels.Statistics', 'Views.Record.Panels. this.render(); } }, this); - } + }, + actionRefresh: function () { + this.model.fetch(); + }, }); From 2ec4464a52226dbb5e2df27736fbbd5de545d863 Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 5 Mar 2015 15:12:55 +0200 Subject: [PATCH 21/22] dev --- .../crm/src/views/campaign/record/panels/statistics.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js b/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js index 2fbdea2299..b990677f19 100644 --- a/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js +++ b/frontend/client/modules/crm/src/views/campaign/record/panels/statistics.js @@ -30,23 +30,23 @@ Espo.define('Crm:Views.Campaign.Record.Panels.Statistics', 'Views.Record.Panels. switch (type) { case 'Email': case 'Newsletter': - this.fields = ['sentCount', 'openedCount', 'clickedCount', 'optedOutCount', 'bouncedCount', 'revenue']; + this.fieldList = ['sentCount', 'openedCount', 'clickedCount', 'optedOutCount', 'bouncedCount', 'revenue']; break; case 'Web': case 'Television': case 'Radio': - this.fields = ['leadCreatedCount', 'revenue']; + this.fieldList = ['leadCreatedCount', 'revenue']; break; case 'Mail': - this.fields = ['sentCount', 'leadCreatedCount', 'revenue']; + this.fieldList = ['sentCount', 'leadCreatedCount', 'revenue']; break; default: - this.fields = ['leadCreatedCount', 'revenue']; + this.fieldList = ['leadCreatedCount', 'revenue']; } }, setup: function () { - this.fields = ['sentCount', 'openedCount', 'clickedCount', 'optedOutCount', 'bouncedCount', 'leadCreatedCount', 'revenue']; + this.fieldList = ['sentCount', 'openedCount', 'clickedCount', 'optedOutCount', 'bouncedCount', 'leadCreatedCount', 'revenue']; Dep.prototype.setup.call(this); this.setupFieldList(); From 817fc2fd40362599d42379087ee3a4faf1367473 Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 5 Mar 2015 18:36:07 +0200 Subject: [PATCH 22/22] fix ORM Query --- application/Espo/ORM/DB/Query/Base.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/application/Espo/ORM/DB/Query/Base.php b/application/Espo/ORM/DB/Query/Base.php index 812d942026..e013bf34e0 100644 --- a/application/Espo/ORM/DB/Query/Base.php +++ b/application/Espo/ORM/DB/Query/Base.php @@ -167,7 +167,7 @@ abstract class Base if (!empty($params['groupBy']) && is_array($params['groupBy'])) { $arr = array(); foreach ($params['groupBy'] as $field) { - $arr[] = $this->convertComplexExpression($entity, $field, $entity->getEntityType()); + $arr[] = $this->convertComplexExpression($entity, $field); } $groupByPart = implode(', ', $arr); } @@ -201,11 +201,13 @@ abstract class Base } - protected function convertComplexExpression($entity, $field, $entityName = null, $distinct = false) + protected function convertComplexExpression($entity, $field, $distinct = false) { $function = null; $relName = null; + $entityType = $entity->getEntityType(); + if (strpos($field, ':')) { list($function, $field) = explode(':', $field); } @@ -230,13 +232,11 @@ abstract class Base if (!empty($entity->fields[$field]['select'])) { $part = $entity->fields[$field]['select']; } else { - if ($entityName) { - $part = $this->toDb($entityName) . '.' . $part; - } + $part = $this->toDb($entityType) . '.' . $part; } } if ($function) { - $part = $this->getFunctionPart(strtoupper($function), $part, $entityName, $distinct); + $part = $this->getFunctionPart(strtoupper($function), $part, $entityType, $distinct); } return $part; } @@ -257,7 +257,7 @@ abstract class Base if (array_key_exists($field, $entity->fields)) { $fieldDefs = $entity->fields[$field]; } else { - $part = $this->convertComplexExpression($entity, $field, $entity->getEntityType(), $distinct); + $part = $this->convertComplexExpression($entity, $field, $distinct); $arr[] = $part . ' AS `' . $field . '`'; continue; }