From b783fbdcd1855632122bd34b048d5e12d8d7f829 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 8 Sep 2013 10:09:35 +0000 Subject: [PATCH] Todo framework operational --- Basic/Enums/ObjectOptionalDataType.cs | 2 +- Logic/Financial/IAttestable.cs | 2 + Logic/Financial/Salary.cs | 5 + Logic/Logic.csproj | 11 + .../DashboardTodos.Designer.cs | 153 ++++++++++++ .../App_LocalResources/DashboardTodos.resx | 151 ++++++++++++ Logic/Swarm/DashboardTodo.cs | 24 ++ Logic/Swarm/DashboardTodos.cs | 222 ++++++++++++++++++ Site5/App_Code/DataV5Base.cs | 2 +- Site5/Master-v5.master | 10 +- Site5/Master-v5.master.cs | 12 +- Site5/Security/Login.aspx | 2 +- Utility/Properties/AssemblyInfo.cs | 2 +- 13 files changed, 591 insertions(+), 7 deletions(-) create mode 100644 Logic/Swarm/App_LocalResources/DashboardTodos.Designer.cs create mode 100644 Logic/Swarm/App_LocalResources/DashboardTodos.resx create mode 100644 Logic/Swarm/DashboardTodo.cs create mode 100644 Logic/Swarm/DashboardTodos.cs diff --git a/Basic/Enums/ObjectOptionalDataType.cs b/Basic/Enums/ObjectOptionalDataType.cs index cf16a29b..256ee32a 100644 --- a/Basic/Enums/ObjectOptionalDataType.cs +++ b/Basic/Enums/ObjectOptionalDataType.cs @@ -194,7 +194,7 @@ namespace Swarmops.Basic.Enums /// OrgCurrency, /// - /// First bookkeeping year of org in Activizr (can set inbound balances for this year only) + /// First bookkeeping year of org in Swarmops (can set inbound balances for this year only) /// OrgFirstFiscalYear, /// diff --git a/Logic/Financial/IAttestable.cs b/Logic/Financial/IAttestable.cs index bc22d3b8..f6f23e24 100644 --- a/Logic/Financial/IAttestable.cs +++ b/Logic/Financial/IAttestable.cs @@ -9,5 +9,7 @@ namespace Swarmops.Logic.Financial { void Attest(Person attester); void Deattest(Person deattester); + + FinancialAccount Budget { get; } } } diff --git a/Logic/Financial/Salary.cs b/Logic/Financial/Salary.cs index dd616542..36e6bfb2 100644 --- a/Logic/Financial/Salary.cs +++ b/Logic/Financial/Salary.cs @@ -148,6 +148,11 @@ namespace Swarmops.Logic.Financial } } + public FinancialAccount Budget // needed for IAttestable + { + get { return this.PayrollItem.Budget; } + } + public PayrollAdjustments Adjustments { diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index b8b20e1b..2613f8c9 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -241,9 +241,16 @@ + + True + True + DashboardTodos.resx + + + @@ -309,6 +316,10 @@ Authentication.sv-SE.Designer.cs Designer + + ResXFileCodeGenerator + DashboardTodos.Designer.cs + \ No newline at end of file diff --git a/Logic/Swarm/App_LocalResources/DashboardTodos.Designer.cs b/Logic/Swarm/App_LocalResources/DashboardTodos.Designer.cs new file mode 100644 index 00000000..d302198a --- /dev/null +++ b/Logic/Swarm/App_LocalResources/DashboardTodos.Designer.cs @@ -0,0 +1,153 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1008 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Swarmops.Logic.Swarm.App_LocalResources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class DashboardTodos { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal DashboardTodos() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Swarmops.Logic.Swarm.App_LocalResources.DashboardTodos", typeof(DashboardTodos).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Attest cash advances {0}. + /// + internal static string Attest_CashAdvance_Many { + get { + return ResourceManager.GetString("Attest_CashAdvance_Many", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Attest cash advance #{0}. + /// + internal static string Attest_CashAdvance_One { + get { + return ResourceManager.GetString("Attest_CashAdvance_One", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Attest expense claims {0}. + /// + internal static string Attest_ExpenseClaim_Many { + get { + return ResourceManager.GetString("Attest_ExpenseClaim_Many", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Attest expense claim #{0}. + /// + internal static string Attest_ExpenseClaim_One { + get { + return ResourceManager.GetString("Attest_ExpenseClaim_One", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Settle {0} payouts. + /// + internal static string Payout_Many { + get { + return ResourceManager.GetString("Payout_Many", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Settle one payout. + /// + internal static string Payout_One { + get { + return ResourceManager.GetString("Payout_One", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Settle {0} overdue payouts. + /// + internal static string Payout_Overdue_Many { + get { + return ResourceManager.GetString("Payout_Overdue_Many", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Settle one overdue payout. + /// + internal static string Payout_Overdue_One { + get { + return ResourceManager.GetString("Payout_Overdue_One", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Settle {0} urgent payouts. + /// + internal static string Payout_Urgent_Many { + get { + return ResourceManager.GetString("Payout_Urgent_Many", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Settle one urgent payout. + /// + internal static string Payout_Urgent_One { + get { + return ResourceManager.GetString("Payout_Urgent_One", resourceCulture); + } + } + } +} diff --git a/Logic/Swarm/App_LocalResources/DashboardTodos.resx b/Logic/Swarm/App_LocalResources/DashboardTodos.resx new file mode 100644 index 00000000..88f5a054 --- /dev/null +++ b/Logic/Swarm/App_LocalResources/DashboardTodos.resx @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Attest cash advances {0} + + + Attest cash advance #{0} + + + Attest expense claims {0} + + + Attest expense claim #{0} + + + Settle {0} payouts + Instead of "Pay out payout". That sounds too repetitititive. + + + Settle one payout + + + Settle {0} overdue payouts + + + Settle one overdue payout + + + Settle {0} urgent payouts + + + Settle one urgent payout + + \ No newline at end of file diff --git a/Logic/Swarm/DashboardTodo.cs b/Logic/Swarm/DashboardTodo.cs new file mode 100644 index 00000000..1b00ffaf --- /dev/null +++ b/Logic/Swarm/DashboardTodo.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Swarmops.Logic.Swarm +{ + public class DashboardTodo + { + public string Icon { get; set; } + public string Description { get; set; } + public string Url { get; set; } + public TodoUrgency Urgency { get; set; } + } + + public enum TodoUrgency + { + Unknown = 0, + Normal, + Yellow, + Orange, + Red + } +} diff --git a/Logic/Swarm/DashboardTodos.cs b/Logic/Swarm/DashboardTodos.cs new file mode 100644 index 00000000..823c7b99 --- /dev/null +++ b/Logic/Swarm/DashboardTodos.cs @@ -0,0 +1,222 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security; +using System.Text; +using Swarmops.Basic.Enums; +using Swarmops.Logic.DashboardTasks; +using Swarmops.Logic.Financial; +using Swarmops.Logic.Security; +using Swarmops.Logic.Structure; +using Swarmops.Logic.Support; + +namespace Swarmops.Logic.Swarm +{ + public class DashboardTodos: List + { + public static DashboardTodos ForPerson (Person person, Organization organization) + { + DashboardTodos result = new DashboardTodos(); + + result.AddExpenseClaimAttestations(person, organization); + result.AddCashAdvanceAttestations(person, organization); + result.AddPayouts(person, organization); + + // TODO: Add any hooks + + return result; + } + + + // TODO: Refactor the attest-X functions into one function with minimal differences + + + private void AddExpenseClaimAttestations(Person person, Organization organization) + { + ExpenseClaims claims = ExpenseClaims.ForOrganization(organization); + List expenseClaimIds = new List(); + + bool isPersonOrgAdmin = false; + + if (person.Identity == 1) + { + isPersonOrgAdmin = true; // TODO: Make more advanced, obviously + } + + foreach (ExpenseClaim claim in claims) + { + if (claim.Attested) + { + continue; + } + + bool attestable = false; + + if (claim.Budget.OwnerPersonId == 0 && isPersonOrgAdmin) + { + attestable = true; + } + else if (claim.Budget.OwnerPersonId == person.Identity) + { + attestable = true; + } + + if (attestable) + { + expenseClaimIds.Add(claim.Identity); + } + } + + if (expenseClaimIds.Count > 0) + { + DashboardTodo todo = new DashboardTodo(); + + if (expenseClaimIds.Count > 1) + { + todo.Description = String.Format(App_LocalResources.DashboardTodos.Attest_ExpenseClaim_Many, Formatting.GenerateRangeString(expenseClaimIds)); + } + else + { + todo.Description = String.Format(App_LocalResources.DashboardTodos.Attest_ExpenseClaim_One, expenseClaimIds[0]); + } + + todo.Icon = "/Images/PageIcons/iconshock-stamped-paper-16px.png"; + todo.Url = "/Pages/v5/Financial/AttestCosts.aspx"; + + this.Add(todo); + } + } + + private void AddCashAdvanceAttestations(Person person, Organization organization) + { + CashAdvances advances = CashAdvances.ForOrganization(organization); + List cashAdvanceIds = new List(); + + bool isPersonOrgAdmin = false; + + if (person.Identity == 1) + { + isPersonOrgAdmin = true; // TODO: Make more advanced, obviously + } + + foreach (CashAdvance advance in advances) + { + if (advance.Attested) + { + continue; + } + + bool attestable = false; + + if (advance.Budget.OwnerPersonId == 0 && isPersonOrgAdmin) + { + attestable = true; + } + else if (advance.Budget.OwnerPersonId == person.Identity) + { + attestable = true; + } + + + if (attestable) + { + cashAdvanceIds.Add(advance.Identity); + } + } + + if (cashAdvanceIds.Count > 0) + { + DashboardTodo todo = new DashboardTodo(); + + if (cashAdvanceIds.Count > 1) + { + todo.Description = String.Format(App_LocalResources.DashboardTodos.Attest_CashAdvance_Many, Formatting.GenerateRangeString(cashAdvanceIds)); + } + else + { + todo.Description = String.Format(App_LocalResources.DashboardTodos.Attest_CashAdvance_One, cashAdvanceIds[0]); + } + + todo.Icon = "/Images/PageIcons/iconshock-stamped-paper-16px.png"; + todo.Url = "/Pages/v5/Financial/AttestCosts.aspx"; + + this.Add(todo); + } + } + + private void AddPayouts(Person person, Organization organization) + { + if (!person.HasAccess(new Access(organization, AccessAspect.Financials, AccessType.Write))) + { + return; // do not add this if can't pay out + } + + + DashboardTodo todoNormal = new DashboardTodo(); + DashboardTodo todoUrgent = new DashboardTodo(); + DashboardTodo todoOverdue = new DashboardTodo(); + + todoNormal.Url = + todoUrgent.Url = + todoOverdue.Url = "/Pages/v5/Financial/PayOutMoney.aspx"; + + todoNormal.Icon = + todoUrgent.Icon = + todoOverdue.Icon = "/Images/PageIcons/iconshock-money-envelope-16px.png"; + + int payoutCount = 0; + int urgentPayoutCount = 0; + int overduePayoutCount = 0; + + Payouts payouts = Payouts.Construct(organization); + + foreach (Payout payout in payouts) + { + payoutCount++; + + if (payout.DependentInvoices.Count > 0) + { + if (payout.ExpectedTransactionDate < DateTime.Today) + { + overduePayoutCount++; + } + else if (payout.ExpectedTransactionDate < DateTime.Today.AddDays(7)) + { + urgentPayoutCount++; + } + } + } + + if (payoutCount > 0) + { + todoNormal.Description = payoutCount > 1 + ? String.Format(App_LocalResources.DashboardTodos.Payout_Many, + payoutCount) + : App_LocalResources.DashboardTodos.Payout_One; + this.Add(todoNormal); + } + + if (overduePayoutCount > 0) + { + todoOverdue.Description = overduePayoutCount > 1 + ? String.Format(App_LocalResources.DashboardTodos.Payout_Overdue_Many, + payoutCount) + : App_LocalResources.DashboardTodos.Payout_Overdue_One; + todoOverdue.Urgency = TodoUrgency.Red; + this.Add(todoOverdue); + } + + if (urgentPayoutCount > 0) + { + todoUrgent.Description = overduePayoutCount > 1 + ? String.Format(App_LocalResources.DashboardTodos.Payout_Urgent_Many, + payoutCount) + : App_LocalResources.DashboardTodos.Payout_Urgent_One; + todoUrgent.Urgency = TodoUrgency.Yellow; + this.Add(todoUrgent); + } + } + + + } +} diff --git a/Site5/App_Code/DataV5Base.cs b/Site5/App_Code/DataV5Base.cs index 3b1f963c..a3b84796 100644 --- a/Site5/App_Code/DataV5Base.cs +++ b/Site5/App_Code/DataV5Base.cs @@ -11,7 +11,7 @@ using Swarmops.Logic.Structure; /// /// Summary description for PageV5Base -/// Base class to use for all pages that uses the Activizr-v5 master page +/// Base class to use for all pages that uses the Swarmops-v5 master page /// public class DataV5Base : System.Web.UI.Page diff --git a/Site5/Master-v5.master b/Site5/Master-v5.master index 80208bed..95cdc94b 100644 --- a/Site5/Master-v5.master +++ b/Site5/Master-v5.master @@ -17,7 +17,7 @@ - Activizr - Pirate Edition + Swarmops @@ -293,7 +293,13 @@
- + + + +
diff --git a/Site5/Master-v5.master.cs b/Site5/Master-v5.master.cs index cfffbbf8..a0777bd3 100644 --- a/Site5/Master-v5.master.cs +++ b/Site5/Master-v5.master.cs @@ -80,7 +80,17 @@ namespace Swarmops this.LabelActionPlaceholder1.Text = "Action shortcut 1 (TODO)"; this.LabelActionPlaceholder2.Text = "Action shortcut 2 (TODO)"; - this.LabelActionItemsHere.Text = "Action items here (TODO)"; + this.LabelNoTodoItems.Text = "No Action Items (LOC)"; + + // Set up todo items + + DashboardTodos todos = DashboardTodos.ForPerson(_currentUser, _currentOrganization); + + this.RepeaterTodoItems.DataSource = todos; + this.RepeaterTodoItems.DataBind(); + this.LabelNoTodoItems.Visible = (todos.Count == 0); + + // Set up main menu RadMenu mainMenu = FindControl("MainMenu") as RadMenu; diff --git a/Site5/Security/Login.aspx b/Site5/Security/Login.aspx index e9131a6c..27cd7fdd 100644 --- a/Site5/Security/Login.aspx +++ b/Site5/Security/Login.aspx @@ -11,7 +11,7 @@ - Activizr Beta - Login + Swarmops Alpha - Login diff --git a/Utility/Properties/AssemblyInfo.cs b/Utility/Properties/AssemblyInfo.cs index 7e729136..ae98fc89 100644 --- a/Utility/Properties/AssemblyInfo.cs +++ b/Utility/Properties/AssemblyInfo.cs @@ -6,7 +6,7 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle ("Activizr Utility Classes")] +[assembly: AssemblyTitle ("Swarmops Utility Classes")] [assembly: AssemblyDescription ("")] [assembly: AssemblyConfiguration ("")] [assembly: AssemblyCompany ("Disorganized")]