blob: eadfa1b6cbcb0388f1af098f1d0190ac79098fcc [file] [log] [blame]
Rushabh Mehta2fa2f712012-09-24 19:13:42 +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
17var current_module;
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053018
19wn.provide('erpnext.startup');
20
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053021erpnext.startup.start = function() {
22 console.log('Starting up...');
23 $('#startup_div').html('Starting up...').toggle(true);
24
Rushabh Mehtabd919ca2012-11-28 15:19:51 +053025 if(user != 'Guest'){
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053026 // setup toolbar
27 erpnext.toolbar.setup();
28
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053029 // complete registration
Rushabh Mehta2f7e1ab2013-06-26 17:20:12 +053030 if(in_list(user_roles,'System Manager') && (wn.boot.setup_complete==='No')) {
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053031 wn.require("app/js/complete_setup.js");
32 erpnext.complete_setup.show();
Rushabh Mehta2f7e1ab2013-06-26 17:20:12 +053033 } else if(!wn.boot.customer_count) {
34 if(wn.get_route()[0]!=="Setup") {
35 msgprint("<a class='btn btn-success' href='#Setup'>"
36 + wn._("Proceed to Setup") + "</a>\
37 <br><br><p class='text-muted'>"+
38 wn._("This message goes away after you create your first customer.")+
39 "</p>", wn._("Welcome"));
40 }
41 } else if(wn.boot.expires_on && in_list(user_roles, 'System Manager')) {
Rushabh Mehtad1784cc2012-11-12 12:57:42 +053042 var today = dateutil.str_to_obj(wn.boot.server_date);
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053043 var expires_on = dateutil.str_to_obj(wn.boot.expires_on);
44 var diff = dateutil.get_diff(expires_on, today);
Anand Doshi5f17be82012-12-15 18:38:18 +053045 var payment_link = "<a href=\"https://erpnext.com/modes-of-payment.html\" target=\"_blank\">See Payment Options.</a>";
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053046 if (0 <= diff && diff <= 15) {
47 var expiry_string = diff==0 ? "today" : repl("in %(diff)s day(s)", { diff: diff });
48 $('header').append(repl('<div class="expiry-info"> \
49 Your ERPNext subscription will <b>expire %(expiry_string)s</b>. \
50 Please renew your subscription to continue using ERPNext \
Anand Doshi5f17be82012-12-15 18:38:18 +053051 (and remove this annoying banner). %(payment_link)s\
52 </div>', { expiry_string: expiry_string, payment_link: payment_link }));
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053053 } else if (diff < 0) {
54 $('header').append(repl('<div class="expiry-info"> \
Anand Doshi5f17be82012-12-15 18:38:18 +053055 This ERPNext subscription <b>has expired</b>. %(payment_link)s\
56 </div>', { expiry_string: expiry_string, payment_link: payment_link }));
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053057 }
58 }
59 erpnext.set_about();
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053060 }
61}
62
Rushabh Mehta9d1faea2012-10-02 14:56:41 +053063// start
64$(document).bind('startup', function() {
65 erpnext.startup.start();
Anand Doshi5f17be82012-12-15 18:38:18 +053066});