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

<asp:Content ID="js" ContentPlaceHolderID="jsContent" runat="server">
    <script src="../../Scripts/jquery-1.3.1.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.3.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.form.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.blockUI.js" type="text/javascript"></script>
    <script src="../../Scripts/date.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.datePicker.js" type="text/javascript"></script>
    <script src="../../Scripts/spiffy.js" type="text/javascript"></script>
    <script src="../../Scripts/jHelper.js" type="text/javascript"></script>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Dodaj wierszówkę
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
    $(function() {
        $("#Magazine").change(function() {
        var magazineId = $("#Magazine > option:selected").attr("value");
        var urlAction = "<%= Url.Action("FindIssuesById", "Magazine") %>";
        urlAction = urlAction + "/" + magazineId;
        $.getJSON(urlAction, function(data) {
                $("#MagazineItem_IssueId").addItems(data);
            });
        });
    });
</script>
    
    <h2>Dodaj wierszówkę</h2>
    <%= Html.ValidationSummary("Proszę poprawić błędy i spróbować ponownie.") %>

    <div>                        
        <div id="messages"></div>
        <% using (Html.BeginForm("Create", "MagazineItem", Model.MagazineItem))
           { %>
            <fieldset>
                <legend>Nowa wierszówka</legend>
                <div class="formitem">
                    <label for="MagazineItem.AuthorId">Autor:</label>
                    <%= Html.DropDownList("MagazineItem.AuthorId", ViewData.Model.AuthorList, "-- proszę wybrać --")%>
                    <%= Html.ValidationMessage("MagazineItem.AuthorId", "*")%>
                </div>
                <div class="formitem">
                    <label for="Magazine">Gazeta:</label>
                    <%= Html.DropDownList("Magazine", ViewData.Model.MagazineList, "-- proszę wybrać --")%>
                    <%= Html.ValidationMessage("Magazine", "*")%>
                </div>
                <div class="formitem">
                    <label for="MagazineItem.IssueId">Wydanie:</label>
                    <%= Html.DropDownList("MagazineItem.IssueId", ViewData.Model.IssueList, "-- proszę wybrać --")%>
                    <%= Html.ValidationMessage("MagazineItem.IssueId", "*")%>
                </div>
                <div class="formitem">
                    <label for="MagazineItem.ItemTypeId">Typ:</label>
                    <%= Html.DropDownList("MagazineItem.ItemTypeId", ViewData.Model.ItemTypeList, "-- proszę wybrać --")%>
                    <%= Html.ValidationMessage("MagazineItem.ItemTypeId", "*")%>
                </div>
                <div class="formitem">
                    <label for="MagazineItem.Date">Miesiąc:</label>
                    <%= Html.TextBox("MagazineItem.Date", Model.MagazineItem.Date, new { Class = "date-pick" })%>
                    <%= Html.ValidationMessage("MagazineItem.Date", "*")%>
                </div>
                
                <div class="formitem">
                    <label for="MagazineItem.Caption">Tytuł:</label>
                    <%= Html.TextBox("MagazineItem.Caption", Model.MagazineItem.Caption, new { title = "Proszę wprowadzić tytuł artykułu." })%>
                    <%= Html.ValidationMessage("MagazineItem.Caption", "*")%>
                </div>
                <div class="formitem">
                    <label for="MagazineItem.Description">Opis:</label>
                    <%= Html.TextBox("MagazineItem.Description", Model.MagazineItem.Description, new { title = "Proszę wprowadzić opis artykułu." })%>
                </div>
                <div class="formitem">
                    <label for="MagazineItem.Price">Wycena:</label>
                    <%= Html.TextBox("MagazineItem.Price", Model.MagazineItem.Price.ToString("#0.00"), new { title = "Proszę wprowadzić wycenę artykułu." })%>
                    <%= Html.ValidationMessage("MagazineItem.Price", "*")%>
                </div>
                <div class="formitem">
                    <label for="MagazineItem.Bonus">Bonus:</label>
                    <%= Html.TextBox("MagazineItem.Bonus", Model.MagazineItem.Bonus.ToString("#0.00"), new { title = "Proszę wprowadzić bonus do wyceny artykułu." })%>
                    <%= Html.ValidationMessage("MagazineItem.Bonus", "*")%>
                </div>
                <div class="submit">                
                    <input type="submit" value="Dodaj" />                
                </div>
            </fieldset>        
        <% } %>               
    </div>
    <div>
        <%=Html.ActionLink("Powrót", "Index", "Home") %>
    </div>
</asp:Content>