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-01-17 12:52:22 +00:00
|
|
|
options: "Currency", fieldtype: 'Link'},
|
|
|
|
{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({
|
|
|
|
method:"webnotes.country_info.get_all",
|
|
|
|
callback: function(data) {
|
|
|
|
erpnext.country_info = data.message;
|
|
|
|
d.get_input("country").empty()
|
|
|
|
.add_options([""].concat(keys(data.message).sort()));
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
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){
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
d.fields_dict.country.input.onchange = function() {
|
|
|
|
var country = d.fields_dict.country.input.value;
|
|
|
|
var $timezone = $(d.fields_dict.timezone.input);
|
|
|
|
$timezone.empty();
|
|
|
|
if(country){
|
2013-01-17 12:52:22 +00:00
|
|
|
var timezone_list = erpnext.country_info[country].timezones;
|
|
|
|
if(timezone_list.length==0) {
|
|
|
|
timezone_list = $.map(erpnext.country_info, function(m) {
|
|
|
|
return m.timezones
|
|
|
|
});
|
2012-04-27 10:00:23 +00:00
|
|
|
}
|
2013-01-17 12:52:22 +00:00
|
|
|
$timezone.empty().add_options(timezone_list);
|
|
|
|
|
|
|
|
console.log(d.get_input("currency"))
|
|
|
|
|
|
|
|
d.get_input("currency").val(erpnext.country_info[country].currency);
|
2012-04-27 10:00:23 +00:00
|
|
|
}
|
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',
|
|
|
|
'Telecommunications', 'Transportation', 'Trading', 'Utilities', 'Other'],
|
2012-04-27 10:00:23 +00:00
|
|
|
});
|