blob: 5a81d730a3a1c2e0e510af87e4b773d03f61cecc [file] [log] [blame]
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05301// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
2// License: GNU General Public License v3. See license.txt
Rushabh Mehta2fa2f712012-09-24 19:13:42 +05303
4var current_module;
Rushabh Mehta2fa2f712012-09-24 19:13:42 +05305
6wn.provide('erpnext.startup');
7
Rushabh Mehta2fa2f712012-09-24 19:13:42 +05308erpnext.startup.start = function() {
9 console.log('Starting up...');
10 $('#startup_div').html('Starting up...').toggle(true);
11
Rushabh Mehta8c5a5f12013-10-08 17:59:11 +053012 erpnext.toolbar.setup();
13
14 if(wn.boot.expires_on && in_list(user_roles, 'System Manager')) {
15 erpnext.startup.show_expiry_banner();
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053016 }
17}
18
Anand Doshi43b38df2013-08-09 16:57:53 +053019erpnext.startup.show_expiry_banner = function() {
20 var today = dateutil.str_to_obj(wn.boot.server_date);
21 var expires_on = dateutil.str_to_obj(wn.boot.expires_on);
22 var diff = dateutil.get_diff(expires_on, today);
23 var payment_link = "<a href=\"https://erpnext.com/modes-of-payment.html\" target=\"_blank\">\
24 Click here to buy subscription.</a>";
25
26 var msg = "";
27 if (0 <= diff && diff <= 10) {
28 var expiry_string = diff==0 ? "today" : repl("in %(diff)s day(s)", { diff: diff });
29 msg = repl('Your ERPNext subscription will <b>expire %(expiry_string)s</b>. %(payment_link)s',
30 { expiry_string: expiry_string, payment_link: payment_link });
31 } else if (diff < 0) {
32 msg = repl('This ERPNext subscription <b>has expired</b>. %(payment_link)s', {payment_link: payment_link});
33 }
34
35 if(msg) wn.ui.toolbar.show_banner(msg);
36}
37
Rushabh Mehta9d1faea2012-10-02 14:56:41 +053038// start
39$(document).bind('startup', function() {
40 erpnext.startup.start();
Anand Doshi5f17be82012-12-15 18:38:18 +053041});