// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
/* toolbar settings */
wn.provide('erpnext.toolbar');
erpnext.toolbar.setup = function() {
// modules
erpnext.toolbar.add_modules();
// profile
$('#toolbar-user').append('
Profile Settings');
$('.navbar .pull-right').append('\
');
// help
$('.navbar .pull-right').prepend('\
Help\
')
$('#toolbar-help').append('\
Documentation')
$('#toolbar-help').append('\
Forum')
$('#toolbar-help').append('\
Live Chat (Office Hours)')
erpnext.toolbar.set_new_comments();
}
erpnext.toolbar.add_modules = function() {
$('\
Modules\
\
').prependTo('.navbar .nav:first');
// if no modules list then show all
if(wn.boot.modules_list && typeof(wn.boot.modules_list) == 'string') {
wn.boot.modules_list = JSON.parse(wn.boot.modules_list);
}
else
wn.boot.modules_list = keys(erpnext.modules).sort();
// add to dropdown
for(var i in wn.boot.modules_list) {
var m = wn.boot.modules_list[i]
if(m!='Setup' && wn.boot.profile.allow_modules.indexOf(m)!=-1) {
args = {
module: m,
module_page: erpnext.modules[m],
module_label: m=='HR' ? 'Human Resources' : m
}
$('.navbar .modules').append(repl('%(module_label)s', args));
}
}
// setup for system manager
if(user_roles.indexOf("System Manager")!=-1) {
$('.navbar .modules').append('\
Setup');
}
}
erpnext.toolbar.set_new_comments = function(new_comments) {
var navbar_nc = $('.navbar-new-comments');
if(wn.container.page && wn.container.page.page_name=="messages")
return;
if(new_comments && new_comments.length>0) {
navbar_nc.text(new_comments.length);
navbar_nc.addClass('navbar-new-comments-true')
$.each(new_comments, function(i, v) {
var msg = 'New Message: ' + (v[1].length<=100 ? v[1] : (v[1].substr(0, 100) + "..."));
var id = v[0].replace('/', '-');
if(!$('#' + id)[0]) {
show_alert(msg).attr("id", id);
}
});
} else {
navbar_nc.removeClass('navbar-new-comments-true');
navbar_nc.text(0);
}
}