Rushabh Mehta | 3daa49a | 2014-10-21 16:16:30 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
| 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | import frappe |
| 6 | from frappe import _ |
| 7 | from frappe.utils import cstr |
| 8 | from erpnext.shopping_cart.cart import get_lead_or_customer |
| 9 | |
| 10 | no_cache = 1 |
| 11 | no_sitemap = 1 |
| 12 | |
| 13 | def get_context(context): |
| 14 | party = get_lead_or_customer() |
| 15 | if party.doctype == "Lead": |
| 16 | mobile_no = party.mobile_no |
| 17 | phone = party.phone |
| 18 | else: |
| 19 | mobile_no, phone = frappe.db.get_value("Contact", {"email_id": frappe.session.user, |
| 20 | "customer": party.name}, ["mobile_no", "phone"]) |
| 21 | |
| 22 | return { |
| 23 | "company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name), |
| 24 | "mobile_no": cstr(mobile_no), |
| 25 | "phone": cstr(phone) |
| 26 | } |
| 27 | |
| 28 | @frappe.whitelist() |
| 29 | def update_user(fullname, password=None, company_name=None, mobile_no=None, phone=None): |
| 30 | from erpnext.shopping_cart.cart import update_party |
| 31 | update_party(fullname, company_name, mobile_no, phone) |
| 32 | |
| 33 | if not fullname: |
| 34 | return _("Name is required") |
| 35 | |
| 36 | frappe.db.set_value("User", frappe.session.user, "first_name", fullname) |
| 37 | frappe.local.cookie_manager.set_cookie("full_name", fullname) |
| 38 | |
| 39 | return _("Updated") |
| 40 | |