blob: 6654ca7611dd764270150df7d753094460a93cc1 [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')) {
Rushabh Mehtad1784cc2012-11-12 12:57:42 +053029 var today = dateutil.str_to_obj(wn.boot.server_date);
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053030 var expires_on = dateutil.str_to_obj(wn.boot.expires_on);
31 var diff = dateutil.get_diff(expires_on, today);
Anand Doshi5f17be82012-12-15 18:38:18 +053032 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 +053033 if (0 <= diff && diff <= 15) {
34 var expiry_string = diff==0 ? "today" : repl("in %(diff)s day(s)", { diff: diff });
35 $('header').append(repl('<div class="expiry-info"> \
36 Your ERPNext subscription will <b>expire %(expiry_string)s</b>. \
37 Please renew your subscription to continue using ERPNext \
Anand Doshi5f17be82012-12-15 18:38:18 +053038 (and remove this annoying banner). %(payment_link)s\
39 </div>', { expiry_string: expiry_string, payment_link: payment_link }));
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053040 } else if (diff < 0) {
41 $('header').append(repl('<div class="expiry-info"> \
Anand Doshi5f17be82012-12-15 18:38:18 +053042 This ERPNext subscription <b>has expired</b>. %(payment_link)s\
43 </div>', { expiry_string: expiry_string, payment_link: payment_link }));
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053044 }
45 }
Rushabh Mehta2fa2f712012-09-24 19:13:42 +053046 }
47}
48
Rushabh Mehta9d1faea2012-10-02 14:56:41 +053049// start
50$(document).bind('startup', function() {
51 erpnext.startup.start();
Anand Doshi5f17be82012-12-15 18:38:18 +053052});