From ad37575701f5ae508c50f74a65ae5d3e34d9e226 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 9 Feb 2012 12:48:04 +0530 Subject: [PATCH] First name and last name in setup account dialog --- .../event_updates/complete_registration.js | 32 +++++- .../home/page/event_updates/event_updates.js | 108 ------------------ 2 files changed, 26 insertions(+), 114 deletions(-) diff --git a/erpnext/home/page/event_updates/complete_registration.js b/erpnext/home/page/event_updates/complete_registration.js index 4ed3fe984bc..e7e05742211 100644 --- a/erpnext/home/page/event_updates/complete_registration.js +++ b/erpnext/home/page/event_updates/complete_registration.js @@ -1,14 +1,18 @@ // complete my company registration // -------------------------------- -pscript.complete_registration = function(is_complete) { +pscript.complete_registration = function(is_complete, profile) { if(is_complete == 'No'){ - var d = new Dialog(400, 200, "Please Complete Your Registration"); + var d = new Dialog(400, 200, "Setup your Account"); if(user != 'Administrator'){ d.no_cancel(); // Hide close image $('header').toggle(false); } d.make_body([ + ['HTML', 'Your Profile Details', '

Your Profile Details

'], + ['Data', 'First Name'], + ['Data', 'Last Name'], + ['HTML', 'Company Details', '

Create your first company

'], ['Data','Company Name','Example: Your Company LLC'], ['Data','Company Abbreviation', 'Example: YC (all your acconts will have this as a suffix)'], ['Select','Fiscal Year Start Date'], @@ -23,6 +27,16 @@ pscript.complete_registration = function(is_complete) { d.widgets['Company Name'].disabled = 1; } + if(profile && profile.length>0) { + if(profile[0].first_name && profile[0].first_name!='None') { + d.widgets['First Name'].value = profile[0].first_name; + } + + if(profile[0].last_name && profile[0].last_name!='None') { + d.widgets['Last Name'].value = profile[0].last_name; + } + } + //d.widgets['Save'].disabled = true; // disable Save button pscript.make_dialog_field(d); @@ -39,14 +53,20 @@ pscript.complete_registration = function(is_complete) { d.widgets['Company Name'].value, d.widgets['Company Abbreviation'].value, d.widgets['Fiscal Year Start Date'].value, - d.widgets['Default Currency'].value + d.widgets['Default Currency'].value, + d.widgets['First Name'].value, + d.widgets['Last Name'].value ]; $c_obj('Setup Control','setup_account',JSON.stringify(args),function(r, rt){ sys_defaults = r.message; + user_fullname = r.message.user_fullname; d.hide(); $('header').toggle(true); + page_body.wntoolbar.set_user_name(); }); + } else { + d.widgets['Save'].done_working(); } } d.show(); @@ -72,12 +92,12 @@ pscript.make_dialog_field = function(d) // --------------- pscript.validate_fields = function(d) { - var lst = ['Company Abbreviation', 'Fiscal Year Start Date', 'Default Currency']; + var lst = ['First Name', 'Company Name', 'Company Abbreviation', 'Fiscal Year Start Date', 'Default Currency']; var msg = 'Please enter the following fields'; var flag = 1; for(var i=0; iYour Profile Details'], - ['Data', 'First Name'], - ['Data', 'Last Name'], - ['HTML', 'Company Details', '

Create your first company

'], - ['Data','Company Name','Example: Your Company LLC'], - ['Data','Company Abbreviation', 'Example: YC (all your acconts will have this as a suffix)'], - ['Select','Fiscal Year Start Date'], - ['Select','Default Currency'], - ['Button','Save'], - ]); - - // if company name is set, set the input value - // and disable it - if(locals['Control Panel']['Control Panel'].company_name) { - d.widgets['Company Name'].value = locals['Control Panel']['Control Panel'].company_name; - d.widgets['Company Name'].disabled = 1; - } - - if(profile && profile.length>0) { - if(profile[0].first_name && profile[0].first_name!='None') { - d.widgets['First Name'].value = profile[0].first_name; - } - - if(profile[0].last_name && profile[0].last_name!='None') { - d.widgets['Last Name'].value = profile[0].last_name; - } - } - - //d.widgets['Save'].disabled = true; // disable Save button - pscript.make_dialog_field(d); - - // submit details - d.widgets['Save'].onclick = function() - { - d.widgets['Save'].set_working(); - - flag = pscript.validate_fields(d); - if(flag) - { - var args = [ - d.widgets['Company Name'].value, - d.widgets['Company Abbreviation'].value, - d.widgets['Fiscal Year Start Date'].value, - d.widgets['Default Currency'].value, - d.widgets['First Name'].value, - d.widgets['Last Name'].value - ]; - - $c_obj('Setup Control','setup_account',JSON.stringify(args),function(r, rt){ - sys_defaults = r.message.sys_defaults; - user_fullname = r.message.user_fullname; - d.hide(); - $ds(page_body.wntoolbar.wrapper); - $('#user_fullname').html(user_fullname + " (Profile Settings)"); - }); - } else { - d.widgets['Save'].done_working(); - } - } - d.show(); - } -} - -// make dialog fields -// ------------------ -pscript.make_dialog_field = function(d) -{ - // fiscal year format - fisc_format = d.widgets['Fiscal Year Start Date']; - add_sel_options(fisc_format, ['', '1st Jan', '1st Apr', '1st Jul', '1st Oct']); - - // default currency - 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']; - currency = d.widgets['Default Currency']; - add_sel_options(currency, currency_list); -} - - -// validate fields -// --------------- -pscript.validate_fields = function(d) -{ - var lst = ['First Name', 'Company Name', 'Company Abbreviation', 'Fiscal Year Start Date', 'Default Currency']; - var msg = 'Please enter the following fields\n'; - var flag = 1; - for(var i=0; i