From f12d7d8d22b16d3754cf3bbf2d98418e76a6e9fe Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 29 Nov 2012 16:24:18 +0530 Subject: [PATCH] communication / email cleanup --- core/doctype/communication/communication.py | 11 +++++++---- public/js/legacy/widgets/form/form_fields.js | 1 + public/js/wn/views/communication.js | 20 +++++++++++++------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/core/doctype/communication/communication.py b/core/doctype/communication/communication.py index c6a225b3d8..e2904a4bbe 100644 --- a/core/doctype/communication/communication.py +++ b/core/doctype/communication/communication.py @@ -42,7 +42,7 @@ def get_customer_supplier(args=None): def make(doctype=None, name=None, content=None, subject=None, sender=None, recipients=None, contact=None, lead=None, communication_medium="Email", send_email=False, print_html=None, - attachments='[]'): + attachments='[]', send_me_a_copy=False): # add to Communication sent_via = None @@ -61,10 +61,10 @@ def make(doctype=None, name=None, content=None, subject=None, set_lead_and_contact(d) d.communication_medium = communication_medium if send_email: - send_comm_email(d, name, sent_via, print_html, attachments) - d.save(1) + send_comm_email(d, name, sent_via, print_html, attachments, send_me_a_copy) + d.save(1, ignore_fields=True) -def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]'): +def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]', send_me_a_copy=False): from webnotes.utils.email_lib import sendmail from json import loads @@ -80,6 +80,9 @@ def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]'): mail = get_email(d.recipients.split(","), sender=d.sender, subject=d.subject, msg=d.content) + if send_me_a_copy: + mail.cc.append(d.sender) + if print_html: mail.add_attachment(name.replace(' ','').replace('/','-') + '.html', print_html) diff --git a/public/js/legacy/widgets/form/form_fields.js b/public/js/legacy/widgets/form/form_fields.js index 6099ea0cf2..1c1ddc2ca8 100644 --- a/public/js/legacy/widgets/form/form_fields.js +++ b/public/js/legacy/widgets/form/form_fields.js @@ -260,6 +260,7 @@ _f.CodeField.prototype.make_input = function() { this.label_span.innerHTML = this.df.label; if(this.df.fieldtype=='Text Editor') { + $(this.input_area).css({"min-height":"360px"}); this.input = $a(this.input_area, 'text_area', '', {fontSize:'12px'}); this.myid = wn.dom.set_unique_id(this.input); diff --git a/public/js/wn/views/communication.js b/public/js/wn/views/communication.js index 6a265e9d67..bd95bfeb40 100644 --- a/public/js/wn/views/communication.js +++ b/public/js/wn/views/communication.js @@ -108,6 +108,7 @@ wn.views.CommunicationComposer = Class.extend({ {label:"Message", fieldtype:"Text Editor", reqd: 1, fieldname:"content"}, {label:"Add Reply", fieldtype:"Button"}, {label:"Send Email", fieldtype:"Check"}, + {label:"Send Me A Copy", fieldtype:"Check"}, {label:"Attach Document Print", fieldtype:"Check"}, {label:"Select Print Format", fieldtype:"Select"}, {label:"Select Attachments", fieldtype:"HTML"} @@ -182,6 +183,7 @@ wn.views.CommunicationComposer = Class.extend({ name: me.doc.name, lead: me.doc.lead, contact: me.doc.contact, + send_me_a_copy: form_values.send_me_a_copy, send_email: form_values.send_email, print_html: form_values.attach_document_print ? print_html : "", @@ -199,16 +201,20 @@ wn.views.CommunicationComposer = Class.extend({ var comm_list = cur_frm.communication_view ? cur_frm.communication_view.list : []; - + var signature = wn.boot.profile.email_signature || ""; + if(signature.indexOf("
")==-1 && signature.indexOf(""); + } + if(comm_list.length > 0) { fields.content.input.set_input("

" - + (wn.boot.profile.email_signature || "") + + signature +"

" +"-----In response to-----

" + comm_list[0].content); } else { - fields.content.input.set_input("

" - + (wn.boot.profile.email_signature || "")) + fields.content.input.set_input("

" + signature) } }, setup_autosuggest: function() { @@ -233,9 +239,9 @@ wn.views.CommunicationComposer = Class.extend({ wn.call({ method:'webnotes.utils.email_lib.get_contact_list', args: { - 'select': _e.email_as_field, - 'from': _e.email_as_dt, - 'where': _e.email_as_in, + 'select': "email_id", + 'from': "Contact", + 'where': "email_id", 'txt': extractLast(request.term).value || '%' }, callback: function(r) {