<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Task.Master" Inherits="System.Web.Mvc.ViewPage<PurgeCompleteViewModel>" %>

<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
    <% Html.DevExpress().RenderScripts(Page,
        new Script { ExtensionSuite = ExtensionSuite.GridView },
        new Script { ExtensionSuite = ExtensionSuite.Editors }); %>
    <% Html.DevExpress().RenderStyleSheets(Page,
            new StyleSheet { ExtensionSuite = ExtensionSuite.NavigationAndLayout },
            new StyleSheet { ExtensionSuite = ExtensionSuite.Editors },
            new StyleSheet { ExtensionSuite = ExtensionSuite.HtmlEditor },
            new StyleSheet { ExtensionSuite = ExtensionSuite.GridView }
     ); %>
    <script type="text/javascript">
        function onDateChanged(s, e) {
            submitParametersForm();
        }
        function onStatusChanged() {
            submitParametersForm();
        }
        function submitParametersForm() {
            var parametersForm = document.getElementById("PurgeTaskParameters");
            parametersForm.submit();
        }
    </script>
    <div id="content-wrap">
        <% Html.RenderPartial("Navigation/_SideNavigation", Model.MenuNavigationModel); %>
        <div id="content">
		    <h1 class="left-floating-panel">Purge Completed Tasks</h1>
            <div class="right-floating-panel">Server Timezone<br /><b><%= DateTimeHelper.GetTimezoneName() %></b></div>
            <div class="clear"></div>
            <% using (Html.BeginForm("PurgeCompleted", "Task", FormMethod.Post, new { @id = "PurgeTaskParameters" }))
                { %>
                <div class="left-floating-panel">
                    <table class="standard-list full">
                        <tr>
                            <td>Start Date:</td>
                            <td><% Html.DevExpress().DateEdit(settings =>
                                                            {
                                                                settings.Name = "StartDate";
                                                                settings.Properties.NullText = "MM/dd/yyyy";
                                                                settings.Properties.EditFormat = EditFormat.Custom;
                                                                settings.Properties.EditFormatString = "MM/dd/yyyy";
                                                                settings.Properties.AllowNull = false;
                                                                settings.Properties.ValidationSettings.CausesValidation = false;
                                                                settings.Properties.ValidationSettings.ValidateOnLeave = false;
                                                                settings.Properties.ClientSideEvents.DateChanged = "onDateChanged";
                                                                settings.Date = Model.StartDate;
                                                            }).GetHtml(); %></td>
                            <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td>End Date:</td>
                            <td><% Html.DevExpress().DateEdit(settings =>
                                                            {
                                                                settings.Name = "EndDate";
                                                                settings.Properties.NullText = "MM/dd/yyyy";
                                                                settings.Properties.EditFormat = EditFormat.Custom;
                                                                settings.Properties.EditFormatString = "MM/dd/yyyy";
                                                                settings.Properties.AllowNull = false;
                                                                settings.Properties.ValidationSettings.CausesValidation = false;
                                                                settings.Properties.ValidationSettings.ValidateOnLeave = false;
                                                                settings.Properties.ClientSideEvents.DateChanged = "onDateChanged";
                                                                settings.Date = Model.EndDate;
                                                            }).GetHtml(); %></td>
                        </tr>
                    </table>
                </div>
                <div class="clear"></div>
            <% } %>
            <div id="PurgeTasksContainer"><% Html.RenderPartial("Partials/PurgeCompletedTasks", Model); %></div>
            <br />
            <div class="right-floating-panel"><input type="button" value="Delete" onclick="window.location='<%= Url.Action("DeleteSeletedTasks/" + Model.Status + "/" + Model.StartDate.ToString("MM#dd#yyyy") + "/" + Model.EndDate.ToString("MM#dd#yyyy"), "Task") %>'" class="button" /></div>
            <div class="right-floating-panel"><input type="button" value="Cancel" onclick="window.location='<%: Url.Action("Completed", "Task") %>'" class="button" /></div>
            <div class="clear"></div>
        </div>
    </div>
    <script type="text/javascript">
        window.onunload = function () {
            var cookie = getCookieValue("ClarityPurgedTasksView");

            if (typeof (cookie) !== 'undefined') {
                var date = new Date();
                date.setTime(date.getTime() + (10 * 60 * 1000));

                ASPxClientUtils.SetCookie("ClarityPurgedTasksView", cookie, date);
            }
        }
    </script>
</asp:Content>
