diff --git a/Basic/Types/BasicCurrency.cs b/Basic/Types/BasicCurrency.cs index c29a1849..ed692da1 100644 --- a/Basic/Types/BasicCurrency.cs +++ b/Basic/Types/BasicCurrency.cs @@ -4,16 +4,16 @@ namespace Swarmops.Basic.Types { public class BasicCurrency: IHasIdentity { - public BasicCurrency (int currencyId, string code, string description, string sign) + public BasicCurrency (int currencyId, string code, string name, string sign) { this.CurrencyId = currencyId; this.Code = code; - this.Description = description; + this.Name = name; this.Sign = sign; } public BasicCurrency (BasicCurrency original) - : this (original.CurrencyId, original.Code, original.Description, original.Sign) + : this (original.CurrencyId, original.Code, original.Name, original.Sign) { // empty copy ctor } @@ -21,7 +21,7 @@ namespace Swarmops.Basic.Types public int CurrencyId { get; private set; } public string Code { get; private set; } - public string Description { get; private set; } + public string Name { get; private set; } public string Sign { get; private set; } public int Identity diff --git a/Logic/Financial/Currencies.cs b/Logic/Financial/Currencies.cs new file mode 100644 index 00000000..3d7a55ba --- /dev/null +++ b/Logic/Financial/Currencies.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Swarmops.Basic.Types; +using Swarmops.Database; +using Swarmops.Logic.Support; + +namespace Swarmops.Logic.Financial +{ + public class Currencies: PluralBase + { + public static Currencies GetAll() + { + return FromArray(SwarmDb.GetDatabaseForReading().GetCurrencies()); + } + } +} diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index a1c26923..35c496a1 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -94,6 +94,7 @@ + diff --git a/Logic/Support/SingularFactory.cs b/Logic/Support/SingularFactory.cs index 374e4c75..6b5e53c5 100644 --- a/Logic/Support/SingularFactory.cs +++ b/Logic/Support/SingularFactory.cs @@ -84,6 +84,9 @@ namespace Swarmops.Logic.Support case "Swarmops.Basic.Types.BasicSalary": return Salary.FromBasic((BasicSalary) basic); + case "Swarmops.Basic.Types.BasicCurrency": + return Currency.FromBasic((BasicCurrency) basic); + case "Swarmops.Basic.Types.Financial.BasicFinancialTransactionTagSet": return FinancialTransactionTagSet.FromBasic ((BasicFinancialTransactionTagSet) basic); @@ -131,7 +134,7 @@ namespace Swarmops.Logic.Support // ------------------ FAIL ---------------- default: - throw new NotImplementedException("Unimplemented argument type: " + argumentType); + throw new NotImplementedException("Unimplemented argument type in SingularFactory: " + argumentType); } diff --git a/Site5/App_GlobalResources/Global.resx b/Site5/App_GlobalResources/Global.resx index c352fd27..84808658 100644 --- a/Site5/App_GlobalResources/Global.resx +++ b/Site5/App_GlobalResources/Global.resx @@ -677,7 +677,7 @@ Operatives - NO IDEA SORRY - TODO + Operativehood Corps @@ -695,7 +695,7 @@ Regulars - I HAVE NO IDEA WHAT THIS SHOULD BE - TODO + Regularhood Crew @@ -715,4 +715,26 @@ Seamanship + + Create + Like "Create Organization" + + + Forces + + + Person + + + Person + + + Person + + + People + + + Personhood + \ No newline at end of file diff --git a/Site5/App_GlobalResources/Pages.Admin.resx b/Site5/App_GlobalResources/Pages.Admin.resx new file mode 100644 index 00000000..296c70f8 --- /dev/null +++ b/Site5/App_GlobalResources/Pages.Admin.resx @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Activists will be called + + + Root-level organization + + + Child of {0} + "Create org as..." + + + Create new organization as... + + + You can create a new organization either as a new standalone organization, or as a child organization of the current one. (In a child organization, everybody with responsibility in the parent organization automatically has corresponding rights and privileges.) + + + Operating currency + + + The new organization's name + + + Create New Organization + + + Regular people will be called + This can be "members", etc. + + \ No newline at end of file diff --git a/Site5/Automation/Json-AvailableCurrencies.aspx b/Site5/Automation/Json-AvailableCurrencies.aspx new file mode 100644 index 00000000..0a353acb --- /dev/null +++ b/Site5/Automation/Json-AvailableCurrencies.aspx @@ -0,0 +1 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json-AvailableCurrencies.aspx.cs" Inherits="Swarmops.Frontend.Automation.Json_AvailableCurrencies" %> \ No newline at end of file diff --git a/Site5/Automation/Json-AvailableCurrencies.aspx.cs b/Site5/Automation/Json-AvailableCurrencies.aspx.cs new file mode 100644 index 00000000..088fe235 --- /dev/null +++ b/Site5/Automation/Json-AvailableCurrencies.aspx.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using Swarmops.Logic.Financial; +using Swarmops.Logic.Structure; + +namespace Swarmops.Frontend.Automation +{ + public partial class Json_AvailableCurrencies : DataV5Base + { + protected void Page_Load(object sender, EventArgs e) + { + GetAuthenticationDataAndCulture(); + + Response.ContentType = "application/json"; + + // Is this stuff in cache already? + + string cacheKey = "Currencies-Json-" + Thread.CurrentThread.CurrentCulture.Name; + + string currenciesJson = + (string) Cache[cacheKey]; + + if (currenciesJson != null) + { + Response.Output.WriteLine(currenciesJson); + Response.End(); + return; + } + + Currencies currencies = Currencies.GetAll(); + + List currencyStrings = new List(); + + foreach (Currency currency in currencies) + { + currencyStrings.Add(String.Format("{0} {1}|{0}", currency.Code, currency.Name)); + } + + currencyStrings.Sort(); + currenciesJson = "["; + + foreach (string currencyString in currencyStrings) + { + string[] parts = currencyString.Split('|'); + + currenciesJson += "{" + String.Format("\"label\":\"{0}\",\"code\":\"{1}\"", parts[0], parts[1]) + "},"; + } + + currenciesJson = currenciesJson.TrimEnd(',') + "]"; + + Cache.Insert(cacheKey, currenciesJson, null, DateTime.Now.AddMinutes(60), TimeSpan.Zero); + // cache lasts for sixty minutes, no sliding expiration + Response.Output.WriteLine(currenciesJson); + + Response.End(); + } + + } +} \ No newline at end of file diff --git a/Site5/Images/PageIcons/iconshock-organization-add-40px.png b/Site5/Images/PageIcons/iconshock-organization-add-40px.png new file mode 100644 index 00000000..d554109f Binary files /dev/null and b/Site5/Images/PageIcons/iconshock-organization-add-40px.png differ diff --git a/Site5/MainMenu-v5.xml b/Site5/MainMenu-v5.xml index 9a61fdef..bb35567d 100644 --- a/Site5/MainMenu-v5.xml +++ b/Site5/MainMenu-v5.xml @@ -361,11 +361,11 @@ Submenu - + diff --git a/Site5/Pages/v5/Admin/CreateOrganization.aspx b/Site5/Pages/v5/Admin/CreateOrganization.aspx index 524c2dd1..eb622181 100644 --- a/Site5/Pages/v5/Admin/CreateOrganization.aspx +++ b/Site5/Pages/v5/Admin/CreateOrganization.aspx @@ -1,23 +1,55 @@ <%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="CreateOrganization.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.CreateOrganization" %> -<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %> <%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %> -<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %> - - - - @@ -27,34 +59,18 @@
​
- - - -  
- - - - - - - -  
- ​
- ​
-  
- + ​
+ ​
+ ​
+ ​
+
diff --git a/Site5/Pages/v5/Admin/CreateOrganization.aspx.cs b/Site5/Pages/v5/Admin/CreateOrganization.aspx.cs index 33c5def7..6781e141 100644 --- a/Site5/Pages/v5/Admin/CreateOrganization.aspx.cs +++ b/Site5/Pages/v5/Admin/CreateOrganization.aspx.cs @@ -1,5 +1,8 @@ using System; +using System.Collections.Generic; using System.Web; +using System.Web.UI.WebControls; +using Swarmops.Logic.Financial; namespace Swarmops.Frontend.Pages.v5.Admin { @@ -7,9 +10,9 @@ namespace Swarmops.Frontend.Pages.v5.Admin { protected void Page_Load(object sender, EventArgs e) { - this.PageTitle = Resources.Pages.Financial.FileExpenseClaim_PageTitle; - this.PageIcon = "iconshock-moneyback"; - this.InfoBoxLiteral = Resources.Pages.Financial.FileExpenseClaim_Info; + this.PageTitle = Resources.Pages.Admin.CreateOrganization_PageTitle; + this.PageIcon = "iconshock-organization-add"; + this.InfoBoxLiteral = Resources.Pages.Admin.CreateOrganization_Info; if (!Page.IsPostBack) { @@ -18,13 +21,73 @@ namespace Swarmops.Frontend.Pages.v5.Admin } + private readonly string[] _personLabels = + { + "Activist", "Person", "Sailor", "Regular", "Ambassador", "Salesperson", + "Member", "Operative", "Employee", "Customer", "Conscript", "Resident", "Citizen", "Agent" + }; + + private void Localize() { + this.LabelOrganizationName.Text = Resources.Pages.Admin.CreateOrganization_NewOrgName; + this.LabelActivistLabel.Text = Resources.Pages.Admin.CreateOrganization_ActivistTitle; + this.LabelCreateAs.Text = Resources.Pages.Admin.CreateOrganization_CreateNewOrgAs; + this.LabelNativeCurrency.Text = Resources.Pages.Admin.CreateOrganization_NewOrgCurrency; + this.LabelPersonLabel.Text = Resources.Pages.Admin.CreateOrganization_RegularTitle; + this.ButtonCreate.Text = Resources.Global.Global_Create; + + this.DropPersonLabel.Items.Clear(); + this.DropActivistLabel.Items.Clear(); + this.DropCurrencies.Items.Clear(); + this.DropCreateChild.Items.Clear(); + this.DropPersonLabel.Items.Add(new ListItem(Resources.Global.Global_SelectOne, "0")); + this.DropActivistLabel.Items.Add(new ListItem(Resources.Global.Global_SelectOne, "0")); + this.DropCurrencies.Items.Add(new ListItem(Resources.Global.Global_SelectOne, "0")); + this.DropCreateChild.Items.Add(new ListItem(Resources.Global.Global_SelectOne, "0")); + + + List localizedPersonLabels = new List(); + + foreach (string personLabel in _personLabels) + { + string localizedPersonLabel = + Resources.Global.ResourceManager.GetString("Title_" + personLabel + "_Plural"); + + localizedPersonLabels.Add(localizedPersonLabel + "|" + personLabel); + } + + localizedPersonLabels.Sort(); + + foreach (string localizedPersonLabel in localizedPersonLabels) + { + string[] parts = localizedPersonLabel.Split('|'); + this.DropPersonLabel.Items.Add(new ListItem(parts[0], parts[1])); + this.DropActivistLabel.Items.Add(new ListItem(parts[0], parts[1])); + } + + Currencies currencies = Currencies.GetAll(); + + List currencyStrings = new List(); + + foreach (Currency currency in currencies) + { + currencyStrings.Add(String.Format("{0} {1}|{0}", currency.Code, currency.Name)); + } + + currencyStrings.Sort(); + + foreach (string currencyString in currencyStrings) + { + string[] parts = currencyString.Split('|'); + + this.DropCurrencies.Items.Add(new ListItem(parts[0], parts[1])); + } } - protected void ButtonRequest_Click(object sender, EventArgs e) + protected void ButtonCreate_Click(object sender, EventArgs e) { string successMessage = string.Empty;