diff --git a/Logic/Financial/FinancialAccount.cs b/Logic/Financial/FinancialAccount.cs index 0547b70c..a33ef90d 100644 --- a/Logic/Financial/FinancialAccount.cs +++ b/Logic/Financial/FinancialAccount.cs @@ -9,7 +9,7 @@ using Activizr.Basic.Enums; namespace Activizr.Logic.Financial { - public class FinancialAccount : BasicFinancialAccount, ITreeNode + public class FinancialAccount : BasicFinancialAccount, ITreeNode, IOwnerSettable { private FinancialAccount (BasicFinancialAccount basic) : base(basic) @@ -82,6 +82,11 @@ namespace Activizr.Logic.Financial PirateDb.GetDatabase().SetFinancialAccountBudget(this.Identity, year, amount); } + public void SetBudgetCents (int year, Int64 amount) + { + PirateDb.GetDatabase().SetFinancialAccountBudget(this.Identity, year, amount / 100.0); // TODO: Change db structure to use cents + } + public void SetBudgetMontly (int year, int month, Int64 amountCents) { PirateDb.GetDatabase().SetFinancialAccountBudgetMonthly(this.Identity, year, month, amountCents); @@ -203,5 +208,14 @@ namespace Activizr.Logic.Financial private ObjectOptionalData _optionalData; #endregion + + #region IOwnerSettable members + + public void SetOwner(Person newOwner) + { + this.Owner = newOwner; + } + + #endregion } } \ No newline at end of file diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index cc1d5233..278526cd 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -65,6 +65,7 @@ + diff --git a/Logic/Pirates/Interfaces.cs b/Logic/Pirates/Interfaces.cs new file mode 100644 index 00000000..f3dc3ab4 --- /dev/null +++ b/Logic/Pirates/Interfaces.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Activizr.Logic.Pirates +{ + public interface IOwnerSettable + { + void SetOwner(Person newOwner); + } +} diff --git a/Site5/App_GlobalResources/Controls.Pirates.resx b/Site5/App_GlobalResources/Controls.Pirates.resx new file mode 100644 index 00000000..b8b2da37 --- /dev/null +++ b/Site5/App_GlobalResources/Controls.Pirates.resx @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Change Person... + Displayed in popup that shows an individual as owner of something + + + Change to: + Displayed as header above the person selector when changing person + + \ No newline at end of file diff --git a/Site5/App_GlobalResources/Pages.Global.resx b/Site5/App_GlobalResources/Global.resx similarity index 94% rename from Site5/App_GlobalResources/Pages.Global.resx rename to Site5/App_GlobalResources/Global.resx index 49c21311..d058e9b8 100644 --- a/Site5/App_GlobalResources/Pages.Global.resx +++ b/Site5/App_GlobalResources/Global.resx @@ -141,6 +141,10 @@ Dashboard Title of default page + + Cancel + Displayed as cancellation link on changing something + Change? Link after describing what the user is looking at, allowing a change. @@ -149,6 +153,10 @@ Click image to enlarge. Displayed where thumbnails can be enlarged modally. + + Confirm + Displayed as confirmation link on changing something + -- Select bookkeeping account -- Initializer in dropdown box. diff --git a/Site5/App_GlobalResources/Pages.Global.sv-SE.resx b/Site5/App_GlobalResources/Global.sv-SE.resx similarity index 100% rename from Site5/App_GlobalResources/Pages.Global.sv-SE.resx rename to Site5/App_GlobalResources/Global.sv-SE.resx diff --git a/Site5/Controls/v5/Base/LanguageSelector.ascx.cs b/Site5/Controls/v5/Base/LanguageSelector.ascx.cs index 75726e7b..0c9e4f20 100644 --- a/Site5/Controls/v5/Base/LanguageSelector.ascx.cs +++ b/Site5/Controls/v5/Base/LanguageSelector.ascx.cs @@ -13,7 +13,7 @@ namespace Activizr.Controls.Base { // Localize - this.LabelSelectLanguage.Text = Resources.Pages.Global.CurrentUserInfo_SelectLanguage.ToUpperInvariant(); + this.LabelSelectLanguage.Text = Resources.Global.CurrentUserInfo_SelectLanguage.ToUpperInvariant(); } protected void LinkDanish_Click(object sender, EventArgs e) diff --git a/Site5/Controls/v5/Pirates/PersonDetailPopup.ascx b/Site5/Controls/v5/Pirates/PersonDetailPopup.ascx index 094269ad..a547ae59 100644 --- a/Site5/Controls/v5/Pirates/PersonDetailPopup.ascx +++ b/Site5/Controls/v5/Pirates/PersonDetailPopup.ascx @@ -7,20 +7,20 @@
-


+


-

-
- +

+
+
- - + + diff --git a/Site5/Controls/v5/Pirates/PersonDetailPopup.ascx.cs b/Site5/Controls/v5/Pirates/PersonDetailPopup.ascx.cs index 9a0d4a17..52e2a194 100644 --- a/Site5/Controls/v5/Pirates/PersonDetailPopup.ascx.cs +++ b/Site5/Controls/v5/Pirates/PersonDetailPopup.ascx.cs @@ -13,6 +13,10 @@ using Activizr.Logic.Pirates; using Activizr.Logic.Security; using Telerik.Web.UI; + +public delegate void PersonChangedEventHandler(object sender, PersonChangedEventArgs e); + + public partial class Controls_v5_PersonDetailPopup : ControlV5Base { protected void Page_Load(object sender, EventArgs e) @@ -25,12 +29,22 @@ public partial class Controls_v5_PersonDetailPopup : ControlV5Base } this.LabelPersonName.Style[HtmlTextWriterStyle.FontSize] = "20px"; - this.PersonNewOwner.Width = 167; + this.PersonNew.Width = 157; + + this.ButtonSetNew.Visible = this.Changeable; + + // Localize + + this.ButtonSetNew.Text = Resources.Controls.Pirates.PersonDetailPopup_ChangePerson; + this.LabelWriteLabel.Text = Resources.Controls.Pirates.PersonDetailPopup_ChangeTo; + this.ButtonConfirmPerson.Text = Resources.Global.Global_Confirm; + this.ButtonCancel.Text = Resources.Global.Global_Cancel; } private Person _person; + public object Cookie { get; set; } public Person Person { @@ -38,7 +52,7 @@ public partial class Controls_v5_PersonDetailPopup : ControlV5Base { if (_person == null) { - return this.PersonNewOwner.SelectedPerson; + return this.PersonNew.SelectedPerson; } return _person; @@ -68,23 +82,14 @@ public partial class Controls_v5_PersonDetailPopup : ControlV5Base } - - public FinancialAccount Account - { - set - { - _account = value; - } - } + public bool Changeable { get; set; } - private FinancialAccount _account; - - protected void ButtonSetNewOwner_Click(object sender, EventArgs e) + protected void ButtonSetNew_Click(object sender, EventArgs e) { this.PanelRead.Visible = false; this.PanelWrite.Visible = true; - this.PersonNewOwner.Focus(); + this.PersonNew.Focus(); } public void Reset() @@ -92,7 +97,7 @@ public partial class Controls_v5_PersonDetailPopup : ControlV5Base this.PanelWrite.Visible = false; this.PanelRead.Visible = true; this.ButtonConfirmPerson.Visible = false; - this.PersonNewOwner.SelectedPerson = null; + this.PersonNew.SelectedPerson = null; if (ViewState[this.ClientID + "_PersonId"] == null) { @@ -105,25 +110,26 @@ public partial class Controls_v5_PersonDetailPopup : ControlV5Base } - protected void PersonNewOwner_SelectedPersonChanged(object sender, EventArgs e) + protected void PersonNew_SelectedPersonChanged(object sender, EventArgs e) { - this.ImageAvatar.ImageUrl = this.PersonNewOwner.SelectedPerson.GetSecureAvatarLink(96); + this.ImageAvatar.ImageUrl = this.PersonNew.SelectedPerson.GetSecureAvatarLink(96); this.ButtonConfirmPerson.Visible = true; } protected void ButtonConfirmPerson_Click(object sender, EventArgs e) { - if (this._account == null) - { - throw new InvalidOperationException("Can't set owner for null account"); - } + this._person = this.PersonNew.SelectedPerson; - this._account.Owner = this.PersonNewOwner.SelectedPerson; - this._person = this.PersonNewOwner.SelectedPerson; + IOwnerSettable settableInterface = this.Cookie as IOwnerSettable; + + if (settableInterface != null) + { + settableInterface.SetOwner(this._person); + } if (PersonChanged != null) { - PersonChanged(this, new EventArgs()); + PersonChanged(this, new PersonChangedEventArgs(this.PersonNew.SelectedPerson, this.Cookie)); } this.LabelPersonName.Text = _person.Name; @@ -136,6 +142,21 @@ public partial class Controls_v5_PersonDetailPopup : ControlV5Base Reset(); } - public event EventHandler PersonChanged; + public event PersonChangedEventHandler PersonChanged; } + + +public class PersonChangedEventArgs: EventArgs +{ + public PersonChangedEventArgs(Person newPerson, object cookie) + { + this.NewPerson = newPerson; + this.Cookie = cookie; + } + + public readonly Person NewPerson; + public readonly object Cookie; +} + + diff --git a/Site5/Default.aspx.cs b/Site5/Default.aspx.cs index 4541aaa8..bcc02a10 100644 --- a/Site5/Default.aspx.cs +++ b/Site5/Default.aspx.cs @@ -12,20 +12,20 @@ public partial class Default : PageV5Base protected void Page_Load(object sender, EventArgs e) { - this.PageTitle = Resources.Pages.Global.Dashboard_PageTitle; + this.PageTitle = Resources.Global.Dashboard_PageTitle; this.PageIcon = "iconshock-steering-wheel"; this.LabelActionListMotions.Text = Resources.Pages.Governance.ListMotions_PageTitle; this.LabelActionVote.Text = Resources.Pages.Governance.Vote_PageTitle; - this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; - this.LabelSidebarActions.Text = Resources.Pages.Global.Sidebar_Actions; - this.LabelSidebarTodo.Text = Resources.Pages.Global.Sidebar_Todo; + this.LabelSidebarInfo.Text = Resources.Global.Sidebar_Information; + this.LabelSidebarActions.Text = Resources.Global.Sidebar_Actions; + this.LabelSidebarTodo.Text = Resources.Global.Sidebar_Todo; - this.LabelActionItemsHere.Text = Resources.Pages.Global.Sidebar_Todo_Placeholder; - this.LabelGoThere.Text = Resources.Pages.Global.Global_GoThere; - this.LabelDashboardTemporaryContent.Text = Resources.Pages.Global.Dashboard_Main_Temporary; - this.LabelDashboardInfo.Text = Resources.Pages.Global.Dashboard_Info_Temporary; - this.LabelGoThere2.Text = Resources.Pages.Global.Global_GoThere; + this.LabelActionItemsHere.Text = Resources.Global.Sidebar_Todo_Placeholder; + this.LabelGoThere.Text = Resources.Global.Global_GoThere; + this.LabelDashboardTemporaryContent.Text = Resources.Global.Dashboard_Main_Temporary; + this.LabelDashboardInfo.Text = Resources.Global.Dashboard_Info_Temporary; + this.LabelGoThere2.Text = Resources.Global.Global_GoThere; } } diff --git a/Site5/Master-v5.master.cs b/Site5/Master-v5.master.cs index a5906a38..e7804d60 100644 --- a/Site5/Master-v5.master.cs +++ b/Site5/Master-v5.master.cs @@ -118,8 +118,8 @@ namespace Activizr this.ImageCultureIndicator.ImageUrl = "~/Images/Flags/" + flagName + ".png"; - this.LinkLogout.Text = Resources.Pages.Global.CurrentUserInfo_Logout; - this.LabelPreferences.Text = Resources.Pages.Global.CurrentUserInfo_Preferences; + this.LinkLogout.Text = Resources.Global.CurrentUserInfo_Logout; + this.LabelPreferences.Text = Resources.Global.CurrentUserInfo_Preferences; if (cultureStringLower != "en-gb" && cultureStringLower != "sv-se" && cultureString.Trim().Length > 0) { diff --git a/Site5/Pages/v5/Governance/AddMotion.aspx.cs b/Site5/Pages/v5/Governance/AddMotion.aspx.cs index f9c043ad..fe533a7c 100644 --- a/Site5/Pages/v5/Governance/AddMotion.aspx.cs +++ b/Site5/Pages/v5/Governance/AddMotion.aspx.cs @@ -36,10 +36,10 @@ namespace Activizr.Pages.Governance this.LabelText.Text = Resources.Pages.Governance.AddMotion_Text; this.LabelDecisions.Text = Resources.Pages.Governance.AddMotion_Decisions; - this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; - this.LabelSidebarActions.Text = Resources.Pages.Global.Sidebar_Actions; - this.LabelSidebarTodo.Text = Resources.Pages.Global.Sidebar_Todo; - this.LabelActionItemsHere.Text = Resources.Pages.Global.Sidebar_Todo_Placeholder; + this.LabelSidebarInfo.Text = Resources.Global.Sidebar_Information; + this.LabelSidebarActions.Text = Resources.Global.Sidebar_Actions; + this.LabelSidebarTodo.Text = Resources.Global.Sidebar_Todo; + this.LabelActionItemsHere.Text = Resources.Global.Sidebar_Todo_Placeholder; this.ButtonAddMotion.Text = Resources.Pages.Governance.AddMotion_SubmitMotion; diff --git a/Site5/Pages/v5/Governance/AddMotionAmendment.aspx.cs b/Site5/Pages/v5/Governance/AddMotionAmendment.aspx.cs index 85ae4120..e5baa7cc 100644 --- a/Site5/Pages/v5/Governance/AddMotionAmendment.aspx.cs +++ b/Site5/Pages/v5/Governance/AddMotionAmendment.aspx.cs @@ -37,10 +37,10 @@ namespace Activizr.Pages.Governance this.LabelText.Text = Resources.Pages.Governance.AddMotionAmendment_Text; this.LabelDecision.Text = Resources.Pages.Governance.AddMotionAmendment_Decision; - this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; - this.LabelSidebarActions.Text = Resources.Pages.Global.Sidebar_Actions; - this.LabelSidebarTodo.Text = Resources.Pages.Global.Sidebar_Todo; - this.LabelActionItemsHere.Text = Resources.Pages.Global.Sidebar_Todo_Placeholder; + this.LabelSidebarInfo.Text = Resources.Global.Sidebar_Information; + this.LabelSidebarActions.Text = Resources.Global.Sidebar_Actions; + this.LabelSidebarTodo.Text = Resources.Global.Sidebar_Todo; + this.LabelActionItemsHere.Text = Resources.Global.Sidebar_Todo_Placeholder; this.ButtonAddMotionAmendment.Text = Resources.Pages.Governance.AddMotionAmendment_SubmitAmendment; diff --git a/Site5/Pages/v5/Governance/ListMotions.aspx.cs b/Site5/Pages/v5/Governance/ListMotions.aspx.cs index 698e1ed6..d2c2c03f 100644 --- a/Site5/Pages/v5/Governance/ListMotions.aspx.cs +++ b/Site5/Pages/v5/Governance/ListMotions.aspx.cs @@ -49,14 +49,14 @@ namespace Activizr.Pages.Governance private void Localize() { - this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; - this.LabelSidebarActions.Text = Resources.Pages.Global.Sidebar_Actions; - this.LabelSidebarTodo.Text = Resources.Pages.Global.Sidebar_Todo; - this.LabelActionItemsHere.Text = Resources.Pages.Global.Sidebar_Todo_Placeholder; + this.LabelSidebarInfo.Text = Resources.Global.Sidebar_Information; + this.LabelSidebarActions.Text = Resources.Global.Sidebar_Actions; + this.LabelSidebarTodo.Text = Resources.Global.Sidebar_Todo; + this.LabelActionItemsHere.Text = Resources.Global.Sidebar_Todo_Placeholder; this.LabelSidebarLookingAt.Text = Resources.Pages.Governance.ListMotions_Sidebar_Info; this.LabelMeetingName.Text = _meeting.Name; - this.LabelChangeMeeting.Text = Resources.Pages.Global.Global_Change; + this.LabelChangeMeeting.Text = Resources.Global.Global_Change; LocalizeGrid(); } diff --git a/Site5/Pages/v5/Governance/ViewMotion.aspx.cs b/Site5/Pages/v5/Governance/ViewMotion.aspx.cs index 7bb5fde2..d8da7b3d 100644 --- a/Site5/Pages/v5/Governance/ViewMotion.aspx.cs +++ b/Site5/Pages/v5/Governance/ViewMotion.aspx.cs @@ -38,10 +38,10 @@ namespace Activizr.Pages.Governance this.LabelMotionTextLabel.Text = Resources.Pages.Governance.ViewMotion_Text; this.LabelViewingMotionInfo.Text = Resources.Pages.Governance.ViewMotion_ViewingMotionInfo; - this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; - this.LabelSidebarActions.Text = Resources.Pages.Global.Sidebar_Actions; - this.LabelSidebarTodo.Text = Resources.Pages.Global.Sidebar_Todo; - this.LabelActionItemsHere.Text = Resources.Pages.Global.Sidebar_Todo_Placeholder; + this.LabelSidebarInfo.Text = Resources.Global.Sidebar_Information; + this.LabelSidebarActions.Text = Resources.Global.Sidebar_Actions; + this.LabelSidebarTodo.Text = Resources.Global.Sidebar_Todo; + this.LabelActionItemsHere.Text = Resources.Global.Sidebar_Todo_Placeholder; // Fill in fields diff --git a/Site5/Pages/v5/Governance/Vote.aspx.cs b/Site5/Pages/v5/Governance/Vote.aspx.cs index bc3e9866..2e7ce184 100644 --- a/Site5/Pages/v5/Governance/Vote.aspx.cs +++ b/Site5/Pages/v5/Governance/Vote.aspx.cs @@ -18,10 +18,10 @@ namespace Activizr.Pages.Governance this.PageTitle = Resources.Pages.Governance.Vote_PageTitle; this.PageIcon = "iconshock-vote"; - this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; - this.LabelSidebarActions.Text = Resources.Pages.Global.Sidebar_Actions; - this.LabelSidebarTodo.Text = Resources.Pages.Global.Sidebar_Todo; - this.LabelActionItemsHere.Text = Resources.Pages.Global.Sidebar_Todo_Placeholder; + this.LabelSidebarInfo.Text = Resources.Global.Sidebar_Information; + this.LabelSidebarActions.Text = Resources.Global.Sidebar_Actions; + this.LabelSidebarTodo.Text = Resources.Global.Sidebar_Todo; + this.LabelActionItemsHere.Text = Resources.Global.Sidebar_Todo_Placeholder; this.LabelActionListMotions.Text = Resources.Pages.Governance.ListMotions_PageTitle; this.LabelVotingInfo.Text = String.Format(Resources.Pages.Governance.Vote_Info, _currentOrganization.Name); diff --git a/Site5/Pages/v5/Governance/VoteAmendments.aspx.cs b/Site5/Pages/v5/Governance/VoteAmendments.aspx.cs index 5dae5525..908ae932 100644 --- a/Site5/Pages/v5/Governance/VoteAmendments.aspx.cs +++ b/Site5/Pages/v5/Governance/VoteAmendments.aspx.cs @@ -70,11 +70,11 @@ namespace Activizr.Pages.Governance private void Localize() { this.LabelActionListMotions.Text = Resources.Pages.Governance.ListMotions_PageTitle; - this.LabelActionItemsHere.Text = Resources.Pages.Global.Sidebar_Todo_Placeholder; + this.LabelActionItemsHere.Text = Resources.Global.Sidebar_Todo_Placeholder; this.LabelAmendmentsForMeeting.Text = _meeting.Name; - this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; - this.LabelSidebarActions.Text = Resources.Pages.Global.Sidebar_Actions; - this.LabelSidebarTodo.Text = Resources.Pages.Global.Sidebar_Todo; + this.LabelSidebarInfo.Text = Resources.Global.Sidebar_Information; + this.LabelSidebarActions.Text = Resources.Global.Sidebar_Actions; + this.LabelSidebarTodo.Text = Resources.Global.Sidebar_Todo; this.ButtonSaveVote.Text = Resources.Pages.Governance.VoteAmendments_SaveVote_Temp; this.LabelInfo.Text = Resources.Pages.Governance.VoteAmendments_Info; diff --git a/Site5/Pages/v5/Ledgers/SetRootBudgets.aspx b/Site5/Pages/v5/Ledgers/SetRootBudgets.aspx index eea92a41..5f2985e7 100644 --- a/Site5/Pages/v5/Ledgers/SetRootBudgets.aspx +++ b/Site5/Pages/v5/Ledgers/SetRootBudgets.aspx @@ -3,7 +3,9 @@ - + + +

@@ -15,10 +17,10 @@
Budget, Owner [LOC]
-     
+ Skin="Telerik">
 
 
diff --git a/Site5/Pages/v5/Ledgers/SetRootBudgets.aspx.cs b/Site5/Pages/v5/Ledgers/SetRootBudgets.aspx.cs index 86dbf875..b2540fc2 100644 --- a/Site5/Pages/v5/Ledgers/SetRootBudgets.aspx.cs +++ b/Site5/Pages/v5/Ledgers/SetRootBudgets.aspx.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; @@ -7,14 +8,31 @@ using Activizr.Basic.Enums; using Activizr.Logic.Financial; using Activizr.Logic.Pirates; using Activizr.Logic.Security; +using Activizr.Logic.Structure; using Telerik.Web.UI; public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base { + protected void Page_Init (object sender, EventArgs e) + { + if (Page.IsPostBack) + { + // Create controls, for amounts to be set in Page_Load. This is necessary for events to fire. + // We don't know the year setting here yet. + + FinancialAccounts accounts = GetRootLevelResultAccounts(); + + this.RepeaterAccountBudgets.DataSource = accounts; + this.RepeaterAccountBudgets.DataBind(); + } + } + protected void Page_Load(object sender, EventArgs e) { this.PageAccessRequired = new Access(_currentOrganization, AccessAspect.Bookkeeping, AccessType.Write); + this.HiddenInitOrganizationId.Value = _currentOrganization.Identity.ToString(); + this.PageIcon = "iconshock-moneybag"; this.PageTitle = Resources.Pages.Ledgers.SetRootBudgets_PageTitle; @@ -29,7 +47,7 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base { this.DropYears.Items.Add(new ListItem(currentYear.ToString())); currentYear--; - } while (accounts[0].GetBudgetCents(currentYear) > 0); + } while (accounts[0].GetTree().GetBudgetSumCents(currentYear) > 0); this.DropYears.SelectedIndex = 0; @@ -52,6 +70,9 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base this.DropYears.Style[HtmlTextWriterStyle.FontWeight] = "bold"; this.ButtonSetBudgets.Style[HtmlTextWriterStyle.MarginTop] = "4px"; this.ButtonSetBudgets.Style[HtmlTextWriterStyle.MarginBottom] = "5px"; + this.ButtonSetBudgets.Style[HtmlTextWriterStyle.Padding] = "1px"; + + RebindTooltips(); } protected void UpdateYearlyResult(FinancialAccounts rootAccounts) @@ -62,7 +83,7 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base foreach (FinancialAccount account in rootAccounts) { budgetSum += account.GetTree().GetBudgetSumCents(_year)/100; - actualSum -= account.GetTree().GetDeltaCents(new DateTime(_year,1,1), new DateTime(_year+1, 1, 1))/100; // negative: results accounts are sign reversed + actualSum -= (account.GetTree().GetDeltaCents(new DateTime(_year,1,1), new DateTime(_year+1, 1, 1))+50)/100; // negative: results accounts are sign reversed } this.TextYearlyResult.Text = String.Format("{0:N0}", budgetSum); @@ -106,11 +127,14 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base FinancialAccount account = (FinancialAccount)item.DataItem; - TextBox textBudget = (TextBox) e.Item.FindControl("TextBudget"); + TextBox textBudget = (TextBox) e.Item.FindControl("TextBudget"); - textBudget.Text = String.Format("{0:N0}", account.GetTree().GetBudgetSumCents(_year)/100); - textBudget.Style[HtmlTextWriterStyle.TextAlign] = "right"; - textBudget.Style[HtmlTextWriterStyle.Width] = "80px"; + if (_year > 0) // called from after viewstate parsed + { + textBudget.Text = String.Format("{0:N0}", account.GetTree().GetBudgetSumCents(_year)/100); + textBudget.Style[HtmlTextWriterStyle.TextAlign] = "right"; + textBudget.Style[HtmlTextWriterStyle.Width] = "80px"; + } Label labelOwnerName = (Label) e.Item.FindControl("LabelBudgetOwner"); Person accountOwner = account.Owner; @@ -126,12 +150,12 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base RadToolTip toolTip = (RadToolTip)e.Item.FindControl("ToolTip"); Controls_v5_PersonDetailPopup personDetail = (Controls_v5_PersonDetailPopup)toolTip.FindControl("PersonDetail"); - personDetail.PersonChanged += new EventHandler(PersonDetail_PersonChanged); + personDetail.PersonChanged += new PersonChangedEventHandler(PersonDetail_PersonChanged); if (!Page.IsPostBack && _authority != null) { personDetail.Person = accountOwner; - personDetail.Account = account; + personDetail.Cookie = account; } HiddenField hiddenAccountId = (HiddenField) e.Item.FindControl("HiddenAccountId"); @@ -140,23 +164,22 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base // this.TooltipManager.TargetControls.Add(labelBudgetOwner.ClientID, line.AccountIdentity.ToString(), true); } - void PersonDetail_PersonChanged(object sender, EventArgs e) + + void PersonDetail_PersonChanged(object sender, PersonChangedEventArgs e) { // Here, an owner has changed. We need to re-bind the owners column. - /* - FinancialAccounts accounts = _account.Children; - AccountBudgetLines childData = new AccountBudgetLines(); + // TODO: This resets the budget amounts to the values in the database, which is not really what we want. - foreach (FinancialAccount account in accounts) - { - childData.Add(new AccountBudgetLine(account, _year)); - } + FinancialAccount account = (FinancialAccount) e.Cookie; + account.Owner = e.NewPerson; - this.RepeaterBudgetOwners.DataSource = childData; - this.RepeaterBudgetOwners.DataBind(); + FinancialAccounts accounts = GetRootLevelResultAccounts(); - RebindTooltips();*/ + this.RepeaterAccountBudgets.DataSource = accounts; + this.RepeaterAccountBudgets.DataBind(); + + RebindTooltips(); } protected void DropYears_SelectedIndexChanged(object sender, EventArgs e) @@ -176,8 +199,18 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base private FinancialAccounts GetRootLevelResultAccounts() { - FinancialAccount yearlyResult = _currentOrganization.FinancialAccounts.CostsYearlyResult; - FinancialAccounts allAccounts = FinancialAccounts.ForOrganization(_currentOrganization, FinancialAccountType.Result); + Organization org = _currentOrganization; + + if (org == null && Page.IsPostBack) + { + // If we're being called from Page_Init to create controls just to catch events, then _currentOrganization won't be set. + // We need to create it temporarily from a hidden field: + + org = Organization.FromIdentity(Int32.Parse(Request["ctl00$PlaceHolderMain$HiddenInitOrganizationId"])); + } + + FinancialAccount yearlyResult = org.FinancialAccounts.CostsYearlyResult; + FinancialAccounts allAccounts = FinancialAccounts.ForOrganization(org, FinancialAccountType.Result); // Select root accounts @@ -207,7 +240,7 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base FinancialAccount account = FinancialAccount.FromIdentity(Int32.Parse(hiddenAccountId.Value)); personDetail.Person = account.Owner; - personDetail.Account = account; + personDetail.Cookie = child; } } @@ -224,14 +257,44 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base Label labelActuals = (Label) e.Item.FindControl("LabelAccountActuals"); - Int64 actuals = account.GetTree().GetDeltaCents(new DateTime(_year, 1, 1), new DateTime(_year + 1, 1, 1))/ + Int64 actuals = (account.GetTree().GetDeltaCents(new DateTime(_year, 1, 1), new DateTime(_year + 1, 1, 1))+50)/ 100; labelActuals.Text = String.Format("{0:N0}", -actuals); // negative as results accounts are sign reversed } + protected void ButtonSetBudgets_Click(object sender, EventArgs e) { - throw new NotImplementedException(); + foreach (RepeaterItem repeaterItem in this.RepeaterAccountBudgets.Items) + { + HiddenField hiddenAccountId = (HiddenField) repeaterItem.FindControl("HiddenAccountId"); + TextBox textBudget = (TextBox) repeaterItem.FindControl("TextBudget"); + FinancialAccount account = FinancialAccount.FromIdentity(Int32.Parse(hiddenAccountId.Value)); + + // TODO: Possible race condition here, fix with HiddenField + + Int64 newBudgetAmount = Int64.Parse(textBudget.Text.Replace(",","").Replace(" ",""), Thread.CurrentThread.CurrentCulture); // TODO: May throw -- catch and send error message + + Int64 currentBudgetAmount = account.GetTree().GetBudgetSumCents(_year)/100; + + // Set the new amount to the difference between the single budget of this account and the intended amount + + if (newBudgetAmount != currentBudgetAmount) + { + account.SetBudgetCents(_year, + account.GetBudgetCents(_year) + (newBudgetAmount - currentBudgetAmount)*100); + } + } + + // After updating budgets, rebind repeater + + FinancialAccounts accounts = GetRootLevelResultAccounts(); + + UpdateYearlyResult(accounts); + + this.RepeaterAccountBudgets.DataSource = accounts; + this.RepeaterAccountBudgets.DataBind(); + } } \ No newline at end of file diff --git a/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs b/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs index fc23f522..230d8c67 100644 --- a/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs +++ b/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs @@ -33,22 +33,22 @@ namespace Activizr.Site.Pages.Ledgers { // Localize - this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; - this.LabelSidebarActions.Text = Resources.Pages.Global.Sidebar_Actions; - this.LabelSidebarTodo.Text = Resources.Pages.Global.Sidebar_Todo; + this.LabelSidebarInfo.Text = Resources.Global.Sidebar_Information; + this.LabelSidebarActions.Text = Resources.Global.Sidebar_Actions; + this.LabelSidebarTodo.Text = Resources.Global.Sidebar_Todo; this.LabelDownloadInstructions.Text = Resources.Pages.Ledgers.UploadBankFiles_DownloadInstructions; - this.LabelClickImage.Text = Resources.Pages.Global.Global_ClickImageToEnlarge; + this.LabelClickImage.Text = Resources.Global.Global_ClickImageToEnlarge; this.LabelUploadBankFilesInfo.Text = Resources.Pages.Ledgers.UploadBankFiles_Info; - this.LabelActionItemsHere.Text = Resources.Pages.Global.Sidebar_Todo_Placeholder; + this.LabelActionItemsHere.Text = Resources.Global.Sidebar_Todo_Placeholder; this.LabelSelectBankAndAccount.Text = Resources.Pages.Ledgers.UploadBankFiles_SelectBankAndAccount; this.LabelSelectFileType.Text = Resources.Pages.Ledgers.UploadBankFiles_SelectBankFileType; this.LabelSelectAccount.Text = Resources.Pages.Ledgers.UploadBankFiles_SelectAccount; this.LabelUploadH2Header.Text = Resources.Pages.Ledgers.UploadBankFiles_UploadBankFile; - this.LabelUploadH3Header.Text = Resources.Pages.Global.Global_UploadFileToActivizr; - this.Upload.Text = Resources.Pages.Global.Global_UploadFile; - this.LabelProcessing.Text = Resources.Pages.Global.Global_ProcessingFile; + this.LabelUploadH3Header.Text = Resources.Global.Global_UploadFileToActivizr; + this.Upload.Text = Resources.Global.Global_UploadFile; + this.LabelProcessing.Text = Resources.Global.Global_ProcessingFile; this.LinkUploadAnother.Text = Resources.Pages.Ledgers.UploadBankFiles_UploadAnother; this.LabelModalInstructionHeader.Text = Resources.Pages.Ledgers.UploadBankFiles_BankScreenshot; @@ -176,7 +176,7 @@ namespace Activizr.Site.Pages.Ledgers FinancialAccountType.Asset); this.DropAccounts.Items.Clear(); - this.DropAccounts.Items.Add(Resources.Pages.Global.Global_DropInits_SelectFinancialAccount); + this.DropAccounts.Items.Add(Resources.Global.Global_DropInits_SelectFinancialAccount); foreach (FinancialAccount account in accounts) { @@ -300,7 +300,7 @@ namespace Activizr.Site.Pages.Ledgers { // If no file was uploaded, re-show the instructions div - this.LabelNoFileUploaded.Text = Resources.Pages.Global.Global_Upload_ErrorSelectFile; + this.LabelNoFileUploaded.Text = Resources.Global.Global_Upload_ErrorSelectFile; this.LiteralDivInstructionsStyle.Text = @"style='display:inline'"; } else diff --git a/Site5/Pages/v5/Security/AccessDenied.aspx.cs b/Site5/Pages/v5/Security/AccessDenied.aspx.cs index 806d3a9f..1308f949 100644 --- a/Site5/Pages/v5/Security/AccessDenied.aspx.cs +++ b/Site5/Pages/v5/Security/AccessDenied.aspx.cs @@ -12,7 +12,7 @@ public partial class Security_AccessDenied : PageV5Base this.PageIcon = "iconshock-disconnect"; this.LabelAccessDeniedHeader.Text = Resources.Pages.Security.AccessDenied_Header; - this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; + this.LabelSidebarInfo.Text = Resources.Global.Sidebar_Information; this.LabelAccessDeniedInfo.Text = Resources.Pages.Security.AccessDenied_Info; this.LiteralAccessDeniedRant.Text = String.Format(Resources.Pages.Security.AccessDenied_Rant, _currentOrganization.Name); }