Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaurav Naik committed Apr 30, 2017
2 parents 0e6fd6f + 23609e5 commit c83b230
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion awfis_erpnext/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from __future__ import unicode_literals

__version__ = '2.0.0'
__version__ = '2.0.1'
11 changes: 8 additions & 3 deletions awfis_erpnext/awfis_erpnext/awf.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,15 @@ def create_popup(caller_number, agent_id, call_id):

ld_name = frappe.db.get_value("Lead", {"mobile_no": caller_number_processed}, "name") # frappe.get_all("Lead", fields=["*"], filters={"mobile_no": caller_number_processed})

is_new_lead = False
if not ld_name:
#Create stub lead if lead is not found.
ld = frappe.new_doc("Lead")
ld.mobile_no = caller_number_processed
ld.lead_name = "New Lead ({m})".format(m=caller_number)
ld.lead_name = "Lead ({m})".format(m=caller_number)

#Set mandatory custom fields.
ld.first_name = "New Lead ({m})".format(m=caller_number)
ld.first_name = "Lead ({m})".format(m=caller_number)
ld.awfis_mobile_no = caller_number_processed
ld.source = "Other"
ld.awfis_lead_territory = "All Territories"
Expand All @@ -131,17 +132,21 @@ def create_popup(caller_number, agent_id, call_id):
frappe.set_user(agent_id)
ld.insert(ignore_permissions=True)
frappe.db.commit()

is_new_lead = 1
else:
ld = frappe.get_doc("Lead", ld_name)

is_new_lead = 0

#Make popup content.
lead_fields = {"mobile_no": caller_number,
"lead_name": ld.lead_name,
"company_name": ld.company_name,
"name": ld.name,
"call_timestamp": frappe.utils.datetime.datetime.strftime(frappe.utils.datetime.datetime.today(), '%d/%m/%Y %H:%M:%S'),
"call_id": call_id}
"call_id": call_id,
"is_new_lead": is_new_lead}

popup_content = frappe.render_template("awfis_erpnext/templates/lead_info.html", lead_fields)

Expand Down
11 changes: 9 additions & 2 deletions awfis_erpnext/templates/lead_info.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
<h3>Incoming Call</h3>
<ul style="list-style: none">
<li><h3><i class="icon-phone" style="margin-right: 20px"></i>{{ mobile_no }}</h3></li>
<li><h3><i class="icon-user" style="margin-right: 20px"></i><a href="/desk#Form/Lead/{{ name }}">{{ lead_name }}</a></h3></li>
<li><h3><i class="fa fa-phone" style="margin-right: 20px"></i>{{ mobile_no }}</h3></li>
<li>
<h3>
<i class="fa fa-user" style="margin-right: 20px"></i><a href="/desk#Form/Lead/{{ name }}">{{ lead_name }}</a>
{% if is_new_lead %}
<span class="label label-info">New</span>
{% endif %}
</h3>
</li>
<li><a href="/desk#Form/Lead/{{ name }}">View full info</a></li>
</ul>
<br><span class="small text-muted">Call ID: {{ call_id }} received at {{ call_timestamp }}</span>

0 comments on commit c83b230

Please sign in to comment.