2012-02-29 09:41:06 +00:00
|
|
|
// ERPNext - web based ERP (http://erpnext.com)
|
|
|
|
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
// complete my company registration
|
|
|
|
// --------------------------------
|
2012-04-27 10:00:23 +00:00
|
|
|
wn.provide('erpnext.complete_setup');
|
2012-02-29 09:41:06 +00:00
|
|
|
|
2012-04-27 10:00:23 +00:00
|
|
|
$.extend(erpnext.complete_setup, {
|
|
|
|
show: function() {
|
|
|
|
d = erpnext.complete_setup.prepare_dialog();
|
|
|
|
d.show();
|
|
|
|
},
|
2012-02-29 09:41:06 +00:00
|
|
|
|
2012-04-30 10:13:34 +00:00
|
|
|
prepare_dialog: function() {
|
2012-10-01 09:16:37 +00:00
|
|
|
var d = new wn.ui.Dialog({
|
2012-04-27 10:00:23 +00:00
|
|
|
title: "Setup",
|
|
|
|
fields: [
|
|
|
|
{fieldname:'first_name', label:'Your First Name', fieldtype:'Data', reqd: 1},
|
|
|
|
{fieldname:'last_name', label:'Your Last Name', fieldtype:'Data'},
|
|
|
|
{fieldname:'company_name', label:'Company Name', fieldtype:'Data', reqd:1,
|
|
|
|
description: 'e.g. "My Company LLC"'},
|
|
|
|
{fieldname:'company_abbr', label:'Company Abbreviation', fieldtype:'Data',
|
|
|
|
description:'e.g. "MC"',reqd:1},
|
|
|
|
{fieldname:'fy_start', label:'Financial Year Start Date', fieldtype:'Select',
|
|
|
|
description:'Your financial year begins on"', reqd:1,
|
|
|
|
options: erpnext.complete_setup.fy_start_list.join('\n')},
|
2013-01-17 12:52:22 +00:00
|
|
|
{fieldname:'country', label: 'Country', reqd:1,
|
|
|
|
options: "", fieldtype: 'Select'},
|
2012-04-27 10:00:23 +00:00
|
|
|
{fieldname:'currency', label: 'Default Currency', reqd:1,
|
2013-05-20 08:13:50 +00:00
|
|
|
options: "", fieldtype: 'Select'},
|
2013-01-17 12:52:22 +00:00
|
|
|
{fieldname:'timezone', label: 'Time Zone', reqd:1,
|
|
|
|
options: "", fieldtype: 'Select'},
|
2012-04-27 10:00:23 +00:00
|
|
|
{fieldname:'industry', label: 'Industry', reqd:1,
|
|
|
|
options: erpnext.complete_setup.industry_list.join('\n'), fieldtype: 'Select'},
|
|
|
|
{fieldname:'update', label:'Setup',fieldtype:'Button'},
|
|
|
|
],
|
|
|
|
});
|
2012-04-30 10:13:34 +00:00
|
|
|
|
2012-04-27 10:00:23 +00:00
|
|
|
if(user != 'Administrator'){
|
|
|
|
$(d.appframe.$titlebar).find('.close').toggle(false); // Hide close image
|
|
|
|
$('header').toggle(false); // hide toolbar
|
|
|
|
}
|
|
|
|
|
2013-01-17 12:52:22 +00:00
|
|
|
wn.call({
|
2013-05-20 08:13:50 +00:00
|
|
|
method:"webnotes.country_info.get_country_timezone_info",
|
2013-01-17 12:52:22 +00:00
|
|
|
callback: function(data) {
|
2013-05-20 08:13:50 +00:00
|
|
|
erpnext.country_info = data.message.country_info;
|
|
|
|
erpnext.all_timezones = data.message.all_timezones;
|
2013-01-17 12:52:22 +00:00
|
|
|
d.get_input("country").empty()
|
2013-05-20 08:13:50 +00:00
|
|
|
.add_options([""].concat(keys(erpnext.country_info).sort()));
|
|
|
|
d.get_input("currency").empty()
|
|
|
|
.add_options(wn.utils.unique([""].concat($.map(erpnext.country_info,
|
|
|
|
function(opts, country) { return opts.currency; }))).sort());
|
|
|
|
d.get_input("timezone").empty()
|
|
|
|
.add_options([""].concat(erpnext.all_timezones));
|
2013-01-17 12:52:22 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2012-04-27 10:00:23 +00:00
|
|
|
// on clicking update
|
|
|
|
d.fields_dict.update.input.onclick = function() {
|
|
|
|
var data = d.get_values();
|
|
|
|
if(!data) return;
|
|
|
|
$(this).set_working();
|
|
|
|
$c_obj('Setup Control','setup_account',data,function(r, rt){
|
2013-06-24 06:41:15 +00:00
|
|
|
if(!r.exc) {
|
|
|
|
sys_defaults = r.message;
|
|
|
|
user_fullname = r.message.user_fullname;
|
|
|
|
wn.boot.user_info[user].fullname = user_fullname;
|
|
|
|
d.hide();
|
|
|
|
$('header').toggle(true);
|
|
|
|
wn.container.wntoolbar.set_user_name();
|
|
|
|
|
|
|
|
setTimeout(function() { window.location.reload(); }, 3000);
|
2013-07-04 12:59:55 +00:00
|
|
|
} else {
|
|
|
|
$(this).done_working();
|
2013-06-24 06:41:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-27 10:00:23 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
d.fields_dict.country.input.onchange = function() {
|
|
|
|
var country = d.fields_dict.country.input.value;
|
|
|
|
var $timezone = $(d.fields_dict.timezone.input);
|
|
|
|
$timezone.empty();
|
2013-05-20 08:13:50 +00:00
|
|
|
// add country specific timezones first
|
2012-04-27 10:00:23 +00:00
|
|
|
if(country){
|
2013-05-20 08:13:50 +00:00
|
|
|
var timezone_list = erpnext.country_info[country].timezones || [];
|
|
|
|
$timezone.add_options(timezone_list.sort());
|
2013-01-17 12:52:22 +00:00
|
|
|
|
|
|
|
d.get_input("currency").val(erpnext.country_info[country].currency);
|
2012-04-27 10:00:23 +00:00
|
|
|
}
|
2013-05-20 08:13:50 +00:00
|
|
|
// add all timezones at the end, so that user has the option to change it to any timezone
|
|
|
|
$timezone.add_options([""].concat(erpnext.all_timezones));
|
2013-01-17 12:52:22 +00:00
|
|
|
|
2012-04-27 10:00:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// company name already set
|
|
|
|
if(wn.control_panel.company_name) {
|
|
|
|
var inp = d.fields_dict.company_name.input;
|
|
|
|
inp.value = wn.control_panel.company_name;
|
|
|
|
inp.disabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set first name, last name
|
|
|
|
if(user_fullname) {
|
|
|
|
u = user_fullname.split(' ');
|
|
|
|
if(u[0]) {
|
|
|
|
d.fields_dict.first_name.input.value = u[0];
|
|
|
|
}
|
|
|
|
if(u[1]) {
|
|
|
|
d.fields_dict.last_name.input.value = u[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return d;
|
|
|
|
},
|
2012-02-29 09:41:06 +00:00
|
|
|
|
2012-04-27 10:00:23 +00:00
|
|
|
fy_start_list: ['', '1st Jan', '1st Apr', '1st Jul', '1st Oct'],
|
2013-01-17 12:52:22 +00:00
|
|
|
|
|
|
|
industry_list: ['', 'Aerospace and Defence', 'Agriculture', 'Apparel', 'Automobile',
|
|
|
|
'Banking', 'Biotechnology', 'Chemical', 'Communications', 'Consulting', 'Customer Service',
|
|
|
|
'Education', 'Electronics', 'Energy', 'Engineering', 'Entertainment', 'Environmental',
|
|
|
|
'Finance', 'Food and Beverage', 'Government', 'Healthcare', 'Hospitality',
|
|
|
|
'Information Technology', 'Insurance', 'Machinery', 'Manufacturing', 'Media',
|
|
|
|
'Not For Profit', 'Recreation', 'Retail', 'Shipping', 'Technology',
|
2013-05-20 08:13:50 +00:00
|
|
|
'Telecommunications', 'Transportation', 'Trading', 'Utilities', 'Other'],
|
2012-04-27 10:00:23 +00:00
|
|
|
});
|