feat: Show contact on incoming call
This commit is contained in:
parent
03c3bd5f4a
commit
dd6b70c7cd
@ -4,9 +4,15 @@ import frappe
|
|||||||
def get_contact_doc(phone_number):
|
def get_contact_doc(phone_number):
|
||||||
phone_number = phone_number[-10:]
|
phone_number = phone_number[-10:]
|
||||||
contacts = frappe.get_all('Contact', or_filters={
|
contacts = frappe.get_all('Contact', or_filters={
|
||||||
'phone': ['like', '%{}%'.format(phone_number)],
|
'phone': ['like', '%{}'.format(phone_number)],
|
||||||
'mobile_no': ['like', '%{}%'.format(phone_number)]
|
'mobile_no': ['like', '%{}'.format(phone_number)]
|
||||||
}, fields=['*'])
|
}, fields=['*'])
|
||||||
|
|
||||||
if contacts:
|
if contacts:
|
||||||
return contacts[0]
|
return contacts[0]
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_last_communication(phone_number, customer=None):
|
||||||
|
# find last communication through phone_number
|
||||||
|
# find last issues, opportunity, lead
|
||||||
|
pass
|
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"css/erpnext.css": [
|
"css/erpnext.css": [
|
||||||
"public/less/erpnext.less",
|
"public/less/erpnext.less",
|
||||||
"public/less/hub.less"
|
"public/less/hub.less",
|
||||||
|
"public/less/call_summary.less"
|
||||||
],
|
],
|
||||||
"css/marketplace.css": [
|
"css/marketplace.css": [
|
||||||
"public/less/hub.less"
|
"public/less/hub.less"
|
||||||
@ -49,7 +50,8 @@
|
|||||||
"public/js/education/student_button.html",
|
"public/js/education/student_button.html",
|
||||||
"public/js/education/assessment_result_tool.html",
|
"public/js/education/assessment_result_tool.html",
|
||||||
"public/js/hub/hub_factory.js",
|
"public/js/hub/hub_factory.js",
|
||||||
"public/js/call_summary_dialog.js"
|
"public/js/call_popup/call_summary_dialog.js",
|
||||||
|
"public/js/call_popup/call_summary.html"
|
||||||
],
|
],
|
||||||
"js/item-dashboard.min.js": [
|
"js/item-dashboard.min.js": [
|
||||||
"stock/dashboard/item_dashboard.html",
|
"stock/dashboard/item_dashboard.html",
|
||||||
|
101
erpnext/public/js/call_popup/call_summary_dialog.js
Normal file
101
erpnext/public/js/call_popup/call_summary_dialog.js
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
class CallSummaryDialog {
|
||||||
|
constructor(opts) {
|
||||||
|
this.number = opts.number;
|
||||||
|
this.make();
|
||||||
|
}
|
||||||
|
|
||||||
|
make() {
|
||||||
|
var d = new frappe.ui.Dialog({
|
||||||
|
'title': `Incoming Call: ${this.number}`,
|
||||||
|
'fields': [{
|
||||||
|
'fieldname': 'customer_info',
|
||||||
|
'fieldtype': 'HTML'
|
||||||
|
}, {
|
||||||
|
'fieldtype': 'Section Break'
|
||||||
|
}, {
|
||||||
|
'fieldtype': 'Text',
|
||||||
|
'label': "Last Communication",
|
||||||
|
'fieldname': 'last_communication',
|
||||||
|
'default': 'This is not working please helpppp',
|
||||||
|
'placeholder': __("Select or add new customer"),
|
||||||
|
'readonly': true
|
||||||
|
}, {
|
||||||
|
'fieldtype': 'Column Break'
|
||||||
|
}, {
|
||||||
|
'fieldtype': 'Text',
|
||||||
|
'label': 'Call Summary',
|
||||||
|
'fieldname': 'call_communication',
|
||||||
|
'default': 'This is not working please helpppp',
|
||||||
|
"placeholder": __("Select or add new customer")
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
// this.body.html(this.get_dialog_skeleton());
|
||||||
|
frappe.xcall('erpnext.crm.call_summary.call_summary_utils.get_contact_doc', {
|
||||||
|
phone_number: this.number
|
||||||
|
}).then(res => {
|
||||||
|
this.make_customer_contact(res, d.fields_dict["customer_info"].$wrapper);
|
||||||
|
// this.make_last_communication_section();
|
||||||
|
});
|
||||||
|
d.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
get_dialog_skeleton() {
|
||||||
|
return `
|
||||||
|
<div class="call-summary-body">
|
||||||
|
<div class="customer-info flex">
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<div class="last-communication"></div>
|
||||||
|
<div class="call-summary"></div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div class="flex">
|
||||||
|
<div class="section-right"></div>
|
||||||
|
<div class="section-left"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
make_customer_contact(res, wrapper) {
|
||||||
|
if (!res) {
|
||||||
|
wrapper.append('<b>Unknown Contact</b>');
|
||||||
|
} else {
|
||||||
|
wrapper.append(`
|
||||||
|
<img src="${res.image}">
|
||||||
|
<div class='flex-column'>
|
||||||
|
<span>${res.first_name} ${res.last_name}</span>
|
||||||
|
<span>${res.mobile_no}</span>
|
||||||
|
<span>Customer: <b>Some Enterprise</b></span>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
make_last_communication_section() {
|
||||||
|
const last_communication_section = this.body.find('.last-communication');
|
||||||
|
const last_communication = frappe.ui.form.make_control({
|
||||||
|
parent: last_communication_section,
|
||||||
|
df: {
|
||||||
|
fieldtype: "Text",
|
||||||
|
label: "Last Communication",
|
||||||
|
fieldname: "last_communication",
|
||||||
|
'default': 'This is not working please helpppp',
|
||||||
|
"placeholder": __("Select or add new customer")
|
||||||
|
},
|
||||||
|
});
|
||||||
|
last_communication.set_value('This is not working please helpppp');
|
||||||
|
}
|
||||||
|
|
||||||
|
make_summary_section() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).on('app_ready', function() {
|
||||||
|
frappe.realtime.on('incoming_call', data => {
|
||||||
|
const number = data.CallFrom;
|
||||||
|
frappe.call_summary_dialog = new CallSummaryDialog({
|
||||||
|
number
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -1,32 +0,0 @@
|
|||||||
class CallSummaryDialog {
|
|
||||||
constructor(opts) {
|
|
||||||
this.number = opts.number;
|
|
||||||
this.make();
|
|
||||||
}
|
|
||||||
|
|
||||||
make() {
|
|
||||||
var d = new frappe.ui.Dialog();
|
|
||||||
this.$modal_body = $(d.body);
|
|
||||||
this.call_summary_dialog = d;
|
|
||||||
$(d.header).html(`<div>Incoming Call: ${this.number}</div>`);
|
|
||||||
frappe.xcall('erpnext.crm.call_summary.call_summary_utils.get_contact_doc', {
|
|
||||||
phone_number: this.number
|
|
||||||
}).then(res => {
|
|
||||||
if (!res) {
|
|
||||||
this.$modal_body.html('Unknown Contact');
|
|
||||||
} else {
|
|
||||||
this.$modal_body.append(`${frappe.utils.get_form_link('Contact', res.name, true)}`)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
d.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).on('app_ready', function() {
|
|
||||||
frappe.realtime.on('incoming_call', data => {
|
|
||||||
const number = data.CallFrom;
|
|
||||||
frappe.call_summary_dialog = new CallSummaryDialog({
|
|
||||||
number
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
6
erpnext/public/less/call_summary.less
Normal file
6
erpnext/public/less/call_summary.less
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.customer-info {
|
||||||
|
img {
|
||||||
|
width: auto;
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user