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

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Karta dziennikarza
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Karta dziennikarza</h2>
    <h3>Rok, miesiąc: <%= Html.Encode(Model.Date.ToString("yyyy-MM"))%></h3>
    <h3>Dziennikarz: <%= Html.Encode(Model.FullName)%></h3>
    <table>
        <tr>
            <th>Gazeta</th>
            <th>Wydanie</th>
            <th>Typ</th>
            <th>Tytuł artykułu</th>
            <th>Podstawa</th>
            <th>Dodatek</th>
            <th>Razem</th>
            <th>Opis</th>
        </tr>

    <% foreach (var key in Model.MagazineItems.Keys) { %>
        <tr>
            <td colspan="8" style="text-align:left;">
                <strong><%= Html.Encode(key)%></strong>
            </td>
        </tr>
            
            <% foreach (var item in Model.MagazineItems[key]) { %>
            <tr>
                <td colspan="2">
                    <%= Html.Encode(item.Issue.Number)%>
                </td>
                <td>
                    <%= Html.Encode(item.ItemType.Name)%>
                </td>
                <td>
                    <%= Html.Encode(item.Caption)%>
                </td>
                <td>
                    <%= Html.Encode(String.Format("{0:F}", item.Price))%>
                </td>
                <td>
                    <%= Html.Encode(String.Format("{0:F}", item.Bonus))%>
                </td>
                <td>
                    <%= Html.Encode(String.Format("{0:F}", item.Price + item.Bonus))%>
                </td>
                <td>
                    <%= Html.Encode(item.Description)%>
                </td>
            </tr>
            <% } %>
            <tr>
                <td colspan="3">&nbsp;</td>
                <td><strong>Razem dla <%= Html.Encode(key)%></strong></td>
                <td><%= Html.Encode(String.Format("{0:F}", Model.MagazineItems[key].Sum(i=>i.Price)))%></td>
                <td><%= Html.Encode(String.Format("{0:F}", Model.MagazineItems[key].Sum(i=>i.Bonus)))%></td>
                <td><%= Html.Encode(String.Format("{0:F}", Model.MagazineItems[key].Sum(i=>i.Price + i.Bonus)))%></td>
                <td>&nbsp;</td>
            </tr>
            
    <% } %>
    <tr>
                <td colspan="3">&nbsp;</td>
                <td><strong>Razem</strong></td>
                <td>
                    <strong><%= Html.Encode(String.Format("{0:F}", Model.Price))%></strong>
                </td>
                <td>
                    <strong><%= Html.Encode(String.Format("{0:F}", Model.Bonus))%></strong>
                </td>
                <td>
                    <strong><%= Html.Encode(String.Format("{0:F}", Model.Price + Model.Bonus))%></strong>
                </td>
                <td>&nbsp;</td>
    </tr>

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

