Removed obsolete page

This commit is contained in:
Rick Falkvinge
2015-02-11 12:07:02 +01:00
parent a06c0a44b4
commit 5233b7d3d9
2 changed files with 0 additions and 405 deletions
@@ -1,70 +0,0 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="SetRootBudgets.aspx.cs" Inherits="Pages_v5_Ledgers_SetRootBudgets" %>
<%@ Register src="~/Controls/v5/Swarm/PersonDetailPopup.ascx" tagName="PersonDetailPopup" tagPrefix="act5" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
<asp:HiddenField ID="HiddenInitOrganizationId" Value="" runat="server" />
<h2><asp:Label ID="LabelRootBudgetHeader" Text="Root Budgets For Org [LOC]" runat="server" /><div style="float:right"><asp:DropDownList ID="DropYears" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropYears_SelectedIndexChanged" /></div></h2>
<div class="entryLabelsAdmin" style="margin-right:30px;width:200px">
<strong><asp:Label ID="LabelAccountHeader" Text="Account [LOC]" runat="server" /></strong><br/>
<asp:Repeater ID="RepeaterAccountNames" runat="server" OnItemDataBound="RepeaterAccountNames_ItemDataBound" ><ItemTemplate><asp:Label ID="LabelAccountName" runat="server" Text="Unset Account Name" /> <em>(<asp:Label ID="LabelAccountType" runat="server" Text="Type [LOC]" />)</em><br /></ItemTemplate></asp:Repeater>
<em><asp:Label ID="LabelYearlyResultLabel" runat="server" Text="Yearly Result [LOC]" /></em>
</div>
<div class="entryFieldsAdmin">
<strong><asp:Label ID="LabelBudgetOwnerHeader" runat="server" Text="Budget, Owner [LOC]" /></strong><br/>
<asp:Repeater ID="RepeaterAccountBudgets" OnItemDataBound="RepeaterAccountBudgets_ItemDataBound" runat="server"><ItemTemplate><asp:HiddenField runat="server" ID="HiddenAccountId" /><asp:HiddenField runat="server" ID="HiddenCurrentBudget" /><asp:TextBox ID="TextBudget" runat="server" Text="Not set" />&nbsp;&nbsp;<span style="border-bottom: dashed 1px #808080;cursor:pointer"><asp:Label ID="LabelBudgetOwner" runat="server" /></span><br/></ItemTemplate></asp:Repeater>
<asp:TextBox ID="TextYearlyResult" Text="Yearly Result (fill in programmatically)" runat="server" ReadOnly="true" Enabled="false" />&nbsp;<br/>
<asp:Button ID="ButtonSetBudgets" Text="Set New Budgets [LOC]" OnClick="ButtonSetBudgets_Click" runat="server" />&nbsp;
</div>
<div class="entryLabelsAdmin" style="margin-left:20px;width:100px;text-align:right">
<strong><asp:Label ID="LabelActualsHeader" Text="Actuals [LOC]" runat="server" /></strong><br/>
<asp:Repeater ID="RepeaterAccountActuals" runat="server" OnItemDataBound="RepeaterAccountActuals_ItemDataBound"><ItemTemplate><asp:Label ID="LabelAccountActuals" Text="Unset actuals" runat="server" /><br/></ItemTemplate></asp:Repeater>
<asp:Label ID="LabelYearlyResultActuals" runat="server" Text="Yearly Result [LOC]" /><br/>
</div>
<div style="clear:both"></div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
<h2 class="blue"><asp:Label ID="LabelSidebarInfo" runat="server" Text="INFO [Loc]" /><span class="arrow"></span></h2>
<div class="box">
<div class="content">
<asp:Label ID="LabelDashboardInfo" Text="You have not localized the dashboard information box." runat="server" /></a>
</div>
</div>
<h2 class="blue"><asp:Label ID="LabelSidebarActions" Text="ACTIONS [Loc]" runat="server" /><span class="arrow"></span></h2>
<div class="box">
<div class="content"><!--
<div class="link-row-encaps" onclick="document.location='/Pages/v5/Governance/Vote.aspx';" >
<div class="link-row-icon" style="background-image:url('/Images/PageIcons/iconshock-vote-16px.png')"></div>
<asp:Label ID="LabelActionVote" runat="server" />
</div>
<div class="link-row-encaps" onclick="document.location='/Pages/v5/Governance/ListMotions.aspx';" >
<div class="link-row-icon" style="background-image:url('/Images/PageIcons/iconshock-motions-16px.png')"></div>
<asp:Label ID="LabelActionListMotions" runat="server" />
</div>-->
</div>
</div>
<h2 class="orange"><asp:Label ID="LabelSidebarTodo" Text="TODO [Loc]" runat="server" /><span class="arrow"></span></h2>
<div class="box">
<div class="content">
<asp:Label ID="LabelActionItemsHere" runat="server" />
</div>
</div>
</asp:Content>
@@ -1,335 +0,0 @@
using System;
using System.Threading;
using System.Web.UI;
using System.Web.UI.WebControls;
using Resources;
using Resources.Pages;
using Swarmops.Basic.Enums;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Swarm;
public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base
{
private int _year;
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)
{
PageAccessRequired = new Access (CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Write);
this.HiddenInitOrganizationId.Value = CurrentOrganization.Identity.ToString();
PageIcon = "iconshock-moneybag";
PageTitle = Ledgers.SetRootBudgets_PageTitle;
if (!Page.IsPostBack)
{
FinancialAccounts accounts = GetRootLevelResultAccounts();
int currentYear = DateTime.Today.Year;
this._year = currentYear;
do
{
this.DropYears.Items.Add (new ListItem (currentYear.ToString()));
currentYear--;
} while (accounts[0].GetTree().GetBudgetSumCents (currentYear) > 0);
this.DropYears.SelectedIndex = 0;
this.RepeaterAccountNames.DataSource = accounts;
this.RepeaterAccountNames.DataBind();
this.RepeaterAccountBudgets.DataSource = accounts;
this.RepeaterAccountBudgets.DataBind();
this.RepeaterAccountActuals.DataSource = accounts;
this.RepeaterAccountActuals.DataBind();
UpdateYearlyResult (accounts);
this.LabelRootBudgetHeader.Text = String.Format (Ledgers.SetRootBudgets_PageHeader,
CurrentOrganization.Name);
this.LabelAccountHeader.Text = Global.Financial_BookkeepingAccountShort;
this.LabelYearlyResultLabel.Text = Global.Financial_YearlyResult;
this.ButtonSetBudgets.Text = Ledgers.SetRootBudgets_SetNewBudgets;
this.LabelBudgetOwnerHeader.Text = Ledgers.SetRootBudgets_BudgetOwnerHeader;
this.LabelSidebarActions.Text = Global.Sidebar_Actions;
this.LabelSidebarInfo.Text = Global.Sidebar_Information;
this.LabelSidebarTodo.Text = Global.Sidebar_Todo;
this.LabelDashboardInfo.Text = Ledgers.SetRootBudgets_Info;
LocalizeActualsHeader();
}
else
{
this._year = Int32.Parse (this.DropYears.SelectedItem.Text);
}
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();
}
private void LocalizeActualsHeader()
{
if (CurrentOrganization.Parameters.FiscalBooksClosedUntilYear >= this._year)
{
this.LabelActualsHeader.Text = Global.Financial_Actuals;
}
else if (this._year == DateTime.Today.Year)
{
this.LabelActualsHeader.Text = Global.Financial_ActualsToDate;
}
else
{
this.LabelActualsHeader.Text = Global.Financial_ActualsPreliminary;
}
}
protected void UpdateYearlyResult (FinancialAccounts rootAccounts)
{
Int64 budgetSum = 0;
Int64 actualSum = 0;
foreach (FinancialAccount account in rootAccounts)
{
budgetSum += account.GetTree().GetBudgetSumCents (this._year)/100;
actualSum -=
(account.GetTree().GetDeltaCents (new DateTime (this._year, 1, 1), new DateTime (this._year + 1, 1, 1)) +
50)/100; // negative: results accounts are sign reversed
}
this.TextYearlyResult.Text = String.Format ("{0:N0}", budgetSum);
this.TextYearlyResult.Style[HtmlTextWriterStyle.Width] = "80px";
this.TextYearlyResult.Style[HtmlTextWriterStyle.TextAlign] = "right";
this.LabelYearlyResultActuals.Text = String.Format ("{0:N0}", actualSum);
}
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");
if (this._year > 0) // called from after viewstate parsed
{
textBudget.Text = String.Format ("{0:N0}", account.GetTree().GetBudgetSumCents (this._year)/100);
textBudget.Style[HtmlTextWriterStyle.TextAlign] = "right";
textBudget.Style[HtmlTextWriterStyle.Width] = "80px";
}
Label labelOwnerName = (Label) e.Item.FindControl ("LabelBudgetOwner");
Person accountOwner = account.Owner;
if (accountOwner == null)
{
labelOwnerName.Text = Global.Global_NoOwner;
}
else
{
labelOwnerName.Text = accountOwner.Formal;
}
// RadToolTip toolTip = (RadToolTip)e.Item.FindControl("ToolTip");
// Swarmops.Controls.Swarm.PersonDetailPopup personDetail = (PersonDetailPopup)toolTip.FindControl("PersonDetail");
// personDetail.PersonChanged += new PersonChangedEventHandler(PersonDetail_PersonChanged);
if (!Page.IsPostBack && CurrentAuthority != null)
{
/*
personDetail.Person = accountOwner;
personDetail.Cookie = account;*/
}
HiddenField hiddenAccountId = (HiddenField) e.Item.FindControl ("HiddenAccountId");
hiddenAccountId.Value = account.Identity.ToString();
// this.TooltipManager.TargetControls.Add(labelBudgetOwner.ClientID, line.AccountIdentity.ToString(), true);
}
/*
private void PersonDetail_PersonChanged(object sender, PersonChangedEventArgs e)
{
// Here, an owner has changed. We need to re-bind the owners column.
// TODO: This resets the budget amounts to the values in the database, which is not really what we want.
FinancialAccount account = (FinancialAccount) e.Cookie;
account.Owner = e.NewPerson;
FinancialAccounts accounts = GetRootLevelResultAccounts();
this.RepeaterAccountBudgets.DataSource = accounts;
this.RepeaterAccountBudgets.DataBind();
// RebindTooltips();
}*/
protected void DropYears_SelectedIndexChanged (object sender, EventArgs e)
{
FinancialAccounts accounts = GetRootLevelResultAccounts();
UpdateYearlyResult (accounts);
this.RepeaterAccountBudgets.DataSource = accounts;
this.RepeaterAccountBudgets.DataBind();
this.RepeaterAccountActuals.DataSource = accounts;
this.RepeaterAccountActuals.DataBind();
LocalizeActualsHeader();
// this.RebindTooltips();
}
private FinancialAccounts GetRootLevelResultAccounts()
{
Organization org = CurrentOrganization;
if (org == null && Page.IsPostBack)
{
// If we're being called from Page_Init to create controls just to catch events, then this.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
FinancialAccounts accounts = new FinancialAccounts();
foreach (FinancialAccount account in allAccounts)
{
if (account.ParentFinancialAccountId == 0 && account.Identity != yearlyResult.Identity)
{
accounts.Add (account);
}
}
return accounts;
}
/*
protected void RebindTooltips()
{
foreach (RepeaterItem repeaterItem in this.RepeaterAccountBudgets.Items)
{
HiddenField hiddenAccountId = (HiddenField)repeaterItem.FindControl("HiddenAccountId");
FinancialAccount child = FinancialAccount.FromIdentity(Int32.Parse(hiddenAccountId.Value));
RadToolTip toolTip = (RadToolTip)repeaterItem.FindControl("ToolTip");
PersonDetailPopup personDetail = (PersonDetailPopup)toolTip.FindControl("PersonDetail");
FinancialAccount account = FinancialAccount.FromIdentity(Int32.Parse(hiddenAccountId.Value));
personDetail.Person = account.Owner;
personDetail.Cookie = child;
}
}*/
protected void RepeaterAccountActuals_ItemDataBound (object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if (item.DataItem == null)
{
return;
}
FinancialAccount account = (FinancialAccount) item.DataItem;
Label labelActuals = (Label) e.Item.FindControl ("LabelAccountActuals");
Int64 actuals =
(account.GetTree().GetDeltaCents (new DateTime (this._year, 1, 1), new DateTime (this._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)
{
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 (this._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 (this._year,
account.GetBudgetCents (this._year) + (newBudgetAmount - currentBudgetAmount)*100);
}
}
// After updating budgets, rebind repeater
FinancialAccounts accounts = GetRootLevelResultAccounts();
UpdateYearlyResult (accounts);
this.RepeaterAccountBudgets.DataSource = accounts;
this.RepeaterAccountBudgets.DataBind();
}
}