dont send invitation for self if accepted
This commit is contained in:
@@ -45,5 +45,8 @@
|
||||
"planned": "Planned",
|
||||
"held": "Held",
|
||||
"todays": "Today's"
|
||||
},
|
||||
"messages": {
|
||||
"nothingHasBeenSent": "Nothing were sent"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,11 +138,19 @@ class Meeting extends \Espo\Services\Record
|
||||
|
||||
$emailHash = array();
|
||||
|
||||
$sentCount = 0;
|
||||
|
||||
$users = $entity->get('users');
|
||||
foreach ($users as $user) {
|
||||
if ($user->id === $this->getUser()->id) {
|
||||
if ($entity->getLinkMultipleColumn('users', 'status', $user->id) === 'Accepted') {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ($user->get('emailAddress') && !array_key_exists($user->get('emailAddress'), $emailHash)) {
|
||||
$invitationManager->sendInvitation($entity, $user, 'users');
|
||||
$emailHash[$user->get('emailAddress')] = true;
|
||||
$sentCount ++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,6 +159,7 @@ class Meeting extends \Espo\Services\Record
|
||||
if ($contact->get('emailAddress') && !array_key_exists($contact->get('emailAddress'), $emailHash)) {
|
||||
$invitationManager->sendInvitation($entity, $contact, 'contacts');
|
||||
$emailHash[$user->get('emailAddress')] = true;
|
||||
$sentCount ++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,9 +168,12 @@ class Meeting extends \Espo\Services\Record
|
||||
if ($lead->get('emailAddress') && !array_key_exists($lead->get('emailAddress'), $emailHash)) {
|
||||
$invitationManager->sendInvitation($entity, $lead, 'leads');
|
||||
$emailHash[$user->get('emailAddress')] = true;
|
||||
$sentCount ++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$sentCount) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,26 +26,28 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('crm:views/call/detail', 'views/detail', function (Dep) {
|
||||
Espo.define('crm:views/call/detail', ['views/detail', 'crm:views/meeting/detail'], function (Dep, MeetingDetail) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
if (['Held', 'Not Held'].indexOf(this.model.get('status')) == -1) {
|
||||
if (this.getAcl().checkModel(this.model, 'edit') && this.getAcl().checkScope('Email', 'create')) {
|
||||
this.menu.buttons.push({
|
||||
'label': 'Send Invitations',
|
||||
'action': 'sendInvitations',
|
||||
'acl': 'edit',
|
||||
});
|
||||
|
||||
MeetingDetail.prototype.controlSendInvitationsButton.call(this);
|
||||
this.listenTo(this.model, 'change', function () {
|
||||
if (
|
||||
this.model.hasChanged('status')
|
||||
||
|
||||
this.model.hasChanged('teamsIds')
|
||||
) {
|
||||
MeetingDetail.prototype.controlSendInvitationsButton.call(this);
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
actionSendInvitations: function () {
|
||||
if (confirm(this.translate('confirmation', 'messages'))) {
|
||||
this.$el.find('[data-action="sendInvitations"]').addClass('disabled');
|
||||
this.disableMenuItem('sendInvitations');
|
||||
this.notify('Sending...');
|
||||
$.ajax({
|
||||
url: 'Call/action/sendInvitations',
|
||||
@@ -53,12 +55,16 @@
|
||||
data: JSON.stringify({
|
||||
id: this.model.id
|
||||
}),
|
||||
success: function () {
|
||||
this.notify('Sent', 'success');
|
||||
this.$el.find('[data-action="sendInvitations"]').removeClass('disabled');
|
||||
success: function (result) {
|
||||
if (result) {
|
||||
this.notify('Sent', 'success');
|
||||
} else {
|
||||
Espo.Ui.warning(this.translate('nothingHasBeenSent', 'messages', 'Meeting'));
|
||||
}
|
||||
this.enableMenuItem('sendInvitations');
|
||||
}.bind(this),
|
||||
error: function () {
|
||||
this.$el.find('[data-action="sendInvitations"]').removeClass('disabled');
|
||||
this.enableMenuItem('sendInvitations');
|
||||
}.bind(this),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -32,20 +32,55 @@ Espo.define('crm:views/meeting/detail', 'views/detail', function (Dep) {
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
if (['Held', 'Not Held'].indexOf(this.model.get('status')) == -1) {
|
||||
if (this.getAcl().checkModel(this.model, 'edit') && this.getAcl().checkScope('Email', 'create')) {
|
||||
this.menu.buttons.push({
|
||||
'label': 'Send Invitations',
|
||||
'action': 'sendInvitations',
|
||||
'acl': 'edit',
|
||||
});
|
||||
this.controlSendInvitationsButton();
|
||||
this.listenTo(this.model, 'change', function () {
|
||||
if (
|
||||
this.model.hasChanged('status')
|
||||
||
|
||||
this.model.hasChanged('teamsIds')
|
||||
) {
|
||||
this.controlSendInvitationsButton();
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
controlSendInvitationsButton: function () {
|
||||
var show = true;;
|
||||
|
||||
if (
|
||||
~['Held', 'Not Held'].indexOf(this.model.get('status'))
|
||||
) {
|
||||
show = false;
|
||||
}
|
||||
|
||||
if (show && (!this.getAcl().checkModel(this.model, 'edit') || !this.getAcl().checkScope('Email', 'create'))) {
|
||||
show = false;
|
||||
}
|
||||
|
||||
if (show) {
|
||||
var userIdList = this.model.getLinkMultipleIdList('users');
|
||||
var contactIdList = this.model.getLinkMultipleIdList('contacts');
|
||||
var leadIdList = this.model.getLinkMultipleIdList('leads');
|
||||
|
||||
if (!contactIdList.length && !leadIdList.length && !userIdList.length) {
|
||||
show = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (show) {
|
||||
this.addMenuItem('buttons', {
|
||||
label: 'Send Invitations',
|
||||
action: 'sendInvitations',
|
||||
acl: 'edit',
|
||||
});
|
||||
} else {
|
||||
this.removeMenuItem('sendInvitations');
|
||||
}
|
||||
},
|
||||
|
||||
actionSendInvitations: function () {
|
||||
if (confirm(this.translate('confirmation', 'messages'))) {
|
||||
this.$el.find('button[data-action="sendInvitations"]').addClass('disabled');
|
||||
this.disableMenuItem('sendInvitations');
|
||||
this.notify('Sending...');
|
||||
$.ajax({
|
||||
url: 'Meeting/action/sendInvitations',
|
||||
@@ -53,12 +88,17 @@ Espo.define('crm:views/meeting/detail', 'views/detail', function (Dep) {
|
||||
data: JSON.stringify({
|
||||
id: this.model.id
|
||||
}),
|
||||
success: function () {
|
||||
this.notify('Sent', 'success');
|
||||
this.$el.find('[data-action="sendInvitations"]').removeClass('disabled');
|
||||
success: function (result) {
|
||||
if (result) {
|
||||
this.notify('Sent', 'success');
|
||||
} else {
|
||||
Espo.Ui.warning(this.translate('nothingHasBeenSent', 'messages', 'Meeting'));
|
||||
}
|
||||
|
||||
this.enableMenuItem('sendInvitations');
|
||||
}.bind(this),
|
||||
error: function () {
|
||||
this.$el.find('[data-action="sendInvitations"]').removeClass('disabled');
|
||||
this.enableMenuItem('sendInvitations');
|
||||
}.bind(this),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -142,6 +142,14 @@ Espo.define('views/main', 'view', function (Dep) {
|
||||
}
|
||||
},
|
||||
|
||||
disableMenuItem: function (action) {
|
||||
this.$el.find('.header .header-buttons [data-action="'+action+'"]').addClass('disabled');
|
||||
},
|
||||
|
||||
enableMenuItem: function (action) {
|
||||
this.$el.find('.header .header-buttons [data-action="'+action+'"]').removeClass('disabled');
|
||||
},
|
||||
|
||||
removeMenuItem: function (name, doNotReRender) {
|
||||
var index = -1;
|
||||
var type = false;
|
||||
|
||||
Reference in New Issue
Block a user