diff --git a/Site5/Images/Icons/iconshock-balloon-undo-16px.png b/Site5/Images/Icons/iconshock-balloon-undo-16px.png index 637dd1fb..2754b4be 100644 Binary files a/Site5/Images/Icons/iconshock-balloon-undo-16px.png and b/Site5/Images/Icons/iconshock-balloon-undo-16px.png differ diff --git a/Site5/Images/Icons/undo-16px.png b/Site5/Images/Icons/undo-16px.png new file mode 100644 index 00000000..825b083c Binary files /dev/null and b/Site5/Images/Icons/undo-16px.png differ diff --git a/Site5/Pages/v5/Financial/AttestCosts.aspx b/Site5/Pages/v5/Financial/AttestCosts.aspx index 9601ce44..5e8c8c63 100644 --- a/Site5/Pages/v5/Financial/AttestCosts.aspx +++ b/Site5/Pages/v5/Financial/AttestCosts.aspx @@ -25,30 +25,44 @@ $('#TableAttestableCosts').datagrid( { onLoadSuccess: function () { - $(".LocalIconApproval").attr("src", "/Images/Icons/iconshock-greentick-16px-desat-light.png"); + $(".LocalIconApproval").attr("src", "/Images/Icons/iconshock-balloon-yes-16px.png"); $(".LocalIconApproved").attr("src", "/Images/Icons/iconshock-greentick-16px.png"); $(".LocalIconApproved, .LocalIconDenied").css("display", "none"); - $(".LocalIconDenial").attr("src", "/Images/Icons/iconshock-redcross-16px-desat-light.png"); + $(".LocalIconDenial").attr("src", "/Images/Icons/iconshock-balloon-no-16px.png"); $(".LocalIconApproval, .LocalIconApproved, .LocalIconDenial").css("cursor", "pointer"); $(".LocalIconApproval").mouseover(function () { if ($(this).attr("rel") != "loading") { - $(this).attr("src", "/Images/Icons/iconshock-greentick-16px-desat.png"); + $(this).attr("src", "/Images/Icons/iconshock-balloon-yes-16px-hot.png"); } }); + $(".LocalIconApproval").mouseout(function () { if ($(this).attr("rel") != "loading") { - $(this).attr("src", "/Images/Icons/iconshock-greentick-16px-desat-light.png"); + $(this).attr("src", "/Images/Icons/iconshock-balloon-yes-16px.png"); } }); + + $(".LocalIconApproved").mouseover(function () { + if ($(this).attr("rel") != "loading") { + $(this).attr("src", "/Images/Icons/undo-16px.png"); + } + }); + + $(".LocalIconApproved").mouseout(function () { + if ($(this).attr("rel") != "loading") { + $(this).attr("src", "/Images/Icons/iconshock-greentick-16px.png"); + } + }); + $(".LocalIconApproval").click(function () { if ($(this).attr("rel") != "loading") { $(this).attr("rel", "loading"); $(this).attr("src", "/Images/Abstract/ajaxloader-medium.gif"); - $("#IconDenial" + $(this).attr("baseid")).fadeTo(1000, 0.01).css("cursor","default"); + $("#IconDenial" + $(this).attr("baseid")).fadeTo(1000, 0.01).css("cursor", "default"); $(this).fadeOut(2000, function () { $(this).css("display", "none"); - $(this).attr("src", "/Images/Icons/iconshock-greentick-16px-desat-light.png"); + $(this).attr("src", "/Images/Icons/iconshock-balloon-yes-16px.png"); $(this).attr("rel", "active"); $("#IconApproved" + $(this).attr("baseid")).fadeIn(100); alertify.success("Foo approved."); @@ -56,6 +70,7 @@ } }); + $(".LocalIconApproved").click(function () { if ($(this).attr("rel") != "loading") { $(this).attr("rel", "loading"); @@ -73,6 +88,27 @@ } }); + + + + $(".LocalIconDenial").mouseover(function () { + if ($(this).attr("rel") != "loading") { + $(this).attr("src", "/Images/Icons/iconshock-balloon-no-16px-hot.png"); + } + }); + + $(".LocalIconDenial").mouseout(function () { + if ($(this).attr("rel") != "loading") { + $(this).attr("src", "/Images/Icons/iconshock-balloon-no-16px.png"); + } + }); + + + $(".LocalIconDenial").click(function () { + alert('Denying attestation is not yet implemented, but you can just leave the unwanted cost here until it is.'); + }); + + } } ); @@ -87,19 +123,19 @@ -

+

- - - - - - - + + + + + + +
ItemBeneficiaryDescriptionBudgetRequestedDocsAction
diff --git a/Site5/Pages/v5/Financial/AttestCosts.aspx.cs b/Site5/Pages/v5/Financial/AttestCosts.aspx.cs index 3e1405eb..f0eddf7b 100644 --- a/Site5/Pages/v5/Financial/AttestCosts.aspx.cs +++ b/Site5/Pages/v5/Financial/AttestCosts.aspx.cs @@ -2,9 +2,14 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.ServiceModel.Security; using System.Web; +using System.Web.Services; using System.Web.UI; using System.Web.UI.WebControls; +using Swarmops.Logic.Financial; +using Swarmops.Logic.Structure; +using Swarmops.Logic.Swarm; namespace Swarmops.Frontend.Pages.v5.Financial { @@ -32,5 +37,87 @@ namespace Swarmops.Frontend.Pages.v5.Financial this.PageTitle = Resources.Pages.Finance.AttestCosts_PageTitle; this.InfoBoxLiteral = Resources.Pages.Finance.AttestCosts_Info; } + + [WebMethod] + public static string Attest (string identifier) + { + string identity = HttpContext.Current.User.Identity.Name; + string[] identityTokens = identity.Split(','); + + string userIdentityString = identityTokens[0]; + string organizationIdentityString = identityTokens[1]; + + int currentUserId = Convert.ToInt32(userIdentityString); + int currentOrganizationId = Convert.ToInt32(organizationIdentityString); + + Person currentUser = Person.FromIdentity(currentUserId); + Organization currentOrganization = Organization.FromIdentity(currentOrganizationId); + + char costType = identifier[0]; + int itemId = Int32.Parse(identifier.Substring(1)); + string beneficiary = string.Empty; + string result = string.Empty; + + switch(costType) + { + case 'A': // Case advance + CashAdvance advance = CashAdvance.FromIdentity(itemId); + if (advance.OrganizationId != currentOrganizationId) + { + throw new InvalidOperationException("Called to attest out-of-org line item"); + } + if (advance.FinancialAccount.OwnerPersonId != currentUserId) + { + throw new SecurityAccessDeniedException("Called without attestation privileges"); + } + + result = "XYZ Cash Advance"; + advance.Attest(currentUser); + break; + } + + return result; + } + + [WebMethod] + public static string Deattest(string identifier) + { + string identity = HttpContext.Current.User.Identity.Name; + string[] identityTokens = identity.Split(','); + + string userIdentityString = identityTokens[0]; + string organizationIdentityString = identityTokens[1]; + + int currentUserId = Convert.ToInt32(userIdentityString); + int currentOrganizationId = Convert.ToInt32(organizationIdentityString); + + Person currentUser = Person.FromIdentity(currentUserId); + Organization currentOrganization = Organization.FromIdentity(currentOrganizationId); + + char costType = identifier[0]; + int itemId = Int32.Parse(identifier.Substring(1)); + string beneficiary = string.Empty; + string result = string.Empty; + + switch (costType) + { + case 'A': // Case advance + CashAdvance advance = CashAdvance.FromIdentity(itemId); + if (advance.OrganizationId != currentOrganizationId) + { + throw new InvalidOperationException("Called to attest out-of-org line item"); + } + if (advance.FinancialAccount.OwnerPersonId != currentUserId) + { + throw new SecurityAccessDeniedException("Called without attestation privileges"); + } + + result = "XYZ Cash Advance"; + advance.Deattest(currentUser); + break; + } + + return result; + } } } \ No newline at end of file