diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000000..8b2106b847 Binary files /dev/null and b/favicon.ico differ diff --git a/patches/patch.py b/patches/patch.py index 384ee2a003..ade080503e 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -1298,3 +1298,26 @@ def execute(patch_no): # load the new billing page if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')): reload_doc('server_tools','page','billing') + elif patch_no == 327: + # patch for support email settings now moved to email settings + reload_doc('setup','doctype','email_settings') + + # map fields from support to email settings + field_map = { + 'support_email': 'email', + 'support_host':'host', + 'support_username': 'username', + 'support_password': 'password', + 'sync_support_mails': 'integrate_incoming', + 'signature': 'support_signature' + } + + for key in field_map: + webnotes.conn.set_value('Email Settings',None,key, \ + webnotes.conn.get_value('Support Email Settings',None,field_map[key])) + + # delete support email settings + from webnotes.model import delete_doc + delete_doc('DocType', 'Support Email Settings') + + # delete description field \ No newline at end of file diff --git a/setup/doctype/email_settings/email_settings.py b/setup/doctype/email_settings/email_settings.py index 12c24646e1..b19e4e2911 100644 --- a/setup/doctype/email_settings/email_settings.py +++ b/setup/doctype/email_settings/email_settings.py @@ -1,44 +1,37 @@ -# Please edit this list and import only required elements import webnotes - -from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add -from webnotes.model import db_exists -from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType -from webnotes.model.doclist import getlist, copy_doclist -from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax -from webnotes import session, form, is_testing, msgprint, errprint - -set = webnotes.conn.set sql = webnotes.conn.sql -get_value = webnotes.conn.get_value -in_transaction = webnotes.conn.in_transaction -convert_to_lists = webnotes.conn.convert_to_lists -# ----------------------------------------------------------------------------------------- - class DocType: - def __init__(self,doc,doclist): - self.doc,self.doclist = doc,doclist + def __init__(self,doc,doclist): + self.doc,self.doclist = doc,doclist - def set_vals(self): - res = sql("select field, value from `tabSingles` where doctype = 'Control Panel' and field IN ('outgoing_mail_server','mail_login','mail_password','auto_email_id','mail_port','use_ssl')") - ret = {} - for r in res: - ret[cstr(r[0])]=r[1] and cstr(r[1]) or '' - - return str(ret) + def set_vals(self): + res = sql("select field, value from `tabSingles` where doctype = 'Control Panel' and field IN ('outgoing_mail_server','mail_login','mail_password','auto_email_id','mail_port','use_ssl')") + ret = {} + for r in res: + ret[cstr(r[0])]=r[1] and cstr(r[1]) or '' + + return str(ret) - def on_update(self): - if self.doc.outgoing_mail_server: - sql("update `tabSingles` set value ='%s' where doctype = 'Control Panel' and field = 'outgoing_mail_server'"%self.doc.outgoing_mail_server) - if self.doc.mail_login: - sql("update `tabSingles` set value ='%s' where doctype = 'Control Panel' and field = 'mail_login'"%self.doc.mail_login) - if self.doc.mail_password: - sql("update `tabSingles` set value ='%s' where doctype = 'Control Panel' and field = 'mail_password'"%self.doc.mail_password) - if self.doc.auto_email_id: - sql("update `tabSingles` set value ='%s' where doctype = 'Control Panel' and field = 'auto_email_id'"%self.doc.auto_email_id) - if self.doc.mail_port: - sql("update `tabSingles` set value ='%s' where doctype = 'Control Panel' and field = 'mail_port'"%self.doc.mail_port) - if self.doc.use_ssl: - sql("update `tabSingles` set value ='%s' where doctype = 'Control Panel' and field = 'use_ssl'"%self.doc.use_ssl) \ No newline at end of file + def set_cp_value(self, key): + """ + Update value in control panel + """ + if self.doc.fields.get(key): + webnotes.conn.set_value('Control Panel', None, key, self.doc.fields[key]) + + def on_update(self): + """ + Sets or cancels the event in the scheduler + """ + # update control panel + map(self.set_cp_value, 'outgoing_mail_server', 'mail_login', 'mail_password', 'auto_email_id', 'mail_port', 'use_ssl') + + # setup scheduler for support emails + if cint(self.doc.sync_support_mails): + from webnotes.utils.scheduler import set_event + set_event('support.doctype.support_ticket.get_support_mails', 60*5, 1) + else: + from webnotes.utils.scheduler import cancel_event + cancel_event('support.doctype.support_ticket.get_support_mails') \ No newline at end of file diff --git a/setup/doctype/email_settings/email_settings.txt b/setup/doctype/email_settings/email_settings.txt index 31bc93285f..1b50694bf2 100644 --- a/setup/doctype/email_settings/email_settings.txt +++ b/setup/doctype/email_settings/email_settings.txt @@ -5,14 +5,14 @@ { 'creation': '2010-08-08 17:08:59', 'docstatus': 0, - 'modified': '2011-01-04 11:21:25', - 'modified_by': 'umair@iwebnotes.com', + 'modified': '2011-07-25 11:07:14', + 'modified_by': 'Administrator', 'owner': 'harshada@webnotestech.com' }, # These values are common for all DocType { - '_last_update': '1307707462', + '_last_update': '1300962303', 'allow_copy': 1, 'allow_email': 1, 'allow_print': 1, @@ -24,7 +24,7 @@ 'name': '__common__', 'section_style': 'Simple', 'server_code_error': ' ', - 'version': 27 + 'version': 30 }, # These values are common for all DocField @@ -69,12 +69,20 @@ 'idx': 2 }, + # DocField + { + 'doctype': 'DocField', + 'fieldtype': 'Section Break', + 'idx': 1, + 'label': 'Outgoing Mails' + }, + # DocField { 'doctype': 'DocField', 'fieldname': 'outgoing_mail_server', 'fieldtype': 'Data', - 'idx': 1, + 'idx': 2, 'label': 'Outgoing Mail Server' }, @@ -83,7 +91,7 @@ 'doctype': 'DocField', 'fieldname': 'mail_port', 'fieldtype': 'Data', - 'idx': 2, + 'idx': 3, 'label': 'Mail Port' }, @@ -92,7 +100,7 @@ 'doctype': 'DocField', 'fieldname': 'use_ssl', 'fieldtype': 'Check', - 'idx': 3, + 'idx': 4, 'label': 'Use SSL' }, @@ -101,7 +109,7 @@ 'doctype': 'DocField', 'fieldname': 'mail_login', 'fieldtype': 'Data', - 'idx': 4, + 'idx': 5, 'label': 'Login Id' }, @@ -110,7 +118,7 @@ 'doctype': 'DocField', 'fieldname': 'mail_password', 'fieldtype': 'Password', - 'idx': 5, + 'idx': 6, 'label': 'Mail Password' }, @@ -119,7 +127,94 @@ 'doctype': 'DocField', 'fieldname': 'auto_email_id', 'fieldtype': 'Data', - 'idx': 6, + 'idx': 7, 'label': 'Auto Email Id' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldtype': 'Section Break', + 'idx': 8, + 'label': 'Support Ticket Mail Settings' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'sync_support_mails', + 'fieldtype': 'Check', + 'idx': 9, + 'label': 'Sync Support Mails' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'support_email', + 'fieldtype': 'Data', + 'idx': 10, + 'label': 'Support Email' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'support_host', + 'fieldtype': 'Data', + 'idx': 11, + 'label': 'Mail Server' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'support_use_ssl', + 'fieldtype': 'Check', + 'idx': 12, + 'label': 'Use SSL' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'support_username', + 'fieldtype': 'Data', + 'idx': 13, + 'label': 'User Name' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'support_password', + 'fieldtype': 'Password', + 'idx': 14, + 'label': 'Support Password' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldtype': 'Column Break', + 'idx': 15 + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'support_signature', + 'fieldtype': 'Text', + 'idx': 16, + 'label': 'Signature' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'support_autoreply', + 'fieldtype': 'Text', + 'idx': 17, + 'label': 'Autoreply' } ] \ No newline at end of file diff --git a/setup/doctype/support_email_settings/__init__.py b/setup/doctype/support_email_settings/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/setup/doctype/support_email_settings/support_email_settings.py b/setup/doctype/support_email_settings/support_email_settings.py deleted file mode 100644 index 44d87350a4..0000000000 --- a/setup/doctype/support_email_settings/support_email_settings.py +++ /dev/null @@ -1,18 +0,0 @@ -import webnotes -from webnotes.utils import cint - -class DocType: - def __init__(self,dt,dn): - self.doc, self.doctype = dt,dn - - def on_update(self): - """ - Sets or cancels the event in the scheduler - """ - if cint(self.doc.integrate_incoming): - from webnotes.utils.scheduler import set_event - set_event('support.doctype.support_ticket.get_support_mails', 60*5, 1) - else: - from webnotes.utils.scheduler import cancel_event - cancel_event('support.doctype.support_ticket.get_support_mails') - diff --git a/setup/doctype/support_email_settings/support_email_settings.txt b/setup/doctype/support_email_settings/support_email_settings.txt deleted file mode 100644 index 6079567bfa..0000000000 --- a/setup/doctype/support_email_settings/support_email_settings.txt +++ /dev/null @@ -1,144 +0,0 @@ -# DocType, Support Email Settings -[ - - # These values are common in all dictionaries - { - 'creation': '2011-05-23 14:50:45', - 'docstatus': 0, - 'modified': '2011-05-28 09:25:53', - 'modified_by': 'Administrator', - 'owner': 'Administrator' - }, - - # These values are common for all DocType - { - '_last_update': '1306554355', - 'colour': 'White:FFF', - 'doctype': 'DocType', - 'in_dialog': 1, - 'issingle': 1, - 'module': 'Setup', - 'name': '__common__', - 'read_only': 1, - 'section_style': 'Simple', - 'show_in_menu': 1, - 'version': 8 - }, - - # These values are common for all DocField - { - 'doctype': 'DocField', - 'name': '__common__', - 'parent': 'Support Email Settings', - 'parentfield': 'fields', - 'parenttype': 'DocType', - 'permlevel': 0 - }, - - # These values are common for all DocPerm - { - 'create': 1, - 'doctype': 'DocPerm', - 'idx': 1, - 'name': '__common__', - 'parent': 'Support Email Settings', - 'parentfield': 'permissions', - 'parenttype': 'DocType', - 'permlevel': 0, - 'read': 1, - 'role': 'System Manager', - 'write': 1 - }, - - # DocType, Support Email Settings - { - 'doctype': 'DocType', - 'name': 'Support Email Settings' - }, - - # DocPerm - { - 'doctype': 'DocPerm' - }, - - # DocField - { - 'colour': 'White:FFF', - 'description': 'The full email id of your incoming support emails', - 'doctype': 'DocField', - 'fieldname': 'email', - 'fieldtype': 'Data', - 'idx': 1, - 'label': 'Email', - 'options': 'Email' - }, - - # DocField - { - 'colour': 'White:FFF', - 'description': 'By checking this, your incoming mails will automatically be integrated with the Support Ticket', - 'doctype': 'DocField', - 'fieldname': 'integrate_incoming', - 'fieldtype': 'Check', - 'idx': 2, - 'label': 'Integrate Incoming' - }, - - # DocField - { - 'colour': 'White:FFF', - 'description': 'Signature appended to the outgoing email (Text / HTML)', - 'doctype': 'DocField', - 'fieldname': 'signature', - 'fieldtype': 'Text', - 'idx': 3, - 'label': 'Signature' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldtype': 'Column Break', - 'idx': 4 - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'use_ssl', - 'fieldtype': 'Check', - 'idx': 5, - 'label': 'Use SSL' - }, - - # DocField - { - 'colour': 'White:FFF', - 'description': 'eg. pop.gmail.com', - 'doctype': 'DocField', - 'fieldname': 'host', - 'fieldtype': 'Data', - 'idx': 6, - 'label': 'Host' - }, - - # DocField - { - 'colour': 'White:FFF', - 'description': 'Support Email Id', - 'doctype': 'DocField', - 'fieldname': 'username', - 'fieldtype': 'Data', - 'idx': 7, - 'label': 'Username' - }, - - # DocField - { - 'doctype': 'DocField', - 'fieldname': 'password', - 'fieldtype': 'Password', - 'idx': 8, - 'label': 'Password' - } -] \ No newline at end of file diff --git a/support/doctype/support_ticket/__init__.py b/support/doctype/support_ticket/__init__.py index 0ca33ec0b9..d9c50652b1 100644 --- a/support/doctype/support_ticket/__init__.py +++ b/support/doctype/support_ticket/__init__.py @@ -6,14 +6,26 @@ class SupportMailbox(POP3Mailbox): def __init__(self): """ settings_doc must contain - is_ssl, host, username, password + use_ssl, host, username, password """ - POP3Mailbox.__init__(self, 'Support Email Settings') + from webnotes.model.doc import Document + + # extract email settings + self.email_settings = Document('Email Settings','Email Settings') + + s = Document('Support Email Settings') + s.use_ssl = self.email_settings.support_use_ssl + s.host = self.email_settings.support_host + s.username = self.email_settings.support_username + s.password = self.email_settings.support_password + + POP3Mailbox.__init__(self, s) def check_mails(self): """ returns true if there are active sessions """ + self.auto_close_tickets() return webnotes.conn.sql("select user from tabSessions where time_to_sec(timediff(now(), lastupdate)) < 1800") def process_message(self, mail): @@ -56,6 +68,36 @@ class SupportMailbox(POP3Mailbox): # update feed update_feed(d) + # send auto reply + self.send_auto_reply(d) + + def send_auto_reply(self, d): + """ + Send auto reply to emails + """ + signature = self.email_settings.support_signature + + response = self.email_settings.support_autoreply or (""" +A new Ticket has been raised for your query. If you have any additional information, please +reply back to this mail. + +We will get back to you as soon as possible + +[This is an automatic response] + """ + signature) + + sendmail(\ + recipients = [d.raised_by], \ + sender = self.email_settings.support_email, \ + subject = '['+d.name+'] ' + d.subject, \ + msg= autoresponse) + + def auto_close_tickets(self): + """ + Auto Closes Waiting for Customer Support Ticket after 15 days + """ + webnotes.conn.sql("update `tabSupport Ticket` set status = 'Closed' where status = 'Waiting for Customer' and date_sub(curdate(),interval 15 Day) > modified") + def get_support_mails(): """ @@ -63,8 +105,3 @@ def get_support_mails(): """ SupportMailbox().get_messages() -def auto_close_tickets(): - """ - Auto Closes Waiting for Customer Support Ticket after 15 days - """ - webnotes.conn.sql("update `tabSupport Ticket` set status = 'Closed' where status = 'Waiting for Customer' and date_sub(curdate(),interval 15 Day) > modified") diff --git a/support/doctype/support_ticket/support_ticket.js b/support/doctype/support_ticket/support_ticket.js index 2c1e77faed..914227b222 100644 --- a/support/doctype/support_ticket/support_ticket.js +++ b/support/doctype/support_ticket/support_ticket.js @@ -20,9 +20,9 @@ $.extend(cur_frm.cscript, { items: [ { column: 0, - label:'Support Email Settings', + label:'Email Settings', description:'Integrate your incoming support emails to support ticket', - onclick: function() { loaddoc('Support Email Settings','Support Email Settings'); } + onclick: function() { loaddoc('Email Settings','Email Settings'); } }, ] }) diff --git a/support/doctype/support_ticket/support_ticket.py b/support/doctype/support_ticket/support_ticket.py index 75defbeb34..c71304a0f7 100644 --- a/support/doctype/support_ticket/support_ticket.py +++ b/support/doctype/support_ticket/support_ticket.py @@ -19,7 +19,7 @@ class DocType(TransactionBase): response = self.doc.new_response + '\n\n[Please do not change the subject while responding.]' - signature = webnotes.conn.get_value('Support Email Settings',None,'signature') + signature = webnotes.conn.get_value('Email Settings',None,'support_signature') if signature: response += '\n\n' + signature @@ -27,7 +27,7 @@ class DocType(TransactionBase): sendmail(\ recipients = [self.doc.raised_by], \ - sender=webnotes.conn.get_value('Support Email Settings',None,'email'), \ + sender=webnotes.conn.get_value('Email Settings',None,'support_email'), \ subject=subject, \ msg=response) diff --git a/support/doctype/support_ticket/support_ticket.txt b/support/doctype/support_ticket/support_ticket.txt index caeb801f9a..211f51240e 100644 --- a/support/doctype/support_ticket/support_ticket.txt +++ b/support/doctype/support_ticket/support_ticket.txt @@ -24,7 +24,7 @@ 'server_code_error': ' ', 'show_in_menu': 0, 'subject': '%(subject)s', - 'tag_fields': 'status,allocated_to', + 'tag_fields': 'status', 'version': 150 },