<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wierszowki.Models.MagazineItemViewData>" %>
<%@ Import namespace="Wierszowki.Core.Validation"%> 
<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>
    <script src="../../Scripts/jquery.validate.js" type="text/javascript" ></script>
    <script src="../../Scripts/xVal.jquery.validate.js" type="text/javascript"></script>
    <script src="../../Scripts/jqueryvalid.js" type="text/javascript"></script>
    <script src="../../Scripts/xValCreateMagazineItem.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">
        $(document).ready(function() {            
            $("#Magazine_Id").change(function() {
                var magazineId = $("#Magazine_Id > option:selected").attr("value");
                var urlAction = "<%= Url.Action("FindIssuesById", "Magazine") %>";
                urlAction = urlAction + "/" + magazineId;
                $.getJSON(urlAction, function(data) {
                    $("#IssueId").addItems(data);
                });
            });        
        });
    </script>
    <h2>Dodaj wierszówkę</h2>
    <%= Html.ValidationSummary("Proszę poprawić błędy i spróbować ponownie.")%>
    <div>                      
        <% Html.BeginForm("Create", "MagazineItem", Model.MagazineItem, FormMethod.Post, new { id = "myform" }) ;
            %>
            <fieldset>
                <legend>Nowa wierszówka</legend>
                <div class="formitem">
                    <label for="MagazineItem.AuthorId">Autor:</label>
                    <%= Html.DropDownList("AuthorId", ViewData.Model.AuthorList, "-- proszę wybrać --")%>
                    <%= Html.ValidationMessage("AuthorId", "*")%>
                    <br />
                </div>
                <div class="formitem">
                    <label for="Magazine">Gazeta:</label>
                    <%= Html.DropDownList("Magazine.Id", ViewData.Model.MagazineList, "-- proszę wybrać --")%>
                    <%= Html.ValidationMessage("Magazine.Id", "*")%>
                    <br />
                </div>
                <div class="formitem">
                    <label for="MagazineItem.IssueId">Wydanie:</label>
                    <%= Html.DropDownList("IssueId", ViewData.Model.IssueList, "-- proszę wybrać --")%>
                    <%= Html.ValidationMessage("IssueId", "*")%>
                    <br />
                </div>
                <div class="formitem">
                    <label for="MagazineItem.ItemTypeId">Typ:</label>
                    <%= Html.DropDownList("ItemTypeId", ViewData.Model.ItemTypeList, "-- proszę wybrać --")%>
                    <%= Html.ValidationMessage("ItemTypeId", "*")%>
                     <br />
                </div>
                <div class="formitem">
                    <label for="MagazineItem.Date">Miesiąc:</label>
                    <%= Html.TextBox("Date", ViewData.Model.MagazineItem.Date, new { Class = "date-pick" })%>
                    <%= Html.ValidationMessage("Date", "*")%>
                    <br />
                </div>                
                <div class="formitem">
                    <label for="MagazineItem.Caption">Tytuł:</label>
                    <%= Html.TextBox("Caption", ViewData.Model.MagazineItem.Caption)%>
                    <%= Html.ValidationMessage("Caption", "*")%>
                    <br />
                </div>
                <div class="formitem">
                    <label for="MagazineItem.Description">Opis:</label>
                    <%= Html.TextArea("Description", ViewData.Model.MagazineItem.Description)%>
                    <br />
                </div>
                <div class="formitem">
                    <label for="MagazineItem.Price">Wycena:</label>
                    <%= Html.TextBox("Price", ViewData.Model.MagazineItem.Price)%>
                    <%= Html.ValidationMessage("Price", "*")%> 
                    <br />
                </div>
                <div class="formitem">
                    <label for="MagazineItem.Bonus">Bonus:</label>
                    <%= Html.TextBox("Bonus", ViewData.Model.MagazineItem.Bonus)%>
                    <%= Html.ValidationMessage("Bonus", "*")%>
                    <br />
                </div>
                <div>                
                    <input type="submit" value="Dodaj" name="dodaj" id="dodaj"/>                
                </div>
            </fieldset>        
        <% Html.EndForm();%>               
    </div>
    <div>
        <%=Html.ActionLink("Powrót", "Index", "Home") %>
        <%=Html.ClientSideValidation<MagazineItemValidation>("MagazineItem")%>
    </div>
</asp:Content>