activity account contact fiexes
This commit is contained in:
@@ -36,16 +36,18 @@ class Meeting extends \Espo\Core\Repositories\Event
|
||||
{
|
||||
protected function beforeSave(Entity $entity, array $options = array())
|
||||
{
|
||||
if (!$entity->isNew() && $entity->isAttributeChanged('parentId')) {
|
||||
$entity->set('accountId', null);
|
||||
}
|
||||
|
||||
$parentId = $entity->get('parentId');
|
||||
$parentType = $entity->get('parentType');
|
||||
if (!empty($parentId) || !empty($parentType)) {
|
||||
if ($parentId && $parentType) {
|
||||
$parent = $this->getEntityManager()->getEntity($parentType, $parentId);
|
||||
if (!empty($parent)) {
|
||||
if ($parent) {
|
||||
$accountId = null;
|
||||
if ($parent->getEntityType() == 'Account') {
|
||||
$accountId = $parent->id;
|
||||
} else if ($parent->get('accountId')) {
|
||||
$accountId = $parent->get('accountId');
|
||||
} else if ($parent->getEntityType() == 'Lead') {
|
||||
if ($parent->get('status') == 'Converted') {
|
||||
if ($parent->get('createdAccountId')) {
|
||||
@@ -53,7 +55,10 @@ class Meeting extends \Espo\Core\Repositories\Event
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($accountId)) {
|
||||
if (!$accountId && $parent->get('accountId') && $parent->getRelationParam('account', 'entity') == 'Account') {
|
||||
$accountId = $parent->get('accountId');
|
||||
}
|
||||
if ($accountId) {
|
||||
$entity->set('accountId', $accountId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,26 +103,46 @@ class Task extends \Espo\Core\Repositories\Event
|
||||
}
|
||||
}
|
||||
|
||||
if (!$entity->isNew() && $entity->isAttributeChanged('parentId')) {
|
||||
$entity->set('accountId', null);
|
||||
$entity->set('contactId', null);
|
||||
}
|
||||
|
||||
$parentId = $entity->get('parentId');
|
||||
$parentType = $entity->get('parentType');
|
||||
if (!empty($parentId) || !empty($parentType)) {
|
||||
if ($parentId && $parentType) {
|
||||
$parent = $this->getEntityManager()->getEntity($parentType, $parentId);
|
||||
if (!empty($parent)) {
|
||||
if ($parent) {
|
||||
$accountId = null;
|
||||
$contactId = null;
|
||||
if ($parent->getEntityType() == 'Account') {
|
||||
$accountId = $parent->id;
|
||||
} else if ($parent->get('accountId')) {
|
||||
$accountId = $parent->get('accountId');
|
||||
} else if ($parent->getEntityType() == 'Lead') {
|
||||
if ($parent->get('status') == 'Converted') {
|
||||
if ($parent->get('createdAccountId')) {
|
||||
$accountId = $parent->get('createdAccountId');
|
||||
}
|
||||
if ($parent->get('createdContactId')) {
|
||||
$contactId = $parent->get('createdContactId');
|
||||
}
|
||||
}
|
||||
} else if ($parent->getEntityType() == 'Contact') {
|
||||
$contactId = $parent->id;
|
||||
}
|
||||
if (!empty($accountId)) {
|
||||
|
||||
if (!$accountId && $parent->get('accountId') && $parent->getRelationParam('account', 'entity') == 'Account') {
|
||||
$accountId = $parent->get('accountId');
|
||||
}
|
||||
if (!$contactId && $parent->get('contactId') && $parent->getRelationParam('contact', 'entity') == 'Contact') {
|
||||
$contactId = $parent->get('contactId');
|
||||
}
|
||||
|
||||
if ($accountId) {
|
||||
$entity->set('accountId', $accountId);
|
||||
}
|
||||
if ($contactId) {
|
||||
$entity->set('contactId', $contactId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
"account": "Account (Primary)",
|
||||
"accounts": "Accounts",
|
||||
"casesPrimary": "Cases (Primary)",
|
||||
"tasksPrimary": "Tasks (expanded)",
|
||||
"portalUser": "Portal User",
|
||||
"originalLead": "Original Lead",
|
||||
"documents": "Documents"
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
"reminders": "Reminders"
|
||||
},
|
||||
"links": {
|
||||
"attachments": "Attachments"
|
||||
"attachments": "Attachments",
|
||||
"account": "Account",
|
||||
"contact": "Contact"
|
||||
},
|
||||
"options": {
|
||||
"status": {
|
||||
|
||||
@@ -395,6 +395,12 @@
|
||||
"entity": "Document",
|
||||
"foreign": "contacts",
|
||||
"audited": true
|
||||
},
|
||||
"tasksPrimary": {
|
||||
"type": "hasMany",
|
||||
"entity": "Task",
|
||||
"foreign": "contact",
|
||||
"layoutRelationshipsDisabled": true
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
|
||||
@@ -66,6 +66,10 @@
|
||||
"type": "link",
|
||||
"readOnly": true
|
||||
},
|
||||
"contact": {
|
||||
"type": "link",
|
||||
"readOnly": true
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "datetime",
|
||||
"readOnly": true
|
||||
@@ -126,6 +130,10 @@
|
||||
"account": {
|
||||
"type": "belongsTo",
|
||||
"entity": "Account"
|
||||
},
|
||||
"contact": {
|
||||
"type": "belongsTo",
|
||||
"entity": "Contact"
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
|
||||
@@ -249,17 +249,23 @@ class Email extends \Espo\Core\ORM\Repositories\RDB
|
||||
$entity->setLinkMultipleColumn('users', 'isRead', $entity->get('createdById'), true);
|
||||
}
|
||||
|
||||
if (!$entity->isNew() && $entity->isAttributeChanged('parentId')) {
|
||||
$entity->set('accountId', null);
|
||||
}
|
||||
|
||||
$parentId = $entity->get('parentId');
|
||||
$parentType = $entity->get('parentType');
|
||||
if (!empty($parentId) || !empty($parentType)) {
|
||||
if ($parentId && $parentType) {
|
||||
$parent = $this->getEntityManager()->getEntity($parentType, $parentId);
|
||||
if (!empty($parent)) {
|
||||
if ($parent) {
|
||||
$accountId = null;
|
||||
if ($parent->getEntityType() == 'Account') {
|
||||
$accountId = $parent->id;
|
||||
} else if ($parent->has('accountId')) {
|
||||
}
|
||||
if (!$accountId && $parent->get('accountId') && $parent->getRelationParam('account', 'entity') == 'Account') {
|
||||
$accountId = $parent->get('accountId');
|
||||
}
|
||||
if (!empty($accountId)) {
|
||||
if ($accountId) {
|
||||
$account = $this->getEntityManager()->getEntity('Account', $accountId);
|
||||
if ($account) {
|
||||
$entity->set('accountId', $accountId);
|
||||
|
||||
Reference in New Issue
Block a user