email to case

This commit is contained in:
yuri
2015-05-19 15:17:11 +03:00
parent fea113269b
commit f7a367d755
3 changed files with 55 additions and 1 deletions
@@ -2,6 +2,7 @@
"labels": {
"Create Lead": "Create Lead",
"Create Contact": "Create Contact",
"Create Task": "Create Task"
"Create Task": "Create Task",
"Create Case": "Create Case"
}
}
@@ -33,5 +33,20 @@ class CaseObj extends \Espo\Services\Record
'emails'
);
public function afterCreate($entity, array $data)
{
parent::afterCreate($entity, $data);
if (!empty($data['emailId'])) {
$email = $this->getEntityManager()->getEntity('Email', $data['emailId']);
if ($email && !$email->get('parentId')) {
$email->set(array(
'parentType' => 'Case',
'parentId' => $entity->id
));
$this->getEntityManager()->saveEntity($email);
}
}
}
}
+38
View File
@@ -63,6 +63,15 @@ Espo.define('Views.Email.Detail', ['Views.Detail', 'EmailHelper'], function (Dep
acl: 'edit',
aclScope: 'Task'
});
if (this.model.get('parentType') !== 'Case' || !this.model.get('parentId')) {
this.menu.dropdown.push({
label: 'Create Case',
action: 'createCase',
acl: 'edit',
aclScope: 'Case'
});
}
},
actionCreateLead: function () {
@@ -117,6 +126,35 @@ Espo.define('Views.Email.Detail', ['Views.Detail', 'EmailHelper'], function (Dep
}.bind(this));
},
actionCreateCase: function () {
var attributes = {};
if (this.model.get('parentType') == 'Account' && this.model.get('parentId')) {
attributes.accountId = this.model.get('parentId');
attributes.accountName = this.model.get('parentName');
attributes.emailsIds = [this.model.id];
attributes.emailId = this.model.id;
}
attributes.name = this.model.get('name');
var viewName = this.getMetadata().get('clientDefs.Case.modalViews.detail') || 'Modals.Edit';
this.notify('Loading...');
this.createView('quickCreate', viewName, {
scope: 'Case',
attributes: attributes,
}, function (view) {
view.render();
view.notify(false);
view.once('after:save', function () {
this.model.fetch();
this.removeMenuItem('createCase');
view.close();
}.bind(this));
}.bind(this));
},
actionCreateTask: function () {
var attributes = {};