frappe.pages['setup-wizard'].onload = function(wrapper) { if(sys_defaults.company) { frappe.set_route("desktop"); return; } $(".navbar:first").toggle(false); $("body").css({"padding-top":"30px"}); var wizard_settings = { page_name: "setup-wizard", parent: wrapper, on_complete: function(wiz) { var values = wiz.get_values(); wiz.show_working(); frappe.call({ method: "erpnext.setup.page.setup_wizard.setup_wizard.setup_account", args: values, callback: function(r) { if(r.exc) { var d = msgprint(__("There were errors.")); d.custom_onhide = function() { frappe.set_route(erpnext.wiz.page_name, "0"); } } else { wiz.show_complete(); setTimeout(function() { if(user==="Administrator") { msgprint(__("Login with your new User ID") + ":" + values.email); setTimeout(function() { frappe.app.logout(); }, 2000); } else { window.location = "/desk"; } }, 2000); } } }) }, title: __("ERPNext Setup Guide"), welcome_html: '
' + __('Welcome to ERPNext. Over the next few minutes we will help you setup your ERPNext account. Try and fill in as much information as you have even if it takes a bit longer. It will save you a lot of time later. Good Luck!') + '
', working_html: '' + __('Sit tight while your system is being setup. This may take a few moments.') + '
', complete_html: '' + __('Your setup is complete. Refreshing...') + '
', slides: [ // User { title: __("The First User: You"), icon: "icon-user", fields: [ {"fieldname": "first_name", "label": __("First Name"), "fieldtype": "Data", reqd:1}, {"fieldname": "last_name", "label": __("Last Name"), "fieldtype": "Data", reqd:1}, {"fieldname": "email", "label": __("Email Id"), "fieldtype": "Data", reqd:1, "description":"Your Login Id", "options":"Email"}, {"fieldname": "password", "label": __("Password"), "fieldtype": "Password", reqd:1}, {fieldtype:"Attach Image", fieldname:"attach_user", label:"Attach Your User..."}, ], help: __('The first user will become the System Manager (you can change that later).'), onload: function(slide) { if(user!=="Administrator") { slide.form.fields_dict.password.$wrapper.toggle(false); slide.form.fields_dict.email.$wrapper.toggle(false); slide.form.fields_dict.first_name.set_input(frappe.boot.user.first_name); slide.form.fields_dict.last_name.set_input(frappe.boot.user.last_name); delete slide.form.fields_dict.email; delete slide.form.fields_dict.password; } } }, // Organization { title: __("The Organization"), icon: "icon-building", fields: [ {fieldname:'company_name', label: __('Company Name'), fieldtype:'Data', reqd:1, placeholder: 'e.g. "My Company LLC"'}, {fieldname:'company_abbr', label: __('Company Abbreviation'), fieldtype:'Data', placeholder:'e.g. "MC"',reqd:1}, {fieldname:'fy_start_date', label:'Financial Year Start Date', fieldtype:'Date', description:'Your financial year begins on', reqd:1}, {fieldname:'fy_end_date', label:'Financial Year End Date', fieldtype:'Date', description:'Your financial year ends on', reqd:1}, {fieldname:'company_tagline', label: __('What does it do?'), fieldtype:'Data', placeholder:'e.g. "Build tools for builders"', reqd:1}, ], help: __('The name of your company for which you are setting up this system.'), onload: function(slide) { slide.get_input("company_name").on("change", function() { var parts = slide.get_input("company_name").val().split(" "); var abbr = $.map(parts, function(p) { return p ? p.substr(0,1) : null }).join(""); slide.get_input("company_abbr").val(abbr.toUpperCase()); }).val(frappe.boot.sysdefaults.company_name || "").trigger("change"); slide.get_input("fy_start_date").on("change", function() { var year_end_date = frappe.datetime.add_days(frappe.datetime.add_months( frappe.datetime.user_to_obj(slide.get_input("fy_start_date").val()), 12), -1); slide.get_input("fy_end_date").val(frappe.datetime.obj_to_user(year_end_date)); }); } }, // Country { title: __("Country, Timezone and Currency"), icon: "icon-flag", fields: [ {fieldname:'country', label: __('Country'), reqd:1, options: "", fieldtype: 'Select'}, {fieldname:'currency', label: __('Default Currency'), reqd:1, options: "", fieldtype: 'Select'}, {fieldname:'timezone', label: __('Time Zone'), reqd:1, options: "", fieldtype: 'Select'}, {fieldname:'chart_of_accounts', label: __('Chart of Accounts'), options: "", fieldtype: 'Select'} ], help: __('Select your home country and check the timezone and currency.'), onload: function(slide, form) { frappe.call({ method:"frappe.country_info.get_country_timezone_info", callback: function(data) { erpnext.country_info = data.message.country_info; erpnext.all_timezones = data.message.all_timezones; slide.get_input("country").empty() .add_options([""].concat(keys(erpnext.country_info).sort())); slide.get_input("currency").empty() .add_options(frappe.utils.unique([""].concat($.map(erpnext.country_info, function(opts, country) { return opts.currency; }))).sort()); slide.get_input("timezone").empty() .add_options([""].concat(erpnext.all_timezones)); } }) slide.get_input("country").on("change", function() { var country = slide.get_input("country").val(); var $timezone = slide.get_input("timezone"); $timezone.empty(); // add country specific timezones first if(country){ var timezone_list = erpnext.country_info[country].timezones || []; $timezone.add_options(timezone_list.sort()); slide.get_input("currency").val(erpnext.country_info[country].currency); } // 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)); // get country specific chart of accounts frappe.call({ method: "erpnext.accounts.doctype.chart_of_accounts.chart_of_accounts.get_charts_for_country", args: {"country": country}, callback: function(r) { if(r.message) slide.get_input("chart_of_accounts").empty() .add_options([""].concat(r.message)); } }) }); } }, // Logo { icon: "icon-bookmark", title: __("Logo and Letter Heads"), help: __('Upload your letter head and logo - you can edit them later.'), fields: [ {fieldtype:"Attach Image", fieldname:"attach_letterhead", label:"Attach Letterhead..."}, {fieldtype:"Attach Image", fieldname:"attach_logo", label:"Attach Logo..."}, ], }, // Taxes { icon: "icon-money", "title": __("Add Taxes"), "help": __("List your tax heads (e.g. VAT, Excise) (upto 3) and their standard rates. This will create a standard template, you can edit and add more later."), "fields": [], }, // Customers { icon: "icon-group", "title": __("Your Customers"), "help": __("List a few of your customers. They could be organizations or individuals."), "fields": [], }, // Items to Sell { icon: "icon-barcode", "title": __("Your Products or Services"), "help": __("List your products or services that you sell to your customers. Make sure to check the Item Group, Unit of Measure and other properties when you start."), "fields": [], }, // Suppliers { icon: "icon-group", "title": __("Your Suppliers"), "help": __("List a few of your suppliers. They could be organizations or individuals."), "fields": [], }, // Items to Buy { icon: "icon-barcode", "title": __("Products or Services You Buy"), "help": __("List a few products or services you buy from your suppliers or vendors. If these are same as your products, then do not add them."), "fields": [], }, ] } // taxes for(var i=1; i<4; i++) { wizard_settings.slides[4].fields = wizard_settings.slides[4].fields.concat([ {fieldtype:"Data", fieldname:"tax_"+ i, label:"Tax " + 1, placeholder:"e.g. VAT"}, {fieldtype:"Column Break"}, {fieldtype:"Data", fieldname:"tax_rate_i", label:"Rate (%)", placeholder:"e.g. 5"}, {fieldtype:"Section Break"}, ]) } // customers for(var i=1; i<6; i++) { wizard_settings.slides[5].fields = wizard_settings.slides[5].fields.concat([ {fieldtype:"Data", fieldname:"customer_" + i, label:"Customer " + i, placeholder:"Customer Name"}, {fieldtype:"Column Break"}, {fieldtype:"Data", fieldname:"customer_contact_" + i, label:"Contact", placeholder:"Contact Name"}, {fieldtype:"Section Break"} ]) } // products for(var i=1; i<6; i++) { wizard_settings.slides[6].fields = wizard_settings.slides[6].fields.concat([ {fieldtype:"Data", fieldname:"item_" + i, label:"Item " + i, placeholder:"A Product or Service"}, {fieldtype:"Column Break"}, {fieldtype:"Attach", fieldname:"item_img_" + i, label:"Attach Image..."}, {fieldtype:"Section Break"}, {fieldtype:"Column Break"}, {fieldtype:"Select", label:"Group", fieldname:"item_group_" + i, options:["Products", "Services", "Raw Material", "Sub Assemblies"]}, {fieldtype:"Column Break"}, {fieldtype:"Select", fieldname:"item_uom_" + i, label:"UOM", options:["Unit", "Nos", "Box", "Pair", "Kg", "Set", "Hour", "Minute"]}, {fieldtype:"Section Break"} ]) } for(var i=1; i<6; i++) { wizard_settings.slides[7].fields = wizard_settings.slides[7].fields.concat([ {fieldtype:"Data", fieldname:"supplier_" + i, label:"Supplier " + i, placeholder:"Supplier Name"}, {fieldtype:"Column Break"}, {fieldtype:"Data", fieldname:"supplier_contact_" + i, label:"Contact", placeholder:"Contact Name"}, {fieldtype:"Section Break"} ]) } for(var i=1; i<6; i++) { wizard_settings.slides[8].fields = wizard_settings.slides[8].fields.concat([ {fieldtype:"Data", fieldname:"item_buy_" + i, label:"Item " + i, placeholder:"A Product or Service"}, {fieldtype:"Column Break"}, {fieldtype:"Section Break"}, {fieldtype:"Column Break"}, {fieldtype:"Select", fieldname:"item_buy_group_" + i, label: "Group", options:["Raw Material", "Consumable", "Sub Assemblies", "Services", "Products"]}, {fieldtype:"Column Break"}, {fieldtype:"Select", fieldname:"item_buy_uom_" + i, label: "UOM", options:["Unit", "Nos", "Box", "Pair", "Kg", "Set", "Hour", "Minute"]}, {fieldtype:"Section Break"}, ]) } erpnext.wiz = new frappe.wiz.Wizard(wizard_settings) } frappe.pages['setup-wizard'].onshow = function(wrapper) { if(frappe.get_route()[1]) erpnext.wiz.show(frappe.get_route()[1]); } frappe.provide("frappe.wiz"); frappe.wiz.Wizard = Class.extend({ init: function(opts) { $.extend(this, opts); this.slides = this.slides; this.slide_dict = {}; this.show_welcome(); }, get_message: function(html) { return $(repl('%(help)s
\