diff --git a/erpnext/home/page/desktop/desktop.css b/erpnext/home/page/desktop/desktop.css index e460c11607..cc6126e200 100644 --- a/erpnext/home/page/desktop/desktop.css +++ b/erpnext/home/page/desktop/desktop.css @@ -69,14 +69,14 @@ } /* Hover and click effects */ -.case-border:hover, .circle:hover { - box-shadow: 0 0 2px 0px black, 0 0 10px 1px white; - -moz-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white; - -webkit-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white; - -o-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white; +.case-border:hover, .circle:hover, .hover-effect { + box-shadow: 0 0 2px 0px black, 0 0 10px 1px white !important; + -moz-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white !important; + -webkit-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white !important; + -o-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white !important; } -.case-border:active, .case-border:focus, .circle:active, .circle:focus { +.case-border:active, .case-border:focus, .case-border-click { transform: scale(0.98, 0.98); -ms-transform: scale(0.98, 0.98); /* IE 9 */ -webkit-transform: scale(0.98, 0.98); /* Safari and Chrome */ @@ -84,6 +84,14 @@ -moz-transform: scale(0.98, 0.98); /* Firefox */ } +.circle:active, .circle:focus, .circle-click { + transform: scale(1, 1); + -ms-transform: scale(1, 1); /* IE 9 */ + -webkit-transform: scale(1, 1); /* Safari and Chrome */ + -o-transform: scale(1, 1); /* Opera */ + -moz-transform: scale(1, 1); /* Firefox */ +} + .circle { border-radius: 30px; -moz-border-radius: 30px; @@ -93,9 +101,8 @@ min-width: 15px; background: #B00D07; padding: 3px; - z-index: 2; float: right; - margin-top: -10px; + margin-top: -74px; margin-right: 10px; border: 2px solid white; box-shadow: 0 0 10px 1px black; @@ -106,10 +113,8 @@ .circle-text { color: white; - vertical-align: middle; text-align: center; display: inline-block; - margin-top: -3px; - text-shadow: 1px 1px 5px #000; + margin-top: 1px; } diff --git a/erpnext/home/page/desktop/desktop.js b/erpnext/home/page/desktop/desktop.js index dab1e761b0..7852ab23fa 100644 --- a/erpnext/home/page/desktop/desktop.js +++ b/erpnext/home/page/desktop/desktop.js @@ -95,9 +95,37 @@ erpnext.desktop.render = function() { } erpnext.desktop.show_pending_notifications = function() { - $('#messages a:first').prepend('
\ -
'); - $('#msg_count').toggle(false); + var add_circle = function(str_module, id, title) { + var module = $('#'+str_module); + module.find('a:first').append( + repl('', {id: id, title: title})); + + var case_border = module.find('.case-border'); + var circle = module.find('.circle'); + + var add_hover_and_click = function(primary, secondary, hover_class, click_class) { + primary + .hover( + function() { secondary.addClass(hover_class); }, + function() { secondary.removeClass(hover_class); }) + .mousedown(function() { secondary.addClass(click_class); }) + .mouseup(function() { secondary.removeClass(click_class); }) + .focusin(function() { $(this).mousedown(); }) + .focusout(function() { $(this).mouseup(); }) + } + + add_hover_and_click(case_border, circle, 'hover-effect', 'circle-click'); + add_hover_and_click(circle, case_border, 'hover-effect', 'case-border-click'); + + } + + add_circle('messages', 'unread_messages', 'Unread Messages'); + add_circle('support', 'open_support_tickets', 'Open Support Tickets'); + add_circle('todo', 'things_todo', 'Things To Do'); + add_circle('calendar', 'todays_events', 'Todays Events'); + update_messages(); } diff --git a/erpnext/home/page/event_updates/event_updates.js b/erpnext/home/page/event_updates/event_updates.js index d86a1d869c..b2825f31be 100644 --- a/erpnext/home/page/event_updates/event_updates.js +++ b/erpnext/home/page/event_updates/event_updates.js @@ -600,7 +600,7 @@ pscript.home_make_status = function() { // get values $c_page('home', 'event_updates', 'get_status_details', user, function(r,rt) { - page_body.wntoolbar.set_new_comments(r.message.unread_messages); + //page_body.wntoolbar.set_new_comments(r.message.unread_messages); // render online users pscript.online_users_obj.render(r.message.online_users); diff --git a/erpnext/home/page/event_updates/event_updates.py b/erpnext/home/page/event_updates/event_updates.py index 05f1cfc609..32d6756e8c 100644 --- a/erpnext/home/page/event_updates/event_updates.py +++ b/erpnext/home/page/event_updates/event_updates.py @@ -26,8 +26,7 @@ def get_online_users(arg=None): and t1.user not in ('Guest','Administrator') and TIMESTAMPDIFF(HOUR,t1.lastupdate,NOW()) <= 1""", as_list=1) or [] -@webnotes.whitelist() -def get_unread_messages(arg=None): +def get_unread_messages(): "returns unread (docstatus-0 messages for a user)" return webnotes.conn.sql("""\ SELECT name, comment @@ -37,6 +36,49 @@ def get_unread_messages(arg=None): AND ifnull(docstatus,0)=0 """, webnotes.user.name, as_list=1) +def get_open_support_tickets(): + """ + Returns a count of open support tickets + """ + from webnotes.utils import cint + open_support_tickets = webnotes.conn.sql("""\ + SELECT COUNT(*) FROM `tabSupport Ticket` + WHERE status = 'Open'""") + return open_support_tickets and cint(open_support_tickets[0][0]) or 0 + +def get_things_todo(): + """ + Returns a count of incomplete todos + """ + from webnotes.utils import cint + incomplete_todos = webnotes.conn.sql("""\ + SELECT COUNT(*) FROM `tabToDo Item` + WHERE IFNULL(checked, 0) = 0 + AND owner = %s""", webnotes.session.get('user')) + return incomplete_todos and cint(incomplete_todos[0][0]) or 0 + +def get_todays_events(): + """ + Returns a count of todays events in calendar + """ + from webnotes.utils import nowdate, cint + todays_events = webnotes.conn.sql("""\ + SELECT COUNT(*) FROM `tabEvent` + WHERE owner = %s + AND event_type != 'Cancel' + AND event_date = %s""", ( + webnotes.session.get('user'), nowdate())) + return todays_events and cint(todays_events[0][0]) or 0 + +@webnotes.whitelist() +def get_global_status_messages(arg=None): + return { + 'unread_messages': get_unread_messages(), + 'open_support_tickets': get_open_support_tickets(), + 'things_todo': get_things_todo(), + 'todays_events': get_todays_events(), + } + @webnotes.whitelist() def get_status_details(arg=None): """get toolbar items""" @@ -47,7 +89,8 @@ def get_status_details(arg=None): # system messages ret = { 'user_count': len(online) or 0, - 'unread_messages': get_unread_messages(), + #'unread_messages': get_unread_messages(), + #'open_support_tickets': get_open_support_tickets(), 'online_users': online or [], 'setup_status': get_setup_status(), 'registration_complete': cint(get_defaults('registration_complete')) and 'Yes' or 'No', diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js index 0a2ac23e1d..c00770c4d9 100644 --- a/erpnext/startup/startup.js +++ b/erpnext/startup/startup.js @@ -110,20 +110,29 @@ var update_messages = function(reset) { if(inList(['Guest'], user)) { return; } if(!reset) { - $c_page('home', 'event_updates', 'get_unread_messages', null, + $c_page('home', 'event_updates', 'get_global_status_messages', null, function(r,rt) { if(!r.exc) { // This function is defined in toolbar.js - page_body.wntoolbar.set_new_comments(r.message); - var circle = $('#msg_count') - if(circle) { - if(r.message.length) { - circle.find('span:first').text(r.message.length); - circle.toggle(true); - } else { - circle.toggle(false); + page_body.wntoolbar.set_new_comments(r.message.unread_messages); + + var show_in_circle = function(parent_id, msg) { + var parent = $('#'+parent_id); + if(parent) { + if(msg) { + parent.find('span:first').text(msg); + parent.toggle(true); + } else { + parent.toggle(false); + } } } + + show_in_circle('unread_messages', r.message.unread_messages.length); + show_in_circle('open_support_tickets', r.message.open_support_tickets); + show_in_circle('things_todo', r.message.things_todo); + show_in_circle('todays_events', r.message.todays_events); + } else { clearInterval(wn.updates.id); } @@ -131,7 +140,7 @@ var update_messages = function(reset) { ); } else { page_body.wntoolbar.set_new_comments(0); - $('#msg_count').toggle(false); + $('#unread_messages').toggle(false); } } diff --git a/js/all-app.js b/js/all-app.js index 686b0b846e..612e78c748 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -2229,8 +2229,8 @@ else if(nm=='Accounts Browser') pscript.make_chart(chart_type);} loadpage(nm,call_back);} var update_messages=function(reset){if(inList(['Guest'],user)){return;} -if(!reset){$c_page('home','event_updates','get_unread_messages',null,function(r,rt){if(!r.exc){page_body.wntoolbar.set_new_comments(r.message);var circle=$('#msg_count') -if(circle){if(r.message.length){circle.find('span:first').text(r.message.length);circle.toggle(true);}else{circle.toggle(false);}}}else{clearInterval(wn.updates.id);}});}else{page_body.wntoolbar.set_new_comments(0);$('#msg_count').toggle(false);}} +if(!reset){$c_page('home','event_updates','get_global_status_messages',null,function(r,rt){if(!r.exc){page_body.wntoolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}} +show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}});}else{page_body.wntoolbar.set_new_comments(0);$('#unread_messages').toggle(false);}} erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);} wn.updates.id=setInterval(update_messages,60000);} erpnext.set_user_background=function(src){set_style(repl('body { background: url("files/%(src)s") repeat;}',{src:src}))} @@ -2279,7 +2279,7 @@ if(user_roles.indexOf("System Manager")!=-1){$('.navbar .modules').append('