diff --git a/Logic/Financial/Payout.cs b/Logic/Financial/Payout.cs index f9ddb6ce..2c303edd 100644 --- a/Logic/Financial/Payout.cs +++ b/Logic/Financial/Payout.cs @@ -172,12 +172,6 @@ namespace Swarmops.Logic.Financial { get { - if (Identity != 0) - { - throw new InvalidOperationException ( - "Should never use ProtoIdentity after Identity has been established"); - } - string result = string.Empty; // ReSharper disable LoopCanBeConvertedToQuery diff --git a/Site5/App_GlobalResources/Global.resx b/Site5/App_GlobalResources/Global.resx index 6677d60d..0ab752b3 100644 --- a/Site5/App_GlobalResources/Global.resx +++ b/Site5/App_GlobalResources/Global.resx @@ -644,4 +644,8 @@ -- Several - select -- Displayed when multiple choice + + Options + For various page-specific checkboxes etc + \ No newline at end of file diff --git a/Site5/App_GlobalResources/Pages.Financial.resx b/Site5/App_GlobalResources/Pages.Financial.resx index b962e47b..353a574a 100644 --- a/Site5/App_GlobalResources/Pages.Financial.resx +++ b/Site5/App_GlobalResources/Pages.Financial.resx @@ -330,7 +330,7 @@ These are the various forms of costs to the organization that have passed all the hurdles for payout. They are ready to be paid out to the recipient. Here is where you check them off as being paid out (probably while having your bank open in another window). - Show open, unmatched payouts ({0:N0}) + Show open payouts ({0:N0}) These are payouts that have been ordered, but aren't yet mapped to actual transactions. Can be shown for the purpose of undoing them if they were wrong. diff --git a/Site5/Images/Icons/iconshock-balloon-no-16px-disabled.png b/Site5/Images/Icons/iconshock-balloon-no-16px-disabled.png new file mode 100644 index 00000000..95ad50d1 Binary files /dev/null and b/Site5/Images/Icons/iconshock-balloon-no-16px-disabled.png differ diff --git a/Site5/Images/Icons/iconshock-balloon-undo-16px-hot.png b/Site5/Images/Icons/iconshock-balloon-undo-16px-hot.png new file mode 100644 index 00000000..d3a2833e Binary files /dev/null and b/Site5/Images/Icons/iconshock-balloon-undo-16px-hot.png differ diff --git a/Site5/Pages/v5/Financial/Json-PayableCosts.aspx.cs b/Site5/Pages/v5/Financial/Json-PayableCosts.aspx.cs index 850f932a..2257de4d 100644 --- a/Site5/Pages/v5/Financial/Json-PayableCosts.aspx.cs +++ b/Site5/Pages/v5/Financial/Json-PayableCosts.aspx.cs @@ -16,22 +16,21 @@ namespace Swarmops.Frontend.Pages.Financial // Get all payable items - Payouts payouts = Payouts.Construct (CurrentOrganization); + Payouts prototypePayouts = Payouts.Construct (CurrentOrganization); + Payouts previousPayouts = Payouts.ForOrganization (CurrentOrganization); // gets all currently open payouts - enabled for undoing // Format as JSON and return Response.ContentType = "application/json"; - string json = FormatAsJson (payouts); + string json = "{\"rows\":[" + FormatPrototypesAsJson (prototypePayouts) + "," + FormatPreviousAsJson (previousPayouts) + "]}"; Response.Output.WriteLine (json); Response.End(); } - private string FormatAsJson (Payouts payouts) + private string FormatPrototypesAsJson (Payouts payouts) { StringBuilder result = new StringBuilder (16384); - result.Append ("{\"rows\":["); - DateTime today = DateTime.Today; foreach (Payout payout in payouts) @@ -46,8 +45,12 @@ namespace Swarmops.Frontend.Pages.Financial "\"reference\":\"{5}\"," + "\"amount\":\"{6:N2}\"," + "\"action\":\"" + - "" + - "\"", + "" + + "" + + "" + + "" + + "" + + "\"", payout.ProtoIdentity, (payout.ExpectedTransactionDate <= today ? Global.Global_ASAP @@ -63,7 +66,47 @@ namespace Swarmops.Frontend.Pages.Financial result.Remove (result.Length - 1, 1); // remove last comma - result.Append ("]}"); + return result.ToString(); + } + + private string FormatPreviousAsJson(Payouts payouts) + { + StringBuilder result = new StringBuilder(16384); + + DateTime today = DateTime.Today; + + foreach (Payout payout in payouts) + { + result.Append("{"); + result.AppendFormat( + "\"itemId\":\"{0}\"," + + "\"databaseId\":\"{8}\"," + + "\"due\":\"{1}\"," + + "\"recipient\":\"{2}\"," + + "\"bank\":\"{3}\"," + + "\"account\":\"{4}\"," + + "\"reference\":\"{5}\"," + + "\"amount\":\"{6:N2}\"," + + "\"action\":\"" + + "" + + "" + + "" + + "" + + "" + + "\"", + payout.ProtoIdentity, + payout.ExpectedTransactionDate.ToShortDateString(), + JsonSanitize(TryLocalize(payout.Recipient)), + JsonSanitize(payout.Bank), + JsonSanitize(payout.Account), + JsonSanitize(TryLocalize(payout.Reference)), + payout.AmountCents / 100.0, + payout.ProtoIdentity.Replace("|", ""), + payout.Identity); + result.Append("},"); + } + + result.Remove(result.Length - 1, 1); // remove last comma return result.ToString(); } diff --git a/Site5/Pages/v5/Financial/PayOutMoney.aspx b/Site5/Pages/v5/Financial/PayOutMoney.aspx index 06623554..24c728ad 100644 --- a/Site5/Pages/v5/Financial/PayOutMoney.aspx +++ b/Site5/Pages/v5/Financial/PayOutMoney.aspx @@ -14,19 +14,46 @@ '/Images/Abstract/ajaxloader-medium.gif', '/Images/Icons/iconshock-balloon-yes-16px-hot.png', '/Images/Icons/iconshock-balloon-no-16px-hot.png', + '/Images/Icons/iconshock-balloon-undo-16px-hot.png', '/Images/Icons/iconshock-greentick-16px.png', '/Images/Icons/iconshock-redcross-16px.png', - '/Images/Icons/undo-16px.png' + '/Images/Icons/iconshock-balloon-undo-16px.png' ]); $(document).ready(function () { + + $('#CheckOptionsShowPrevious').change(function() { + var checked = $('#CheckOptionsShowPrevious').prop('checked'); + + if (checked) { + $('.rowPrevious').show(); + } else { + $('.rowPrevious').hide(); + } + }); + $('#TablePayableCosts').datagrid( { + rowStyler: function (index, rowData) { + if (rowData.databaseId != null) { + return { class: "rowPrevious row" + rowData.itemId.replace(/\|/g, '') }; + } + + if (rowData.itemId != null) { + return { class: "row" + rowData.itemId.replace(/\|/g, '') }; + } + + return ''; + }, + onLoadSuccess: function () { $(".LocalIconApproval").attr("src", "/Images/Icons/iconshock-balloon-yes-16px.png"); + $(".LocalIconDenial").attr("src", "/Images/Icons/iconshock-balloon-no-16px-disabled.png"); $(".LocalIconApproved").attr("src", "/Images/Icons/iconshock-greentick-16px.png"); - $(".LocalIconApproved").css("display", "none"); - $(".LocalIconApproval, .LocalIconApproved").css("cursor", "pointer"); + $(".LocalIconDenied").attr("src", "/Images/Icons/iconshock-cross-16px.png"); + $(".LocalIconUndo").attr("src", "/Images/Icons/iconshock-balloon-undo-16px.png"); + $(".LocalIconApproved.LocalPrototype, .LocalIconUndo.LocalPrototype, .LocalIconDenied.LocalPrototype, .LocalIconApproval.LocalPrevious, .LocalIconDenial.LocalPrevious, .LocalIconDenied.LocalPrevious").css("display", "none"); + $(".LocalIconApproval, .LocalIconUndo").css("cursor", "pointer"); $(".LocalIconApproval").mouseover(function () { if ($(this).attr("rel") != "loading") { @@ -40,68 +67,82 @@ } }); - $(".LocalIconApproved").mouseover(function () { + $(".LocalIconUndo").mouseover(function () { if ($(this).attr("rel") != "loading") { - $(this).attr("src", "/Images/Icons/undo-16px.png"); + $(this).attr("src", "/Images/Icons/iconshock-balloon-undo-16px-hot.png"); } }); - $(".LocalIconApproved").mouseout(function () { + $(".LocalIconUndo").mouseout(function () { if ($(this).attr("rel") != "loading") { - $(this).attr("src", "/Images/Icons/iconshock-greentick-16px.png"); + $(this).attr("src", "/Images/Icons/iconshock-balloon-undo-16px.png"); } }); $(".LocalIconApproval").click(function () { if ($(this).attr("rel") != "loading") { + + var jsonData = {}; + jsonData.protoIdentity = $(this).attr("baseid"); + $(this).attr("rel", "loading"); $(this).attr("src", "/Images/Abstract/ajaxloader-medium.gif"); - $("#IconDenial" + $(this).attr("baseid").replace(/\|/g,'')).fadeTo(1000, 0.01).css("cursor", "default"); - var thisIcon = this; + $("#IconDenial" + $(this).attr("baseid").replace(/\|/g,'')).fadeTo(1000, 0.01); + $.ajax({ type: "POST", url: "/Pages/v5/Financial/PayOutMoney.aspx/ConfirmPayout", - data: "{'protoIdentity': '" + escape($(this).attr("baseid")) + "'}", + data: $.toJSON(jsonData), contentType: "application/json; charset=utf-8", dataType: "json", - success: function (msg) { - $(thisIcon).attr("databaseid", msg.d.AssignedId); - $(thisIcon).css("display", "none"); - $(thisIcon).attr("src", "/Images/Icons/iconshock-balloon-yes-16px.png"); - $(thisIcon).attr("rel", "active"); - $("#IconApproved" + $(thisIcon).attr("baseid").replace(/\|/g, '')).fadeIn(100); - alertify.success(unescape(msg.d.DisplayMessage)); - } + success: $.proxy(function (msg) { + var baseid = $(this).attr("baseid").replace(/\|/g, ''); + $(this).attr("databaseid", msg.d.AssignedId); + $(this).attr("src", "/Images/Icons/iconshock-balloon-yes-16px.png"); + $(this).attr("rel", "active"); + $(this).hide(); + $("#IconApproved" + baseid).fadeIn(100); + $("#IconDenial" + baseid).css('opacity', 1.0).hide(); + $("#IconUndo" + baseid).fadeIn(100); + $('.row' + baseid).animate({ color: "#888" }, 400); + alertify.success(msg.d.DisplayMessage); + }, this) }); } }); - $(".LocalIconApproved").click(function () { + $(".LocalIconUndo").click(function () { if ($(this).attr("rel") != "loading") { - var thisIcon = this; - + var jsonData = {}; + jsonData.databaseId = $("#IconApproval" + $(this).attr("baseid").replace(/\|/g, '')).attr("databaseid"); + $(this).attr("rel", "loading"); $(this).attr("src", "/Images/Abstract/ajaxloader-medium.gif"); + $("#IconApproved" + $(this).attr("baseid").replace(/\|/g, '')).fadeTo(1000, 0.01); + $.ajax({ type: "POST", url: "/Pages/v5/Financial/PayOutMoney.aspx/UndoPayout", - data: "{'databaseId': '" + $("#IconApproval" + $(thisIcon).attr("baseid").replace(/\|/g, '')).attr("databaseid") + "'}", + data: $.toJSON(jsonData), contentType: "application/json; charset=utf-8", dataType: "json", - success: function (msg) { + success: $.proxy(function (msg) { if (msg.d.Success) { - $(thisIcon).css("display", "none"); - $(thisIcon).attr("src", "/Images/Icons/iconshock-greentick-16px.png"); - $(thisIcon).attr("rel", ""); - $("#IconApproval" + $(thisIcon).attr("baseid").replace(/\|/g, '')).fadeIn(100); - $("#" + $(thisIcon).attr("rel"), ""); - alertify.log(unescape(msg.d.DisplayMessage)); + var baseid = $(this).attr("baseid").replace(/\|/g, ''); + $(this).attr("src", "/Images/Icons/iconshock-balloon-undo-16px.png"); + $(this).attr("rel", ""); + $(this).hide(); + $("#IconApproved" + baseid).css('opacity', 1.0).hide(); + $("#IconApproval" + baseid).fadeIn(100); + $("#IconDenial" + baseid).fadeIn(100); + $('.row' + baseid).animate({ color: "#000" }, 100); + alertify.log(msg.d.DisplayMessage); } else { - $(thisIcon).attr("src", "/Images/Icons/iconshock-greentick-16px.png"); - alertify.error(unescape(msg.d.DisplayMessage)); + $(this).attr("src", "/Images/Icons/iconshock-greentick-16px.png"); + alertify.error(msg.d.DisplayMessage); // TODO: Add alert box? } - } + }, this) }); } @@ -118,12 +159,23 @@ .datagrid-row-selected,.datagrid-row-over{ background:transparent; } + .LocalIconApproval, .LocalIconApproved { + padding-right: 3px; + } + body.rtl .LocalIconApproval, body.rtl .LocalIconApproved { + padding-left: 3px; + padding-right: initial; + } + .rowPrevious { + color: #888; + display: none; + }

@@ -131,13 +183,24 @@ - + - +
+ +

+ +
+
+ +
+
+
diff --git a/Site5/Pages/v5/Financial/PayOutMoney.aspx.cs b/Site5/Pages/v5/Financial/PayOutMoney.aspx.cs index 20909f9d..2f7ace5d 100644 --- a/Site5/Pages/v5/Financial/PayOutMoney.aspx.cs +++ b/Site5/Pages/v5/Financial/PayOutMoney.aspx.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.ServiceModel.Security; using System.Web; using System.Web.Services; @@ -43,6 +44,16 @@ namespace Swarmops.Frontend.Pages.Financial this.LabelGridHeaderPaid.Text = Resources.Pages.Financial.PayOutMoney_GridHeader_PaidOut; this.LabelGridHeaderRecipient.Text = Resources.Pages.Financial.PayOutMoney_GridHeader_Recipient; this.LabelGridHeaderReference.Text = Resources.Pages.Financial.PayOutMoney_GridHeader_Reference; + + this.LabelSidebarOptions.Text = Resources.Global.Sidebar_Options; + + int previouslyOpenPayouts = GetOpenCount(); + this.LabelOptionsShowPrevious.Text = String.Format(Resources.Pages.Financial.PayOutMoney_OptionShowOpen, previouslyOpenPayouts); + } + + private int GetOpenCount() + { + return Payouts.ForOrganization (CurrentOrganization).Count; } [WebMethod] @@ -72,7 +83,7 @@ namespace Swarmops.Frontend.Pages.Financial result.DisplayMessage = String.Format (Resources.Pages.Financial.PayOutMoney_PayoutCreated, payout.Identity, payout.Recipient); - result.DisplayMessage = HttpUtility.UrlEncode (result.DisplayMessage).Replace ("+", "%20"); + result.DisplayMessage = result.DisplayMessage; return result; } @@ -81,8 +92,14 @@ namespace Swarmops.Frontend.Pages.Financial public static UndoPayoutResult UndoPayout (int databaseId) { AuthenticationData authData = GetAuthenticationDataAndCulture(); - UndoPayoutResult result = new UndoPayoutResult(); + if ( + !authData.CurrentUser.HasAccess(new Access(authData.CurrentOrganization, AccessAspect.Financials))) + { + throw new SecurityAccessDeniedException("Insufficient privileges for operation"); + } + + UndoPayoutResult result = new UndoPayoutResult(); Payout payout = Payout.FromIdentity (databaseId); if (!payout.Open) @@ -98,9 +115,7 @@ namespace Swarmops.Frontend.Pages.Financial payout.UndoPayout(); - result.DisplayMessage = - HttpUtility.UrlEncode (String.Format (Resources.Pages.Financial.PayOutMoney_PayoutUndone, databaseId)) - .Replace ("+", "%20"); + result.DisplayMessage = String.Format (Resources.Pages.Financial.PayOutMoney_PayoutUndone, databaseId); result.Success = true; return result; } diff --git a/Site5/Pages/v5/Ledgers/AccountPlan.aspx.cs b/Site5/Pages/v5/Ledgers/AccountPlan.aspx.cs index fea7fddf..f0035308 100644 --- a/Site5/Pages/v5/Ledgers/AccountPlan.aspx.cs +++ b/Site5/Pages/v5/Ledgers/AccountPlan.aspx.cs @@ -92,6 +92,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers FinancialAccounts organizationAccounts = FinancialAccounts.ForOrganization(this.CurrentOrganization); int inactiveCount = organizationAccounts.Count(account => !account.Active); + this.LabelSidebarOptions.Text = Resources.Global.Sidebar_Options; this.LabelOptionsShowInactive.Text = String.Format(Resources.Pages.Ledgers.AccountPlan_Options_ShowInactive, inactiveCount); } PageAccessRequired = new Access (CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Write);