blob: 663c7b97f05587b0cf3a105d7aa0ba86cae60aec [file] [log] [blame]
Rushabh Mehta12852e72012-02-29 15:11:06 +05301// ERPNext - web based ERP (http://erpnext.com)
2// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17// complete my company registration
18// --------------------------------
19
20erpnext.complete_setup = function() {
21 var currency_list = ['', 'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AZN',
22 'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BRL', 'BSD', 'BTN', 'BYR',
23 'BZD', 'CAD', 'CDF', 'CFA', 'CFP', 'CHF', 'CLP', 'CNY', 'COP', 'CRC', 'CUC', 'CZK', 'DJF',
24 'DKK', 'DOP', 'DZD', 'EEK', 'EGP', 'ERN', 'ETB', 'EUR', 'EURO', 'FJD', 'FKP', 'FMG', 'GBP',
25 'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GQE', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF',
26 'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF',
27 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LTL', 'LVL', 'LYD',
28 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MUR', 'MVR', 'MWK', 'MXN', 'MYR',
29 'MZM', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NRs', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP',
30 'PKR', 'PLN', 'PYG', 'QAR', 'RMB', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SCR', 'SDG', 'SDR',
31 'SEK', 'SGD', 'SHP', 'SOS', 'SRD', 'STD', 'SYP', 'SZL', 'THB', 'TJS', 'TMT', 'TND', 'TRY',
32 'TTD', 'TWD', 'TZS', 'UAE', 'UAH', 'UGX', 'USD', 'USh', 'UYU', 'UZS', 'VEB', 'VND', 'VUV',
33 'WST', 'XAF', 'XCD', 'XDR', 'XOF', 'XPF', 'YEN', 'YER', 'YTL', 'ZAR', 'ZMK', 'ZWR'];
34
35 var d = new wn.widgets.Dialog({
36 title: "Setup",
37 fields: [
38 {fieldname:'first_name', label:'Your First Name', fieldtype:'Data'},
39 {fieldname:'last_name', label:'Your Last Name', fieldtype:'Data'},
40 {fieldname:'company_name', label:'Company Name', fieldtype:'Data', reqd:1,
41 description: 'e.g. "My Company LLC"'},
42 {fieldname:'company_abbr', label:'Company Abbreviation', fieldtype:'Data',
43 description:'e.g. "MC"',reqd:1},
44 {fieldname:'fy_start', label:'Financial Year Start Date', fieldtype:'Select',
45 description:'Your financial year begins on"', reqd:1,
46 options=['', '1st Jan', '1st Apr', '1st Jul', '1st Oct'].join('\n')},
47 {fieldname:'currency': label: 'Default Currency', reqd:1,
48 options=currency_list.join('\n')},
49 {fieldname:'update', label:'Setup',fieldtype:'Button'}
50 ]
51 })
52
53 // prepare
54 if(user != 'Administrator'){
55 d.no_cancel(); // Hide close image
56 $('header').toggle(false); // hide toolbar
57 }
58
59 // company name already set
60 if(wn.control_panel.company_name) {
61 var inp = d.fields_dict.company_name.input;
62 inp.value = wn.control_panel.company_name;
63 inp.disabled = true;
64 }
65
66 // set first name, last name
67 if(user_fullname) {
68 u = user_fullname.spilt(' ');
69 if(u[0]) {
70 d.fields_dict.first_name.input.value = u[0];
71 }
72 if(u[1]) {
73 d.fields_dict.last_name.input.value = u[1];
74 }
75 }
76
77 // setup
78 d.fields_dict.update.input.onclick = function() {
79 var data = d.get_values();
80 if(!data) return;
81 $(this).set_working();
82 $c_obj('Setup Control','setup_account',data,function(r, rt){
83 sys_defaults = r.message;
84 user_fullname = r.message.user_fullname;
85 wn.boot.user_fullnames[user] = user_fullname;
86 d.hide();
87 $('header').toggle(true);
88 page_body.wntoolbar.set_user_name();
89 });
90 }
91
92 d.show();
93}