From 967f8e72fcc122e60973c35bd4316107e21358dd Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 18 Nov 2014 20:37:21 +0100 Subject: [PATCH] Edit Organization switches work, roughly --- Console/Console.cs | 4 +- Console/Console.csproj | 1 - .../OrganizationFinancialAccounts.cs | 7 + Logic/Structure/Organization.cs | 8 +- Site5/Pages/v5/Admin/EditOrganization.aspx | 74 +++++- Site5/Pages/v5/Admin/EditOrganization.aspx.cs | 244 +++++++++++++++++- 6 files changed, 320 insertions(+), 18 deletions(-) diff --git a/Console/Console.cs b/Console/Console.cs index 5f674350..de83cce8 100644 --- a/Console/Console.cs +++ b/Console/Console.cs @@ -534,7 +534,7 @@ namespace Swarmops //PirateWeb.Utility.Special.Sweden.SupportDatabase.CloseDelayWarnings(); - NewsletterChecker.Run(); + // NewsletterChecker.Run(); } @@ -1155,7 +1155,7 @@ namespace Swarmops private static void RunForumCheck() { - SwedishForumMemberCheck.Run(); + // SwedishForumMemberCheck.Run(); } private static void RunRepaidTest() diff --git a/Console/Console.csproj b/Console/Console.csproj index 24ffb6e2..b65b9fd6 100644 --- a/Console/Console.csproj +++ b/Console/Console.csproj @@ -59,7 +59,6 @@ - diff --git a/Logic/Financial/OrganizationFinancialAccounts.cs b/Logic/Financial/OrganizationFinancialAccounts.cs index 38fc4c71..971e623c 100644 --- a/Logic/Financial/OrganizationFinancialAccounts.cs +++ b/Logic/Financial/OrganizationFinancialAccounts.cs @@ -100,11 +100,13 @@ namespace Swarmops.Logic.Financial public FinancialAccount AssetsBitcoinCold { get { return this[OrganizationFinancialAccountType.AssetsBitcoinCold]; } + set { this[OrganizationFinancialAccountType.AssetsBitcoinCold] = value; } } public FinancialAccount AssetsBitcoinHot { get { return this[OrganizationFinancialAccountType.AssetsBitcoinHot]; } + set { this[OrganizationFinancialAccountType.AssetsBitcoinHot] = value; } } public FinancialAccount AssetsOutboundInvoices @@ -120,11 +122,13 @@ namespace Swarmops.Logic.Financial public FinancialAccount AssetsPaypal { get { return this[OrganizationFinancialAccountType.AssetsPaypal]; } + set { this[OrganizationFinancialAccountType.AssetsPaypal] = value; } } public FinancialAccount AssetsVatInbound { get { return this[OrganizationFinancialAccountType.AssetsVatInbound]; } + set { this[OrganizationFinancialAccountType.AssetsVatInbound] = value; } } public FinancialAccount CostsBankFees @@ -140,6 +144,7 @@ namespace Swarmops.Logic.Financial public FinancialAccount CostsCurrencyFluctuations { get { return this[OrganizationFinancialAccountType.CostsCurrencyFluctuations]; } + set { this[OrganizationFinancialAccountType.CostsCurrencyFluctuations] = value; } } public FinancialAccount CostsInfrastructure @@ -185,6 +190,7 @@ namespace Swarmops.Logic.Financial public FinancialAccount DebtsVatOutbound { get { return this[OrganizationFinancialAccountType.DebtsVatOutbound]; } + set { this[OrganizationFinancialAccountType.DebtsVatOutbound] = value; } } public FinancialAccount DebtsEarmarkedVirtualBanking @@ -205,6 +211,7 @@ namespace Swarmops.Logic.Financial public FinancialAccount IncomeCurrencyFluctuations { get { return this[OrganizationFinancialAccountType.IncomeCurrencyFluctuations]; } + set { this[OrganizationFinancialAccountType.IncomeCurrencyFluctuations] = value; } } public FinancialAccount IncomeDonations diff --git a/Logic/Structure/Organization.cs b/Logic/Structure/Organization.cs index 02c70974..1d0c225e 100644 --- a/Logic/Structure/Organization.cs +++ b/Logic/Structure/Organization.cs @@ -225,8 +225,8 @@ namespace Swarmops.Logic.Structure // FinancialAccount.Create(this, "Bitcoin Holdings (Hot)", FinancialAccountType.Asset, null); //FinancialAccounts[OrganizationFinancialAccountType.AssetsBitcoinCold] = // FinancialAccount.Create(this, "Bitcoin Cold Storage", FinancialAccountType.Asset, null); - FinancialAccounts[OrganizationFinancialAccountType.AssetsVatInbound] = - FinancialAccount.Create(this, "Inbound Value Added Tax", FinancialAccountType.Asset, null); + //FinancialAccounts[OrganizationFinancialAccountType.AssetsVatInbound] = + // FinancialAccount.Create(this, "Inbound Value Added Tax", FinancialAccountType.Asset, null); FinancialAccounts[OrganizationFinancialAccountType.CostsAllocatedFunds] = FinancialAccount.Create(this, "Allocated funds", FinancialAccountType.Cost, null); FinancialAccounts[OrganizationFinancialAccountType.CostsBankFees] = @@ -247,8 +247,8 @@ namespace Swarmops.Logic.Structure FinancialAccount.Create(this, "Salaries Due", FinancialAccountType.Debt, null); FinancialAccounts[OrganizationFinancialAccountType.DebtsTax] = FinancialAccount.Create(this, "Taxes Due", FinancialAccountType.Debt, null); - FinancialAccounts[OrganizationFinancialAccountType.DebtsVatOutbound] = - FinancialAccount.Create(this, "Outbound Value Added Tax", FinancialAccountType.Debt, null); + //FinancialAccounts[OrganizationFinancialAccountType.DebtsVatOutbound] = + // FinancialAccount.Create(this, "Outbound Value Added Tax", FinancialAccountType.Debt, null); FinancialAccounts[OrganizationFinancialAccountType.IncomeDonations] = FinancialAccount.Create(this, "Donations", FinancialAccountType.Income, null); diff --git a/Site5/Pages/v5/Admin/EditOrganization.aspx b/Site5/Pages/v5/Admin/EditOrganization.aspx index 89198f70..4cfefccc 100644 --- a/Site5/Pages/v5/Admin/EditOrganization.aspx +++ b/Site5/Pages/v5/Admin/EditOrganization.aspx @@ -11,14 +11,74 @@ $('.EditCheck').switchbutton({ checkedLabel: '<%=Resources.Global.Global_On.ToUpperInvariant() %>', uncheckedLabel: '<%=Resources.Global.Global_Off.ToUpperInvariant() %>', - }).change(function() { + }).change(function () { + + if (suppressSwitchResponse) { + return; + } + $('#divUseAccountPlan').slideDown().fadeIn(); + + var jsonData = {}; + jsonData.switchName = $(this).attr("rel"); + jsonData.switchValue = $(this).prop('checked'); + + $.ajax({ + type: "POST", + url: "EditOrganization.aspx/SwitchToggled", + data: $.toJSON(jsonData), + contentType: "application/json; charset=utf-8", + dataType: "json", + success: function (msg) { + if (msg.d.Success) { + alertify.log(msg.d.DisplayMessage); + } else { + // do nothing + } + }, + error: function (msg) { + // TODO: Reset switch, protest server unreachable + } + + }); }); + + // Ask for initial data + + $.ajax({ + type: "POST", + url: "EditOrganization.aspx/GetInitialData", + data: "{}", + contentType: "application/json; charset=utf-8", + dataType: "json", + success: function (msg) { + initializeSettings(msg.d); + }, + error: function (msg) { + // TODO: try again? bail out? + alert("The server did not respond with the organization's current settings."); + } + + }); + }); + function initializeSettings(orgSettings) { + console.log(orgSettings); + suppressSwitchResponse = true; + $("#CheckEnableBitcoinCold").prop("checked", orgSettings.AccountBitcoinCold).change(); + $("#CheckEnableBitcoinHot").prop("checked", orgSettings.AccountBitcoinHot).change(); + $("#CheckEnablePaypal").prop("checked", orgSettings.AccountPaypal).change(); + $("#CheckEnableForex").prop("checked", orgSettings.AccountsForex).change(); + $("#CheckEnableVat").prop("checked", orgSettings.AccountsVat).change(); + suppressSwitchResponse = false; + } + + var suppressSwitchResponse = false; + -