communication / email cleanup
This commit is contained in:
parent
cc7301eb9f
commit
f12d7d8d22
3 changed files with 21 additions and 11 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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("<br>")==-1 && signature.indexOf("<p")==-1
|
||||
&& signature.indexOf("<img")==-1 && signature.indexOf("<div")==-1) {
|
||||
signature = signature.replace(/\n/g, "<br>");
|
||||
}
|
||||
|
||||
if(comm_list.length > 0) {
|
||||
fields.content.input.set_input("<p></p>"
|
||||
+ (wn.boot.profile.email_signature || "")
|
||||
+ signature
|
||||
+"<p></p>"
|
||||
+"-----In response to-----<p></p>"
|
||||
+ comm_list[0].content);
|
||||
} else {
|
||||
fields.content.input.set_input("<p></p>"
|
||||
+ (wn.boot.profile.email_signature || ""))
|
||||
fields.content.input.set_input("<p></p>" + 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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue