From 7b772bde3cb29b45ce48df44dae1347a7178208d Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 16 May 2019 15:24:12 +0300 Subject: [PATCH 01/40] cs fix --- application/Espo/Modules/Crm/Services/Activities.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/application/Espo/Modules/Crm/Services/Activities.php b/application/Espo/Modules/Crm/Services/Activities.php index 2452de3141..6556d927c2 100644 --- a/application/Espo/Modules/Crm/Services/Activities.php +++ b/application/Espo/Modules/Crm/Services/Activities.php @@ -225,7 +225,7 @@ class Activities extends \Espo\Core\Services\Base $selectManager = $this->getSelectManagerFactory()->create('Email'); - $selectParams = array( + $selectParams = [ 'select' => [ 'id', 'name', @@ -243,16 +243,16 @@ class Activities extends \Espo\Core\Services\Base 'hasAttachment' ], 'leftJoins' => [['users', 'usersLeft']], - 'whereClause' => array( + 'whereClause' => [ 'usersLeftMiddle.userId' => $entity->id - ), + ], 'customJoin' => '' - ); + ]; if (!empty($statusList)) { - $selectParams['whereClause'][] = array( + $selectParams['whereClause'][] = [ 'status' => $statusList - ); + ]; } $selectManager->applyAccess($selectParams); From bf8ab4dec2c79b112d445a7fb2dae6d4e0395a99 Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 16 May 2019 16:18:41 +0300 Subject: [PATCH 02/40] account shipping address copy button hidden --- .../views/account/fields/shipping-address.js | 57 +++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/client/modules/crm/src/views/account/fields/shipping-address.js b/client/modules/crm/src/views/account/fields/shipping-address.js index 377d4d80ed..e6011c8827 100644 --- a/client/modules/crm/src/views/account/fields/shipping-address.js +++ b/client/modules/crm/src/views/account/fields/shipping-address.js @@ -26,21 +26,55 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('crm:views/account/fields/shipping-address', 'views/fields/address', function (Dep) { +define('crm:views/account/fields/shipping-address', 'views/fields/address', function (Dep) { return Dep.extend({ copyFrom: 'billingAddress', + setup: function () { + Dep.prototype.setup.call(this); + + this.attributePartList = this.getMetadata().get(['fields', 'address', 'actualFields']) || []; + + this.allAddressAttributeList = []; + this.attributePartList.forEach(function (part) { + this.allAddressAttributeList.push(this.copyFrom + Espo.Utils.upperCaseFirst(part)); + this.allAddressAttributeList.push(this.name + Espo.Utils.upperCaseFirst(part)); + }, this); + + this.listenTo(this.model, 'change', function () { + var isChanged = false; + this.allAddressAttributeList.forEach(function (attribute) { + if (this.model.hasChanged(attribute)) { + isChanged = true; + } + }, this); + if (isChanged) { + if (this.isEditMode() && this.isRendered() && this.$copyButton) { + if (this.toShowCopyButton()) { + this.$copyButton.removeClass('hidden'); + } else { + this.$copyButton.addClass('hidden'); + } + } + } + }, this); + }, + afterRender: function () { Dep.prototype.afterRender.call(this); if (this.mode == 'edit') { var label = this.translate('Copy Billing', 'labels', 'Account'); - $btn = $('').on('click', function () { + this.$copyButton = $(''); + this.$copyButton.on('click', function () { this.copy(this.copyFrom); }.bind(this)); - this.$el.append($btn); + if (!this.toShowCopyButton()) { + this.$copyButton.addClass('hidden'); + } + this.$el.append(this.$copyButton); } }, @@ -51,9 +85,24 @@ Espo.define('crm:views/account/fields/shipping-address', 'views/fields/address', this.model.set(destField, this.model.get(sourceField)); }, this); + }, + toShowCopyButton: function () { + var billingIsNotEmpty = false; + var shippingIsNotEmpty = false; + this.attributePartList.forEach(function (part) { + var attribute = this.copyFrom + Espo.Utils.upperCaseFirst(part); + if (this.model.get(attribute)) { + billingIsNotEmpty = true; + } + var attribute = this.name + Espo.Utils.upperCaseFirst(part); + if (this.model.get(attribute)) { + shippingIsNotEmpty = true; + } + }, this); + + return billingIsNotEmpty && !shippingIsNotEmpty; }, }); }); - From 2cf820e181fabaf93502c08c02a91de1b4b6aa44 Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 16 May 2019 16:53:09 +0300 Subject: [PATCH 03/40] user activities fix and optimization --- .../Espo/Modules/Crm/Services/Activities.php | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/application/Espo/Modules/Crm/Services/Activities.php b/application/Espo/Modules/Crm/Services/Activities.php index 6556d927c2..d67fcbc055 100644 --- a/application/Espo/Modules/Crm/Services/Activities.php +++ b/application/Espo/Modules/Crm/Services/Activities.php @@ -104,7 +104,7 @@ class Activities extends \Espo\Core\Services\Base { $selectManager = $this->getSelectManagerFactory()->create('Meeting'); - $selectParams = array( + $selectParams = [ 'select' => [ 'id', 'name', @@ -119,33 +119,31 @@ class Activities extends \Espo\Core\Services\Base 'parentId', 'status', 'createdAt', - ['VALUE:', 'hasAttachment'] + ['VALUE:', 'hasAttachment'], ], - 'leftJoins' => [['users', 'usersLeft']], - 'whereClause' => array( - ), - 'customJoin' => '' - ); + 'leftJoins' => [['MeetingUser', 'usersLeftMiddle', ['usersLeftMiddle.meetingId:' => 'meeting.id']]], + 'whereClause' => [], + ]; - $where = array( + $where = [ 'usersLeftMiddle.userId' => $entity->id - ); + ]; if ($entity->isPortal() && $entity->get('contactId')) { $selectParams['leftJoins'][] = ['contacts', 'contactsLeft']; $selectParams['distinct'] = true; $where['contactsLeftMiddle.contactId'] = $entity->get('contactId'); - $selectParams['whereClause'][] = array( + $selectParams['whereClause'][] = [ 'OR' => $where - ); + ]; } else { $selectParams['whereClause'][] = $where; } if (!empty($statusList)) { - $selectParams['whereClause'][] = array( + $selectParams['whereClause'][] = [ 'status' => $statusList - ); + ]; } $selectManager->applyAccess($selectParams); @@ -176,12 +174,10 @@ class Activities extends \Espo\Core\Services\Base 'parentId', 'status', 'createdAt', - ['VALUE:', 'hasAttachment'] + ['VALUE:', 'hasAttachment'], ], - 'leftJoins' => [['users', 'usersLeft']], - 'whereClause' => [ - ], - 'customJoin' => '' + 'leftJoins' => [['CallUser', 'usersLeftMiddle', ['usersLeftMiddle.callId:' => 'call.id']]], + 'whereClause' => [], ]; $where = [ @@ -231,7 +227,7 @@ class Activities extends \Espo\Core\Services\Base 'name', ['dateSent', 'dateStart'], ['VALUE:', 'dateEnd'], - ['VALUE:', 'dateStart'], + ['VALUE:', 'dateStartDate'], ['VALUE:', 'dateEndDate'], ['VALUE:Email', '_scope'], 'assignedUserId', @@ -242,11 +238,11 @@ class Activities extends \Espo\Core\Services\Base 'createdAt', 'hasAttachment' ], - 'leftJoins' => [['users', 'usersLeft']], + 'leftJoins' => [['EmailUser', 'usersLeftMiddle', ['usersLeftMiddle.emailId:' => 'email.id']]], 'whereClause' => [ 'usersLeftMiddle.userId' => $entity->id ], - 'customJoin' => '' + 'customJoin' => '', ]; if (!empty($statusList)) { From 1d29d74204df7fe63c8b359a80d2434490e9c6f5 Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 17 May 2019 12:46:39 +0300 Subject: [PATCH 04/40] cs fix --- .../Espo/Modules/Crm/Services/Activities.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/application/Espo/Modules/Crm/Services/Activities.php b/application/Espo/Modules/Crm/Services/Activities.php index d67fcbc055..924fbd8a78 100644 --- a/application/Espo/Modules/Crm/Services/Activities.php +++ b/application/Espo/Modules/Crm/Services/Activities.php @@ -618,10 +618,10 @@ class Activities extends \Espo\Core\Services\Base protected function getResultFromQueryParts($parts, $scope, $id, $params) { if (empty($parts)) { - return array( + return [ 'list' => [], 'total' => 0 - ); + ]; } $pdo = $this->getEntityManager()->getPDO(); @@ -632,29 +632,29 @@ class Activities extends \Espo\Core\Services\Base } if (!$onlyScope) { - $qu = implode(" UNION ", $parts); + $sql = implode(" UNION ", $parts); } else { - $qu = $parts[$onlyScope]; + $sql = $parts[$onlyScope]; } - $countQu = "SELECT COUNT(*) AS 'count' FROM ({$qu}) AS c"; - $sth = $pdo->prepare($countQu); + $sqlCount = "SELECT COUNT(*) AS 'count' FROM ({$sql}) AS c"; + $sth = $pdo->prepare($sqlCount); $sth->execute(); $row = $sth->fetch(PDO::FETCH_ASSOC); $totalCount = $row['count']; - $qu .= " + $sql .= " ORDER BY dateStart DESC, createdAt DESC "; if (!empty($params['maxSize'])) { - $qu .= " + $sql .= " LIMIT :offset, :maxSize "; } - $sth = $pdo->prepare($qu); + $sth = $pdo->prepare($sql); if (!empty($params['maxSize'])) { $offset = 0; @@ -681,10 +681,10 @@ class Activities extends \Espo\Core\Services\Base $list[] = $row; } - return array( + return [ 'list' => $list, 'total' => $totalCount - ); + ]; } protected function accessCheck($entity) From 86b24ff6189995fc3d0a1b47d6c432f3c6562c9c Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 17 May 2019 12:50:27 +0300 Subject: [PATCH 05/40] orm field type attribute role --- .../Core/Utils/Database/Orm/Converter.php | 6 ++- .../Utils/Database/Orm/Fields/Currency.php | 8 ++++ .../Core/Utils/Database/Orm/Fields/Link.php | 41 +++++++++-------- .../Database/Orm/Fields/LinkMultiple.php | 11 +++-- .../Utils/Database/Orm/Fields/LinkParent.php | 46 +++++++++++-------- 5 files changed, 70 insertions(+), 42 deletions(-) diff --git a/application/Espo/Core/Utils/Database/Orm/Converter.php b/application/Espo/Core/Utils/Database/Orm/Converter.php index 4d88403c68..ebf0c5494b 100644 --- a/application/Espo/Core/Utils/Database/Orm/Converter.php +++ b/application/Espo/Core/Utils/Database/Orm/Converter.php @@ -91,7 +91,7 @@ class Converter 'select' => 'select', 'orderBy' => 'orderBy', 'where' => 'where', - 'storeArrayValues' => 'storeArrayValues' + 'storeArrayValues' => 'storeArrayValues', ); protected $idParams = array( @@ -506,6 +506,10 @@ class Converter } } + if (isset($fieldParams['type'])) { + $values['fieldType'] = $fieldParams['type']; + } + return $values; } diff --git a/application/Espo/Core/Utils/Database/Orm/Fields/Currency.php b/application/Espo/Core/Utils/Database/Orm/Fields/Currency.php index 601c2ac735..3608ad2fd5 100644 --- a/application/Espo/Core/Utils/Database/Orm/Fields/Currency.php +++ b/application/Espo/Core/Utils/Database/Orm/Fields/Currency.php @@ -100,6 +100,8 @@ class Currency extends Base 'sql' => $converedFieldName . " {direction}", 'leftJoins' => $leftJoins, ], + 'attributeRole' => 'valueConverted', + 'fieldType' => 'currency', ]; $defs[$entityType]['fields'][$fieldName]['orderBy'] = [ @@ -108,6 +110,12 @@ class Currency extends Base ]; } + $defs[$entityType]['fields'][$fieldName]['attributeRole'] = 'value'; + $defs[$entityType]['fields'][$fieldName]['fieldType'] = 'currency'; + + $defs[$entityType]['fields'][$fieldName . 'Currency']['attributeRole'] = 'currency'; + $defs[$entityType]['fields'][$fieldName . 'Currency']['fieldType'] = 'currency'; + return $defs; } } diff --git a/application/Espo/Core/Utils/Database/Orm/Fields/Link.php b/application/Espo/Core/Utils/Database/Orm/Fields/Link.php index bf25a637f2..6b008e69a9 100644 --- a/application/Espo/Core/Utils/Database/Orm/Fields/Link.php +++ b/application/Espo/Core/Utils/Database/Orm/Fields/Link.php @@ -35,25 +35,30 @@ class Link extends Base { $fieldParams = $this->getFieldParams(); - $data = array( - $entityName => array ( - 'fields' => array( - $fieldName.'Id' => array( + $data = [ + $entityName => [ + 'fields' => [ + $fieldName.'Id' => [ 'type' => 'foreignId', - 'index' => $fieldName - ), - $fieldName.'Name' => array( + 'index' => $fieldName, + 'attributeRole' => 'id', + 'fieldType' => 'link', + ], + $fieldName.'Name' => [ 'type' => 'varchar', - 'notStorable' => true - ) - ) - ), - 'unset' => array( - $entityName => array( - 'fields.'.$fieldName - ) - ) - ); + 'notStorable' => true, + 'attributeRole' => 'name', + 'fieldType' => 'link', + ] + ] + ], + 'unset' => [ + $entityName => [ + 'fields.' . $fieldName + ] + ] + ]; + if (!empty($fieldParams['notStorable'])) { $data[$entityName]['fields'][$fieldName.'Id']['notStorable'] = true; } @@ -64,4 +69,4 @@ class Link extends Base return $data; } -} \ No newline at end of file +} diff --git a/application/Espo/Core/Utils/Database/Orm/Fields/LinkMultiple.php b/application/Espo/Core/Utils/Database/Orm/Fields/LinkMultiple.php index d977c84dab..d9a65bea83 100644 --- a/application/Espo/Core/Utils/Database/Orm/Fields/LinkMultiple.php +++ b/application/Espo/Core/Utils/Database/Orm/Fields/LinkMultiple.php @@ -41,12 +41,16 @@ class LinkMultiple extends Base 'notStorable' => true, 'isLinkMultipleIdList' => true, 'relation' => $fieldName, - 'isUnordered' => true + 'isUnordered' => true, + 'attributeRole' => 'idList', + 'fieldType' => 'linkMultiple', ], $fieldName.'Names' => [ 'type' => 'jsonObject', 'notStorable' => true, - 'isLinkMultipleNameMap' => true + 'isLinkMultipleNameMap' => true, + 'attributeRole' => 'nameMap', + 'fieldType' => 'linkMultiple', ] ] ], @@ -71,7 +75,8 @@ class LinkMultiple extends Base $data[$entityName]['fields'][$fieldName . 'Columns'] = [ 'type' => 'jsonObject', 'notStorable' => true, - 'columns' => $columns + 'columns' => $columns, + 'attributeRole' => 'columnsMap', ]; } diff --git a/application/Espo/Core/Utils/Database/Orm/Fields/LinkParent.php b/application/Espo/Core/Utils/Database/Orm/Fields/LinkParent.php index 2e2de76f4d..7adebe13d2 100644 --- a/application/Espo/Core/Utils/Database/Orm/Fields/LinkParent.php +++ b/application/Espo/Core/Utils/Database/Orm/Fields/LinkParent.php @@ -33,33 +33,39 @@ class LinkParent extends Base { protected function load($fieldName, $entityName) { - $data = array( - $entityName => array ( - 'fields' => array( - $fieldName.'Id' => array( + $data = [ + $entityName => [ + 'fields' => [ + $fieldName.'Id' => [ 'type' => 'foreignId', - 'index' => $fieldName - ), - $fieldName.'Type' => array( + 'index' => $fieldName, + 'attributeRole' => 'id', + 'fieldType' => 'linkParent', + ], + $fieldName.'Type' => [ 'type' => 'foreignType', 'notNull' => false, 'index' => $fieldName, - 'len' => 100 - ), - $fieldName.'Name' => array( + 'len' => 100, + 'attributeRole' => 'type', + 'fieldType' => 'linkParent', + ], + $fieldName.'Name' => [ 'type' => 'varchar', 'notStorable' => true, 'relation' => $fieldName, - 'isParentName' => true - ) - ) - ), - 'unset' => array( - $entityName => array( + 'isParentName' => true, + 'attributeRole' => 'name', + 'fieldType' => 'linkParent', + ] + ] + ], + 'unset' => [ + $entityName => [ 'fields.'.$fieldName - ) - ) - ); + ] + ] + ]; $fieldParams = $this->getFieldParams(); @@ -72,4 +78,4 @@ class LinkParent extends Base return $data; } -} \ No newline at end of file +} From 61def7e332dc7933d8108ca008cfaa798d503873 Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 17 May 2019 12:50:36 +0300 Subject: [PATCH 06/40] pdf currency symbol --- application/Espo/Core/Htmlizer/Htmlizer.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/application/Espo/Core/Htmlizer/Htmlizer.php b/application/Espo/Core/Htmlizer/Htmlizer.php index a3a2e8d24d..dbcb182fe0 100644 --- a/application/Espo/Core/Htmlizer/Htmlizer.php +++ b/application/Espo/Core/Htmlizer/Htmlizer.php @@ -147,6 +147,7 @@ class Htmlizer } $type = $entity->getAttributeType($attribute); + $fieldType = $entity->getAttributeParam($attribute, 'fieldType'); if ($type == Entity::DATETIME) { if (!empty($data[$attribute])) { @@ -194,6 +195,14 @@ class Htmlizer unset($data[$attribute]); } + if ($fieldType === 'currency') { + if ($entity->getAttributeParam($attribute, 'attributeRole') === 'currency') { + if ($currencyValue = $data[$attribute]) { + $data[$attribute . 'Symbol'] = $this->metadata->get(['app', 'currency', 'symbolMap', $currencyValue]); + } + } + } + if (array_key_exists($attribute, $data)) { $keyRaw = $attribute . '_RAW'; $data[$keyRaw] = $data[$attribute]; From 875b01dcd660392089256448a19bcbbba56a1224 Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 17 May 2019 13:16:07 +0300 Subject: [PATCH 07/40] lastViewed metadata scopes param --- application/Espo/Services/LastViewed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/Espo/Services/LastViewed.php b/application/Espo/Services/LastViewed.php index f3a4ef569f..707a270d45 100644 --- a/application/Espo/Services/LastViewed.php +++ b/application/Espo/Services/LastViewed.php @@ -49,7 +49,7 @@ class LastViewed extends \Espo\Core\Services\Base $scopes = $this->getInjection('metadata')->get('scopes'); $targetTypeList = array_filter(array_keys($scopes), function ($item) use ($scopes) { - return !empty($scopes[$item]['object']); + return !empty($scopes[$item]['object']) || !empty($scopes[$item]['lastViewed']); }); $offset = $params['offset']; From f01715452fe800bdbe94d057f892195864963d4f Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 17 May 2019 13:18:19 +0300 Subject: [PATCH 08/40] last viewed date short --- .../Resources/layouts/ActionHistoryRecord/listLastViewed.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/Espo/Resources/layouts/ActionHistoryRecord/listLastViewed.json b/application/Espo/Resources/layouts/ActionHistoryRecord/listLastViewed.json index e1f49b4d32..bbfe1200b6 100644 --- a/application/Espo/Resources/layouts/ActionHistoryRecord/listLastViewed.json +++ b/application/Espo/Resources/layouts/ActionHistoryRecord/listLastViewed.json @@ -1,5 +1,5 @@ [ {"name":"targetType", "notSortable": true, "width": 22}, {"name":"target", "notSortable": true}, - {"name":"createdAt", "notSortable": true, "width": 20, "align": "right"} + {"name":"createdAt", "notSortable": true, "width": 20, "align": "right", "view": "views/fields/datetime-short"} ] \ No newline at end of file From ac96ebffa5af1668e18a2dfb7798ab1f2e8059a8 Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 17 May 2019 15:15:17 +0300 Subject: [PATCH 09/40] btn-text --- .../crm/res/templates/calendar/calendar.tpl | 12 ++-- .../crm/res/templates/calendar/timeline.tpl | 12 ++-- client/res/templates/dashboard.tpl | 6 +- client/res/templates/record/detail.tpl | 4 +- client/res/templates/record/list.tpl | 2 +- client/res/templates/record/search.tpl | 4 +- client/src/views/modals/detail.js | 2 + frontend/less/espo/custom.less | 56 ++++++++++++++++++- 8 files changed, 77 insertions(+), 21 deletions(-) diff --git a/client/modules/crm/res/templates/calendar/calendar.tpl b/client/modules/crm/res/templates/calendar/calendar.tpl index b23fb81577..d3026f4097 100644 --- a/client/modules/crm/res/templates/calendar/calendar.tpl +++ b/client/modules/crm/res/templates/calendar/calendar.tpl @@ -5,12 +5,12 @@
- - + +
- + - +
@@ -19,10 +19,10 @@
{{#each ../modeDataList}} - + {{/each}}
- +