diff --git a/application/Espo/Modules/Crm/Hooks/Task/DateCompleted.php b/application/Espo/Modules/Crm/Hooks/Task/DateCompleted.php new file mode 100644 index 0000000000..64c9936929 --- /dev/null +++ b/application/Espo/Modules/Crm/Hooks/Task/DateCompleted.php @@ -0,0 +1,69 @@ + $options + */ + public function beforeSave(Entity $entity, array $options): void + { + if (!$entity->isAttributeChanged(self::FIELD_STATUS)) { + return; + } + + if ( + ($options[SaveOption::IMPORT] ?? false) && + $entity->get(self::FIELD_DATE_COMPLETED) + ) { + return; + } + + if ($entity->getStatus() !== Task::STATUS_COMPLETED) { + $entity->set(self::FIELD_DATE_COMPLETED, null); + + return; + } + + $entity->setValueObject(self::FIELD_DATE_COMPLETED, DateTime::createNow()); + } +} diff --git a/application/Espo/Modules/Crm/Repositories/Task.php b/application/Espo/Modules/Crm/Repositories/Task.php index e76263eea3..de078fcc51 100644 --- a/application/Espo/Modules/Crm/Repositories/Task.php +++ b/application/Espo/Modules/Crm/Repositories/Task.php @@ -29,7 +29,6 @@ namespace Espo\Modules\Crm\Repositories; -use Espo\Core\Utils\DateTime; use Espo\Modules\Crm\Entities\Account as AccountEntity; use Espo\Modules\Crm\Entities\Contact as ContactEntity; use Espo\Modules\Crm\Entities\Lead as LeadEntity; @@ -50,14 +49,6 @@ class Task extends EventRepository */ protected function beforeSave(Entity $entity, array $options = []) { - if ($entity->isAttributeChanged('status')) { - if ($entity->get('status') == TaskEntity::STATUS_COMPLETED) { - $entity->set('dateCompleted', date(DateTime::SYSTEM_DATE_TIME_FORMAT)); - } else { - $entity->set('dateCompleted', null); - } - } - if (!$entity->isNew() && $entity->isAttributeChanged('parentId')) { $entity->set('accountId', null); $entity->set('contactId', null); diff --git a/application/Espo/Services/LeadCapture.php b/application/Espo/Services/LeadCapture.php index 0910cf60eb..685531f0b7 100644 --- a/application/Espo/Services/LeadCapture.php +++ b/application/Espo/Services/LeadCapture.php @@ -73,6 +73,8 @@ class LeadCapture extends Record $attributeIgnoreList = [ 'emailAddressIsOptedOut', 'phoneNumberIsOptedOut', + 'emailAddressIsInvalid', + 'phoneNumberIsInvalid', 'emailAddressData', 'phoneNumberData', ]; diff --git a/application/Espo/Tools/App/LanguageService.php b/application/Espo/Tools/App/LanguageService.php index aba919045f..f130f1b613 100644 --- a/application/Espo/Tools/App/LanguageService.php +++ b/application/Espo/Tools/App/LanguageService.php @@ -177,15 +177,15 @@ class LanguageService */ private function unsetEmpty(array &$data, string $scope): void { - if ($data[$scope]['options'] === []) { + if (($data[$scope]['options'] ?? null) === []) { unset($data[$scope]['options']); } - if ($data[$scope]['fields'] === []) { + if (($data[$scope]['fields'] ?? null) === []) { unset($data[$scope]['fields']); } - if ($data[$scope]['links'] === []) { + if (($data[$scope]['links'] ?? null) === []) { unset($data[$scope]['links']); } } diff --git a/application/Espo/Tools/Import/Import.php b/application/Espo/Tools/Import/Import.php index a842fa9aaa..546c74bece 100644 --- a/application/Espo/Tools/Import/Import.php +++ b/application/Espo/Tools/Import/Import.php @@ -630,6 +630,12 @@ class Import private function processForeignName(CoreEntity $entity, string $attribute): void { + $nameValue = $entity->get($attribute); + + if ($nameValue === null) { + return; + } + $relation = $entity->getAttributeParam($attribute, 'relation'); if (!$relation) { @@ -671,8 +677,6 @@ class Import return; } - $nameValue = $entity->get($attribute); - if ($isPerson) { $where = $this->parsePersonName($nameValue, $this->params->getPersonNameFormat() ?? ''); } diff --git a/client/src/views/main.js b/client/src/views/main.js index 6ec8242c77..ea078766ad 100644 --- a/client/src/views/main.js +++ b/client/src/views/main.js @@ -410,14 +410,18 @@ define('views/main', ['view'], function (Dep) { this.menu[type][method](item); if (!doNotReRender && this.isRendered()) { - this.getHeaderView().reRender(); + this.getHeaderView() + .reRender() + .then(() => this.adjustButtons()); return; } if (!doNotReRender && this.isBeingRendered()) { this.once('after:render', () => { - this.getHeaderView().reRender(); + this.getHeaderView() + .reRender() + .then(() => this.adjustButtons()); }); } }, @@ -448,14 +452,20 @@ define('views/main', ['view'], function (Dep) { } if (!doNotReRender && this.isRendered()) { - this.getHeaderView().reRender(); + this.getHeaderView() + .reRender() + .reRender() + .then(() => this.adjustButtons()); return; } if (!doNotReRender && this.isBeingRendered()) { this.once('after:render', () => { - this.getHeaderView().reRender(); + this.getHeaderView() + .reRender() + .then(() => this.adjustButtons()); + }); return;