blob: d3c93eb24c51b98869ac90fab3a9dcdd7a06a8d1 [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Anand Doshi330dae92013-09-10 13:46:15 +05302# License: GNU General Public License v3. See license.txt
3
4from __future__ import unicode_literals
Rushabh Mehta793ba6b2014-02-14 15:47:51 +05305import frappe
Anand Doshifb109ad2013-09-11 18:58:20 +05306
Rushabh Mehta793ba6b2014-02-14 15:47:51 +05307@frappe.whitelist(allow_guest=True)
Anand Doshifb109ad2013-09-11 18:58:20 +05308def send_message(subject="Website Query", message="", sender="", status="Open"):
Rushabh Mehta793ba6b2014-02-14 15:47:51 +05309 from frappe.templates.pages.contact import send_message as website_send_message
Anand Doshi56f29cb2014-05-02 18:16:45 +053010 res = website_send_message(subject, message, sender)
Anand Doshi5d591eb2014-04-18 16:15:31 +053011
Anand Doshi56f29cb2014-05-02 18:16:45 +053012 if not res:
Anand Doshifb109ad2013-09-11 18:58:20 +053013 return
Anand Doshi5d591eb2014-04-18 16:15:31 +053014
Anand Doshidf019802013-12-04 16:27:30 +053015 if subject=="Support":
16 # create support ticket
Rushabh Mehta1f847992013-12-12 19:12:19 +053017 from erpnext.support.doctype.support_ticket.get_support_mails import add_support_communication
Anand Doshidf019802013-12-04 16:27:30 +053018 add_support_communication(subject, message, sender, mail=None)
19 else:
20 # make lead / communication
Rushabh Mehta1f847992013-12-12 19:12:19 +053021 from erpnext.selling.doctype.lead.get_leads import add_sales_communication
Anand Doshi5d591eb2014-04-18 16:15:31 +053022 add_sales_communication(subject or "Website Query", message, sender, sender,
Anand Doshidf019802013-12-04 16:27:30 +053023 mail=None, status=status)
Anand Doshi5d591eb2014-04-18 16:15:31 +053024
Anand Doshi56f29cb2014-05-02 18:16:45 +053025 return res