<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wierszowki.Models.ReportViewData>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Zestawienie wycen wszystkich dziennikarzy - podział na tytuły
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Zestawienie wycen wszystkich dziennikarzy - podział na tytuły</h2>
    <h3>Rok, miesiąc: <%= Html.Encode(Model.ReportDate.ToString("yyyy-MM"))%></h3>
    
    <%if (Model.Employment != null) { %>
        <h3>Forma zatrudnienia: <%= Html.Encode(Model.Employment.Name)%></h3>
    <%} %>
    <table>
        <tr>
            <th>
                Imię i nazwisko
            </th>
            
            <% foreach (var item in Model.Magazines) { %>
                <th><%=Html.Encode(item.NickName) %></th>
            <% } %>
            
            <th>
                Razem
            </th>
        </tr>
    <% var total = decimal.Zero; %>
    <% foreach (var item in Model.Authors) { %>
        <tr>
            <td>
                <%= Html.Encode(item.FirstName + " " + item.LastName)%>
            </td>
            <% var authorTotal = decimal.Zero; %>
            <% foreach (var m in Model.Magazines) { %>
                <% authorTotal += Model.ReportData[item.Id][m.NickName]; %>
                <td><%=Html.Encode(String.Format("{0:F}", Model.ReportData[item.Id][m.NickName]))%></td>
            <% } %>
            <td>
                <%=Html.Encode(String.Format("{0:F}", authorTotal))%>
            </td>
        </tr>
        <% total += authorTotal; %>
    <% } %>
        <tr>
            <td><strong>Suma</strong></td>
            
            <% foreach (var m in Model.Magazines) { %>
            <% var magazineTotal = decimal.Zero; %>
                <% foreach (var item in Model.Authors) 
                     magazineTotal += Model.ReportData[item.Id][m.NickName]; 
              %>
            <td><strong><%=Html.Encode(String.Format("{0:F}", magazineTotal))%></strong></td>
    <% } %>
            <td><strong><%=Html.Encode(String.Format("{0:F}", total))%></strong></td>
        </tr>
    </table>

    <p>
        <%= Html.ActionLink("Powrót", "Index") %>
    </p>
</asp:Content>