From d194e6b5cfa40187981539141cb78c28560a0f58 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 24 Jan 2012 17:08:53 +0530 Subject: [PATCH] Fix: show message if contact doesn't have email if notification control is enabled --- .../notification_control.js | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/erpnext/setup/doctype/notification_control/notification_control.js b/erpnext/setup/doctype/notification_control/notification_control.js index 13c3087fc5..2e9bb10a02 100644 --- a/erpnext/setup/doctype/notification_control/notification_control.js +++ b/erpnext/setup/doctype/notification_control/notification_control.js @@ -10,23 +10,22 @@ cur_frm.cscript.select_transaction = function(doc, dt, dn) { } cur_frm.cscript.notify = function(doc, args) { - if(validate_email(args['send_to'] || doc.contact_email || '')) { - $c_obj('Notification Control', 'get_formatted_message', { - type: args['type'], - doctype: args['doctype'], - contact_name: args['contact_name'] || doc.contact_display - }, function(r, rt) { - if(!r.exc) { - var res = JSON.parse(r.message); - var send_from = (function() { - if(user!='Administrator') { - return user; - } else { - var cp = locals['Control Panel']['Control Panel']; - return (cp.auto_email_id || 'automail@erpnext.com'); - } - })(); - if(res.send) { + $c_obj('Notification Control', 'get_formatted_message', { + type: args['type'], + doctype: args['doctype'], + contact_name: args['contact_name'] || doc.contact_display + }, function(r, rt) { + if(!r.exc) { + var res = JSON.parse(r.message); + var send_from = (function() { + if(user!='Administrator') { + return user; + } else { + return (wn.control_panel.auto_email_id || 'automail@erpnext.com'); + } + })(); + if(res.send) { + if(validate_email(args['send_to'] || doc.contact_email || '')) { var print_heading = (doc.select_print_heading || args['type']) sendmail( args['send_to'] || doc.contact_email, @@ -38,9 +37,11 @@ cur_frm.cscript.notify = function(doc, args) { ); msgprint('This ' + print_heading + ' is being sent to ' + (args['send_to'] || doc.contact_email) + '
...'); + } else { + msgprint('Invalid/Missing Email Address. ' + print_heading + ' not sent.'); } } - //console.log(JSON.parse(r.message)); - }); - } + } + //console.log(JSON.parse(r.message)); + }); }