Added download link to P&L report; deploying
This commit is contained in:
@@ -124,6 +124,10 @@
|
||||
<value>P&L for {0} for</value>
|
||||
<comment>The {0} is the organization name. The year number follows this string.</comment>
|
||||
</data>
|
||||
<data name="ProfitLossStatement_DownloadFileName" xml:space="preserve">
|
||||
<value>ProfitLoss</value>
|
||||
<comment>Must ONLY contain A-Z, a-z characters - nothing accented!</comment>
|
||||
</data>
|
||||
<data name="ProfitLossStatement_Info" xml:space="preserve">
|
||||
<value>The P&L is an overview of income and expenditures, which are grouped by budgets or cost/income type. The sum of all income and expenditure is the yearly result. You may also want to look at the <a href="BalanceSheet.aspx">balance sheet</a> which is the overview of assets and debts.</value>
|
||||
</data>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1018 B |
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
@@ -0,0 +1 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Csv-ProfitLossData.aspx.cs" Inherits="Pages_v5_Ledgers_Csv_ProfitLossData" %>
|
||||
@@ -0,0 +1,106 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Activizr.Basic.Enums;
|
||||
using Activizr.Logic.Financial;
|
||||
using Activizr.Logic.Pirates;
|
||||
using Activizr.Logic.Security;
|
||||
using Activizr.Logic.Structure;
|
||||
using System.Globalization;
|
||||
|
||||
public partial class Pages_v5_Ledgers_Csv_ProfitLossData : System.Web.UI.Page
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
// Current authentication
|
||||
|
||||
string identity = HttpContext.Current.User.Identity.Name;
|
||||
string[] identityTokens = identity.Split(',');
|
||||
|
||||
string userIdentityString = identityTokens[0];
|
||||
string organizationIdentityString = identityTokens[1];
|
||||
|
||||
int currentUserId = Convert.ToInt32(userIdentityString);
|
||||
int currentOrganizationId = Convert.ToInt32(organizationIdentityString);
|
||||
|
||||
Person currentUser = Person.FromIdentity(currentUserId);
|
||||
Authority authority = currentUser.GetAuthority();
|
||||
Organization currentOrganization = Organization.FromIdentity(currentOrganizationId);
|
||||
|
||||
// Get culture
|
||||
|
||||
string cultureString = "en-US";
|
||||
HttpCookie cookie = Request.Cookies["PreferredCulture"];
|
||||
|
||||
if (cookie != null)
|
||||
{
|
||||
cultureString = cookie.Value;
|
||||
}
|
||||
|
||||
_renderCulture = new CultureInfo(cultureString);
|
||||
|
||||
// Get current year
|
||||
|
||||
_year = DateTime.Today.Year;
|
||||
|
||||
string yearParameter = Request.QueryString["Year"];
|
||||
|
||||
if (!string.IsNullOrEmpty(yearParameter))
|
||||
{
|
||||
_year = Int32.Parse(yearParameter); // will throw if non-numeric - don't matter for app
|
||||
}
|
||||
|
||||
YearlyReport report = YearlyReport.Create(currentOrganization, _year, FinancialAccountType.Result);
|
||||
|
||||
Response.ClearContent();
|
||||
Response.ClearHeaders();
|
||||
Response.ContentType = "text/plain";
|
||||
Response.AppendHeader("Content-Disposition", "attachment;filename=" + Resources.Pages.Ledgers.ProfitLossStatement_DownloadFileName + _year.ToString(CultureInfo.InvariantCulture) + "-" + DateTime.Today.ToString("yyyyMMdd") + ".csv");
|
||||
|
||||
if (_year == DateTime.Today.Year)
|
||||
{
|
||||
Response.Output.WriteLine("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\"", Resources.Pages.Ledgers.ProfitLossStatement_AccountName, Resources.Pages.Ledgers.ProfitLossStatement_LastYear,
|
||||
Resources.Pages.Ledgers.ProfitLossStatement_Q1, Resources.Pages.Ledgers.ProfitLossStatement_Q2, Resources.Pages.Ledgers.ProfitLossStatement_Q3, Resources.Pages.Ledgers.ProfitLossStatement_Q4,
|
||||
Resources.Pages.Ledgers.ProfitLossStatement_Ytd);
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Output.WriteLine("\"{0}\",\"{1}\",\"{6}-{2}\",\"{6}-{3}\",\"{6}-{4}\",\"{6}-{5}\",\"{6}\"", Resources.Pages.Ledgers.ProfitLossStatement_AccountName, _year-1,
|
||||
Resources.Pages.Ledgers.ProfitLossStatement_Q1, Resources.Pages.Ledgers.ProfitLossStatement_Q2, Resources.Pages.Ledgers.ProfitLossStatement_Q3, Resources.Pages.Ledgers.ProfitLossStatement_Q4,
|
||||
_year);
|
||||
}
|
||||
|
||||
RecurseCsvReport(report.ReportLines, string.Empty);
|
||||
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private int _year = 2012;
|
||||
private CultureInfo _renderCulture;
|
||||
|
||||
private void RecurseCsvReport (List<YearlyReportLine> reportLines, string accountPrefix)
|
||||
{
|
||||
foreach (YearlyReportLine line in reportLines)
|
||||
{
|
||||
Response.Output.WriteLine("\"{0}{1}\",{2},{3},{4},{5},{6},{7}",
|
||||
accountPrefix, line.AccountName,
|
||||
line.AccountValues.PreviousYear / -100.0,
|
||||
line.AccountValues.Quarters[0] / -100.0,
|
||||
line.AccountValues.Quarters[1] / -100.0,
|
||||
line.AccountValues.Quarters[2] / -100.0,
|
||||
line.AccountValues.Quarters[3] / -100.0,
|
||||
line.AccountValues.ThisYear / -100.0);
|
||||
|
||||
|
||||
if (line.Children.Count > 0)
|
||||
{
|
||||
RecurseCsvReport(line.Children, "-" + accountPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,9 @@
|
||||
$('span.loadingHeader').hide();
|
||||
|
||||
var selectedYear = $('#<%=DropYears.ClientID %>').val();
|
||||
|
||||
$('div#linkDownloadReport').attr("onclick", "document.location='Csv-ProfitLossData.aspx?Year=" + selectedYear + "';");
|
||||
$('#spanDownloadText').text('<%=Resources.Pages.Ledgers.ProfitLossStatement_DownloadFileName %>' + selectedYear + "-<%=DateTime.Today.ToString("yyyyMMdd") %>.csv");
|
||||
|
||||
if (selectedYear == currentYear)
|
||||
{
|
||||
@@ -74,6 +77,9 @@
|
||||
color: #1C397E;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
table.datagrid-ftable {
|
||||
font-weight: 500;
|
||||
}
|
||||
</style>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
|
||||
@@ -99,5 +105,16 @@
|
||||
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
|
||||
<h2 class="blue"><asp:Label ID="LabelSidebarDownload" Text="Download This" runat="server" /><span class="arrow"></span></h2>
|
||||
|
||||
<div class="box">
|
||||
<div class="content">
|
||||
<div class="link-row-encaps" id="linkDownloadReport" onclick="document.location='placeholder';" >
|
||||
<div class="link-row-icon" style="background-image:url('/Images/Icons/iconshock-downarrow-16px.png');background-position:-1px -1px"></div>
|
||||
<span id="spanDownloadText">ProfitLossxxxx-yyyymmdd.csv</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user