diff --git a/Basic/Types/Financial/BasicFinancialAccount.cs b/Basic/Types/Financial/BasicFinancialAccount.cs index 528ce32c..296d99d5 100644 --- a/Basic/Types/Financial/BasicFinancialAccount.cs +++ b/Basic/Types/Financial/BasicFinancialAccount.cs @@ -30,7 +30,7 @@ namespace Swarmops.Basic.Types.Financial public int FinancialAccountId { get; private set; } - public string Name { get; private set; } + public string Name { get; protected set; } public int OrganizationId { get; private set; } public FinancialAccountType AccountType { get; private set; } public int OwnerPersonId { get; protected set; } diff --git a/Database/Database-Financials.cs b/Database/Database-Financials.cs index fcf8ab67..c697aaa3 100644 --- a/Database/Database-Financials.cs +++ b/Database/Database-Financials.cs @@ -678,6 +678,22 @@ namespace Swarmops.Database } } + public void SetFinancialAccountName(int financialAccountId, string name) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("SetFinancialAccountName", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "financialAccountId", financialAccountId); + AddParameterWithName(command, "name", name); + + command.ExecuteNonQuery(); + } + } + private BasicFinancialTransactionRow ReadFinancialTransactionRowFromDataReader(DbDataReader reader) { int rowId = reader.GetInt32(0); diff --git a/Logic/Financial/FinancialAccount.cs b/Logic/Financial/FinancialAccount.cs index 20ba9fe4..6aedc061 100644 --- a/Logic/Financial/FinancialAccount.cs +++ b/Logic/Financial/FinancialAccount.cs @@ -189,6 +189,17 @@ namespace Swarmops.Logic.Financial } + public string Name + { + get { return base.Name; } + set + { + // TODO: OPENEDYEAR TEST + SwarmDb.GetDatabaseForWriting().SetFinancialAccountName(this.Identity, value); + base.Name = value; + } + } + #region ITreeNode Members diff --git a/Site5/Master-v5.master b/Site5/Master-v5.master index 81fad962..a483e017 100644 --- a/Site5/Master-v5.master +++ b/Site5/Master-v5.master @@ -12,6 +12,7 @@ + diff --git a/Site5/Pages/v5/Ledgers/AccountPlan.aspx b/Site5/Pages/v5/Ledgers/AccountPlan.aspx index f695ca36..d120d477 100644 --- a/Site5/Pages/v5/Ledgers/AccountPlan.aspx +++ b/Site5/Pages/v5/Ledgers/AccountPlan.aspx @@ -37,7 +37,7 @@ }); $(".IconEdit").click(function() { - var accountId = $(this).attr("accountId"); + accountId = $(this).attr("accountId"); var accountType = accountId.substring(0,1); // A, D, I, C accountId = accountId.substring(1); @@ -64,7 +64,7 @@ if (accountType == 'I') { accountTree.combotree('reload', '/Automation/Json-FinancialAccountsTree.aspx?AccountType=Income&ExcludeId=' + accountId); } else { // C for Costs aka Expenses - accountTree.combotree('reload', '/Automation/Json-FinancialAccountsTree.aspx?AccountType=Cost&ExcludeId=' + accountId); + accountTree.combotree('reload', '/Automation/Json-FinancialAccountsTree.aspx?AccountType=Cost&ExcludeId=' + accountId); } } @@ -82,8 +82,13 @@ $('#CheckAccountActive').switchButton( {checked: msg.d.Open }); $('#CheckAccountExpensable').switchButton( {checked: msg.d.Expensable }); $('#CheckAccountAdministrative').switchButton( {checked: msg.d.Administrative }); + + modalAccountName = msg.d.AccountName; $('#TextAccountName').val(msg.d.AccountName); + + modalAccountBudget = msg.d.Budget; $('#TextAccountBudget').val(msg.d.Budget); + $('#SpanEditBalance').text(msg.d.Balance); //var parentAccountNode = accountTree.tree('find', msg.d.ParentAccountId); @@ -114,6 +119,37 @@ $('#divModalCover').fadeOut(); }); + $('#TextAccountName').blur(function() { + + var newAccountName = $('#TextAccountName').val(); + if (modalAccountName == newAccountName) { + return; // nothing changed, nothing to do + } + + $('#TextAccountName').css('background-color', '#FFFFE0'); + $.ajax({ + type: "POST", + url: "AccountPlan.aspx/SetAccountName", + data: "{'accountId': '" + escape(accountId) + "', 'name':'" + escape(newAccountName) + "'}", + contentType: "application/json; charset=utf-8", + dataType: "json", + success: function(msg) { + if (msg.d) { // saved + $('#TextAccountName').css('background-color', '#E0FFE0'); + modalAccountName = $('#TextAccountName').val(); // race condition because async. Matters? + } else { + $('#TextAccountName').css('background-color', '#FFA0A0'); + $('#TextAccountName').val(modalAccountName); + } + $('#TextAccountName').animate({ backgroundColor: "#FFFFFF" }, 250); + } + }); + }); + + $('#TextAccountBudget').blur(function() { + alert('foo'); + }); + $('.EditCheck').switchButton( { height:16, @@ -129,7 +165,11 @@ $('#divModalCover').fadeIn(); } - var currentYear = <%=DateTime.Today.Year %>; + var currentYear = <%=DateTime.Today.Year %>; + + var modalAccountName = ""; + var modalAccountBudget = ""; + var accountId = 0;