diff --git a/Site5/App_GlobalResources/Menu5.resx b/Site5/App_GlobalResources/Menu5.resx index 352e4d25..58929ca1 100644 --- a/Site5/App_GlobalResources/Menu5.resx +++ b/Site5/App_GlobalResources/Menu5.resx @@ -339,6 +339,9 @@ Add Member + + List/Find People + List Members diff --git a/Site5/App_GlobalResources/Pages.People.resx b/Site5/App_GlobalResources/Pages.People.resx new file mode 100644 index 00000000..c00d516e --- /dev/null +++ b/Site5/App_GlobalResources/Pages.People.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Find people in the organization (write more here) + + + Find, List People + + \ No newline at end of file diff --git a/Site5/Automation/Json-GeographiesTree.aspx b/Site5/Automation/Json-GeographiesTree.aspx new file mode 100644 index 00000000..a14e65bb --- /dev/null +++ b/Site5/Automation/Json-GeographiesTree.aspx @@ -0,0 +1 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json-GeographiesTree.aspx.cs" Inherits="Swarmops.Frontend.Automation.Json_GeographiesTree" %> \ No newline at end of file diff --git a/Site5/Automation/Json-GeographiesTree.aspx.cs b/Site5/Automation/Json-GeographiesTree.aspx.cs new file mode 100644 index 00000000..2529ae15 --- /dev/null +++ b/Site5/Automation/Json-GeographiesTree.aspx.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Swarmops.Logic.Financial; +using Swarmops.Logic.Swarm; +using Swarmops.Logic.Security; +using Swarmops.Logic.Structure; + +namespace Swarmops.Frontend.Automation +{ + public partial class Json_GeographiesTree : DataV5Base + { + protected void Page_Load(object sender, EventArgs e) + { + Response.ContentType = "application/json"; + + int rootGeographyId = Geography.RootIdentity; + + // What's our root GeographyId? (probably Geography.RootIdentity...) + + string rootIdString = Request.QueryString["RootGeographyId"]; + if (!string.IsNullOrEmpty(rootIdString)) + { + rootGeographyId = Int32.Parse(rootIdString); // will throw if invalid Int32, but who cares + } + + // Is this stuff in cache already? + + string cacheKey = "Geographies-Json-" + rootGeographyId.ToString(CultureInfo.InvariantCulture); + + string accountsJson = + (string) Cache[cacheKey]; + + if (accountsJson != null) + { + Response.Output.WriteLine(accountsJson); + Response.End(); + return; + } + + // Not in cache. Construct. + + Geography rootGeography = Geography.FromIdentity(rootGeographyId); + + // Get geography tree + + Geographies geographies = rootGeography.GetTree(); + + // Build tree (there should be a template for this) + + Dictionary> treeMap = new Dictionary>(); + + foreach (Geography geography in geographies) + { + if (!treeMap.ContainsKey(geography.ParentIdentity)) + { + treeMap[geography.ParentIdentity] = new List(); + } + + treeMap[geography.ParentIdentity].Add(geography); + } + + int renderRootNodeId = rootGeography.ParentGeographyId; // This works as rootGeography will be the only present child in the collection; other children won't be there + + accountsJson = RecurseTreeMap(treeMap, renderRootNodeId); + + Cache.Insert(cacheKey, accountsJson, null, DateTime.Now.AddMinutes(5), TimeSpan.Zero); + // cache lasts for five minutes, no sliding expiration + Response.Output.WriteLine(accountsJson); + + Response.End(); + } + + private string RecurseTreeMap(Dictionary> treeMap, int node) + { + List elements = new List(); + + foreach (Geography geography in treeMap[node]) + { + string element = string.Format("\"id\":{0},\"text\":\"{1}\"", geography.Identity, + JsonSanitize(geography.Name)); + + if (treeMap.ContainsKey(geography.Identity)) + { + element += ",\"state\":\"closed\",\"children\":" + RecurseTreeMap(treeMap, geography.Identity); + } + + elements.Add("{" + element + "}"); + } + + return "[" + String.Join(",", elements.ToArray()) + "]"; + + } + } +} \ No newline at end of file diff --git a/Site5/Controls/v5/Base/ComboGeographies.ascx b/Site5/Controls/v5/Base/ComboGeographies.ascx new file mode 100644 index 00000000..51dfa51f --- /dev/null +++ b/Site5/Controls/v5/Base/ComboGeographies.ascx @@ -0,0 +1,41 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ComboGeographies.ascx.cs" Inherits="Swarmops.Controls.Base.ComboGeographies" %> + + + + \ No newline at end of file diff --git a/Site5/Controls/v5/Base/ComboGeographies.ascx.cs b/Site5/Controls/v5/Base/ComboGeographies.ascx.cs new file mode 100644 index 00000000..74278262 --- /dev/null +++ b/Site5/Controls/v5/Base/ComboGeographies.ascx.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Swarmops.Logic.Structure; + +namespace Swarmops.Controls.Base +{ + public partial class ComboGeographies : ControlV5Base + { + protected void Page_Load(object sender, EventArgs e) + { + RootGeography = Geography.Root; // set to "world" unless manually set to something else + } + + public string OnClientLoaded { get; set; } + public string OnClientSelect { get; set; } + protected int RootGeographyId { get; private set; } + protected string RootGeographyName { get; private set; } + + public Geography RootGeography + { + set + { + this.RootGeographyId = value.Identity; + RootGeographyName = value.Name; + } + } + } +} \ No newline at end of file diff --git a/Site5/MainMenu-v5.xml b/Site5/MainMenu-v5.xml index fdf06b62..8f92d19f 100644 --- a/Site5/MainMenu-v5.xml +++ b/Site5/MainMenu-v5.xml @@ -13,11 +13,12 @@ - Placeholder_Todo - 1 + People_ListFind + 2 - Disabled + /Pages/v5/People/ListFindPeople.aspx + Link diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateData.aspx b/Site5/Pages/v5/Admin/Hacks/PopulateData.aspx index 0d51c17a..eb22a78b 100644 --- a/Site5/Pages/v5/Admin/Hacks/PopulateData.aspx +++ b/Site5/Pages/v5/Admin/Hacks/PopulateData.aspx @@ -48,7 +48,7 @@ width: "100%" }, { queue: false }); - this.document.location = '/'; + window.location = '/'; } else { diff --git a/Site5/Pages/v5/People/ListFindPeople.aspx b/Site5/Pages/v5/People/ListFindPeople.aspx new file mode 100644 index 00000000..43c92c11 --- /dev/null +++ b/Site5/Pages/v5/People/ListFindPeople.aspx @@ -0,0 +1,157 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="ListFindPeople.aspx.cs" Inherits="Swarmops.Frontend.Pages.People.ListFindPeople" %> +<%@ Register src="~/Controls/v5/UI/ExternalScripts.ascx" tagname="ExternalScripts" tagprefix="Swarmops5" %> +<%@ Register src="~/Controls/v5/Base/ComboGeographies.ascx" tagname="ComboGeographies" tagprefix="Swarmops5" %> + + + + + + + + + + + + + + + + + + Geography + Name pattern + + Matching people + + + + + + + + + + + + + + + + + diff --git a/Site5/Pages/v5/People/ListFindPeople.aspx.cs b/Site5/Pages/v5/People/ListFindPeople.aspx.cs new file mode 100644 index 00000000..3207f2cd --- /dev/null +++ b/Site5/Pages/v5/People/ListFindPeople.aspx.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +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.Basic.Enums; +using Swarmops.Database; +using Swarmops.Logic.Financial; +using Swarmops.Logic.Security; + +namespace Swarmops.Frontend.Pages.People +{ + public partial class ListFindPeople : PageV5Base + { + protected void Page_Load(object sender, EventArgs e) + { + this.PageIcon = "iconshock-money-envelope"; + + if (!Page.IsPostBack) + { + Localize(); + } + + + } + + private void Localize() + { + this.PageTitle = Resources.Pages.Financial.PayOutMoney_PageTitle; + this.InfoBoxLiteral = Resources.Pages.Financial.PayOutMoney_Info; + this.LabelPayOutMoneyHeader.Text = Resources.Pages.Financial.PayOutMoney_Header; + this.LabelGridHeaderAccount.Text = Resources.Pages.Financial.PayOutMoney_GridHeader_BankAccount; + this.LabelGridHeaderAmount.Text = Resources.Pages.Financial.PayOutMoney_GridHeader_Amount; + this.LabelGridHeaderBank.Text = Resources.Pages.Financial.PayOutMoney_GridHeader_BankName; + this.LabelGridHeaderDue.Text = Resources.Pages.Financial.PayOutMoney_GridHeader_DueDate; + 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; + + } + + public struct ConfirmPayoutResult + { + public int AssignedId; + public string DisplayMessage; + }; + + [WebMethod] + public static ConfirmPayoutResult ConfirmPayout (string protoIdentity) + { + protoIdentity = HttpUtility.UrlDecode(protoIdentity); + + AuthenticationData authData = GetAuthenticationDataAndCulture(); + + if (!authData.CurrentUser.HasAccess(new Access(authData.CurrentOrganization, AccessAspect.Financials, AccessType.Write))) + { + throw new SecurityAccessDeniedException("Insufficient privileges for operation"); + } + + ConfirmPayoutResult result = new ConfirmPayoutResult(); + + Payout payout = Payout.CreateFromProtoIdentity(authData.CurrentUser, protoIdentity); + Swarmops.Logic.Support.PWEvents.CreateEvent(EventSource.PirateWeb, EventType.PayoutCreated, + authData.CurrentUser.Identity, 1, 1, 0, payout.Identity, + protoIdentity); + + // Create result and return it + + result.AssignedId = payout.Identity; + result.DisplayMessage = String.Format(Resources.Pages.Financial.PayOutMoney_PayoutCreated, payout.Identity, + payout.Recipient); + + result.DisplayMessage = HttpUtility.UrlEncode(result.DisplayMessage).Replace("+", "%20"); + + return result; + } + + public struct UndoPayoutResult + { + public bool Success; + public string DisplayMessage; + } + + [WebMethod] + public static UndoPayoutResult UndoPayout (int databaseId) + { + AuthenticationData authData = GetAuthenticationDataAndCulture(); + UndoPayoutResult result = new UndoPayoutResult(); + + Payout payout = Payout.FromIdentity(databaseId); + + if (!payout.Open) + { + // this payout has already been settled, or picked up for settling + + result.Success = false; + result.DisplayMessage = String.Format(Resources.Pages.Financial.PayOutMoney_PayoutCannotUndo, + databaseId); + + return result; + } + + payout.UndoPayout(); + + result.DisplayMessage = HttpUtility.UrlEncode(String.Format(Resources.Pages.Financial.PayOutMoney_PayoutUndone, databaseId)).Replace("+","%20"); + result.Success = true; + return result; + } + } + +} \ No newline at end of file