This commit is contained in:
Rushabh Mehta 2012-03-14 19:07:11 +05:30
commit f47192c5ce
11 changed files with 136 additions and 33 deletions

View File

@ -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;
}

View File

@ -95,9 +95,37 @@ erpnext.desktop.render = function() {
}
erpnext.desktop.show_pending_notifications = function() {
$('#messages a:first').prepend('<div id="msg_count" class="circle" title="Unread Messages">\
<span class="circle-text"></span></div>');
$('#msg_count').toggle(false);
var add_circle = function(str_module, id, title) {
var module = $('#'+str_module);
module.find('a:first').append(
repl('<div id="%(id)s" class="circle" title="%(title)s" style="display: None">\
<span class="circle-text"></span>\
</div>', {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();
}

View File

@ -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);

View File

@ -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',

View File

@ -0,0 +1,3 @@
def execute():
import webnotes
webnotes.conn.sql("update `tabDocPerm` set cancel = 1 where parent = 'Stock Reconciliation' and ifnull(submit, 0) = 1")

View File

@ -182,5 +182,10 @@ patch_list = [
'patch_file': 'remove_series_defval',
'description': 'Remove rv series default value'
},
{
'patch_module': 'patches.jan_mar_2012',
'patch_file': 'update_stockreco_perm',
'description': 'Update stock reco permission'
},
]

View File

@ -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);
}
}

View File

@ -2185,8 +2185,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}))}

View File

@ -1117,8 +1117,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}))}

View File

@ -1 +1 @@
1049
1049

10
wnf.py
View File

@ -97,6 +97,9 @@ def setup_options():
parser.add_option("--replace", nargs=3, default=False,
metavar = "search replace_by extension",
help="file search-replace")
parser.add_option("--cci", nargs=1, metavar="CacheItem Key",
help="Clear Cache Item")
return parser.parse_args()
@ -209,6 +212,13 @@ def run():
import webnotes.utils.scheduler
print webnotes.utils.scheduler.trigger('execute_' + options.run_scheduler_event)
elif options.cci is not None:
if options.cci=='all':
webnotes.conn.sql("DELETE FROM __CacheItem")
else:
from webnotes.utils.cache import CacheItem
CacheItem(options.cci).clear()
# print messages
if webnotes.message_log:
print '\n'.join(webnotes.message_log)