Hello,
is possible to have a cutom entity as attendees in Meeting and Call ?
Thanks
is possible to have a cutom entity as attendees in Meeting and Call ?
Thanks
{ "sidePanels":{ "detail":[ { "name":"attendees", "label":"Attendees", [COLOR=#FFA500] "view":"custom:views/meeting/record/panels/attendees",[/COLOR] "options":{ "fieldList":[ "users", "contacts", "leads" ] }, "sticked": true, "isForm": true, "notRefreshable": true } ], "detailSmall":[ { "name":"attendees", "label":"Attendees", [COLOR=#FFA500] "view":"custom:views/meeting/record/panels/attendees",[/COLOR] "sticked": true, "isForm": true, "notRefreshable": true } ], "edit":[ { "name":"attendees", "label":"Attendees", [COLOR=#FFA500] "view":"custom:views/meeting/record/panels/attendees",[/COLOR] "sticked": true, "isForm": true, "notRefreshable": true } ], "editSmall":[ { "name":"attendees", "label":"Attendees", [COLOR=#FFA500] "view":"custom:views/meeting/record/panels/attendees",[/COLOR] "sticked": true, "isForm": true, "notRefreshable": true } ] } }
Espo.define('[COLOR=#FFA500]custom:views/meeting/record/panels/attendees[/COLOR]', 'crm:views/meeting/record/panels/attendees', function (Dep) { return Dep.extend({ setupFields: function () { this.fieldList = []; this.fieldList.push('users'); if (this.getAcl().check('Contact') && !this.getMetadata().get('scopes.Contact.disabled')) { this.fieldList.push('contacts'); } if (this.getAcl().check('Lead') && !this.getMetadata().get('scopes.Lead.disabled')) { this.fieldList.push('leads'); } if (this.getAcl().check('ServiceTech') && !this.getMetadata().get('scopes.ServiceTech.disabled')) { this.fieldList.push('serviceTechs'); } } }); });
{
"fields": {
"parent": {
"entityList": [
"Account",
"Lead",
"Contact",
"Opportunity",
"Case",
"Patient"
]
},
"patients": {
"type": "linkMultiple",
"layoutDetailDisabled": false,
"layoutMassUpdateDisabled": false,
"importDisabled": false,
"noLoad": false,
"isCustom": true,
"view": "crm:views/meeting/fields/contacts",
"columns": {
"status": "acceptanceStatus"
},
"additionalAttributeList": ["columns"],
"orderBy": "name"
}
},
"links": {
"patients": {
"type": "hasMany",
"foreign": "meetings",
"entity": "Patient",
"audited": false,
"isCustom": true,
"additionalColumns": {
"status": {
"type": "varchar",
"len": "36",
"default": "None"
}
},
"columnAttributeMap": {
"status": "acceptanceStatus"
}
}
}
}
"acceptanceStatus": {
"type": "varchar",
"notStorable": true,
"exportDisabled": true,
"disabled": true
},
"acceptanceStatusMeetings": {
"type": "enum",
"notStorable": true,
"directUpdateDisabled": true,
"layoutAvailabilityList": ["filters"],
"importDisabled": true,
"exportDisabled": true,
"view": "crm:views/lead/fields/acceptance-status",
"link": "meetings",
"column": "status"
}
"meetings": {
"type": "hasMany",
"foreign": "patients",
"entity": "Meeting",
"layoutRelationshipsDisabled": true,
"audited": false,
"isCustom": true,
"columnAttributeMap": {
"status": "acceptanceStatus"
}
}
switch ($scope) {
case 'Contact':
$link = 'contacts';
break;
case 'Lead':
$link = 'leads';
break;
case 'User':
$link = 'users';
break;
case 'Patient':
$link = 'patients';
break;
}
<?php
/************************************************** **********************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2021 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
* Website: https://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/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************** **********************/
namespace Espo\Custom\Services;
use Espo\Core\Exceptions\Error;
use Espo\Core\Exceptions\NotFound;
use Espo\Core\Exceptions\Forbidden;
use Espo\ORM\{
Entity,
QueryParams\Select,
};
class Activities extends \Espo\Modules\Crm\Services\Activities {
protected function isPerson($scope)
{
return in_array($scope, ['Contact', 'Lead', 'User', 'Patient']) ||
$this->getMetadata()->get(['scopes', $scope, 'type']) === 'Person';
}
protected function getActivitiesMeetingQuery(
Entity $entity, array $statusList = [], $isHistory = false, $additinalSelectParams = null
) {
$scope = $entity->getEntityType();
$id = $entity->id;
$methodName = 'getActivities' . $scope . 'MeetingQuery';
if (method_exists($this, $methodName)) {
return $this->$methodName($entity, $statusList, $isHistory, $additinalSelectParams);
}
$selectManager = $this->getSelectManagerFactory()->create('Meeting');
$baseSelectParams = [
'from' => 'Meeting',
'select' => [
'id',
'name',
['dateStart', 'dateStart'],
['dateEnd', 'dateEnd'],
['dateStartDate', 'dateStartDate'],
['dateEndDate', 'dateEndDate'],
['VALUE:Meeting', '_scope'],
'assignedUserId',
'assignedUserName',
'parentType',
'parentId',
'status',
'createdAt',
['VALUE:', 'hasAttachment'],
],
'whereClause' => [],
];
if (!empty($statusList)) {
$baseSelectParams['whereClause'][] = [
'status' => $statusList
];
}
$selectParams = $baseSelectParams;
if ($scope == 'Account') {
$selectParams['whereClause'][] = [
'OR' => [
[
'parentId' => $id,
'parentType' => 'Account'
],
[
'accountId' => $id
]
]
];
} else if ($scope == 'Lead' && $entity->get('createdAccountId')) {
$selectParams['whereClause'][] = [
'OR' => [
[
'parentId' => $id,
'parentType' => 'Lead'
],
[
'accountId' => $entity->get('createdAccountId')
]
]
];
} else {
$selectParams['whereClause']['parentId'] = $id;
$selectParams['whereClause']['parentType'] = $scope;
}
$selectManager->applyAccess($selectParams);
$selectParams = $selectManager->mergeSelectParams($selectParams, $additinalSelectParams);
$query = Select::fromRaw($selectParams);
if (!$this->isPerson($scope)) {
return $query;
}
$queryList = [$query];
$link = null;
switch ($scope) {
case 'Contact':
$link = 'contacts';
break;
case 'Lead':
$link = 'leads';
break;
case 'User':
$link = 'users';
break;
case 'Patient':
$link = 'patients';
}
//$GLOBALS['log']->warning( 'JE SUIS ICI' );
if (!$link) {
return $queryList;
}
$selectParams = $baseSelectParams;
$selectManager->addJoin($link, $selectParams);
$selectParams['whereClause'][$link .'.id'] = $id;
$selectParams['whereClause'][] = [
'OR' => [
'parentType!=' => $scope,
'parentId!=' => $id,
'parentType' => null,
'parentId' => null,
]
];
$selectManager->applyAccess($selectParams);
$selectParams = $selectManager->mergeSelectParams($selectParams, $additinalSelectParams);
$query = Select::fromRaw($selectParams);
$queryList[] = $query;
return $queryList;
}
protected function getActivitiesCallQuery(
Entity $entity, array $statusList = [], $isHistory = false, $additinalSelectParams = null
) {
$scope = $entity->getEntityType();
$id = $entity->id;
$methodName = 'getActivities' .$scope . 'CallQuery';
if (method_exists($this, $methodName)) {
return $this->$methodName($entity, $statusList, $isHistory, $additinalSelectParams);
}
$selectManager = $this->getSelectManagerFactory()->create('Call');
$baseSelectParams = [
'from' => 'Call',
'select' => [
'id',
'name',
['dateStart', 'dateStart'],
['dateEnd', 'dateEnd'],
['VALUE:', 'dateStartDate'],
['VALUE:', 'dateEndDate'],
['VALUE:Call', '_scope'],
'assignedUserId',
'assignedUserName',
'parentType',
'parentId',
'status',
'createdAt',
['VALUE:', 'hasAttachment'],
],
'whereClause' => [],
];
if (!empty($statusList)) {
$baseSelectParams['whereClause'][] = [
'status' => $statusList
];
}
$selectParams = $baseSelectParams;
if ($scope == 'Account') {
$selectParams['whereClause'][] = [
'OR' => [
[
'parentId' => $id,
'parentType' => 'Account'
],
[
'accountId' => $id
]
]
];
} else if ($scope == 'Lead' && $entity->get('createdAccountId')) {
$selectParams['whereClause'][] = [
'OR' => [
[
'parentId' => $id,
'parentType' => 'Lead'
],
[
'accountId' => $entity->get('createdAccountId')
]
]
];
} else {
$selectParams['whereClause']['parentId'] = $id;
$selectParams['whereClause']['parentType'] = $scope;
}
$selectManager->applyAccess($selectParams);
$selectParams = $selectManager->mergeSelectParams($selectParams, $additinalSelectParams);
$query = Select::fromRaw($selectParams);
if (!$this->isPerson($scope)) {
return $query;
}
$queryList = [$query];
$link = null;
switch ($scope) {
case 'Contact':
$link = 'contacts';
break;
case 'Lead':
$link = 'leads';
break;
case 'User':
$link = 'users';
break;
}
if (!$link) {
return $queryList;
}
$selectParams = $baseSelectParams;
$selectManager->addJoin($link, $selectParams);
$selectParams['whereClause'][$link .'.id'] = $id;
$selectParams['whereClause'][] = [
'OR' => [
'parentType!=' => $scope,
'parentId!=' => $id,
'parentType' => null,
'parentId' => null,
]
];
$selectManager->applyAccess($selectParams);
$selectParams = $selectManager->mergeSelectParams($selectParams, $additinalSelectParams);
$query = Select::fromRaw($selectParams);
$queryList[] = $query;
return $queryList;
}
}
<?php
if ($scope == 'Account') {
$selectParams['whereClause'][] = [
'OR' => [
[
'parentId' => $id,
'parentType' => 'Account'
],
[
'accountId' => $id
]
]
];
} else if ($scope == 'Lead' && $entity->get('createdAccountId')) {
$selectParams['whereClause'][] = [
'OR' => [
[
'parentId' => $id,
'parentType' => 'Lead'
],
[
'accountId' => $entity->get('createdAccountId')
]
]
];
} else {
$selectParams['whereClause']['parentId'] = $id;
$selectParams['whereClause']['parentType'] = $scope;
}
$selectParams['whereClause'][] = [
'OR' => [
[
'parentId' => $id,
'parentType' => $scope
],
[
'accountId' => $id
]
]
];
Comment