<%@ Page Language="C#" MasterPageFile="~/masterpages/eReport.master" Async="true"
    AutoEventWireup="true" Inherits="site_Reports_Bundles"
    Title="eSecuritel: Report Bundles" Theme="eMain" Codebehind="Bundles.aspx.cs" %>
<%@ Register Src="~/Controls/ScriptingHelper.ascx" TagName="ScriptingHelper" TagPrefix="uc" %>
<%@ Register Src="~/Controls/HITSCalendar.ascx" TagPrefix="uc" TagName="HITSCalendar" %>
<%@ Register Src="~/Controls/ReportCategory.ascx" TagName="ReportCategory" TagPrefix="uc" %>
<%@ Register Src="~/Controls/CustomSorter.ascx" TagName = "CustomSorter" TagPrefix = "uc" %>
<%@ Register Assembly="eSecuritel.HITS.UI.Components" Namespace="eSecuritel.HITS.UI.Components" TagPrefix="cc1" %>
<%@ Register TagPrefix="eSecuritelHITSControls" Namespace="WebSite.Controls" Assembly="WebSite" %>
<%@ Import Namespace="HITSWebService" %>

<asp:Content ID="Content1" ContentPlaceHolderID="eContent" runat="Server">
    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
        <Scripts>
            <asp:ScriptReference Path="~/script/eSetFormControls.js" />
        </Scripts>
    </asp:ScriptManagerProxy>

    <uc:ScriptingHelper ID = "ScriptingHelper1" runat = "server" />
    <cc1:ExtendedValidationSummary ID="ExtendedValidationSummaryTop" runat="server" HeaderText="<%$ Resources: Default, LabelPleasecorrectthefollowingerrors %>" />
    <h1>
        <asp:Localize ID="Localize25" runat="server" Text="<%$ Resources: ReportsManagement, LabelReportBundles %>" />
    </h1>
    
    <div class="mastersearch">
        <img src="../../images/Collapse_13x13.jpg" style="vertical-align: middle" class="showstate"
            onclick="expandMasterSearch(this, 'm_pnlCurrentJobs')" alt="contract" />
        <asp:Localize ID="Localize24" runat="server" Text="<%$ Resources: ReportsManagement, LocalizeSearchBundlesJobs %>" />
    </div>
    <div id="m_pnlCurrentJobs">
        <div style="background-color: #d4deee">
            <table width="100%">
                <tr>
                    <td align="right">
                        <asp:Localize ID="Localize14" runat="server" Text="<%$ Resources: ReportsManagement, LabelWhoColon %>" />
                    </td>
                    <td>
                        <asp:TextBox ID="txtWho" runat="server" Width = "165px" ValidationGroup = "BundleSearch" />
                        <SmartAjaxToolkit:SmartAutoCompleteExtender ID="aceUser" runat="server"
                        OnAutoCompleteCallback="aceUser_AutoCompleteCallback" TargetControlID="txtWho" UpdateMode="Callback"
                        EnableCaching="true" MinimumPrefixLength="1" />
                    </td>
                    <td align="right">
                        <asp:Localize ID="Localize15" runat="server" Text="<%$ Resources: OrganizationManagement, LabelCarrierColon %>" />
                    </td>
                    <td>
                        <asp:TextBox ID="txtCarrier" runat="server" Width = "165px" ValidationGroup = "BundleSearch" />
                         <SmartAjaxToolkit:SmartAutoCompleteExtender ID="aceCarrier" runat="server"
                        OnAutoCompleteCallback="aceCarrier_AutoCompleteCallback" TargetControlID="txtCarrier" UpdateMode="Callback"
                        EnableCaching="true" MinimumPrefixLength="1" />
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Localize ID="Localize16" runat="server" Text="<%$ Resources: ReportsManagement, LabelBundleColon %>" />
                    </td>
                    <td>
                        <asp:ListBox ID="lbBundles" runat="server" SelectionMode="Multiple" ValidationGroup = "BundleSearch" />
                    </td>
                    <td align="right">
                        <asp:Localize ID="Localize17" runat="server" Text="<%$ Resources: Default, LabelStatusColon %>" />
                    </td>
                    <td>
                        <asp:ListBox ID="lbStatuses" runat="server" SelectionMode="Multiple" ValidationGroup = "BundleSearch" />
                    </td>
                </tr>
                <tr>
                    <td align="right">
                    </td>
                    <td>
                        <asp:Localize ID="Localize18" runat="server" Text="<%$ Resources: Default, HeaderTextFrom %>" />
                    </td>
                    <td align="right">
                    </td>
                    <td>
                        <asp:Localize ID="Localize19" runat="server" Text="<%$ Resources: Default, HeaderTextTo %>" />
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Localize ID="Localize20" runat="server" Text="<%$ Resources: ReportsManagement, LabelCreatedOnColon %>" />
                    </td>
                    <td>
                        <uc:HITSCalendar ID="calCreatedOnFrom" runat="server" ValidationGroup = "BundleSearch" />
                    </td>
                    <td align="right">
                    </td>
                    <td>
                        <uc:HITSCalendar ID="calCreateOnTo" runat="server" ValidationGroup = "BundleSearch" />
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Localize ID="Localize21" runat="server" Text="<%$ Resources: ReportsManagement, LabelGeneratedOnColon %>" />
                    </td>
                    <td>
                        <uc:HITSCalendar ID="calGeneratedOnFrom" runat="server" ValidationGroup = "BundleSearch" />
                    </td>
                    <td align="right">
                    </td>
                    <td>
                        <uc:HITSCalendar ID="calGeneratedOnTo" runat="server" ValidationGroup = "BundleSearch" />
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Localize ID="Localize22" runat="server" Text="<%$ Resources: ReportsManagement, LabelCompletedOnColon %>" />
                    </td>
                    <td>
                        <uc:HITSCalendar ID="calCompletedOnFrom" runat="server" ValidationGroup = "BundleSearch" />
                    </td>
                    <td align="right">
                    </td>
                    <td>
                        <uc:HITSCalendar ID="calCompletedOnTo" runat="server" ValidationGroup = "BundleSearch" />
                    </td>
                </tr>
            </table>            
        </div>
        <div style="text-align:center;padding:5px;">
            <asp:Button ID="btnSearchBundleJobs" runat="server" ValidationGroup = "BundleSearch" Text="<%$ Resources: Default, ButtonSearch %>" OnClick="btnSearchBundleJobs_Click" CssClass = "pagebutton" />
            <input id = "btnClear" type="button" runat = "server" class = "pagebutton" value = "<%$ Resources: Default, ButtonClear %>" validationgroup = "BundleSearch" />
        </div>
                
        <h2>    
            <asp:Localize ID="Localize23" runat="server" Text="<%$ Resources: Default, LabelSearchResults %>" />
        </h2>
        <asp:Label ID="lblNoBundleJobs" runat="server" Text="<%$ Resources: ReportsManagement, LabelNojobsfound %>" />
        
            <cc1:HitsSearchGridView ID="grdBundleJobs" runat="server" Width="100%" AutoGenerateColumns="False"
                AllowPaging="True" OnMenuItemCommand="grdBundleJobs_OnMenuItemCommand"
                ShowMenu="True" ShowSelectField="True" ShowActivateMenu="False" ShowDeActivateMenu="False"
                ShowEmailMenu="False" ShowPrintMenu="False" ShowHotlineMenu="False" ShowDeHotlineMenu="False"
                CustomPagerID="HitsPager1" OnCustomPageIndexChanged="grdBundleJobs_PageIndexChanged"
                OnCustomPageIndexChanging="grdBundleJobs_PageIndexChanging" 
                ShowDeleteMenu="True" ShowDeSelectMenu="True" ShowSelectMenu="True" 
                ShowExportMenu="False" ShowSetStatus="False" PageSize = "20">
                
                <Columns>
                    <asp:TemplateField HeaderText="" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:ImageButton ID="ibtnStatus" CommandArgument='<%#((ReportBundleJobData)Container.DataItem).ErrorDescription %>'
                                ToolTip='<%# ((ReportBundleJobData)Container.DataItem).StatusDescription %>'
                                runat="server" ImageUrl='<%# string.Format("../../images/BundleJob.{0}.jpg", ((ReportBundleJobData)Container.DataItem).Status.ToString()) %>'
                                OnClick="ibtnStatus_Click" Enabled='<%# ((ReportBundleJobData)Container.DataItem).Status == JobStatus.Fail %>'
                                CausesValidation="false" />
                        </ItemTemplate>                    
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:HyperLink ID = "hypBundleName" runat = "server" Text = '<%# string.Format("{0} - {1}",((ReportBundleJobData)Container.DataItem).ReportBundle.Name,((ReportBundleJobData)Container.DataItem).ReportBundle.Description) %>' NavigateUrl = '<%# string.Format("~/site/Reports/BundleDetails.aspx?BundleJobId={0}",((ReportBundleJobData)Container.DataItem).Id) %>' Target="_blank" />
                        </ItemTemplate>
                        <HeaderTemplate>
                            <asp:Localize ID = "Localize1" runat = "server" Text = "<%$ Resources: ReportsManagement, HeaderTextBundle %>" /><br />
                            <uc:CustomSorter ID = "CustomSorter1" runat = "server"  SortExpression = "BundleName" OnSortAscendingClicked = "grdBundleJobs_SortClicked" OnSortDescendingClicked = "grdBundleJobs_SortClicked" />
                        </HeaderTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>                        
                            <asp:Label ID = "Label2" runat = "server" Text = "<%#((ReportBundleJobData)Container.DataItem).StatusDescription %>" />
                        </ItemTemplate>
                        <HeaderTemplate>
                            <asp:Localize ID = "Localize2" runat = "server" Text = "<%$ Resources: ReportsManagement, HeaderTextBundleStatus %>" /><br />
                            <uc:CustomSorter ID = "CustomSorter2" runat = "server"  SortExpression = "StatusId" OnSortAscendingClicked = "grdBundleJobs_SortClicked" OnSortDescendingClicked = "grdBundleJobs_SortClicked" />
                        </HeaderTemplate>
                    </asp:TemplateField>
                    <asp:BoundField HeaderText = "Assigned To Gate" DataField = "AssignedToGate" />
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Label ID = "Label7" runat = "server" Text = "<%#((ReportBundleJobData)Container.DataItem).UserName %>" />
                        </ItemTemplate>
                        <HeaderTemplate>
                            <asp:Localize ID = "Localize30" runat = "server" Text = "<%$ Resources: ReportsManagement, HeaderTextWho %>" /><br />
                            <uc:CustomSorter ID = "CustomSorter7" runat = "server" SortExpression = "User" OnSortAscendingClicked = "grdBundleJobs_SortClicked" OnSortDescendingClicked = "grdBundleJobs_SortClicked" />
                        </HeaderTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Label ID = "Label3" runat = "server" Text = "<%#((ReportBundleJobData)Container.DataItem).CreatedDate %>" />
                        </ItemTemplate>
                        <HeaderTemplate>
                            <asp:Localize ID = "Localize3" runat = "server" Text = "<%$ Resources: ReportsManagement, HeaderTextCreatedOn %>" /><br />
                            <uc:CustomSorter ID = "CustomSorter3" runat = "server"  SortExpression = "CreatedDate" OnSortAscendingClicked = "grdBundleJobs_SortClicked" OnSortDescendingClicked = "grdBundleJobs_SortClicked" />
                        </HeaderTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Label ID = "Label4" runat = "server" Text = "<%#((ReportBundleJobData)Container.DataItem).GenerateDate %>" />
                        </ItemTemplate>
                        <HeaderTemplate>
                            <asp:Localize ID = "Localize4" runat = "server" Text = "<%$ Resources: ReportsManagement, HeaderTextGeneratedOn %>" /><br />
                            <uc:CustomSorter ID = "CustomSorter4" runat = "server"  SortExpression = "GenerateDate" OnSortAscendingClicked = "grdBundleJobs_SortClicked" OnSortDescendingClicked = "grdBundleJobs_SortClicked" />
                        </HeaderTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Label ID = "Label5" runat = "server" Text = "<%#((ReportBundleJobData)Container.DataItem).CompletedDate %>" />
                        </ItemTemplate>
                        <HeaderTemplate>
                            <asp:Localize ID = "Localize5" runat = "server" Text = "<%$ Resources: ReportsManagement, HeaderTextCompletedDate %>" /><br />
                            <uc:CustomSorter ID = "CustomSorter5" runat = "server"  SortExpression = "CompletedDate" OnSortAscendingClicked = "grdBundleJobs_SortClicked" OnSortDescendingClicked = "grdBundleJobs_SortClicked" />
                        </HeaderTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Label ID = "Label6" runat = "server" Text = "<%#((ReportBundleJobData)Container.DataItem).LastDownloadDate %>" />
                        </ItemTemplate>
                        <HeaderTemplate>
                            <asp:Localize ID = "Localize6" runat = "server" Text = "<%$ Resources: ReportsManagement, HeaderTextLastDownloadDate %>" /><br />
                            <uc:CustomSorter ID = "CustomSorter6" runat = "server"  SortExpression = "LastDownloadDate" OnSortAscendingClicked = "grdBundleJobs_SortClicked" OnSortDescendingClicked = "grdBundleJobs_SortClicked" />
                        </HeaderTemplate>
                    </asp:TemplateField>                    
                    <asp:TemplateField HeaderText="<%$ Resources: ReportsManagement, HeaderTextOriginalBundle %>">
                        <ItemTemplate>
                            <asp:ImageButton OnClick="ibtnDownloadBundle_Click" CommandArgument='<%# ((ReportBundleJobData)Container.DataItem).FullBundleDownloadPath %>'
                                Visible='<%# ((ReportBundleJobData)Container.DataItem).Status == JobStatus.Complete || ((ReportBundleJobData)Container.DataItem).Status == JobStatus.GeneratedPendingApproval %>'
                                ToolTip='<%# ((ReportBundleJobData)Container.DataItem).Status == JobStatus.Complete || ((ReportBundleJobData)Container.DataItem).Status == JobStatus.GeneratedPendingApproval ? "Download Bundle" : "Processing, Please Wait..." %>'
                                ID="ibtnDownloadBundle" runat="server" ImageUrl="../../images/document_plain.png"
                                CausesValidation="false" />
                            <asp:Label ID="lblBundleFileSize" runat="server" Text='<%# string.Format("{0:#,0 (bytes);;}",((ReportBundleJobData)Container.DataItem).FileSize) %>' />
                            <asp:HiddenField ID="hdnServerFileName" runat="server" Value='<%# ((ReportBundleJobData)Container.DataItem).Filename %>' />
                            <asp:HiddenField ID = "hdnBundleJobId" runat = "server" Value = '<%# ((ReportBundleJobData)Container.DataItem).Id %>' />
                        </ItemTemplate>
                    </asp:TemplateField>                                        
                </Columns> 
            <PagerTemplate>
                <cc1:HitsPager ID="HitsPager1" runat="server" GoButtonText="<%$ Resources: Default, GoButtonText %>" />
            </PagerTemplate>
            <PagerSettings Mode="NumericFirstLast" />
        </cc1:HitsSearchGridView>
    </div>
    <br />
    <h2>
        <asp:Localize ID="Localize26" runat="server" Text="<%$ Resources: ReportsManagement, LabelSelectaBundle %>" />
    </h2>
    <table cellpadding="10">
        <tr>
            <td>
                <asp:Localize ID="Localize27" runat="server" Text="<%$ Resources: ReportsManagement, LabelBundlesColon %>" />
            </td>
            <td style="width:auto">
                <asp:DropDownList ID="ddlBundles" runat="server"  />
                <asp:Button ID="btnExecuteBundle" runat="server" Text="<%$ Resources: Default, ButtonExecute %>" Visible="true" OnClick="btnExecuteBundle_Click" CssClass = "pagebutton" />
                <asp:LinkButton ID="lbtnEditParameters" runat="server" 
                    onclick="lbtnEditParameters_Click" Text="<%$ Resources: ReportsManagement, LinkEditParameters %>"></asp:LinkButton>
            </td>
           <td>                         
                <eSecuritelHITSControls:Calendar               
                ID="SetInvoicingParamData"  runat="server" ValidationName="SetParam Calendar" />
                 <%--ID="SetInvoicingParamData"  runat="server" ValidationGroup="SetParamData" ValidationName="SetParam Calendar" Required="true" />--%>
                
            </td> 
            <td>
                <asp:Button ID="SetParam" runat="server" Text="<%$ Resources: ReportsManagement, ButtonSetParameters %>" 
                    ValidationGroup="SetParamData" onclick="SetParam_Click" 
                    CssClass="pagebutton" />
            </td> 
           
        </tr>
    </table>
    <asp:Panel ID="pnlBundleReportParameters" runat="server" Visible="false">
        <%--<h2>
            <asp:Localize ID="Localize9" runat="server" Text="Global Parameters" />
        </h2>
        <table>
            <tr>
                <td align="right">
                    <asp:Localize ID="Localize8" runat="server" Text="Carrier:" />
                </td>
                <td>
                    <asp:ListBox ID="lbCarriers" runat="server" SelectionMode="Multiple" />
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Localize ID="Localize10" runat="server" Text="<%$ Resources : Default,DateFromLabel %>" />
                </td>
                <td>
                    <uc:HITSCalendar ID="calDateFrom" runat="server" ValidationName="Date From" Enabled="true"
                        Required="true" />
                </td>
                <td align="right">
                    <asp:Localize ID="Localize11" runat="server" Text="<%$ Resources : Default,DateToLabel %>" />
                </td>
                <td>
                    <uc:HITSCalendar ID="calDateTo" runat="server" ValidationName="Date From" Enabled="true"
                        Required="true" />
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Localize ID="Localize12" runat="server" Text="Claim Type:" />
                </td>
                <td>
                    <asp:ListBox ID="lbLossType" runat="server" SelectionMode="Multiple" />
                </td>
                <td align="right">
                    <asp:Localize ID="Localize13" runat="server" Text="Claim Status:" />
                </td>
                <td>
                    <asp:ListBox ID="lbClaimStatus" runat="server" SelectionMode="Multiple" />
                </td>
            </tr>
        </table>--%>
        <asp:PlaceHolder ID="phReportUserControls" runat="server" />
    </asp:Panel>
    <cc1:ExtendedValidationSummary ID="ExtendedValidationSummaryBottom" runat="server"
        HeaderText="<%$ Resources: Default, LabelPleasecorrectthefollowingerrors %>" />
    <asp:Panel ID="pnlBundleExecuted" runat="server" Style="display: none; width: 250px;">
        <asp:Panel ID="pnlBundleExecutedHeader" runat="server" EnableViewState="false" CssClass="modalHeader">
            <asp:Localize ID="Localize29" runat="server" EnableViewState="false" Text="<%$ Resources: ReportsManagement, LocalizeBundleCreationInProgress %>" />
        </asp:Panel>
        <asp:Panel ID="pnlBundleExecutedBody" runat="server" CssClass="modalContent">
            <div style="padding: 5px;">
                <asp:Localize ID="Localize28" runat="server" Text="<%$ Resources: ReportsManagement, LabelPleasecheckbackshortlyforyourrequestedbundle %>" />
            </div>
            <hr />
            <asp:Button ID="btnCloseBundleExecuted" runat="server" EnableViewState="false" Text="<%$ Resources: Default, ButtonClose %>"
                OnClick="btnCloseBundleExecuted_Click" />
        </asp:Panel>
    </asp:Panel>
    <asp:Panel ID="pnlErrorDescription" runat="server" Style="display: none; width: 850px;height:600px;overflow:auto;">
        <asp:Panel ID="pnlErrorDescriptionHeader" runat="server" EnableViewState="false"
            CssClass="modalHeader">
            <asp:Localize ID="Localize7" runat="server" EnableViewState="False" 
                Text="<%$ Resources: ReportsManagement, LocalizeErrorDescription %>" />
        </asp:Panel>
        <asp:Panel ID="pnlErrorDescriptionBody" runat="server" CssClass="modalContent">
            <div style="padding: 5px;">
                <asp:Literal ID="litBundleErrorDescription" runat="server" />
            </div>
            <asp:Button ID="btnCloseErrorDescription" runat="server" Text="<%$ Resources: Default, ButtonClose %>" />
        </asp:Panel>
    </asp:Panel>    
    <asp:Button runat="server" EnableViewState="false" ID="hiddenTargetControlForModalPopup"
        Style="display: none" />
    <eSecuritelHITSControls:HITSModalPopupExtender runat="server" ID="modalBundleExecutedPopupExtender"
        TargetControlID="hiddenTargetControlForModalPopup" PopupControlID="pnlBundleExecuted"
        BackgroundCssClass="modalBackground"  PopupDragHandleControlID="pnlBundleExecutedHeader" />
    <eSecuritelHITSControls:HITSModalPopupExtender runat="server" ID="modalErrorDescriptionPopupExtender"
        TargetControlID="hiddenTargetControlForModalPopup" PopupControlID="pnlErrorDescription"
        BackgroundCssClass="modalBackground"  PopupDragHandleControlID="pnlErrorDescriptionHeader" />
</asp:Content>