<%@ Page Language="C#" MasterPageFile="~/masterpages/eDashboard.master" AutoEventWireup="true" Inherits="FlushCache" Title="Brightstar Device Protection: Flush Cache" Codebehind="FlushCache.aspx.cs" %>
<%@ Register TagPrefix="eSecuritelHITSControls" Namespace="WebSite.Controls" Assembly="WebSite" %>

<asp:Content ID="Content1" ContentPlaceHolderID="eContent" Runat="Server">
    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
    </asp:ScriptManagerProxy>

    <script language="javascript" type="text/javascript">

        var timer = null;
        var periodTimer = null;

        function TimerTick() {
            var prm = Sys.WebForms.PageRequestManager.getInstance();
            prm._doPostBack('<%= UpdatePanel1.ClientID %>', '');        
        }

        function PeriodTimerTick() {
            
        }

        function OnUpdatePanel1Refresh() {
            var btn = $get('<%= btnStageInvoicingData.ClientID %>');
            var divLoad = $get('<%= divLoading.ClientID %>');

            if ((btn.style.display == 'none') &&
                (timer === null)) {
                
                timer = window.setInterval(TimerTick, 5000);

            } else if ((btn.style.display != 'none') &&
                (timer !== null)) {
                
                window.clearInterval(timer);
                timer = null;
            }
        }
            
    </script>
    
    
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <h2>
                <asp:Localize ID = "Localize4" runat = "server" Text = "Flush Cache" />
            </h2>
            <div style="padding:5px;text-align:center;">
                <div>
                    <asp:Localize ID = "Localize3" runat = "server" Text = "Click to flush Cache" />
                </div>
                <div style="margin-top:5px;">
                    <asp:Button ID = "btnFlushCache" runat = "server" Text = "Flush" OnClick = "btnFlushCache_Click" />
                </div>
                <br />
                <div style="width: 512px; height:32px; margin: auto;">
                    <table cellpadding="0" cellspacing="0" style="margin: auto; text-align: center;">
                        <tr>
                            <td>
                                <asp:Button ID="btnStageInvoicingData" runat="server" Style="margin: auto;" Text="Stage Invoicing Data"
                                    OnClick="btnStageInvoicingData_Click" ValidationGroup="StagingData" />
                            </td>
                            <td nowrap="nowrap">
                                
                                <eSecuritelHITSControls:Calendar 
                                    ID="calStageInvoicingData" 
                                    runat="server" 
                                    ValidationGroup="StagingData"
                                    ValidationName="Staging Calendar"
                                    Required="true"/>
                                
                            </td>                            
                        </tr>
                    </table>
                    <div id="divLoading" runat="server" style="display: none; margin: auto;">
                        <table style="margin: auto;">
                            <tr>
                                <td align="right">
                                    <img alt="Loading" src="images/ajax-loader.gif" />
                                </td>
                                <td align="left">
                                    <span id="spnInvData">Invoicing Data is Staging...</span>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                    <%--<asp:Button runat="server" ID="btnLoadAll" Text="Load Cache" onclick="btnLoadAll_Click"/>
                    <asp:PlaceHolder ID="phCacheViewer" runat="server"></asp:PlaceHolder>--%>
                
            </div>    
            <asp:Panel ID="pnlCacheFlushed" runat="server" style="display:none;width:300px;">       
                <asp:Panel ID="pnlCacheFlushedHeader" runat="server" EnableViewState = "false"  CssClass="modalHeader">                
                    <asp:Localize ID="Localize1" runat="server" EnableViewState = "false"  Text="Cache Flush Complete" />                
                </asp:Panel>
                <asp:Panel ID="pnlCacheFlushedBody" runat="server" CssClass="modalContent">
                    <div style="padding:5px;">
                        <asp:Localize ID = "Localize2" runat = "server" Text = "The Cache is now empty" />
                    </div>
                    <asp:Button ID="btnClose" runat="server" Text="Ok"  Width = "55px" CssClass ="pagebutton" />
                </asp:Panel>
            </asp:Panel>
            <asp:Button runat="server"  EnableViewState = "false" ID="hiddenTargetControlForModalPopup" style="display:none" />
            <eSecuritelHITSControls:HITSModalPopupExtender runat="server" ID="modalPopupCacheFlushed"
                TargetControlID="hiddenTargetControlForModalPopup"
                PopupControlID="pnlCacheFlushed"
                BackgroundCssClass="modalBackground"
                
                PopupDragHandleControlID="pnlCacheFlushedHeader" />
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

