diff --git a/Site5/App_GlobalResources/Pages.Ledgers.resx b/Site5/App_GlobalResources/Pages.Ledgers.resx index ff70927a..0cbcfcaa 100644 --- a/Site5/App_GlobalResources/Pages.Ledgers.resx +++ b/Site5/App_GlobalResources/Pages.Ledgers.resx @@ -117,6 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Set Root Level Budgets + Displayed above main content + Bank Screenshot Displayed as header above modally zoomed screenshot diff --git a/Site5/Images/PageIcons/iconshock-moneybag-128px.png b/Site5/Images/PageIcons/iconshock-moneybag-128px.png new file mode 100644 index 00000000..ed312d84 Binary files /dev/null and b/Site5/Images/PageIcons/iconshock-moneybag-128px.png differ diff --git a/Site5/Images/PageIcons/iconshock-moneybag-16px.png b/Site5/Images/PageIcons/iconshock-moneybag-16px.png new file mode 100644 index 00000000..ac6bd3f5 Binary files /dev/null and b/Site5/Images/PageIcons/iconshock-moneybag-16px.png differ diff --git a/Site5/Images/PageIcons/iconshock-moneybag-40px.png b/Site5/Images/PageIcons/iconshock-moneybag-40px.png new file mode 100644 index 00000000..b5830183 Binary files /dev/null and b/Site5/Images/PageIcons/iconshock-moneybag-40px.png differ diff --git a/Site5/Images/PageIcons/iconshock-treasure-16px.png b/Site5/Images/PageIcons/iconshock-treasure-16px.png new file mode 100644 index 00000000..508372fb Binary files /dev/null and b/Site5/Images/PageIcons/iconshock-treasure-16px.png differ diff --git a/Site5/Images/PageIcons/iconshock-treasure-40px.png b/Site5/Images/PageIcons/iconshock-treasure-40px.png new file mode 100644 index 00000000..7c99abbd Binary files /dev/null and b/Site5/Images/PageIcons/iconshock-treasure-40px.png differ diff --git a/Site5/Master-v5.master b/Site5/Master-v5.master index 976c0a40..3be4475a 100644 --- a/Site5/Master-v5.master +++ b/Site5/Master-v5.master @@ -119,7 +119,7 @@ - + diff --git a/Site5/Pages/v5/Ledgers/SetRootBudgets.aspx b/Site5/Pages/v5/Ledgers/SetRootBudgets.aspx new file mode 100644 index 00000000..6949f74e --- /dev/null +++ b/Site5/Pages/v5/Ledgers/SetRootBudgets.aspx @@ -0,0 +1,57 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="SetRootBudgets.aspx.cs" Inherits="Pages_v5_Ledgers_SetRootBudgets" %> + + + + + +

+ + +
+  
+  
+
+ +
+ +
+ + +

+ +
+
+ +
+
+ +

+ +
+
+
+
+ +

+ +
+
+ +
+
+ + + +
+ diff --git a/Site5/Pages/v5/Ledgers/SetRootBudgets.aspx.cs b/Site5/Pages/v5/Ledgers/SetRootBudgets.aspx.cs new file mode 100644 index 00000000..9ca5f3c8 --- /dev/null +++ b/Site5/Pages/v5/Ledgers/SetRootBudgets.aspx.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Activizr.Basic.Enums; +using Activizr.Logic.Financial; +using Activizr.Logic.Security; + +public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base +{ + protected void Page_Load(object sender, EventArgs e) + { + this.PageAccessRequired = new Access(_currentOrganization, AccessAspect.Bookkeeping, AccessType.Write); + + this.PageIcon = "iconshock-moneybag"; + this.PageTitle = Resources.Pages.Ledgers.SetRootBudgets_PageTitle; + + if (!Page.IsPostBack) + { + FinancialAccounts accounts = GetRootLevelAccounts(); + + int currentYear = DateTime.Today.Year; + _year = currentYear; + + do + { + this.DropYears.Items.Add(new ListItem(currentYear.ToString())); + currentYear--; + } while (accounts[0].GetBudgetCents(currentYear) > 0); + + this.DropYears.SelectedIndex = 0; + + this.RepeaterAccountNames.DataSource = accounts; + this.RepeaterAccountNames.DataBind(); + + this.RepeaterAccountBudgets.DataSource = accounts; + this.RepeaterAccountBudgets.DataBind(); + } + else + { + _year = Int32.Parse(DropYears.SelectedItem.Text); + } + + this.DropYears.Style[HtmlTextWriterStyle.FontWeight] = "bold"; + } + + private int _year; + + protected void RepeaterAccountNames_ItemDataBound(object sender, RepeaterItemEventArgs e) + { + RepeaterItem item = e.Item; + + if (item.DataItem == null) + { + return; + } + + FinancialAccount account = (FinancialAccount) item.DataItem; + + Label labelAccountName = (Label) e.Item.FindControl("LabelAccountName"); + Label labelAccountType = (Label) e.Item.FindControl("LabelAccountType"); + + labelAccountName.Text = account.Name; + + // TODO: Add Type Too + + labelAccountType.Text = account.AccountType.ToString(); + } + + protected void RepeaterAccountBudgets_ItemDataBound(object sender, RepeaterItemEventArgs e) + { + RepeaterItem item = e.Item; + + if (item.DataItem == null) + { + return; + } + + FinancialAccount account = (FinancialAccount)item.DataItem; + + TextBox textBudget = (TextBox) e.Item.FindControl("TextBudget"); + + textBudget.Text = String.Format("{0:N0}", account.GetBudgetCents(_year)/100); + textBudget.Style[HtmlTextWriterStyle.TextAlign] = "right"; + textBudget.Style[HtmlTextWriterStyle.Width] = "150px"; + + } + + protected void DropYears_SelectedIndexChanged(object sender, EventArgs e) + { + FinancialAccounts accounts = GetRootLevelAccounts(); + + this.RepeaterAccountBudgets.DataSource = accounts; + this.RepeaterAccountBudgets.DataBind(); + } + + private FinancialAccounts GetRootLevelAccounts() + { + FinancialAccounts allAccounts = FinancialAccounts.ForOrganization(_currentOrganization, FinancialAccountType.Result); + + // Select root accounts + + FinancialAccounts accounts = new FinancialAccounts(); + + foreach (FinancialAccount account in allAccounts) + { + if (account.ParentFinancialAccountId == 0) + { + accounts.Add(account); + } + } + + return accounts; + } +} \ No newline at end of file