<%@ 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/xValEditMagazineItem.js" type="text/javascript"></script>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Edytuj 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) {
                    $("#MagazineItem_IssueId").addItems(data);
                });
           });
        });
    </script>
    <h2>Edytuj wierszówkę</h2>
    <%= Html.ValidationSummary("Proszę poprawić błędy i spróbować ponownie.") %>

    <div>                        
        <div id="messages"></div>
        <%  
            using (Html.BeginForm("Update", "MagazineItem", FormMethod.Post, new { id = "myform" }))
            { %>
            <fieldset>
                <%= Html.Hidden("Info.user_id", Model.Info.user_id)%>
                <%= Html.Hidden("Info.powrot", Model.Info.powrot)%>
                <%= Html.Hidden("Info.month", Model.Info.month)%>
                <%= Html.Hidden("Info.year", Model.Info.year)%>
                <legend>Dane wierszówki</legend>
                <%= Html.Hidden("MagazineItem.Id", Model.MagazineItem.Id)%>
                <div class="formitem">
                    <label for="MagazineItem.AuthorId">Autor:</label>
                    <%= Html.DropDownList("MagazineItem.AuthorId", Model.AuthorList, "-- proszę wybrać --")%>
                    <%= Html.ValidationMessage("MagazineItem.AuthorId", "*")%>
                    <br />
                </div>
                <div class="formitem">
                    <label for="Magazine">Gazeta:</label>
                    <%= Html.DropDownList("Magazine.Id",Model.MagazineList, "-- proszę wybrać --")%>
                    <%= Html.ValidationMessage("Magazine.Id", "*")%>
                    <br />
                </div>                
                <div class="formitem">
                    <label for="MagazineItem.IssueId">Wydanie</label>
                    <%= Html.DropDownList("MagazineItem.IssueId", Model.IssueList, "-- proszę wybrać --")%>
                    <%= Html.ValidationMessage("MagazineItem.IssueId", "*")%>
                    <br />
                </div>
                <div class="formitem">
                    <label for="MagazineItem.ItemTypeId">Typ:</label>
                    <%= Html.DropDownList("MagazineItem.ItemTypeId", Model.ItemTypeList, "-- proszę wybrać --")%>
                    <%= Html.ValidationMessage("MagazineItem.ItemTypeId", "*")%>
                    <br />
                </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", "*")%>
                    <br />
                </div>              
                <div class="formitem">
                    <label for="MagazineItem.Caption">Tytuł:</label>
                    <%= Html.TextBox("MagazineItem.Caption", Model.MagazineItem.Caption )%>
                    <%= Html.ValidationMessage("MagazineItem.Caption", "*")%>
                    <br />
                </div>
                <div class="formitem">
                    <label for="MagazineItem.Description">Opis:</label>
                    <%= Html.TextArea("MagazineItem.Description", Model.MagazineItem.Description )%>
                    <%= Html.ValidationMessage("MagazineItem.Description", "*")%>
                    <br />
                </div>
                <div class="formitem">
                    <label for="MagazineItem.Price">Wycena:</label>
                    <%= Html.TextBox("MagazineItem.Price", Model.MagazineItem.Price.ToString("#0.00"))%>
                    <%= Html.ValidationMessage("MagazineItem.Price", "*")%>
                    <br />
                </div>
                <div class="formitem">
                    <label for="MagazineItem.Bonus">Bonus:</label>
                    <%= Html.TextBox("MagazineItem.Bonus", Model.MagazineItem.Bonus.ToString("#0.00"))%>
                    <%= Html.ValidationMessage("MagazineItem.Bonus", "*")%>
                    <br />
                </div>
                <div>                
                    <input type="submit" name="edit" value="Aktualizuj" />                
                </div>
            </fieldset>        
         <% } %>               
    </div>
    <div>
        <%=Html.ActionLink("Powrót", "Index", "Home") %>
        <%=Html.ClientSideValidation<MagazineItemValidation>("MagazineItem")%>
    </div>
</asp:Content>