brotherton-erpnext/public/js/complete_setup.js
2012-10-01 14:46:37 +05:30

477 lines
19 KiB
JavaScript

// 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
// --------------------------------
wn.provide('erpnext.complete_setup');
$.extend(erpnext.complete_setup, {
show: function() {
d = erpnext.complete_setup.prepare_dialog();
d.show();
},
prepare_dialog: function() {
var d = new wn.ui.Dialog({
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')},
{fieldname:'currency', label: 'Default Currency', reqd:1,
options: erpnext.complete_setup.currency_list.join('\n'), fieldtype: 'Select'},
{fieldname:'industry', label: 'Industry', reqd:1,
options: erpnext.complete_setup.industry_list.join('\n'), fieldtype: 'Select'},
{fieldname:'country', label: 'Country', reqd:1,
options: erpnext.complete_setup.country_list.join('\n'), fieldtype: 'Select'},
{fieldname:'timezone', label: 'Time Zone', reqd:1,
options: '', fieldtype: 'Select'},
{fieldname:'update', label:'Setup',fieldtype:'Button'},
],
});
if(user != 'Administrator'){
$(d.appframe.$titlebar).find('.close').toggle(false); // Hide close image
$('header').toggle(false); // hide toolbar
}
// 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){
var timezone_list = erpnext.complete_setup.timezone_dict[country];
if(timezone_list.length > 1) {
timezone_list = [""].concat(timezone_list);
}
$timezone.add_options(timezone_list);
}
};
// 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;
},
fy_start_list: ['', '1st Jan', '1st Apr', '1st Jul', '1st Oct'],
currency_list: ['', 'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AZN',
'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BRL', 'BSD', 'BTN', 'BYR',
'BZD', 'CAD', 'CDF', 'CFA', 'CFP', 'CHF', 'CLP', 'CNY', 'COP', 'CRC', 'CUC', 'CZK', 'DJF',
'DKK', 'DOP', 'DZD', 'EEK', 'EGP', 'ERN', 'ETB', 'EUR', 'EURO', 'FJD', 'FKP', 'FMG', 'GBP',
'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GQE', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF',
'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF',
'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LTL', 'LVL', 'LYD',
'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MUR', 'MVR', 'MWK', 'MXN', 'MYR',
'MZM', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NRs', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP',
'PKR', 'PLN', 'PYG', 'QAR', 'RMB', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SCR', 'SDG', 'SDR',
'SEK', 'SGD', 'SHP', 'SOS', 'SRD', 'STD', 'SYP', 'SZL', 'THB', 'TJS', 'TMT', 'TND', 'TRY',
'TTD', 'TWD', 'TZS', 'UAE', 'UAH', 'UGX', 'USD', 'USh', 'UYU', 'UZS', 'VEB', 'VND', 'VUV',
'WST', 'XAF', 'XCD', 'XDR', 'XOF', 'XPF', 'YEN', 'YER', 'YTL', 'ZAR', 'ZMK', 'ZWR'],
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'],
country_list: ["", 'Afghanistan', 'Albania', 'Algeria', 'Andorra', 'Angola', 'Antigua and Barbuda',
'Argentina', 'Armenia', 'Australia', 'Austria', 'Azerbaijan', 'Bahamas', 'Bahrain',
'Bangladesh', 'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bhutan', 'Bolivia',
'Bosnia and Herzegovina', 'Botswana', 'Brazil', 'Brunei Darussalam', 'Bulgaria',
'Burkina Faso', 'Burundi', 'Cambodia', 'Cameroon', 'Canada', 'Cape Verde',
'Central African Republic', 'Chad', 'Chile', 'Colombia', 'Comoros', 'Costa Rica',
'Croatia', 'Cuba', 'Cyprus', 'Czech Republic', "C\xc3\xb4te d'Ivoire",
'Democratic Republic of the Congo', 'Denmark', 'Djibouti', 'Dominica',
'Dominican Republic', 'East Timor', 'Ecuador', 'Egypt', 'El Salvador',
'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia', 'Federated States of Micronesia',
'Fiji', 'Finland', 'France', 'Gabon', 'Georgia', 'Germany', 'Ghana', 'Greece',
'Grenada', 'Guatemala', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Honduras', 'Hong Kong',
'Hungary', 'Iceland', 'India', 'Indonesia', 'Iran', 'Iraq', 'Israel', 'Italy',
'Jamaica', 'Japan', 'Jordan', 'Kazakhstan', 'Kenya', 'Kingdom of the Netherlands',
'Kiribati', 'Kuwait', 'Kyrgyzstan', 'Laos', 'Latvia', 'Lebanon', 'Lesotho', 'Liberia',
'Libya', 'Liechtenstein', 'Lithuania', 'Luxembourg', 'Macedonia', 'Madagascar', 'Malawi',
'Malaysia', 'Maldives', 'Mali', 'Malta', 'Marshall Islands', 'Mauritania', 'Mauritius',
'Mexico', 'Moldova', 'Monaco', 'Mongolia', 'Montenegro', 'Morocco', 'Mozambique',
'Myanmar', 'Namibia', 'Nauru', 'Nepal', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria',
'North Korea', 'Norway', 'Oman', 'Pakistan', 'Palau', 'Panama', 'Papua New Guinea',
'Paraguay', "China", 'Peru', 'Philippines', 'Poland', 'Portugal',
'Qatar', 'Republic of Ireland', 'Republic of the Congo', 'Romania', 'Russia', 'Rwanda',
'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Vincent and the Grenadines', 'Samoa',
'San Marino', 'Saudi Arabia', 'Senegal', 'Serbia', 'Seychelles', 'Sierra Leone',
'Singapore', 'Slovakia', 'Slovenia', 'Solomon Islands', 'Somalia', 'South Africa',
'South Korea', 'Spain', 'Sri Lanka', 'Sudan', 'Suriname', 'Swaziland', 'Sweden',
'Switzerland', 'Syria', 'S\xc3\xa3o Tom\xc3\xa9 and Pr\xc3\xadncipe', 'Tajikistan',
'Tanzania', 'Thailand', 'The Gambia', 'Togo', 'Tonga', 'Trinidad and Tobago', 'Tunisia',
'Turkey', 'Turkmenistan', 'Tuvalu', 'Uganda', 'Ukraine', 'United Arab Emirates',
'United Kingdom', 'United States', 'Uruguay', 'Uzbekistan', 'Vanuatu', 'Vatican City',
'Venezuela', 'Vietnam', 'Yemen', 'Zambia', 'Zimbabwe'],
timezone_dict: {
'Afghanistan': ['Asia/Kabul'],
'Albania': ['Europe/Tirane'],
'Algeria': ['Africa/Algiers'],
'Andorra': ['Europe/Andorra'],
'Angola': ['Africa/Luanda'],
'Antigua and Barbuda': ['America/Antigua'],
'Argentina': ['America/Argentina/Buenos_Aires',
'America/Argentina/Cordoba',
'America/Argentina/Jujuy',
'America/Argentina/Tucuman',
'America/Argentina/Catamarca',
'America/Argentina/La_Rioja',
'America/Argentina/San_Juan',
'America/Argentina/Mendoza',
'America/Argentina/Rio_Gallegos',
'America/Argentina/Ushuaia'],
'Armenia': ['Asia/Yerevan'],
'Australia': ['Australia/Lord_Howe',
'Australia/Hobart',
'Australia/Currie',
'Australia/Melbourne',
'Australia/Sydney',
'Australia/Broken_Hill',
'Australia/Brisbane',
'Australia/Lindeman',
'Australia/Adelaide',
'Australia/Darwin',
'Australia/Perth'],
'Austria': ['Europe/Vienna'],
'Azerbaijan': ['Asia/Baku'],
'Bahamas': ['America/Nassau'],
'Bahrain': ['Asia/Bahrain'],
'Bangladesh': ['Asia/Dhaka'],
'Barbados': ['America/Barbados'],
'Belarus': ['Europe/Minsk'],
'Belgium': ['Europe/Brussels'],
'Belize': ['America/Belize'],
'Benin': ['Africa/Porto-Novo'],
'Bhutan': ['Asia/Thimphu'],
'Bolivia': ['America/La_Paz'],
'Bosnia and Herzegovina': ['Europe/Sarajevo'],
'Botswana': ['Africa/Gaborone'],
'Brazil': ['America/Noronha',
'America/Belem',
'America/Fortaleza',
'America/Recife',
'America/Araguaina',
'America/Maceio',
'America/Bahia',
'America/Sao_Paulo',
'America/Campo_Grande',
'America/Cuiaba',
'America/Porto_Velho',
'America/Boa_Vista',
'America/Manaus',
'America/Eirunepe',
'America/Rio_Branco'],
'Brunei Darussalam': ['Asia/Brunei'],
'Bulgaria': ['Europe/Sofia'],
'Burkina Faso': ['Africa/Ouagadougou'],
'Burundi': ['Africa/Bujumbura'],
'Cambodia': ['Asia/Phnom_Penh'],
'Cameroon': ['Africa/Douala'],
'Canada': ['America/St_Johns',
'America/Halifax',
'America/Glace_Bay',
'America/Moncton',
'America/Goose_Bay',
'America/Blanc-Sablon',
'America/Montreal',
'America/Toronto',
'America/Nipigon',
'America/Thunder_Bay',
'America/Pangnirtung',
'America/Iqaluit',
'America/Atikokan',
'America/Rankin_Inlet',
'America/Winnipeg',
'America/Rainy_River',
'America/Cambridge_Bay',
'America/Regina',
'America/Swift_Current',
'America/Edmonton',
'America/Yellowknife',
'America/Inuvik',
'America/Dawson_Creek',
'America/Vancouver',
'America/Whitehorse',
'America/Dawson'],
'Cape Verde': ['Atlantic/Cape_Verde'],
'Central African Republic': ['Africa/Bangui'],
'Chad': ['Africa/Ndjamena'],
'China': ['Asia/Shanghai',
'Asia/Harbin',
'Asia/Chongqing',
'Asia/Urumqi',
'Asia/Kashgar'],
'Chile': ['America/Santiago', 'Pacific/Easter'],
'Colombia': ['America/Bogota'],
'Comoros': ['Indian/Comoro'],
'Costa Rica': ['America/Costa_Rica'],
'Croatia': ['Europe/Zagreb'],
'Cuba': ['America/Havana'],
'Cyprus': ['Asia/Nicosia'],
'Czech Republic': ['Europe/Prague'],
"C\xc3\xb4te d'Ivoire": ['Africa/Abidjan'],
'Democratic Republic of the Congo': ['Africa/Kinshasa', 'Africa/Lubumbashi'],
'Denmark': ['Europe/Copenhagen'],
'Djibouti': ['Africa/Djibouti'],
'Dominica': ['America/Dominica'],
'Dominican Republic': ['America/Santo_Domingo'],
'East Timor': ['Asia/Dili'],
'Ecuador': ['America/Guayaquil', 'Pacific/Galapagos'],
'Egypt': ['Africa/Cairo'],
'El Salvador': ['America/El_Salvador'],
'Equatorial Guinea': ['Africa/Malabo'],
'Eritrea': ['Africa/Asmera'],
'Estonia': ['Europe/Tallinn'],
'Ethiopia': ['Africa/Addis_Ababa'],
'Federated States of Micronesia': ['Pacific/Truk',
'Pacific/Ponape',
'Pacific/Kosrae'],
'Fiji': ['Pacific/Fiji'],
'Finland': ['Europe/Helsinki'],
'France': ['Europe/Paris'],
'Gabon': ['Africa/Libreville'],
'Georgia': ['Asia/Tbilisi'],
'Germany': ['Europe/Berlin'],
'Ghana': ['Africa/Accra'],
'Greece': ['Europe/Athens'],
'Grenada': ['America/Grenada'],
'Guatemala': ['America/Guatemala'],
'Guinea': ['Africa/Conakry'],
'Guinea-Bissau': ['Africa/Bissau'],
'Guyana': ['America/Guyana'],
'Haiti': ['America/Guatemala'],
'Honduras': ['America/Tegucigalpa'],
'Hong Kong': ['Asia/Hong_Kong'],
'Hungary': ['Europe/Budapest'],
'Iceland': ['Atlantic/Reykjavik'],
'India': ['Asia/Calcutta'],
'Indonesia': ['Asia/Jakarta',
'Asia/Pontianak',
'Asia/Makassar',
'Asia/Jayapura'],
'Iran': ['Asia/Tehran'],
'Iraq': ['Asia/Baghdad'],
'Israel': ['Asia/Jerusalem'],
'Italy': ['Europe/Rome'],
'Jamaica': ['America/Jamaica'],
'Japan': ['Asia/Tokyo'],
'Jordan': ['Asia/Amman'],
'Kazakhstan': ['Asia/Almaty',
'Asia/Qyzylorda',
'Asia/Aqtobe',
'Asia/Aqtau',
'Asia/Oral'],
'Kenya': ['Africa/Nairobi'],
'Kingdom of the Netherlands': ['Europe/Amsterdam'],
'Kiribati': ['Pacific/Tarawa', 'Pacific/Enderbury', 'Pacific/Kiritimati'],
'Kuwait': ['Asia/Kuwait'],
'Kyrgyzstan': ['Asia/Bishkek'],
'Laos': ['Asia/Vientiane'],
'Latvia': ['Europe/Riga'],
'Lebanon': ['Asia/Beirut'],
'Lesotho': ['Africa/Maseru'],
'Liberia': ['Africa/Monrovia'],
'Libya': ['Africa/Tripoli'],
'Liechtenstein': ['Europe/Vaduz'],
'Lithuania': ['Europe/Vilnius'],
'Luxembourg': ['Europe/Luxembourg'],
'Macedonia': ['Europe/Skopje'],
'Madagascar': ['Indian/Antananarivo'],
'Malawi': ['Africa/Blantyre'],
'Malaysia': ['Asia/Kuala_Lumpur', 'Asia/Kuching'],
'Maldives': ['Indian/Maldives'],
'Mali': ['Africa/Bamako'],
'Malta': ['Europe/Malta'],
'Marshall Islands': ['Pacific/Majuro', 'Pacific/Kwajalein'],
'Mauritania': ['Africa/Nouakchott'],
'Mauritius': ['Indian/Mauritius'],
'Mexico': ['America/Mexico_City',
'America/Cancun',
'America/Merida',
'America/Monterrey',
'America/Mazatlan',
'America/Chihuahua',
'America/Hermosillo',
'America/Tijuana'],
'Moldova': ['Europe/Chisinau'],
'Monaco': ['Europe/Monaco'],
'Mongolia': ['Asia/Ulaanbaatar', 'Asia/Hovd', 'Asia/Choibalsan'],
'Montenegro': ['Europe/Podgorica'],
'Morocco': ['Africa/Casablanca'],
'Mozambique': ['Africa/Maputo'],
'Myanmar': ['Asia/Rangoon'],
'Namibia': ['Africa/Windhoek'],
'Nauru': ['Pacific/Nauru'],
'Nepal': ['Asia/Katmandu'],
'New Zealand': ['Pacific/Auckland', 'Pacific/Chatham'],
'Nicaragua': ['America/Managua'],
'Niger': ['Africa/Niamey'],
'Nigeria': ['Africa/Lagos'],
'North Korea': ['Asia/Pyongyang'],
'Norway': ['Europe/Oslo'],
'Oman': ['Asia/Muscat'],
'Pakistan': ['Asia/Karachi'],
'Palau': ['Pacific/Palau'],
'Panama': ['America/Panama'],
'Papua New Guinea': ['Pacific/Port_Moresby'],
'Paraguay': ['America/Asuncion'],
'Peru': ['America/Lima'],
'Philippines': ['Asia/Manila'],
'Poland': ['Europe/Warsaw'],
'Portugal': ['Europe/Lisbon', 'Atlantic/Madeira', 'Atlantic/Azores'],
'Qatar': ['Asia/Qatar'],
'Republic of Ireland': ['Europe/Dublin'],
'Republic of the Congo': ['Africa/Brazzaville'],
'Romania': ['Europe/Bucharest'],
'Russia': ['Europe/Kaliningrad',
'Europe/Moscow',
'Europe/Volgograd',
'Europe/Samara',
'Asia/Yekaterinburg',
'Asia/Omsk',
'Asia/Novosibirsk',
'Asia/Krasnoyarsk',
'Asia/Irkutsk',
'Asia/Yakutsk',
'Asia/Vladivostok',
'Asia/Sakhalin',
'Asia/Magadan',
'Asia/Kamchatka',
'Asia/Anadyr'],
'Rwanda': ['Africa/Kigali'],
'Saint Kitts and Nevis': ['America/St_Kitts'],
'Saint Lucia': ['America/St_Lucia'],
'Saint Vincent and the Grenadines': ['America/St_Vincent'],
'Samoa': ['Pacific/Apia'],
'San Marino': ['Europe/San_Marino'],
'Saudi Arabia': ['Asia/Riyadh'],
'Senegal': ['Africa/Dakar'],
'Serbia': ['Europe/Belgrade'],
'Seychelles': ['Indian/Mahe'],
'Sierra Leone': ['Africa/Freetown'],
'Singapore': ['Asia/Singapore'],
'Slovakia': ['Europe/Bratislava'],
'Slovenia': ['Europe/Ljubljana'],
'Solomon Islands': ['Pacific/Guadalcanal'],
'Somalia': ['Africa/Mogadishu'],
'South Africa': ['Africa/Johannesburg'],
'South Korea': ['Asia/Seoul'],
'Spain': ['Europe/Madrid', 'Africa/Ceuta', 'Atlantic/Canary'],
'Sri Lanka': ['Asia/Colombo'],
'Sudan': ['Africa/Khartoum'],
'Suriname': ['America/Paramaribo'],
'Swaziland': ['Africa/Mbabane'],
'Sweden': ['Europe/Stockholm'],
'Switzerland': ['Europe/Zurich'],
'Syria': ['Asia/Damascus'],
'S\xc3\xa3o Tom\xc3\xa9 and Pr\xc3\xadncipe': ['Africa/Sao_Tome'],
'Tajikistan': ['Asia/Dushanbe'],
'Tanzania': ['Africa/Dar_es_Salaam'],
'Thailand': ['Asia/Bangkok'],
'The Gambia': ['Africa/Banjul'],
'Togo': ['Africa/Lome'],
'Tonga': ['Pacific/Tongatapu'],
'Trinidad and Tobago': ['America/Port_of_Spain'],
'Tunisia': ['Africa/Tunis'],
'Turkey': ['Europe/Istanbul'],
'Turkmenistan': ['Asia/Ashgabat'],
'Tuvalu': ['Pacific/Funafuti'],
'Uganda': ['Africa/Kampala'],
'Ukraine': ['Europe/Kiev',
'Europe/Uzhgorod',
'Europe/Zaporozhye',
'Europe/Simferopol'],
'United Arab Emirates': ['Asia/Dubai'],
'United Kingdom': ['Europe/London'],
'United States': ['America/New_York',
'America/Detroit',
'America/Kentucky/Louisville',
'America/Kentucky/Monticello',
'America/Indiana/Indianapolis',
'America/Indiana/Marengo',
'America/Indiana/Knox',
'America/Indiana/Vevay',
'America/Chicago',
'America/Indiana/Vincennes',
'America/Indiana/Petersburg',
'America/Menominee',
'America/North_Dakota/Center',
'America/North_Dakota/New_Salem',
'America/Denver',
'America/Boise',
'America/Shiprock',
'America/Phoenix',
'America/Los_Angeles',
'America/Anchorage',
'America/Juneau',
'America/Yakutat',
'America/Nome',
'America/Adak',
'Pacific/Honolulu'],
'Uruguay': ['America/Montevideo'],
'Uzbekistan': ['Asia/Samarkand', 'Asia/Tashkent'],
'Vanuatu': ['Pacific/Efate'],
'Vatican City': ['Europe/Vatican'],
'Venezuela': ['America/Caracas'],
'Vietnam': ['Asia/Saigon'],
'Yemen': ['Asia/Aden'],
'Zambia': ['Africa/Lusaka'],
'Zimbabwe': ['Africa/Harare'],
},
});