blob: 5ab5545d87424e19e99159ad6c0fc4e42d86b8ce [file] [log] [blame]
Anand Doshi885e0742015-03-03 14:55:30 +05301# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
Rushabh Mehta3daa49a2014-10-21 16:16:30 +05302# License: GNU General Public License v3. See license.txt
3
4from __future__ import unicode_literals
5import frappe
6from frappe import _
7from frappe.utils import cstr
Anand Doshi06ad3082015-09-23 12:46:59 +05308from erpnext.shopping_cart.cart import get_customer
Rushabh Mehta3daa49a2014-10-21 16:16:30 +05309
10no_cache = 1
11no_sitemap = 1
12
13def get_context(context):
Anand Doshi06ad3082015-09-23 12:46:59 +053014 party = get_customer()
15 mobile_no, phone = frappe.db.get_value("Contact", {"email_id": frappe.session.user,
16 "customer": party.name}, ["mobile_no", "phone"])
17
Rushabh Mehta3daa49a2014-10-21 16:16:30 +053018 return {
19 "company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name),
20 "mobile_no": cstr(mobile_no),
21 "phone": cstr(phone)
22 }
Anand Doshi06ad3082015-09-23 12:46:59 +053023
Rushabh Mehta3daa49a2014-10-21 16:16:30 +053024@frappe.whitelist()
25def update_user(fullname, password=None, company_name=None, mobile_no=None, phone=None):
26 from erpnext.shopping_cart.cart import update_party
27 update_party(fullname, company_name, mobile_no, phone)
Anand Doshi06ad3082015-09-23 12:46:59 +053028
Rushabh Mehta3daa49a2014-10-21 16:16:30 +053029 if not fullname:
30 return _("Name is required")
Anand Doshi06ad3082015-09-23 12:46:59 +053031
Rushabh Mehta3daa49a2014-10-21 16:16:30 +053032 frappe.db.set_value("User", frappe.session.user, "first_name", fullname)
33 frappe.local.cookie_manager.set_cookie("full_name", fullname)
Anand Doshi06ad3082015-09-23 12:46:59 +053034
Rushabh Mehta3daa49a2014-10-21 16:16:30 +053035 return _("Updated")