blob: 44d8c34a68d38b628e4e0d21c0b310fb04cc75be [file] [log] [blame]
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05301// ERPNext - web based ERP (http://erpnext.com)
2// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
Rushabh Mehta8c309be2012-01-20 13:47:16 +053017/* toolbar settings */
18wn.provide('erpnext.toolbar');
19
20erpnext.toolbar.setup = function() {
Rushabh Mehtad0251332012-02-21 17:26:50 +053021 // modules
22 erpnext.toolbar.add_modules();
23
Rushabh Mehta8c309be2012-01-20 13:47:16 +053024 // profile
Rushabh Mehta523aec42013-01-07 15:39:54 +053025 $('#toolbar-user').append('<li><a href="#Form/Profile/'+user+'">'
26 +wn._("My Settings")+'...</a></li>');
Rushabh Mehtad0251332012-02-21 17:26:50 +053027
Anand Doshi5b1beeb2012-02-27 17:17:48 +053028 $('.navbar .pull-right').append('\
Rushabh Mehta523aec42013-01-07 15:39:54 +053029 <li><a href="#!messages" title="'+wn._('Unread Messages')
30 +'"><span class="navbar-new-comments"></span></a></li>');
Rushabh Mehta8c309be2012-01-20 13:47:16 +053031
32 // help
Anand Doshi5b1beeb2012-02-27 17:17:48 +053033 $('.navbar .pull-right').prepend('<li class="dropdown">\
Rushabh Mehta6e156c72012-02-21 11:19:24 +053034 <a class="dropdown-toggle" data-toggle="dropdown" href="#" \
Rushabh Mehta523aec42013-01-07 15:39:54 +053035 onclick="return false;">'+wn._('Help')+'<b class="caret"></b></a>\
Rushabh Mehta8c309be2012-01-20 13:47:16 +053036 <ul class="dropdown-menu" id="toolbar-help">\
37 </ul></li>')
38
Rushabh Mehta523aec42013-01-07 15:39:54 +053039 $('#toolbar-help').append('<li><a href="https://erpnext.com/manual" target="_blank">'
40 +wn._('Documentation')+'</a></li>')
Rushabh Mehta8c309be2012-01-20 13:47:16 +053041
Rushabh Mehta523aec42013-01-07 15:39:54 +053042 $('#toolbar-help').append('<li><a href="http://groups.google.com/group/erpnext-user-forum" target="_blank">'
43 +wn._('Forum')+'</a></li>')
Rushabh Mehta8c309be2012-01-20 13:47:16 +053044
45 $('#toolbar-help').append('<li><a href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">\
Rushabh Mehta523aec42013-01-07 15:39:54 +053046 '+wn._('Live Chat')+'</a></li>')
Rushabh Mehta8c309be2012-01-20 13:47:16 +053047
Anand Doshi2aa9ba62012-04-30 15:43:34 +053048 erpnext.toolbar.set_new_comments();
Anand Doshic3023be2012-02-20 16:31:55 +053049}
50
Rushabh Mehtad0251332012-02-21 17:26:50 +053051erpnext.toolbar.add_modules = function() {
52 $('<li class="dropdown">\
53 <a class="dropdown-toggle" data-toggle="dropdown" href="#"\
Rushabh Mehta523aec42013-01-07 15:39:54 +053054 onclick="return false;">'+wn._('Modules')+'<b class="caret"></b></a>\
Rushabh Mehta17da7642012-02-28 18:56:56 +053055 <ul class="dropdown-menu modules">\
Rushabh Mehtad0251332012-02-21 17:26:50 +053056 </ul>\
Anand Doshi5b1beeb2012-02-27 17:17:48 +053057 </li>').prependTo('.navbar .nav:first');
Rushabh Mehta17da7642012-02-28 18:56:56 +053058
Rushabh Mehtaff153492012-12-22 07:42:04 +053059 var modules_list = wn.user.get_desktop_items();
Rushabh Mehta17da7642012-02-28 18:56:56 +053060
61 // add to dropdown
Rushabh Mehta5ade7ca2012-12-21 21:40:19 +053062 for(var i in modules_list) {
63 var m = modules_list[i]
Rushabh Mehtaa38bbe22012-02-29 10:55:43 +053064
Anand Doshi70a3db72012-12-24 18:07:35 +053065 if(m!='Setup' && wn.boot.profile.allow_modules.indexOf(m)!=-1 && wn.modules[m]) {
Rushabh Mehtaa38bbe22012-02-29 10:55:43 +053066 args = {
67 module: m,
Rushabh Mehta946e6d42012-12-21 15:00:29 +053068 module_page: wn.modules[m].link,
Rushabh Mehta523aec42013-01-07 15:39:54 +053069 module_label: wn._(wn.modules[m].label || m)
Rushabh Mehtaa38bbe22012-02-29 10:55:43 +053070 }
71
72 $('.navbar .modules').append(repl('<li><a href="#!%(module_page)s" \
73 data-module="%(module)s">%(module_label)s</a></li>', args));
Rushabh Mehta17da7642012-02-28 18:56:56 +053074 }
Rushabh Mehta17da7642012-02-28 18:56:56 +053075 }
76
77 // setup for system manager
78 if(user_roles.indexOf("System Manager")!=-1) {
79 $('.navbar .modules').append('<li class="divider"></li>\
Rushabh Mehta523aec42013-01-07 15:39:54 +053080 <li><a href="#!Setup" data-module="Setup">'+wn._('Setup')+'</a></li>');
Rushabh Mehta17da7642012-02-28 18:56:56 +053081 }
82
Rushabh Mehtad0251332012-02-21 17:26:50 +053083}
84
Anand Doshi2aa9ba62012-04-30 15:43:34 +053085erpnext.toolbar.set_new_comments = function(new_comments) {
86 var navbar_nc = $('.navbar-new-comments');
Rushabh Mehta9d0569a2012-11-13 11:42:42 +053087 if(cint(new_comments)) {
Anand Doshi2aa9ba62012-04-30 15:43:34 +053088 navbar_nc.addClass('navbar-new-comments-true')
Rushabh Mehta9d0569a2012-11-13 11:42:42 +053089 navbar_nc.text(new_comments);
Anand Doshi2aa9ba62012-04-30 15:43:34 +053090 } else {
91 navbar_nc.removeClass('navbar-new-comments-true');
92 navbar_nc.text(0);
93 }
Rushabh Mehta523aec42013-01-07 15:39:54 +053094}