Rushabh Mehta | 12852e7 | 2012-02-29 15:11:06 +0530 | [diff] [blame] | 1 | // 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 | // -------------------------------- |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 19 | wn.provide('erpnext.complete_setup'); |
Rushabh Mehta | 12852e7 | 2012-02-29 15:11:06 +0530 | [diff] [blame] | 20 | |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 21 | $.extend(erpnext.complete_setup, { |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 22 | show: function() { |
| 23 | d = erpnext.complete_setup.prepare_dialog(); |
| 24 | d.show(); |
| 25 | }, |
Rushabh Mehta | 12852e7 | 2012-02-29 15:11:06 +0530 | [diff] [blame] | 26 | |
Anand Doshi | 2aa9ba6 | 2012-04-30 15:43:34 +0530 | [diff] [blame] | 27 | prepare_dialog: function() { |
Rushabh Mehta | 2d700dd | 2012-10-01 14:46:37 +0530 | [diff] [blame] | 28 | var d = new wn.ui.Dialog({ |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 29 | title: "Setup", |
| 30 | fields: [ |
| 31 | {fieldname:'first_name', label:'Your First Name', fieldtype:'Data', reqd: 1}, |
| 32 | {fieldname:'last_name', label:'Your Last Name', fieldtype:'Data'}, |
| 33 | {fieldname:'company_name', label:'Company Name', fieldtype:'Data', reqd:1, |
| 34 | description: 'e.g. "My Company LLC"'}, |
| 35 | {fieldname:'company_abbr', label:'Company Abbreviation', fieldtype:'Data', |
| 36 | description:'e.g. "MC"',reqd:1}, |
| 37 | {fieldname:'fy_start', label:'Financial Year Start Date', fieldtype:'Select', |
| 38 | description:'Your financial year begins on"', reqd:1, |
| 39 | options: erpnext.complete_setup.fy_start_list.join('\n')}, |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 40 | {fieldname:'country', label: 'Country', reqd:1, |
| 41 | options: "", fieldtype: 'Select'}, |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 42 | {fieldname:'currency', label: 'Default Currency', reqd:1, |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 43 | options: "Currency", fieldtype: 'Link'}, |
| 44 | {fieldname:'timezone', label: 'Time Zone', reqd:1, |
| 45 | options: "", fieldtype: 'Select'}, |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 46 | {fieldname:'industry', label: 'Industry', reqd:1, |
| 47 | options: erpnext.complete_setup.industry_list.join('\n'), fieldtype: 'Select'}, |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 48 | {fieldname:'update', label:'Setup',fieldtype:'Button'}, |
| 49 | ], |
Rushabh Mehta | 12852e7 | 2012-02-29 15:11:06 +0530 | [diff] [blame] | 50 | }); |
Anand Doshi | 2aa9ba6 | 2012-04-30 15:43:34 +0530 | [diff] [blame] | 51 | |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 52 | if(user != 'Administrator'){ |
| 53 | $(d.appframe.$titlebar).find('.close').toggle(false); // Hide close image |
| 54 | $('header').toggle(false); // hide toolbar |
| 55 | } |
| 56 | |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 57 | wn.call({ |
| 58 | method:"webnotes.country_info.get_all", |
| 59 | callback: function(data) { |
| 60 | erpnext.country_info = data.message; |
| 61 | d.get_input("country").empty() |
| 62 | .add_options([""].concat(keys(data.message).sort())); |
| 63 | } |
| 64 | }) |
| 65 | |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 66 | // on clicking update |
| 67 | d.fields_dict.update.input.onclick = function() { |
| 68 | var data = d.get_values(); |
| 69 | if(!data) return; |
| 70 | $(this).set_working(); |
| 71 | $c_obj('Setup Control','setup_account',data,function(r, rt){ |
| 72 | sys_defaults = r.message; |
| 73 | user_fullname = r.message.user_fullname; |
| 74 | wn.boot.user_info[user].fullname = user_fullname; |
| 75 | d.hide(); |
| 76 | $('header').toggle(true); |
| 77 | wn.container.wntoolbar.set_user_name(); |
| 78 | }); |
| 79 | }; |
| 80 | |
| 81 | d.fields_dict.country.input.onchange = function() { |
| 82 | var country = d.fields_dict.country.input.value; |
| 83 | var $timezone = $(d.fields_dict.timezone.input); |
| 84 | $timezone.empty(); |
| 85 | if(country){ |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 86 | var timezone_list = erpnext.country_info[country].timezones; |
| 87 | if(timezone_list.length==0) { |
| 88 | timezone_list = $.map(erpnext.country_info, function(m) { |
| 89 | return m.timezones |
| 90 | }); |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 91 | } |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 92 | $timezone.empty().add_options(timezone_list); |
| 93 | |
| 94 | console.log(d.get_input("currency")) |
| 95 | |
| 96 | d.get_input("currency").val(erpnext.country_info[country].currency); |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 97 | } |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 98 | |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | // company name already set |
| 102 | if(wn.control_panel.company_name) { |
| 103 | var inp = d.fields_dict.company_name.input; |
| 104 | inp.value = wn.control_panel.company_name; |
| 105 | inp.disabled = true; |
| 106 | } |
| 107 | |
| 108 | // set first name, last name |
| 109 | if(user_fullname) { |
| 110 | u = user_fullname.split(' '); |
| 111 | if(u[0]) { |
| 112 | d.fields_dict.first_name.input.value = u[0]; |
| 113 | } |
| 114 | if(u[1]) { |
| 115 | d.fields_dict.last_name.input.value = u[1]; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | return d; |
| 120 | }, |
Rushabh Mehta | 12852e7 | 2012-02-29 15:11:06 +0530 | [diff] [blame] | 121 | |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 122 | fy_start_list: ['', '1st Jan', '1st Apr', '1st Jul', '1st Oct'], |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 123 | |
| 124 | industry_list: ['', 'Aerospace and Defence', 'Agriculture', 'Apparel', 'Automobile', |
| 125 | 'Banking', 'Biotechnology', 'Chemical', 'Communications', 'Consulting', 'Customer Service', |
| 126 | 'Education', 'Electronics', 'Energy', 'Engineering', 'Entertainment', 'Environmental', |
| 127 | 'Finance', 'Food and Beverage', 'Government', 'Healthcare', 'Hospitality', |
| 128 | 'Information Technology', 'Insurance', 'Machinery', 'Manufacturing', 'Media', |
| 129 | 'Not For Profit', 'Recreation', 'Retail', 'Shipping', 'Technology', |
| 130 | 'Telecommunications', 'Transportation', 'Trading', 'Utilities', 'Other'], |
Anand Doshi | 1ed4ef1 | 2012-04-27 15:30:23 +0530 | [diff] [blame] | 131 | }); |