2013-10-04 12:18:05 +00:00
wn . pages [ 'setup-wizard' ] . onload = function ( wrapper ) {
2013-10-08 12:29:11 +00:00
if ( sys _defaults . company ) {
wn . set _route ( "desktop" ) ;
return ;
}
2013-10-07 12:52:29 +00:00
$ ( ".navbar:first" ) . toggle ( false ) ;
2013-10-08 12:29:11 +00:00
$ ( "body" ) . css ( { "padding-top" : "30px" } ) ;
2013-10-07 12:52:29 +00:00
2013-10-04 12:18:05 +00:00
erpnext . wiz = new wn . wiz . Wizard ( {
2013-10-08 12:29:11 +00:00
page _name : "setup-wizard" ,
2013-10-04 12:18:05 +00:00
parent : wrapper ,
2013-10-08 12:29:11 +00:00
on _complete : function ( wiz ) {
var values = wiz . get _values ( ) ;
wiz . show _working ( ) ;
wn . call ( {
method : "setup.page.setup_wizard.setup_wizard.setup_account" ,
args : values ,
callback : function ( r ) {
if ( r . exc ) {
var d = msgprint ( wn . _ ( "There were errors." ) ) ;
d . custom _onhide = function ( ) {
2013-10-09 10:38:54 +00:00
wn . set _route ( erpnext . wiz . page _name , "0" ) ;
2013-10-08 12:29:11 +00:00
}
} else {
wiz . show _complete ( ) ;
setTimeout ( function ( ) {
if ( user === "Administrator" ) {
2013-10-08 12:53:05 +00:00
msgprint ( wn . _ ( "Login with your new User ID" ) + ":" + values . email ) ;
2013-10-08 12:29:11 +00:00
setTimeout ( function ( ) {
wn . app . logout ( ) ;
} , 2000 ) ;
} else {
window . location = "app.html" ;
}
} , 2000 ) ;
}
}
} )
} ,
2013-10-04 12:18:05 +00:00
title : wn . _ ( "ERPNext Setup Guide" ) ,
2013-10-08 12:29:11 +00:00
welcome _html : ' < h1 class = "text-muted text-center" > < i class = "icon-magic" > < / i > < / h 1 > \
< h2 class = "text-center" > '+wn._(' ERPNext Setup ')+' < / h 2 > \
< p class = "text-center" > ' +
wn . _ ( '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!' ) +
'</p>' ,
working _html : ' < h3 class = "text-muted text-center" > < i class = "icon-refresh icon-spin" > < / i > < / h 3 > \
< h2 class = "text-center" > '+wn._(' Setting up ... ')+' < / h 2 > \
< p class = "text-center" > ' +
wn . _ ( 'Sit tight while your system is being setup. This may take a few moments.' ) +
'</p>' ,
complete _html : ' < h1 class = "text-muted text-center" > < i class = "icon-thumbs-up" > < / i > < / h 1 > \
< h2 class = "text-center" > '+wn._(' Setup Complete ! ')+' < / h 2 > \
< p class = "text-center" > ' +
wn . _ ( 'Your setup is complete. Refreshing...' ) +
'</p>' ,
2013-10-04 12:18:05 +00:00
slides : [
// User
{
2013-10-07 12:52:29 +00:00
title : wn . _ ( "The First User: You" ) ,
icon : "icon-user" ,
2013-10-04 12:18:05 +00:00
fields : [
{ "fieldname" : "first_name" , "label" : wn . _ ( "First Name" ) , "fieldtype" : "Data" , reqd : 1 } ,
{ "fieldname" : "last_name" , "label" : wn . _ ( "Last Name" ) , "fieldtype" : "Data" , reqd : 1 } ,
2013-10-09 10:38:54 +00:00
{ "fieldname" : "email" , "label" : wn . _ ( "Email Id" ) , "fieldtype" : "Data" , reqd : 1 , "description" : "Your Login Id" } ,
{ "fieldname" : "password" , "label" : wn . _ ( "Password" ) , "fieldtype" : "Password" , reqd : 1 } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Attach Image" , fieldname : "attach_profile" , label : "Attach Your Profile..." } ,
2013-10-04 12:18:05 +00:00
] ,
2013-10-08 12:29:11 +00:00
help : wn . _ ( '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 _id . $wrapper . toggle ( false ) ;
delete slide . form . fields _dict . email ;
delete slide . form . fields _dict . password ;
}
}
2013-10-04 12:18:05 +00:00
} ,
// Organization
{
title : wn . _ ( "The Organization" ) ,
2013-10-07 12:52:29 +00:00
icon : "icon-building" ,
2013-10-04 12:18:05 +00:00
fields : [
{ fieldname : 'company_name' , label : wn . _ ( 'Company Name' ) , fieldtype : 'Data' , reqd : 1 ,
placeholder : 'e.g. "My Company LLC"' } ,
{ fieldname : 'company_abbr' , label : wn . _ ( 'Company Abbreviation' ) , fieldtype : 'Data' ,
placeholder : 'e.g. "MC"' , reqd : 1 } ,
2013-10-08 12:29:11 +00:00
{ fieldname : 'fy_start' , label : 'Financial Year Start Date' , fieldtype : 'Select' ,
description : 'Your financial year begins on' , reqd : 1 ,
options : [ '' , '1st Jan' , '1st Apr' , '1st Jul' , '1st Oct' ] } ,
2013-10-04 12:18:05 +00:00
{ fieldname : 'company_tagline' , label : wn . _ ( 'What does it do?' ) , fieldtype : 'Data' ,
2013-10-08 12:29:11 +00:00
placeholder : 'e.g. "Build tools for builders"' , reqd : 1 } ,
2013-10-04 12:18:05 +00:00
] ,
help : wn . _ ( '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 ( ) ) ;
} ) ;
}
} ,
// Country
{
title : wn . _ ( "Country, Timezone and Currency" ) ,
2013-10-07 12:52:29 +00:00
icon : "icon-flag" ,
2013-10-04 12:18:05 +00:00
fields : [
{ fieldname : 'country' , label : wn . _ ( 'Country' ) , reqd : 1 ,
options : "" , fieldtype : 'Select' } ,
{ fieldname : 'currency' , label : wn . _ ( 'Default Currency' ) , reqd : 1 ,
options : "" , fieldtype : 'Select' } ,
{ fieldname : 'timezone' , label : wn . _ ( 'Time Zone' ) , reqd : 1 ,
options : "" , fieldtype : 'Select' } ,
] ,
help : wn . _ ( 'Select your home country and check the timezone and currency.' ) ,
onload : function ( slide , form ) {
wn . call ( {
method : "webnotes.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 ( wn . 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 ) ) ;
} ) ;
}
} ,
// Logo
{
2013-10-07 12:52:29 +00:00
icon : "icon-bookmark" ,
2013-10-04 12:18:05 +00:00
title : wn . _ ( "Logo and Letter Heads" ) ,
help : wn . _ ( 'Upload your letter head and logo - you can edit them later.' ) ,
2013-10-07 12:52:29 +00:00
fields : [
{ fieldtype : "Attach Image" , fieldname : "attach_letterhead" , label : "Attach Letterhead..." } ,
{ fieldtype : "Attach Image" , fieldname : "attach_logo" , label : "Attach Logo..." } ,
] ,
2013-10-04 12:18:05 +00:00
} ,
// Taxes
{
2013-10-07 12:52:29 +00:00
icon : "icon-money" ,
2013-10-04 12:18:05 +00:00
"title" : wn . _ ( "Add Taxes" ) ,
"help" : wn . _ ( "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" : [
{ fieldtype : "Data" , fieldname : "tax_1" , label : "Tax 1" , placeholder : "e.g. VAT" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Column Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "tax_rate_1" , label : "Rate (%)" , placeholder : "e.g. 5" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Section Break" } ,
{ fieldtype : "Data" , fieldname : "tax_2" , label : "Tax 2" , placeholder : "e.g. Customs Duty" } ,
{ fieldtype : "Column Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "tax_rate_2" , label : "Rate (%)" , placeholder : "e.g. 5" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Section Break" } ,
{ fieldtype : "Data" , fieldname : "tax_3" , label : "Tax 3" , placeholder : "e.g. Excise" } ,
{ fieldtype : "Column Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "tax_rate_3" , label : "Rate (%)" , placeholder : "e.g. 5" } ,
2013-10-04 12:18:05 +00:00
] ,
2013-10-07 12:52:29 +00:00
} ,
2013-10-04 12:18:05 +00:00
2013-10-07 12:52:29 +00:00
// Items to Sell
{
icon : "icon-barcode" ,
"title" : wn . _ ( "Your Products or Services" ) ,
2013-10-08 12:29:11 +00:00
"help" : wn . _ ( "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." ) ,
2013-10-07 12:52:29 +00:00
"fields" : [
{ fieldtype : "Data" , fieldname : "item_1" , label : "Item 1" , placeholder : "A Product or Service" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Column Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Attach" , fieldname : "item_img_1" , label : "Attach Image..." } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Section Break" } ,
2013-10-09 10:38:54 +00:00
{ fieldtype : "Column Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_group_1" , options : [ "Products" , "Services" , "Raw Material" , "Sub Assemblies" ] } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_uom_1" , options : [ "Unit" , "Nos" , "Box" , "Pair" , "Kg" , "Set" , "Hour" , "Minute" ] } ,
{ fieldtype : "Section Break" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Data" , fieldname : "item_2" , label : "Item 2" , placeholder : "A Product or Service" } ,
{ fieldtype : "Column Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Attach" , fieldname : "item_img_2" , label : "Attach Image..." } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Section Break" } ,
2013-10-09 10:38:54 +00:00
{ fieldtype : "Column Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_group_2" , options : [ "Products" , "Services" , "Raw Material" , "Sub Assemblies" ] } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_uom_2" , options : [ "Unit" , "Nos" , "Box" , "Pair" , "Kg" , "Set" , "Hour" , "Minute" ] } ,
{ fieldtype : "Section Break" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Data" , fieldname : "item_3" , label : "Item 3" , placeholder : "A Product or Service" } ,
{ fieldtype : "Column Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Attach" , fieldname : "item_img_3" , label : "Attach Image..." } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Section Break" } ,
2013-10-09 10:38:54 +00:00
{ fieldtype : "Column Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_group_3" , options : [ "Products" , "Services" , "Raw Material" , "Sub Assemblies" ] } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_uom_3" , options : [ "Unit" , "Nos" , "Box" , "Pair" , "Kg" , "Set" , "Hour" , "Minute" ] } ,
{ fieldtype : "Section Break" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Data" , fieldname : "item_4" , label : "Item 4" , placeholder : "A Product or Service" } ,
{ fieldtype : "Column Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Attach" , fieldname : "item_img_4" , label : "Attach Image..." } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Section Break" } ,
2013-10-09 10:38:54 +00:00
{ fieldtype : "Column Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_group_4" , options : [ "Products" , "Services" , "Raw Material" , "Sub Assemblies" ] } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_uom_4" , options : [ "Unit" , "Nos" , "Box" , "Pair" , "Kg" , "Set" , "Hour" , "Minute" ] } ,
{ fieldtype : "Section Break" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Data" , fieldname : "item_5" , label : "Item 5" , placeholder : "A Product or Service" } ,
{ fieldtype : "Column Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Attach" , fieldname : "item_img_5" , label : "Attach Image..." } ,
2013-10-09 10:38:54 +00:00
{ fieldtype : "Section Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_group_5" , options : [ "Products" , "Services" , "Raw Material" , "Sub Assemblies" ] } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_uom_5" , options : [ "Unit" , "Nos" , "Box" , "Pair" , "Kg" , "Set" , "Hour" , "Minute" ] } ,
2013-10-07 12:52:29 +00:00
] ,
} ,
// Items to Buy
{
icon : "icon-barcode" ,
"title" : wn . _ ( "Products or Services You Buy" ) ,
"help" : wn . _ ( "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" : [
{ fieldtype : "Data" , fieldname : "item_buy_1" , label : "Item 1" , placeholder : "A Product or Service" } ,
2013-10-09 10:38:54 +00:00
{ fieldtype : "Section Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_buy_group_1" , options : [ "Raw Material" , "Consumable" , "Sub Assemblies" , "Services" , "Products" ] } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_buy_uom_1" , options : [ "Unit" , "Nos" , "Box" , "Pair" , "Kg" , "Set" , "Hour" , "Minute" ] } ,
{ fieldtype : "Section Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "item_buy_2" , label : "Item 2" , placeholder : "A Product or Service" } ,
2013-10-09 10:38:54 +00:00
{ fieldtype : "Section Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_buy_group_2" , options : [ "Raw Material" , "Consumable" , "Sub Assemblies" , "Services" , "Products" ] } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_buy_uom_2" , options : [ "Unit" , "Nos" , "Box" , "Pair" , "Kg" , "Set" , "Hour" , "Minute" ] } ,
{ fieldtype : "Section Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "item_buy_3" , label : "Item 3" , placeholder : "A Product or Service" } ,
2013-10-09 10:38:54 +00:00
{ fieldtype : "Section Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_buy_group_3" , options : [ "Raw Material" , "Consumable" , "Sub Assemblies" , "Services" , "Products" ] } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_buy_uom_3" , options : [ "Unit" , "Nos" , "Box" , "Pair" , "Kg" , "Set" , "Hour" , "Minute" ] } ,
{ fieldtype : "Section Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "item_buy_4" , label : "Item 4" , placeholder : "A Product or Service" } ,
2013-10-09 10:38:54 +00:00
{ fieldtype : "Section Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_buy_group_4" , options : [ "Raw Material" , "Consumable" , "Sub Assemblies" , "Services" , "Products" ] } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_buy_uom_4" , options : [ "Unit" , "Nos" , "Box" , "Pair" , "Kg" , "Set" , "Hour" , "Minute" ] } ,
{ fieldtype : "Section Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "item_buy_5" , label : "Item 5" , placeholder : "A Product or Service" } ,
2013-10-09 10:38:54 +00:00
{ fieldtype : "Section Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_buy_group_5" , options : [ "Raw Material" , "Consumable" , "Sub Assemblies" , "Services" , "Products" ] } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_buy_uom_5" , options : [ "Unit" , "Nos" , "Box" , "Pair" , "Kg" , "Set" , "Hour" , "Minute" ] } ,
2013-10-07 12:52:29 +00:00
] ,
} ,
// Customers
{
icon : "icon-group" ,
"title" : wn . _ ( "Your Customers" ) ,
"help" : wn . _ ( "List a few of your customers. They could be organizations or individuals." ) ,
"fields" : [
{ fieldtype : "Data" , fieldname : "customer_1" , label : "Customer 1" , placeholder : "Customer Name" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "customer_contact_1" , label : "" , placeholder : "Contact Name" } ,
{ fieldtype : "Section Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "customer_2" , label : "Customer 2" , placeholder : "Customer Name" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "customer_contact_2" , label : "" , placeholder : "Contact Name" } ,
{ fieldtype : "Section Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "customer_3" , label : "Customer 3" , placeholder : "Customer Name" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "customer_contact_3" , label : "" , placeholder : "Contact Name" } ,
{ fieldtype : "Section Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "customer_4" , label : "Customer 4" , placeholder : "Customer Name" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "customer_contact_4" , label : "" , placeholder : "Contact Name" } ,
{ fieldtype : "Section Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "customer_5" , label : "Customer 5" , placeholder : "Customer Name" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "customer_contact_5" , label : "" , placeholder : "Contact Name" } ,
2013-10-07 12:52:29 +00:00
] ,
} ,
// Suppliers
{
icon : "icon-group" ,
"title" : wn . _ ( "Your Suppliers" ) ,
"help" : wn . _ ( "List a few of your suppliers. They could be organizations or individuals." ) ,
"fields" : [
{ fieldtype : "Data" , fieldname : "supplier_1" , label : "Supplier 1" , placeholder : "Supplier Name" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "supplier_contact_1" , label : "" , placeholder : "Contact Name" } ,
{ fieldtype : "Section Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "supplier_2" , label : "Supplier 2" , placeholder : "Supplier Name" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "supplier_contact_2" , label : "" , placeholder : "Contact Name" } ,
{ fieldtype : "Section Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "supplier_3" , label : "Supplier 3" , placeholder : "Supplier Name" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "supplier_contact_3" , label : "" , placeholder : "Contact Name" } ,
{ fieldtype : "Section Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "supplier_4" , label : "Supplier 4" , placeholder : "Supplier Name" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "supplier_contact_4" , label : "" , placeholder : "Contact Name" } ,
{ fieldtype : "Section Break" } ,
2013-10-07 12:52:29 +00:00
{ fieldtype : "Data" , fieldname : "supplier_5" , label : "Supplier 5" , placeholder : "Supplier Name" } ,
2013-10-08 12:29:11 +00:00
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "supplier_contact_5" , label : "" , placeholder : "Contact Name" } ,
2013-10-07 12:52:29 +00:00
] ,
}
2013-10-04 12:18:05 +00:00
]
} )
}
wn . pages [ 'setup-wizard' ] . onshow = function ( wrapper ) {
2013-10-08 12:29:11 +00:00
if ( wn . get _route ( ) [ 1 ] )
erpnext . wiz . show ( wn . get _route ( ) [ 1 ] ) ;
2013-10-04 12:18:05 +00:00
}
wn . provide ( "wn.wiz" ) ;
wn . wiz . Wizard = Class . extend ( {
init : function ( opts ) {
$ . extend ( this , opts ) ;
2013-10-08 12:29:11 +00:00
this . slides = this . slides ;
2013-10-04 12:18:05 +00:00
this . slide _dict = { } ;
2013-10-08 12:29:11 +00:00
this . show _welcome ( ) ;
} ,
get _message : function ( html ) {
return $ ( repl ( ' < div class = "panel panel-default" style = "max-width: 400px; margin: auto;" > \
< div class = "panel-body" style = "padding: 40px;" > % ( html ) s < / d i v > \
< / d i v > ' , { h t m l : h t m l } ) )
} ,
show _welcome : function ( ) {
if ( this . $welcome )
return ;
var me = this ;
this . $welcome = this . get _message ( this . welcome _html +
'<br><p class="text-center"><button class="btn btn-primary">' + wn . _ ( "Start" ) + '</button></p>' )
. appendTo ( this . parent ) ;
this . $welcome . find ( ".btn" ) . click ( function ( ) {
me . $welcome . toggle ( false ) ;
me . welcomed = true ;
wn . set _route ( me . page _name , "0" ) ;
} )
this . current _slide = { "$wrapper" : this . $welcome } ;
} ,
show _working : function ( ) {
this . hide _current _slide ( ) ;
wn . set _route ( this . page _name ) ;
this . current _slide = { "$wrapper" : this . get _message ( this . working _html ) . appendTo ( this . parent ) } ;
} ,
show _complete : function ( ) {
this . hide _current _slide ( ) ;
this . current _slide = { "$wrapper" : this . get _message ( this . complete _html ) . appendTo ( this . parent ) } ;
2013-10-04 12:18:05 +00:00
} ,
show : function ( id ) {
2013-10-08 12:29:11 +00:00
if ( ! this . welcomed ) {
2013-10-09 10:38:54 +00:00
wn . set _route ( this . page _name ) ;
2013-10-08 12:29:11 +00:00
return ;
}
2013-10-04 12:18:05 +00:00
id = cint ( id ) ;
if ( this . current _slide && this . current _slide . id === id )
return ;
if ( ! this . slide _dict [ id ] ) {
this . slide _dict [ id ] = new wn . wiz . WizardSlide ( $ . extend ( this . slides [ id ] , { wiz : this , id : id } ) ) ;
this . slide _dict [ id ] . make ( ) ;
}
2013-10-08 12:29:11 +00:00
this . hide _current _slide ( ) ;
2013-10-04 12:18:05 +00:00
this . current _slide = this . slide _dict [ id ] ;
this . current _slide . $wrapper . toggle ( true ) ;
} ,
2013-10-08 12:29:11 +00:00
hide _current _slide : function ( ) {
if ( this . current _slide ) {
this . current _slide . $wrapper . toggle ( false ) ;
this . current _slide = null ;
}
} ,
get _values : function ( ) {
var values = { } ;
$ . each ( this . slide _dict , function ( id , slide ) {
$ . extend ( values , slide . values )
} )
return values ;
}
2013-10-04 12:18:05 +00:00
} ) ;
wn . wiz . WizardSlide = Class . extend ( {
init : function ( opts ) {
$ . extend ( this , opts ) ;
} ,
make : function ( ) {
var me = this ;
2013-10-07 12:52:29 +00:00
this . $wrapper = $ ( repl ( ' < div class = "panel panel-default" style = "margin: 0px 30px;" > \
< div class = "panel-heading" > < div class = "panel-title" > % ( main _title ) s : Step % ( step ) s < / d i v > < / d i v > \
2013-10-04 12:18:05 +00:00
< div class = "panel-body" > \
< div class = "progress" > \
< div class = "progress-bar" style = "width: %(width)s%" > < / d i v > \
< / d i v > \
< div class = "row" > \
< div class = "col-sm-6 form" > < / d i v > \
2013-10-08 12:29:11 +00:00
< div class = "col-sm-6 help" > \
< h3 > < i class = "%(icon)s text-muted" > < / i > % ( t i t l e ) s < / h 3 > < b r > \
< p class = "text-muted" > % ( help ) s < / p > \
< / d i v > \
2013-10-04 12:18:05 +00:00
< / d i v > \
< hr > \
< div class = "footer" > < / d i v > \
< / d i v > \
2013-10-07 12:52:29 +00:00
< / d i v > ' , { h e l p : t h i s . h e l p , t i t l e : t h i s . t i t l e , m a i n _ t i t l e : t h i s . w i z . t i t l e , s t e p : t h i s . i d + 1 ,
width : ( flt ( this . id + 1 ) / ( this . wiz . slides . length + 1 ) ) * 100 , icon : this . icon } ) )
2013-10-04 12:18:05 +00:00
. appendTo ( this . wiz . parent ) ;
this . body = this . $wrapper . find ( ".form" ) [ 0 ] ;
if ( this . fields ) {
this . form = new wn . ui . FieldGroup ( {
fields : this . fields ,
2013-10-07 12:52:29 +00:00
body : this . body ,
no _submit _on _enter : true
2013-10-04 12:18:05 +00:00
} ) ;
this . form . make ( ) ;
} else {
$ ( this . body ) . html ( this . html )
}
if ( this . id > 0 ) {
this . $prev = $ ( "<button class='btn btn-default'>Previous</button>" )
2013-10-08 12:29:11 +00:00
. click ( function ( ) {
wn . set _route ( me . wiz . page _name , me . id - 1 + "" ) ;
} )
2013-10-04 12:18:05 +00:00
. appendTo ( this . $wrapper . find ( ".footer" ) )
. css ( { "margin-right" : "5px" } ) ;
}
if ( this . id + 1 < this . wiz . slides . length ) {
this . $next = $ ( "<button class='btn btn-primary'>Next</button>" )
2013-10-08 12:29:11 +00:00
. click ( function ( ) {
me . values = me . form . get _values ( ) ;
if ( me . values === null )
return ;
wn . set _route ( me . wiz . page _name , me . id + 1 + "" ) ;
} )
2013-10-04 12:18:05 +00:00
. appendTo ( this . $wrapper . find ( ".footer" ) ) ;
} else {
this . $complete = $ ( "<button class='btn btn-primary'>Complete Setup</button>" )
2013-10-08 12:29:11 +00:00
. click ( function ( ) {
me . values = me . form . get _values ( ) ;
if ( me . values === null )
return ;
me . wiz . on _complete ( me . wiz ) ;
} ) . appendTo ( this . $wrapper . find ( ".footer" ) ) ;
2013-10-04 12:18:05 +00:00
}
if ( this . onload ) {
this . onload ( this ) ;
}
} ,
get _input : function ( fn ) {
return this . form . get _input ( fn ) ;
}
} )