${__('No issue raised by the customer.')}`
- }, {
- 'fieldtype': 'Column Break',
+ 'fieldtype': 'Section Break',
}, {
'fieldtype': 'Small Text',
'label': __('Call Summary'),
@@ -41,13 +74,21 @@ class CallPopup {
'click': () => {
const call_summary = this.dialog.get_value('call_summary');
if (!call_summary) return;
- frappe.xcall('erpnext.crm.doctype.utils.add_call_summary', {
- 'docname': this.call_log.id,
+ frappe.xcall('erpnext.communication.doctype.call_log.call_log.add_call_summary', {
+ 'call_log': this.call_log.name,
'summary': call_summary,
}).then(() => {
this.close_modal();
frappe.show_alert({
- message: `${__('Call Summary Saved')}
${__('View call log')}`,
+ message: `
+ ${__('Call Summary Saved')}
+
+
+ ${__('View call log')}
+
+ `,
indicator: 'green'
});
});
@@ -55,71 +96,14 @@ class CallPopup {
}],
});
this.set_call_status();
- this.make_caller_info_section();
this.dialog.get_close_btn().show();
+ this.make_last_interaction_section();
this.dialog.$body.addClass('call-popup');
this.dialog.set_secondary_action(this.close_modal.bind(this));
frappe.utils.play_sound('incoming-call');
this.dialog.show();
}
- make_caller_info_section() {
- const wrapper = this.dialog.get_field('caller_info').$wrapper;
- wrapper.append(` ${__("Loading...")}
`);
- frappe.xcall('erpnext.crm.doctype.utils.get_document_with_phone_number', {
- 'number': this.caller_number
- }).then(contact_doc => {
- wrapper.empty();
- const contact = this.contact = contact_doc;
- if (!contact) {
- this.setup_unknown_caller(wrapper);
- } else {
- this.setup_known_caller(wrapper);
- this.set_call_status();
- this.make_last_interaction_section();
- }
- });
- }
-
- setup_unknown_caller(wrapper) {
- wrapper.append(`
-
- ${__('Unknown Number')}: ${this.caller_number}
-
-
- `).find('button').click(
- () => frappe.set_route(`Form/Contact/New Contact?phone=${this.caller_number}`)
- );
- }
-
- setup_known_caller(wrapper) {
- const contact = this.contact;
- const contact_name = frappe.utils.get_form_link(contact.doctype, contact.name, true, this.get_caller_name());
- const links = contact.links ? contact.links : [];
-
- let contact_links = '';
-
- links.forEach(link => {
- contact_links += `${link.link_doctype}: ${frappe.utils.get_form_link(link.link_doctype, link.link_name, true)}
`;
- });
- wrapper.append(`
-
- ${frappe.avatar(null, 'avatar-xl', contact.name, contact.image || '')}
-
-
${contact_name}
-
${contact.mobile_no || ''}
-
${contact.phone_no || ''}
- ${contact_links}
-
-
- `);
- }
-
set_indicator(color, blink=false) {
let classes = `indicator ${color} ${blink ? 'blink': ''}`;
this.dialog.header.find('.indicator').attr('class', classes);
@@ -129,7 +113,7 @@ class CallPopup {
let title = '';
call_status = call_status || this.call_log.status;
if (['Ringing'].includes(call_status) || !call_status) {
- title = __('Incoming call from {0}', [this.get_caller_name()]);
+ title = __('Incoming call from {0}', [this.get_caller_name() || this.caller_number]);
this.set_indicator('blue', true);
} else if (call_status === 'In Progress') {
title = __('Call Connected');
@@ -164,13 +148,13 @@ class CallPopup {
if (!this.dialog.get_value('call_summary')) {
this.close_modal();
}
- }, 10000);
+ }, 30000);
}
make_last_interaction_section() {
frappe.xcall('erpnext.crm.doctype.utils.get_last_interaction', {
- 'number': this.caller_number,
- 'reference_doc': this.contact
+ 'contact': this.call_log.contact,
+ 'lead': this.call_log.lead
}).then(data => {
const comm_field = this.dialog.get_field('last_communication');
if (data.last_communication) {
@@ -182,15 +166,20 @@ class CallPopup {
const issue = data.last_issue;
const issue_field = this.dialog.get_field("last_issue");
issue_field.set_value(issue.subject);
- issue_field.$wrapper.append(`
- ${__('View all issues from {0}', [issue.customer])}
- `);
+ issue_field.$wrapper.append(`
+
+ ${__('View all issues from {0}', [issue.customer])}
+
+ `);
}
});
}
+
get_caller_name() {
- return this.contact ? this.contact.lead_name || this.contact.name || '' : this.caller_number;
+ let log = this.call_log;
+ return log.contact_name || log.lead_name;
}
+
setup_listener() {
frappe.realtime.on(`call_${this.call_log.id}_disconnected`, call_log => {
this.call_disconnected(call_log);