From 901af83f485a7597160ad1c35292319b5d9104e4 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 27 Sep 2012 17:17:23 +0530 Subject: [PATCH 1/9] lead.js, bugfix --- selling/doctype/lead/lead.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js index 3f45603a64..523ddd22af 100644 --- a/selling/doctype/lead/lead.js +++ b/selling/doctype/lead/lead.js @@ -45,7 +45,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { cur_frm.cscript.make_communication_body(); } -cur_frm.cscript.refresh_custom_buttons = function() { +cur_frm.cscript.refresh_custom_buttons = function(doc) { cur_frm.clear_custom_buttons(); if(!doc.__islocal && !in_list(['Converted', 'Lead Lost'], doc.status)) { if (doc.source != 'Existing Customer') { @@ -61,7 +61,7 @@ cur_frm.cscript.refresh_custom_buttons = function() { cur_frm.cscript.refresh = function(doc, cdt, cdn) { // custom buttons //--------------- - cur_frm.cscript.refresh_custom_buttons(); + cur_frm.cscript.refresh_custom_buttons(doc); erpnext.hide_naming_series(); From 6e04ef79898c3d36eae779a938f815cf068dba23 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 27 Sep 2012 18:41:46 +0530 Subject: [PATCH 2/9] updated messages --- utilities/page/messages/messages.css | 14 +-- utilities/page/messages/messages.html | 28 ------ utilities/page/messages/messages.js | 134 +++++++++++++++----------- utilities/page/messages/messages.py | 5 +- 4 files changed, 85 insertions(+), 96 deletions(-) diff --git a/utilities/page/messages/messages.css b/utilities/page/messages/messages.css index 49b377170d..c461e11a9c 100644 --- a/utilities/page/messages/messages.css +++ b/utilities/page/messages/messages.css @@ -1,17 +1,12 @@ #message-post-text { - width: 50%; } -#message-list { - +#message-list { } .message { - border-radius: 5px; - max-width: 60%; - min-width: 40%; padding: 7px; - margin-bottom: 7px; + border-bottom: 1px solid #ccc; } .message .help { @@ -22,14 +17,9 @@ } .message-other { - background-color: #EBFF9C; - border: 1px solid #C3CF78; - float: right; text-align: right; } .message-self { background-color: #eee; - border: 1px solid #ccc; - float: left; } \ No newline at end of file diff --git a/utilities/page/messages/messages.html b/utilities/page/messages/messages.html index 7538785faf..e69de29bb2 100644 --- a/utilities/page/messages/messages.html +++ b/utilities/page/messages/messages.html @@ -1,28 +0,0 @@ -
-
- × -

Messages

-
- - -
-
-
-
-
-
-
-
- Messages By -
-
- -
-
-
-
-
-
-
\ No newline at end of file diff --git a/utilities/page/messages/messages.js b/utilities/page/messages/messages.js index 9283f9430f..0409563d4d 100644 --- a/utilities/page/messages/messages.js +++ b/utilities/page/messages/messages.js @@ -17,71 +17,87 @@ wn.provide('erpnext.messages'); wn.pages.messages.onload = function(wrapper) { - erpnext.messages.show_active_users(); - erpnext.messages.make_list(); - erpnext.update_messages('reset'); //Resets notification icons - - // post message - $('#message-post').click(function() { - var txt = $('#message-post-text').val(); - if(txt) { - wn.call({ - module:'utilities', - page:'messages', - method:'post', - args: { - txt: txt, - contact: erpnext.messages.contact - }, - callback:function(r,rt) { - $('#message-post-text').val('') - erpnext.messages.list.run(); - }, - btn: this - }); - } + wn.ui.make_app_page({ + parent: wrapper, + title: "Messages" }); - // enable, disable button - $('#message-post-text').keyup(function(e) { - if($(this).val()) { - $('#message-post').attr('disabled', false); - } else { - $('#message-post').attr('disabled', true); - } - - if(e.which==13) { - $('#message-post').click(); - } - }) + $('

Everyone

\ +
\ + \ +
').appendTo($(wrapper).find('.layout-main-section')); + + erpnext.messages = new erpnext.Messages(wrapper); } $(wn.pages.messages).bind('show', function() { erpnext.messages.show(); - setTimeout(erpnext.messages.refresh, 7000); - $('#message-post-text').focus(); + setTimeout("erpnext.messages.refresh()", 7000); }) -erpnext.messages = { +erpnext.Messages = Class.extend({ + init: function(wrapper) { + this.wrapper = wrapper; + this.show_active_users(); + this.make_post_message(); + this.make_list(); + //this.update_messages('reset'); //Resets notification icons + }, + make_post_message: function() { + var me = this; + $('#post-message textarea').keydown(function(e) { + if(e.which==13) { + $('#post-message .btn').click(); + return false; + } + }); + + $('#post-message .btn').click(function() { + var txt = $('#post-message textarea').val(); + if(txt) { + wn.call({ + module:'utilities', + page:'messages', + method:'post', + args: { + txt: txt, + contact: me.contact + }, + callback:function(r,rt) { + $('#post-message textarea').val('') + me.list.run(); + }, + btn: this + }); + } + }); + }, show: function() { - var contact = erpnext.messages.get_contact(); + var contact = this.get_contact(); + $('#message-title').text(contact==user ? "Everyone" : + wn.boot.user_info[contact].fullname) + + $("#show-everyone").toggle(contact!=user); + // can't send message to self - $(wn.pages.messages).find('.well').toggle(contact==user ? false : true); + $('#post-message').toggle(contact!=user); - $(wn.pages.messages).find('h1:first').html('Messages: ' - + (user==contact ? 'From everyone' : wn.user_info(contact).fullname)); - - erpnext.messages.contact = contact; - erpnext.messages.list.opts.args.contact = contact; - erpnext.messages.list.run(); + this.contact = contact; + this.list.opts.args.contact = contact; + this.list.run(); }, // check for updates every 5 seconds if page is active refresh: function() { - setTimeout(erpnext.messages.refresh, 7000); + setTimeout("erpnext.messages.refresh()", 7000); if(wn.container.page.label != 'Messages') return; - erpnext.messages.show(); + this.show(); }, get_contact: function() { var route = location.hash; @@ -95,12 +111,14 @@ erpnext.messages = { return user; }, make_list: function() { - erpnext.messages.list = new wn.ui.Listing({ - parent: $('#message-list').get(0), + this.list = new wn.ui.Listing({ + parent: $(this.wrapper).find('.all-messages'), method: 'utilities.page.messages.messages.get_list', args: { contact: null }, + hide_refresh: true, + no_loading: true, render_row: function(wrapper, data) { $(wrapper).removeClass('list-row'); @@ -117,7 +135,7 @@ erpnext.messages = { } else { data.cls = 'message-other'; data.delete_html = ''; - if(erpnext.messages.contact==user) { + if(this.contact==user) { data.reply_html = repl('\ Reply', data) } @@ -142,22 +160,28 @@ erpnext.messages = { }); }, show_active_users: function() { + var me = this; wn.call({ module:'utilities', page:'messages', method:'get_active_users', callback: function(r,rt) { - var $body = $(wn.pages.messages).find('.section-body'); + var $body = $(me.wrapper).find('.layout-side-section'); + $("

Users


").appendTo($body); for(var i in r.message) { var p = r.message[i]; p.fullname = wn.user_info(p.name).fullname; p.name = p.name.replace('@', '__at__'); - $body.append(repl('', p)) + p.label_status = p.has_sessions ? "label-success" : ""; + p.status = p.has_sessions ? "Online" : "Offline"; + $(repl('

%(status)s\ + %(fullname)s\ +

', p)) + .appendTo($body); } } }); } -} +}); diff --git a/utilities/page/messages/messages.py b/utilities/page/messages/messages.py index 25284132f3..f2381ab61f 100644 --- a/utilities/page/messages/messages.py +++ b/utilities/page/messages/messages.py @@ -48,7 +48,10 @@ def get_list(arg=None): @webnotes.whitelist() def get_active_users(arg=None): - return webnotes.conn.sql("""select name from tabProfile + return webnotes.conn.sql("""select name, + (select count(*) from tabSessions where user=tabProfile.name + and timediff(now(), lastupdate) < time("01:00:00")) as has_session + from tabProfile where ifnull(enabled,0)=1 and docstatus < 2 and name not in ('Administrator', 'Guest') From 7f9c369266ea739c51a27b4848783f071a948299 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 27 Sep 2012 18:48:43 +0530 Subject: [PATCH 3/9] updated messages --- utilities/page/messages/messages.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/utilities/page/messages/messages.js b/utilities/page/messages/messages.js index 0409563d4d..8e8cb6fb83 100644 --- a/utilities/page/messages/messages.js +++ b/utilities/page/messages/messages.js @@ -170,14 +170,16 @@ erpnext.Messages = Class.extend({ $("

Users


").appendTo($body); for(var i in r.message) { var p = r.message[i]; - p.fullname = wn.user_info(p.name).fullname; - p.name = p.name.replace('@', '__at__'); - p.label_status = p.has_sessions ? "label-success" : ""; - p.status = p.has_sessions ? "Online" : "Offline"; - $(repl('

%(status)s\ - %(fullname)s\ -

', p)) - .appendTo($body); + if(p.name != user) { + p.fullname = wn.user_info(p.name).fullname; + p.name = p.name.replace('@', '__at__'); + p.label_status = p.has_session ? "label-success" : ""; + p.status = p.has_session ? "Online" : "Offline"; + $(repl('

%(status)s\ + %(fullname)s\ +

', p)) + .appendTo($body); + } } } }); From dd46b524676c6bb43a728845023d802c7e1c9718 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 27 Sep 2012 19:01:52 +0530 Subject: [PATCH 4/9] updated messages --- utilities/page/messages/messages.css | 1 - 1 file changed, 1 deletion(-) diff --git a/utilities/page/messages/messages.css b/utilities/page/messages/messages.css index c461e11a9c..2a32de03a3 100644 --- a/utilities/page/messages/messages.css +++ b/utilities/page/messages/messages.css @@ -17,7 +17,6 @@ } .message-other { - text-align: right; } .message-self { From 294778a83c0e72633e8920d7711e3b4f2a412844 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 27 Sep 2012 15:43:06 +0200 Subject: [PATCH 5/9] messages.js: allow user to task messages --- utilities/page/messages/messages.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/utilities/page/messages/messages.js b/utilities/page/messages/messages.js index 8e8cb6fb83..5ad540fac7 100644 --- a/utilities/page/messages/messages.js +++ b/utilities/page/messages/messages.js @@ -129,18 +129,22 @@ erpnext.Messages = Class.extend({ if(data.owner==user) { data.cls = 'message-self'; data.comment_by_fullname = 'You'; - data.delete_html = repl('×', data); } else { data.cls = 'message-other'; - data.delete_html = ''; if(this.contact==user) { data.reply_html = repl('\ Reply', data) } } + // delete + data.delete_html = ""; + if(data.owner==user || data.comment.indexOf("assigned to")!=-1) { + data.delete_html = repl('×', data); + } + wrapper.innerHTML = repl('
%(delete_html)s\ %(comment)s\
by %(comment_by_fullname)s, %(creation)s
\ From b02744de8fbf7b084229d58b5bf096c0999138b0 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 28 Sep 2012 09:56:55 +0530 Subject: [PATCH 6/9] updates to form comment (post on enter) and global defaults --- .../global_defaults/global_defaults.js | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/setup/doctype/global_defaults/global_defaults.js b/setup/doctype/global_defaults/global_defaults.js index 631fd0b615..e8a174b6c9 100644 --- a/setup/doctype/global_defaults/global_defaults.js +++ b/setup/doctype/global_defaults/global_defaults.js @@ -16,7 +16,19 @@ // Validate cur_frm.cscript.validate = function(doc, cdt, cdn) { - $c_obj(make_doclist(cdt, cdn), 'get_defaults', '', function(r, rt){ - sys_defaults = r.message; - }); -} \ No newline at end of file + $c_obj(make_doclist(cdt, cdn), 'get_defaults', '', function(r, rt){ + sys_defaults = r.message; + }); +} + +cur_frm.fields_dict['default_territory'].get_query = function(doc,cdt,cdn) { + return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50'; +} + +cur_frm.fields_dict['default_customer_group'].get_query = function(doc,cdt,cdn) { + return 'SELECT `tabCustomer Group`.`name`, `tabCustomer Group`.`parent_customer_group` FROM `tabCustomer Group` WHERE `tabCustomer Group`.`is_group` = "No" AND `tabCustomer Group`.`docstatus`!= 2 AND `tabCustomer Group`.%(key)s LIKE "%s" ORDER BY `tabCustomer Group`.`name` ASC LIMIT 50'; +} + +cur_frm.fields_dict['default_item_group'].get_query = function(doc,cdt,cdn) { + return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50' +} From 224714c24881572401bf23145a1397a0b8ed5671 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 28 Sep 2012 10:23:27 +0530 Subject: [PATCH 7/9] no role access for financial analytics --- .../page/accounts_home/accounts_home.html | 4 ++-- .../customer_address_contact.sql | 8 +++++--- startup/js/modules.js | 20 ++++++++++++------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/accounts/page/accounts_home/accounts_home.html b/accounts/page/accounts_home/accounts_home.html index 7fb2c326ee..5950173c5b 100644 --- a/accounts/page/accounts_home/accounts_home.html +++ b/accounts/page/accounts_home/accounts_home.html @@ -69,12 +69,12 @@ href="#!Form/Sales and Purchase Return Tool/Sales and Purchase Return Tool">Sales or Purchase Returns
diff --git a/selling/search_criteria/customer_address_contact/customer_address_contact.sql b/selling/search_criteria/customer_address_contact/customer_address_contact.sql index 3752ebc04e..b30a6f9f09 100644 --- a/selling/search_criteria/customer_address_contact/customer_address_contact.sql +++ b/selling/search_criteria/customer_address_contact/customer_address_contact.sql @@ -1,4 +1,4 @@ -select +SELECT `tabCustomer`.name, `tabCustomer`.customer_name, `tabAddress`.address_line1, @@ -12,7 +12,7 @@ select `tabContact`.phone, `tabContact`.mobile_no, `tabContact`.email_id -from +FROM `tabCustomer` left join `tabAddress` on ( `tabAddress`.customer=`tabCustomer`.name and @@ -22,5 +22,7 @@ from `tabContact`.customer=`tabCustomer`.name and ifnull(`tabContact`.is_primary_contact, 0)=1 ) -order by +WHERE + `tabCustomer`.docstatus<2 +ORDER BY `tabCustomer`.customer_name asc \ No newline at end of file diff --git a/startup/js/modules.js b/startup/js/modules.js index 71d012e44b..914df8116d 100644 --- a/startup/js/modules.js +++ b/startup/js/modules.js @@ -28,13 +28,19 @@ erpnext.module_page.setup_page = function(module, wrapper) { // not have read permissions erpnext.module_page.hide_links = function(wrapper) { + function replace_link(link) { + var txt = $(link).text(); + $(link).parent().css('color', '#999'); + $(link).replaceWith('' + +txt+''); + } + // lists $(wrapper).find('[href*="List/"]').each(function() { var href = $(this).attr('href'); var dt = href.split('/')[1]; if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) { - var txt = $(this).text(); - $(this).parent().css('color', '#999').html(txt); + replace_link(this); } }); @@ -42,8 +48,7 @@ erpnext.module_page.hide_links = function(wrapper) { $(wrapper).find('[data-doctype]').each(function() { var dt = $(this).attr('data-doctype'); if(wn.boot.profile.all_read.indexOf(dt)==-1) { - var txt = $(this).text(); - $(this).parent().css('color', '#999').html(txt); + replace_link(this); } }); @@ -52,8 +57,7 @@ erpnext.module_page.hide_links = function(wrapper) { var href = $(this).attr('href'); var dt = href.split('/')[1]; if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) { - var txt = $(this).text(); - $(this).parent().css('color', '#999').html(txt); + replace_link(this); } }); @@ -62,7 +66,9 @@ erpnext.module_page.hide_links = function(wrapper) { if(!has_common(user_roles, [$(this).attr("data-role"), "System Manager"])) { var html = $(this).html(); $(this).parent().css('color', '#999'); - $(this).replaceWith(html); + $(this).replaceWith(''+html+''); } }); } From cebb02753ce7a22248d70409af7fad2146c32e0e Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 28 Sep 2012 12:18:43 +0530 Subject: [PATCH 8/9] added shortcuts --- startup/startup.js | 16 ++++++++++++++++ website/doctype/style_settings/style_settings.js | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/startup/startup.js b/startup/startup.js index 9a6a52625d..90f284e837 100644 --- a/startup/startup.js +++ b/startup/startup.js @@ -195,3 +195,19 @@ erpnext.hide_naming_series = function() { } } } + +Mousetrap.bind(["command+g", "ctrl+g"], function() { + wn.ui.toolbar.search.show(); + return false; +}); + +Mousetrap.bind(["command+s", "ctrl+s"], function() { + if(cur_frm) + cur_frm.save(); + return false; +}); + +Mousetrap.bind(["command+n", "ctrl+n"], function() { + wn.ui.toolbar.new_dialog.show(); + return false; +}); \ No newline at end of file diff --git a/website/doctype/style_settings/style_settings.js b/website/doctype/style_settings/style_settings.js index 0d0bf9e6ec..54091a38f2 100644 --- a/website/doctype/style_settings/style_settings.js +++ b/website/doctype/style_settings/style_settings.js @@ -14,9 +14,9 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -wn.require('lib/js/lib/jscolor/jscolor.js'); cur_frm.cscript.onload_post_render = function() { + wn.require('lib/public/js/lib/jscolor/jscolor.js'); cur_frm.fields_dict.background_color.input.className = 'color'; jscolor.bind(); } \ No newline at end of file From 534a7a92feceae348950b03adab8fd921d7b6860 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 28 Sep 2012 12:33:42 +0530 Subject: [PATCH 9/9] updated shortcuts --- selling/doctype/customer/customer.txt | 83 ++++++++++++++++++++------- startup/startup.js | 5 -- 2 files changed, 62 insertions(+), 26 deletions(-) diff --git a/selling/doctype/customer/customer.txt b/selling/doctype/customer/customer.txt index f95121f996..489523f25a 100644 --- a/selling/doctype/customer/customer.txt +++ b/selling/doctype/customer/customer.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - u'creation': '2012-07-18 20:34:41', + u'creation': '2012-09-21 09:56:34', u'docstatus': 0, - u'modified': '2012-09-17 11:31:55', + u'modified': '2012-09-28 12:31:42', u'modified_by': u'Administrator', u'owner': u'Administrator' }, @@ -454,23 +454,13 @@ # DocPerm { 'amend': 0, - 'cancel': 1, - 'create': 1, + 'cancel': 0, + 'create': 0, u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'Sales Master Manager', + 'permlevel': 1, + 'role': u'Sales Manager', 'submit': 0, - 'write': 1 - }, - - # DocPerm - { - 'cancel': 1, - 'create': 1, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'Accounts Manager', - 'write': 1 + 'write': 0 }, # DocPerm @@ -491,7 +481,7 @@ 'cancel': 0, 'create': 0, u'doctype': u'DocPerm', - 'permlevel': 0, + 'permlevel': 1, 'role': u'Sales User', 'submit': 0, 'write': 0 @@ -503,14 +493,40 @@ 'cancel': 0, 'create': 0, u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'All', + 'permlevel': 0, + 'role': u'Sales User', 'submit': 0, 'write': 0 }, # DocPerm { + 'amend': 0, + 'cancel': 1, + 'create': 1, + u'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Sales Master Manager', + 'submit': 0, + 'write': 1 + }, + + # DocPerm + { + 'amend': 0, + 'cancel': 0, + 'create': 0, + u'doctype': u'DocPerm', + 'permlevel': 1, + 'role': u'Sales Master Manager', + 'submit': 0, + 'write': 0 + }, + + # DocPerm + { + 'cancel': 0, + 'create': 0, u'doctype': u'DocPerm', 'permlevel': 2, 'role': u'Accounts Manager', @@ -519,6 +535,8 @@ # DocPerm { + 'cancel': 0, + 'create': 0, u'doctype': u'DocPerm', 'permlevel': 2, 'role': u'System Manager', @@ -527,8 +545,31 @@ # DocPerm { + 'cancel': 0, + 'create': 0, u'doctype': u'DocPerm', 'permlevel': 2, - 'role': u'All' + 'role': u'All', + 'write': 0 + }, + + # DocPerm + { + 'cancel': 1, + 'create': 1, + u'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Accounts Manager', + 'write': 1 + }, + + # DocPerm + { + 'cancel': 0, + 'create': 0, + u'doctype': u'DocPerm', + 'permlevel': 1, + 'role': u'All', + 'write': 0 } ] \ No newline at end of file diff --git a/startup/startup.js b/startup/startup.js index 90f284e837..73938db280 100644 --- a/startup/startup.js +++ b/startup/startup.js @@ -205,9 +205,4 @@ Mousetrap.bind(["command+s", "ctrl+s"], function() { if(cur_frm) cur_frm.save(); return false; -}); - -Mousetrap.bind(["command+n", "ctrl+n"], function() { - wn.ui.toolbar.new_dialog.show(); - return false; }); \ No newline at end of file