blob: eee8a05620825900b980bbcf41a97c18b7d5b789 [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 Mehtabd919ca2012-11-28 15:19:51 +053012 if(user != 'Guest'){
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053013 // setup toolbar
14 erpnext.toolbar.setup();
15
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053016 // complete registration
Rushabh Mehta2f7e1ab2013-06-26 17:20:12 +053017 if(in_list(user_roles,'System Manager') && (wn.boot.setup_complete==='No')) {
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053018 wn.require("app/js/complete_setup.js");
19 erpnext.complete_setup.show();
Rushabh Mehta2f7e1ab2013-06-26 17:20:12 +053020 } else if(!wn.boot.customer_count) {
21 if(wn.get_route()[0]!=="Setup") {
22 msgprint("<a class='btn btn-success' href='#Setup'>"
23 + wn._("Proceed to Setup") + "</a>\
24 <br><br><p class='text-muted'>"+
25 wn._("This message goes away after you create your first customer.")+
26 "</p>", wn._("Welcome"));
27 }
28 } else if(wn.boot.expires_on && in_list(user_roles, 'System Manager')) {
Anand Doshi43b38df2013-08-09 16:57:53 +053029 erpnext.startup.show_expiry_banner();
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053030 }
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053031 }
32}
33
Anand Doshi43b38df2013-08-09 16:57:53 +053034erpnext.startup.show_expiry_banner = function() {
35 var today = dateutil.str_to_obj(wn.boot.server_date);
36 var expires_on = dateutil.str_to_obj(wn.boot.expires_on);
37 var diff = dateutil.get_diff(expires_on, today);
38 var payment_link = "<a href=\"https://erpnext.com/modes-of-payment.html\" target=\"_blank\">\
39 Click here to buy subscription.</a>";
40
41 var msg = "";
42 if (0 <= diff && diff <= 10) {
43 var expiry_string = diff==0 ? "today" : repl("in %(diff)s day(s)", { diff: diff });
44 msg = repl('Your ERPNext subscription will <b>expire %(expiry_string)s</b>. %(payment_link)s',
45 { expiry_string: expiry_string, payment_link: payment_link });
46 } else if (diff < 0) {
47 msg = repl('This ERPNext subscription <b>has expired</b>. %(payment_link)s', {payment_link: payment_link});
48 }
49
50 if(msg) wn.ui.toolbar.show_banner(msg);
51}
52
Rushabh Mehta9d1faea2012-10-02 14:56:41 +053053// start
54$(document).bind('startup', function() {
55 erpnext.startup.start();
Anand Doshi5f17be82012-12-15 18:38:18 +053056});