added automatic lead creation for sales email id
This commit is contained in:
parent
9942987c9c
commit
2e5db35856
@ -82,6 +82,7 @@ erpnext.desktop.show_pending_notifications = function() {
|
|||||||
add_circle('module-icon-calendar', 'todays_events', 'Todays Events');
|
add_circle('module-icon-calendar', 'todays_events', 'Todays Events');
|
||||||
add_circle('module-icon-projects-home', 'open_tasks', 'Open Tasks');
|
add_circle('module-icon-projects-home', 'open_tasks', 'Open Tasks');
|
||||||
add_circle('module-icon-questions', 'unanswered_questions', 'Unanswered Questions');
|
add_circle('module-icon-questions', 'unanswered_questions', 'Unanswered Questions');
|
||||||
|
add_circle('module-icon-selling-home', 'open_leads', 'Open Leads');
|
||||||
|
|
||||||
erpnext.update_messages();
|
erpnext.update_messages();
|
||||||
|
|
||||||
|
@ -28,16 +28,12 @@ class JobsMailbox(POP3Mailbox):
|
|||||||
return webnotes.conn.sql("select user from tabSessions where \
|
return webnotes.conn.sql("select user from tabSessions where \
|
||||||
time_to_sec(timediff(now(), lastupdate)) < 1800")
|
time_to_sec(timediff(now(), lastupdate)) < 1800")
|
||||||
|
|
||||||
def get_existing_application(self, email_id):
|
|
||||||
name = webnotes.conn.sql("""select name from `tabJob Applicant` where
|
|
||||||
email_id = %s""", email_id)
|
|
||||||
return name and name[0][0] or None
|
|
||||||
|
|
||||||
def process_message(self, mail):
|
def process_message(self, mail):
|
||||||
if mail.from_email == self.settings.email_id:
|
if mail.from_email == self.settings.email_id:
|
||||||
return
|
return
|
||||||
|
|
||||||
name = self.get_existing_application(mail.from_email)
|
name = webnotes.conn.get_value("Job Applicant", {"email_id": mail.from_email},
|
||||||
|
"name")
|
||||||
if name:
|
if name:
|
||||||
applicant = webnotes.model_wrapper("Job Applicant", name)
|
applicant = webnotes.model_wrapper("Job Applicant", name)
|
||||||
if applicant.doc.status!="Rejected":
|
if applicant.doc.status!="Rejected":
|
||||||
|
@ -108,6 +108,7 @@ erpnext.update_messages = function(reset) {
|
|||||||
show_in_circle('todays_events', r.message.todays_events);
|
show_in_circle('todays_events', r.message.todays_events);
|
||||||
show_in_circle('open_tasks', r.message.open_tasks);
|
show_in_circle('open_tasks', r.message.open_tasks);
|
||||||
show_in_circle('unanswered_questions', r.message.unanswered_questions);
|
show_in_circle('unanswered_questions', r.message.unanswered_questions);
|
||||||
|
show_in_circle('open_leads', r.message.open_leads);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
clearInterval(wn.updates.id);
|
clearInterval(wn.updates.id);
|
||||||
|
@ -11,7 +11,7 @@ erpnext.send_message = function(opts) {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
url: "server.py",
|
url: "server.py",
|
||||||
data: {
|
data: {
|
||||||
cmd: "website.send_message",
|
cmd: "website.helpers.contact.send_message",
|
||||||
subject: opts.subject,
|
subject: opts.subject,
|
||||||
sender: opts.sender,
|
sender: opts.sender,
|
||||||
status: opts.status,
|
status: opts.status,
|
||||||
@ -34,6 +34,8 @@ function valid_email(id) {
|
|||||||
if(id.toLowerCase().search("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?")==-1)
|
if(id.toLowerCase().search("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?")==-1)
|
||||||
return 0; else return 1; }
|
return 0; else return 1; }
|
||||||
|
|
||||||
|
var validate_email = valid_email;
|
||||||
|
|
||||||
function get_url_arg(name) {
|
function get_url_arg(name) {
|
||||||
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
|
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
|
||||||
var regexS = "[\\?&]"+name+"=([^&#]*)";
|
var regexS = "[\\?&]"+name+"=([^&#]*)";
|
||||||
|
57
selling/doctype/lead/get_leads.py
Normal file
57
selling/doctype/lead/get_leads.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# ERPNext - web based ERP (http://erpnext.com)
|
||||||
|
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import webnotes
|
||||||
|
from webnotes.utils import cstr, cint
|
||||||
|
from webnotes.utils.email_lib.receive import POP3Mailbox
|
||||||
|
from core.doctype.communication.communication import make
|
||||||
|
|
||||||
|
class SalesMailbox(POP3Mailbox):
|
||||||
|
def setup(self):
|
||||||
|
self.settings = webnotes.doc("Sales Email Settings", "Sales Email Settings")
|
||||||
|
|
||||||
|
def check_mails(self):
|
||||||
|
return webnotes.conn.sql("select user from tabSessions where \
|
||||||
|
time_to_sec(timediff(now(), lastupdate)) < 1800")
|
||||||
|
|
||||||
|
def process_message(self, mail):
|
||||||
|
if mail.from_email == self.settings.email_id:
|
||||||
|
return
|
||||||
|
|
||||||
|
name = webnotes.conn.get_value("Lead", {"email_id": mail.from_email}, "name")
|
||||||
|
if name:
|
||||||
|
lead = webnotes.model_wrapper("Lead", name)
|
||||||
|
lead.doc.status = "Open"
|
||||||
|
lead.doc.save()
|
||||||
|
else:
|
||||||
|
lead = webnotes.model_wrapper({
|
||||||
|
"doctype":"Lead",
|
||||||
|
"lead_name": mail.from_real_name or mail.from_email,
|
||||||
|
"email_id": mail.from_email,
|
||||||
|
"status": "Open",
|
||||||
|
"source": "Email"
|
||||||
|
})
|
||||||
|
lead.insert()
|
||||||
|
|
||||||
|
mail.save_attachments_in_doc(lead.doc)
|
||||||
|
|
||||||
|
make(content=mail.content, sender=mail.from_email,
|
||||||
|
doctype="Lead", name=lead.doc.name, lead=lead.doc.name)
|
||||||
|
|
||||||
|
def get_leads():
|
||||||
|
if cint(webnotes.conn.get_value('Sales Email Settings', None, 'extract_emails')):
|
||||||
|
SalesMailbox()
|
@ -77,8 +77,11 @@ class DocType(TransactionBase):
|
|||||||
event_user.person = self.doc.contact_by
|
event_user.person = self.doc.contact_by
|
||||||
event_user.save()
|
event_user.save()
|
||||||
|
|
||||||
|
def on_communication_sent(self, comm):
|
||||||
|
webnotes.conn.set(self.doc, 'status', 'Replied')
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
webnotes.conn.sql("""update tabCommunication set lead='' where lead=%s""",
|
webnotes.conn.sql("""delete from tabCommunication where lead=%s""",
|
||||||
self.doc.name)
|
self.doc.name)
|
||||||
webnotes.conn.sql("""update `tabSupport Ticket` set lead='' where lead=%s""",
|
webnotes.conn.sql("""update `tabSupport Ticket` set lead='' where lead=%s""",
|
||||||
self.doc.name)
|
self.doc.name)
|
@ -2,9 +2,9 @@
|
|||||||
{
|
{
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"creation": "2012-11-02 17:16:46",
|
"creation": "2013-01-10 16:34:18",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"modified": "2012-11-27 18:27:47"
|
"modified": "2013-01-16 10:51:58"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"autoname": "naming_series:",
|
"autoname": "naming_series:",
|
||||||
@ -29,6 +29,7 @@
|
|||||||
"doctype": "DocPerm",
|
"doctype": "DocPerm",
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"parenttype": "DocType",
|
"parenttype": "DocType",
|
||||||
|
"report": 1,
|
||||||
"parentfield": "permissions"
|
"parentfield": "permissions"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -39,19 +40,17 @@
|
|||||||
"description": "To manage multiple series please go to Setup > Manage Series",
|
"description": "To manage multiple series please go to Setup > Manage Series",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldtype": "Select",
|
"oldfieldtype": "Select",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Naming Series",
|
"label": "Naming Series",
|
||||||
"oldfieldname": "naming_series",
|
"oldfieldname": "naming_series",
|
||||||
"permlevel": 0,
|
"options": "LEAD\nLEAD/10-11/\nLEAD/MUMBAI/",
|
||||||
"fieldname": "naming_series",
|
"fieldname": "naming_series",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"options": "LEAD\nLEAD/10-11/\nLEAD/MUMBAI/"
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"oldfieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Contact Name",
|
"label": "Contact Name",
|
||||||
"oldfieldname": "lead_name",
|
"oldfieldname": "lead_name",
|
||||||
@ -64,7 +63,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"oldfieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Email Id",
|
"label": "Email Id",
|
||||||
"oldfieldname": "email_id",
|
"oldfieldname": "email_id",
|
||||||
@ -84,29 +82,25 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldtype": "Select",
|
"oldfieldtype": "Select",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Status",
|
"label": "Status",
|
||||||
"oldfieldname": "status",
|
"oldfieldname": "status",
|
||||||
"default": "Open",
|
"default": "Open",
|
||||||
"trigger": "Client",
|
|
||||||
"fieldname": "status",
|
"fieldname": "status",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"search_index": 1,
|
"search_index": 1,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"options": "\nOpen\nAttempted to Contact\nContact in Future\nContacted\nInterested\nNot interested\nLead Lost\nConverted",
|
"options": "\nOpen\nReplied\nAttempted to Contact\nContact in Future\nContacted\nInterested\nNot interested\nLead Lost\nConverted",
|
||||||
"in_filter": 1
|
"in_filter": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Source of the lead. If via a campaign, select \"Campaign\"",
|
"description": "Source of the lead. If via a campaign, select \"Campaign\"",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldtype": "Select",
|
"oldfieldtype": "Select",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Source",
|
"label": "Source",
|
||||||
"oldfieldname": "source",
|
"oldfieldname": "source",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"trigger": "Client",
|
|
||||||
"fieldname": "source",
|
"fieldname": "source",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
@ -121,9 +115,8 @@
|
|||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
|
||||||
"oldfieldtype": "Table",
|
"oldfieldtype": "Table",
|
||||||
"colour": "White:FFF",
|
"allow_on_submit": 0,
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Communication HTML",
|
"label": "Communication HTML",
|
||||||
"oldfieldname": "follow_up",
|
"oldfieldname": "follow_up",
|
||||||
@ -141,45 +134,41 @@
|
|||||||
{
|
{
|
||||||
"description": "Name of organization from where lead has come",
|
"description": "Name of organization from where lead has come",
|
||||||
"oldfieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Company Name",
|
"label": "Company Name",
|
||||||
"oldfieldname": "company_name",
|
"oldfieldname": "company_name",
|
||||||
"trigger": "Client",
|
|
||||||
"fieldname": "company_name",
|
"fieldname": "company_name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"in_filter": 1,
|
"permlevel": 0,
|
||||||
"permlevel": 0
|
"in_filter": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Source of th",
|
"description": "Source of th",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "From Customer",
|
"label": "From Customer",
|
||||||
"oldfieldname": "customer",
|
"oldfieldname": "customer",
|
||||||
"permlevel": 0,
|
"options": "Customer",
|
||||||
"fieldname": "customer",
|
"fieldname": "customer",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"depends_on": "eval:doc.source == 'Existing Customer'",
|
"depends_on": "eval:doc.source == 'Existing Customer'",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"options": "Customer"
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Enter campaign name if the source of lead is campaign.",
|
"description": "Enter campaign name if the source of lead is campaign.",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Campaign Name",
|
"label": "Campaign Name",
|
||||||
"oldfieldname": "campaign_name",
|
"oldfieldname": "campaign_name",
|
||||||
"permlevel": 0,
|
"options": "Campaign",
|
||||||
"fieldname": "campaign_name",
|
"fieldname": "campaign_name",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"depends_on": "eval:doc.source == 'Campaign'",
|
"depends_on": "eval:doc.source == 'Campaign'",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"options": "Campaign"
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
@ -190,7 +179,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"oldfieldtype": "Select",
|
"oldfieldtype": "Select",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Lead Type",
|
"label": "Lead Type",
|
||||||
"oldfieldname": "type",
|
"oldfieldname": "type",
|
||||||
@ -202,7 +190,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"oldfieldtype": "Text",
|
"oldfieldtype": "Text",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Remark",
|
"label": "Remark",
|
||||||
"oldfieldname": "remark",
|
"oldfieldname": "remark",
|
||||||
@ -220,7 +207,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"oldfieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Phone",
|
"label": "Phone",
|
||||||
"oldfieldname": "contact_no",
|
"oldfieldname": "contact_no",
|
||||||
@ -260,7 +246,6 @@
|
|||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"description": "<a href=\"javascript:cur_frm.cscript.TerritoryHelp();\">To manage Territory, click here</a>",
|
"description": "<a href=\"javascript:cur_frm.cscript.TerritoryHelp();\">To manage Territory, click here</a>",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Territory",
|
"label": "Territory",
|
||||||
"oldfieldname": "territory",
|
"oldfieldname": "territory",
|
||||||
@ -313,17 +298,15 @@
|
|||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Country",
|
"label": "Country",
|
||||||
"oldfieldname": "country",
|
"oldfieldname": "country",
|
||||||
"trigger": "Client",
|
"options": "link:Country",
|
||||||
"fieldname": "country",
|
"fieldname": "country",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"options": "link:Country",
|
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"oldfieldtype": "Select",
|
"oldfieldtype": "Select",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "State",
|
"label": "State",
|
||||||
"oldfieldname": "state",
|
"oldfieldname": "state",
|
||||||
@ -344,7 +327,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"oldfieldtype": "Section Break",
|
"oldfieldtype": "Section Break",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "More Info",
|
"label": "More Info",
|
||||||
"fieldname": "more_info",
|
"fieldname": "more_info",
|
||||||
@ -436,7 +418,6 @@
|
|||||||
"description": "Your sales person who will contact the lead in future",
|
"description": "Your sales person who will contact the lead in future",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
"colour": "White:FFF",
|
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Next Contact By",
|
"label": "Next Contact By",
|
||||||
@ -453,7 +434,6 @@
|
|||||||
"description": "Your sales person will get a reminder on this date to contact the lead",
|
"description": "Your sales person will get a reminder on this date to contact the lead",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldtype": "Date",
|
"oldfieldtype": "Date",
|
||||||
"colour": "White:FFF",
|
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Next Contact Date",
|
"label": "Next Contact Date",
|
||||||
@ -470,7 +450,6 @@
|
|||||||
"description": "Date on which the lead was last contacted",
|
"description": "Date on which the lead was last contacted",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldtype": "Date",
|
"oldfieldtype": "Date",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Last Contact Date",
|
"label": "Last Contact Date",
|
||||||
"oldfieldname": "last_contact_date",
|
"oldfieldname": "last_contact_date",
|
||||||
@ -481,7 +460,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
"colour": "White:FFF",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Company",
|
"label": "Company",
|
||||||
"oldfieldname": "company",
|
"oldfieldname": "company",
|
||||||
@ -563,21 +541,5 @@
|
|||||||
"role": "Sales User",
|
"role": "Sales User",
|
||||||
"cancel": 0,
|
"cancel": 0,
|
||||||
"permlevel": 1
|
"permlevel": 1
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"write": 1,
|
|
||||||
"role": "System Manager",
|
|
||||||
"cancel": 0,
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"write": 1,
|
|
||||||
"role": "Guest",
|
|
||||||
"cancel": 0,
|
|
||||||
"permlevel": 0
|
|
||||||
}
|
}
|
||||||
]
|
]
|
@ -16,7 +16,10 @@ wn.doclistviews['Lead'] = wn.views.ListView.extend({
|
|||||||
if(data.status=='Interested') {
|
if(data.status=='Interested') {
|
||||||
data.label_type = 'success'
|
data.label_type = 'success'
|
||||||
}
|
}
|
||||||
else if(['Open', 'Attempted to Contact', 'Contacted', 'Contact in Future'].indexOf(data.status)!=-1) {
|
if(data.status=="Open") {
|
||||||
|
data.label_type = "important"
|
||||||
|
}
|
||||||
|
else if(['Attempted to Contact', 'Contacted', 'Contact in Future'].indexOf(data.status)!=-1) {
|
||||||
data.label_type = 'info'
|
data.label_type = 'info'
|
||||||
}
|
}
|
||||||
data.status_html = repl('<span class="label label-%(label_type)s">%(status)s</span>', data);
|
data.status_html = repl('<span class="label label-%(label_type)s">%(status)s</span>', data);
|
||||||
|
0
setup/doctype/sales_email_settings/__init__.py
Normal file
0
setup/doctype/sales_email_settings/__init__.py
Normal file
12
setup/doctype/sales_email_settings/sales_applicant_list.js
Normal file
12
setup/doctype/sales_email_settings/sales_applicant_list.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
cur_frm.cscript = {
|
||||||
|
refresh: function(doc) {
|
||||||
|
cur_frm.set_intro("");
|
||||||
|
if(doc.extract_emails) {
|
||||||
|
cur_frm.set_intro(wn._("Active: Will extract emails from ") + doc.email_id);
|
||||||
|
} else {
|
||||||
|
cur_frm.set_intro(wn._("Not Active"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
setup/doctype/sales_email_settings/sales_email_settings.py
Normal file
17
setup/doctype/sales_email_settings/sales_email_settings.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import webnotes
|
||||||
|
from webnotes import _
|
||||||
|
from webnotes.utils import cint
|
||||||
|
|
||||||
|
class DocType:
|
||||||
|
def __init__(self, d, dl):
|
||||||
|
self.doc, self.doclist = d, dl
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
if cint(self.doc.extract_emails) and not (self.doc.email_id and self.doc.host and \
|
||||||
|
self.doc.username and self.doc.password):
|
||||||
|
|
||||||
|
webnotes.msgprint(_("""Host, Email and Password required if emails are to be pulled"""),
|
||||||
|
raise_exception=True)
|
89
setup/doctype/sales_email_settings/sales_email_settings.txt
Normal file
89
setup/doctype/sales_email_settings/sales_email_settings.txt
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"owner": "Administrator",
|
||||||
|
"docstatus": 0,
|
||||||
|
"creation": "2013-01-16 10:25:26",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"modified": "2013-01-16 10:25:26"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"issingle": 1,
|
||||||
|
"description": "Email settings to extract Leads from sales email id e.g. \"sales@example.com\"",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"module": "Setup",
|
||||||
|
"name": "__common__"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "__common__",
|
||||||
|
"parent": "Sales Email Settings",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"parenttype": "DocType",
|
||||||
|
"permlevel": 0,
|
||||||
|
"parentfield": "fields"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parent": "Sales Email Settings",
|
||||||
|
"read": 1,
|
||||||
|
"name": "__common__",
|
||||||
|
"create": 1,
|
||||||
|
"doctype": "DocPerm",
|
||||||
|
"write": 1,
|
||||||
|
"parenttype": "DocType",
|
||||||
|
"role": "System Manager",
|
||||||
|
"permlevel": 0,
|
||||||
|
"parentfield": "permissions"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Sales Email Settings",
|
||||||
|
"doctype": "DocType"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Email settings to extract Leads from sales email id e.g. \"sales@example.com\"",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"label": "POP3 Mail Settings",
|
||||||
|
"fieldname": "pop3_mail_settings",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Check to activate",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"label": "Extract Emails",
|
||||||
|
"fieldname": "extract_emails",
|
||||||
|
"fieldtype": "Check"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Email Id where a job applicant will email e.g. \"jobs@example.com\"",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"label": "Email Id",
|
||||||
|
"fieldname": "email_id",
|
||||||
|
"fieldtype": "Data"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "POP3 server e.g. (pop.gmail.com)",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"label": "Host",
|
||||||
|
"fieldname": "host",
|
||||||
|
"fieldtype": "Data"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"label": "Use SSL",
|
||||||
|
"fieldname": "use_ssl",
|
||||||
|
"fieldtype": "Check"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"label": "Username",
|
||||||
|
"fieldname": "username",
|
||||||
|
"fieldtype": "Data"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"label": "Password",
|
||||||
|
"fieldname": "password",
|
||||||
|
"fieldtype": "Password"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocPerm"
|
||||||
|
}
|
||||||
|
]
|
@ -17,6 +17,7 @@ queries = {
|
|||||||
"Purchase Invoice": {"docstatus":0},
|
"Purchase Invoice": {"docstatus":0},
|
||||||
"Leave Application": {"status":"Open"},
|
"Leave Application": {"status":"Open"},
|
||||||
"Expense Claim": {"approval_status":"Draft"},
|
"Expense Claim": {"approval_status":"Draft"},
|
||||||
|
"Job Applicant": {"status":"Open"},
|
||||||
"Purchase Receipt": {"docstatus":0},
|
"Purchase Receipt": {"docstatus":0},
|
||||||
"Delivery Note": {"docstatus":0},
|
"Delivery Note": {"docstatus":0},
|
||||||
"Stock Entry": {"docstatus":0},
|
"Stock Entry": {"docstatus":0},
|
||||||
|
@ -32,7 +32,9 @@ def execute_all():
|
|||||||
from hr.doctype.job_applicant.get_job_applications import get_job_applications
|
from hr.doctype.job_applicant.get_job_applications import get_job_applications
|
||||||
run_fn(get_job_applications)
|
run_fn(get_job_applications)
|
||||||
|
|
||||||
# bulk email
|
from selling.doctype.lead.get_leads import get_leads
|
||||||
|
run_fn(get_job_applications)
|
||||||
|
|
||||||
from webnotes.utils.email_lib.bulk import flush
|
from webnotes.utils.email_lib.bulk import flush
|
||||||
run_fn(flush)
|
run_fn(flush)
|
||||||
|
|
||||||
|
@ -29,38 +29,39 @@ def get_unread_messages():
|
|||||||
|
|
||||||
def get_open_support_tickets():
|
def get_open_support_tickets():
|
||||||
"""Returns a count of open support tickets"""
|
"""Returns a count of open support tickets"""
|
||||||
from webnotes.utils import cint
|
|
||||||
open_support_tickets = webnotes.conn.sql("""\
|
open_support_tickets = webnotes.conn.sql("""\
|
||||||
SELECT COUNT(*) FROM `tabSupport Ticket`
|
SELECT COUNT(*) FROM `tabSupport Ticket`
|
||||||
WHERE status = 'Open'""")
|
WHERE status = 'Open'""")
|
||||||
return open_support_tickets and cint(open_support_tickets[0][0]) or 0
|
return open_support_tickets[0][0]
|
||||||
|
|
||||||
def get_open_tasks():
|
def get_open_tasks():
|
||||||
"""Returns a count of open tasks"""
|
"""Returns a count of open tasks"""
|
||||||
from webnotes.utils import cint
|
|
||||||
return webnotes.conn.sql("""\
|
return webnotes.conn.sql("""\
|
||||||
SELECT COUNT(*) FROM `tabTask`
|
SELECT COUNT(*) FROM `tabTask`
|
||||||
WHERE status = 'Open'""")[0][0]
|
WHERE status = 'Open'""")[0][0]
|
||||||
|
|
||||||
def get_things_todo():
|
def get_things_todo():
|
||||||
"""Returns a count of incomplete todos"""
|
"""Returns a count of incomplete todos"""
|
||||||
from webnotes.utils import cint
|
|
||||||
incomplete_todos = webnotes.conn.sql("""\
|
incomplete_todos = webnotes.conn.sql("""\
|
||||||
SELECT COUNT(*) FROM `tabToDo`
|
SELECT COUNT(*) FROM `tabToDo`
|
||||||
WHERE IFNULL(checked, 0) = 0
|
WHERE IFNULL(checked, 0) = 0
|
||||||
AND (owner = %s or assigned_by=%s)""", (webnotes.session.user, webnotes.session.user))
|
AND (owner = %s or assigned_by=%s)""", (webnotes.session.user, webnotes.session.user))
|
||||||
return incomplete_todos and cint(incomplete_todos[0][0]) or 0
|
return incomplete_todos[0][0]
|
||||||
|
|
||||||
def get_todays_events():
|
def get_todays_events():
|
||||||
"""Returns a count of todays events in calendar"""
|
"""Returns a count of todays events in calendar"""
|
||||||
from webnotes.utils import nowdate, cint
|
from webnotes.utils import nowdate
|
||||||
todays_events = webnotes.conn.sql("""\
|
todays_events = webnotes.conn.sql("""\
|
||||||
SELECT COUNT(*) FROM `tabEvent`
|
SELECT COUNT(*) FROM `tabEvent`
|
||||||
WHERE owner = %s
|
WHERE owner = %s
|
||||||
AND event_type != 'Cancel'
|
AND event_type != 'Cancel'
|
||||||
AND event_date = %s""", (
|
AND event_date = %s""", (
|
||||||
webnotes.session.get('user'), nowdate()))
|
webnotes.session.user, nowdate()))
|
||||||
return todays_events and cint(todays_events[0][0]) or 0
|
return todays_events[0][0]
|
||||||
|
|
||||||
|
def get_open_leads():
|
||||||
|
return webnotes.conn.sql("""select count(*) from tabLead
|
||||||
|
where status='Open'""")[0][0]
|
||||||
|
|
||||||
def get_unanswered_questions():
|
def get_unanswered_questions():
|
||||||
return len(filter(lambda d: d[0]==0,
|
return len(filter(lambda d: d[0]==0,
|
||||||
@ -75,5 +76,6 @@ def get_global_status_messages(arg=None):
|
|||||||
'things_todo': get_things_todo(),
|
'things_todo': get_things_todo(),
|
||||||
'todays_events': get_todays_events(),
|
'todays_events': get_todays_events(),
|
||||||
'open_tasks': get_open_tasks(),
|
'open_tasks': get_open_tasks(),
|
||||||
'unanswered_questions': get_unanswered_questions()
|
'unanswered_questions': get_unanswered_questions(),
|
||||||
|
'open_leads': get_open_leads()
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ $.extend(cur_frm.cscript, {
|
|||||||
var sortfn = function (a, b) { return (b.creation > a.creation) ? 1 : -1; }
|
var sortfn = function (a, b) { return (b.creation > a.creation) ? 1 : -1; }
|
||||||
comm_list = comm_list.sort(sortfn);
|
comm_list = comm_list.sort(sortfn);
|
||||||
|
|
||||||
if(!comm_list.length || (comm_list[0].sender != doc.raised_by)) {
|
if(!comm_list.length || (comm_list[comm_list.length - 1].sender != doc.raised_by)) {
|
||||||
comm_list.push({
|
comm_list.push({
|
||||||
"sender": doc.raised_by,
|
"sender": doc.raised_by,
|
||||||
"creation": doc.creation,
|
"creation": doc.creation,
|
||||||
|
@ -6,34 +6,6 @@ install_docs = [
|
|||||||
|
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
max_tickets_per_hour = 200
|
|
||||||
|
|
||||||
@webnotes.whitelist(allow_guest=True)
|
|
||||||
def send_message():
|
|
||||||
from webnotes.model.doc import Document
|
|
||||||
|
|
||||||
d = Document('Support Ticket')
|
|
||||||
d.subject = webnotes.form_dict.get('subject', 'Website Query')
|
|
||||||
d.description = webnotes.form_dict.get('message')
|
|
||||||
d.raised_by = webnotes.form_dict.get('sender')
|
|
||||||
d.status = webnotes.form_dict.get("status") or "Open"
|
|
||||||
|
|
||||||
if not d.description:
|
|
||||||
webnotes.response["message"] = 'Please write something'
|
|
||||||
return
|
|
||||||
|
|
||||||
if not d.raised_by:
|
|
||||||
webnotes.response["message"] = 'Email Id Required'
|
|
||||||
return
|
|
||||||
|
|
||||||
# guest method, cap max writes per hour
|
|
||||||
if webnotes.conn.sql("""select count(*) from `tabSupport Ticket`
|
|
||||||
where TIMEDIFF(NOW(), modified) < '01:00:00'""")[0][0] > max_tickets_per_hour:
|
|
||||||
webnotes.response["message"] = "Sorry: we believe we have received an unreasonably high number of requests of this kind. Please try later"
|
|
||||||
return
|
|
||||||
|
|
||||||
d.save()
|
|
||||||
webnotes.response["message"] = 'Thank You'
|
|
||||||
|
|
||||||
def get_site_address():
|
def get_site_address():
|
||||||
from webnotes.utils import get_request_site_address
|
from webnotes.utils import get_request_site_address
|
||||||
|
63
website/helpers/contact.py
Normal file
63
website/helpers/contact.py
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# ERPNext - web based ERP (http://erpnext.com)
|
||||||
|
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import webnotes
|
||||||
|
from core.doctype.communication.communication import make
|
||||||
|
|
||||||
|
max_communications_per_hour = 300
|
||||||
|
|
||||||
|
@webnotes.whitelist(allow_guest=True)
|
||||||
|
def send_message(subject="Website Query", message="", sender="", status="Open"):
|
||||||
|
if not message:
|
||||||
|
webnotes.response["message"] = 'Please write something'
|
||||||
|
return
|
||||||
|
|
||||||
|
if not sender:
|
||||||
|
webnotes.response["message"] = 'Email Id Required'
|
||||||
|
return
|
||||||
|
|
||||||
|
# make lead / communication
|
||||||
|
|
||||||
|
name = webnotes.conn.get_value("Lead", {"email_id": sender}, "name")
|
||||||
|
if name:
|
||||||
|
lead = webnotes.model_wrapper("Lead", name)
|
||||||
|
lead.doc.status = "Open"
|
||||||
|
lead.ignore_permissions = True
|
||||||
|
lead.save()
|
||||||
|
else:
|
||||||
|
lead = webnotes.model_wrapper({
|
||||||
|
"doctype":"Lead",
|
||||||
|
"lead_name": sender,
|
||||||
|
"email_id": sender,
|
||||||
|
"status": "Open",
|
||||||
|
"source": "Website"
|
||||||
|
})
|
||||||
|
lead.ignore_permissions = True
|
||||||
|
lead.insert()
|
||||||
|
|
||||||
|
make(content=message, sender=sender,
|
||||||
|
doctype="Lead", name=lead.doc.name, lead=lead.doc.name)
|
||||||
|
|
||||||
|
|
||||||
|
# guest method, cap max writes per hour
|
||||||
|
if webnotes.conn.sql("""select count(*) from `tabCommunication`
|
||||||
|
where TIMEDIFF(NOW(), modified) < '01:00:00'""")[0][0] > max_communications_per_hour:
|
||||||
|
webnotes.response["message"] = "Sorry: we believe we have received an unreasonably high number of requests of this kind. Please try later"
|
||||||
|
return
|
||||||
|
|
||||||
|
webnotes.response["message"] = 'Thank You'
|
Loading…
x
Reference in New Issue
Block a user