<%@ Page Language="C#" MasterPageFile="~/masterpages/eDashboard.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
    Culture="auto" UICulture="auto" Inherits="WebSite.site.HITS.SubscriberCancellation.Default"
    Title="Brightstar Device Protection: Cancelation Letters Master" %>

<%@ Register Src="~/Controls/ScriptingHelper.ascx" TagName="ScriptingHelper" TagPrefix="uc" %>
<%@ Register Src="~/Controls/HITSCalendar.ascx" TagName="HITSCalendar" TagPrefix="uc" %>
<%@ Register Src="~/Controls/DefaultHeader.ascx" TagName="DefaultHeader" TagPrefix="uc" %>
<%@ Register Src="~/Controls/PersistNav.ascx" TagName="PersistNav" 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 Src="~/Controls/ClientCarrierDropDowns.ascx" TagName="ClientCarrierDropDowns" TagPrefix="uc1" %>


<asp:Content ID="Content1" ContentPlaceHolderID="eContent" runat="server">
    <script src="../../../script/eSetFormControls.js" type="text/javascript"></script>

    <script src="../../../script/eGridHelper.js" type="text/javascript"></script>
    <uc:ScriptingHelper ID="ScriptingHelper1" runat="server" />
    <table width="100%">
        <tr>
            <td>
                <h1>
                    <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources: SubscriberManagement, CancelationLettersLabel %>" />
                </h1>
            </td>
            <td align="right">
                <span class='failuremessage'>
                    <asp:Label ID="m_lblLoaderProcessState" runat="server" Text="" />
                </span>
            </td>
        </tr>
    </table>

    <div class="mastersearch">
        <img src="../../../images/Collapse_13x13.jpg" class="showstate" onclick="expandMasterSearch(this, 'm_pnlMasterSearchCriteria')"
            alt="contract" />
        <asp:Literal ID="Literal2" runat="server" Text="<%$ Resources: Default, LabelSearchCriteria %>" />
    </div>
    <asp:UpdatePanel runat="server" ID="update" UpdateMode="Conditional">
        <ContentTemplate>
            <div style="background-color: #DBDCDE" id="m_pnlMasterSearchCriteria">
                <table class="gvTable" cellspacing="0" cellpadding="0" border="0" style="table-layout:fixed;">
                    <tbody>
                        <tr>
                            <td align="right" colspan="2">
                                <div id="client-dd-cancellationLetter" class="client-dd-cancellationLetter">
                                    <uc1:ClientCarrierDropDowns
                                        ID="ucClientCarrierDropDowns"
                                        runat="server"
                                        OrientationOfDropDowns="Vertical"
                                        DropDownWidth="212" LabelWidth="155"
                                        DefaultCarrierText="<%$ Resources: Default, HeaderListItemAll %>"
                                        ShowOnlyDirectBilling="true"
                                        OnCarrierChanged="ucClientCarrierDropDowns_OnCarrierChanged"
                                        OnClientChanged="ucClientCarrierDropDowns_OnClientChanged" />
                                </div>
                            </td>
                            <td style="width: 200px" nowrap align="right">
                                <asp:Literal ID="Literal6" runat="server" Text="<%$ Resources: HandsetManagement, LabelMDNColon %>" />
                            </td>
                            <td style="width: 400px" nowrap>
                                <asp:TextBox CssClass="subscriberSearchDetails-input" ID="txtMDN" runat="server" TextAlign="Left" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:Literal ID="Literal3" runat="server" Text="<%$ Resources: SubscriberManagement, LabelFirstName %>" />
                            </td>
                            <td align="left">
                                <asp:TextBox CssClass="subscriberSearchDetails-input" ID="txtFirstname" runat="server" />
                            </td>
                            <td align="right">
                                <asp:Literal ID="Literal5" runat="server" Text="<%$ Resources: SubscriberManagement, LabelLastName %>" />
                            </td>
                            <td align="left">
                                <asp:TextBox CssClass="subscriberSearchDetails-input" ID="txtLastName" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td nowrap align="right">
                                <asp:Literal ID="Literal4" runat="server" Text="<%$ Resources: SubscriberManagement, SubscriberStatusLabel %>" />
                            </td>
                            <td nowrap align="left">
                                <asp:DropDownList ID="ddlStatus" CssClass="subscriberSearchDetails-select" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlStatus_SelectedIndexChanged" TextAlign="Left">
                                    <asp:ListItem Text="<%$ Resources: SubscriberManagement, HotlinedListItem %>" Value="1"></asp:ListItem>
                                    <asp:ListItem Text="<%$ Resources: SubscriberManagement, TerminatedListItem %>" Value="2"></asp:ListItem>
                                    <asp:ListItem Text="<%$ Resources: SubscriberManagement, ClaimExhaustedListItem %>" Value="3"></asp:ListItem>
                                </asp:DropDownList>
                            </td>
                            <td nowrap align="right">
                                <asp:Literal ID="Literal10" runat="server" Text="<%$ Resources: SubscriberManagement, CancelationLetterLabel %>" />
                            </td>
                            <td nowrap align="left">
                                <asp:DropDownList CssClass="subscriberSearchDetails-select" ID="ddlCancellationLetter" runat="server" AutoPostBack="true"
                                    TextAlign="Left" OnSelectedIndexChanged="ddlCancellationLetter_SelectedIndexChanged">
                                    <%--<asp:ListItem Text="Both" Value="3"></asp:ListItem>--%>
                                    <asp:ListItem Text="<%$ Resources: Default, NoListItem %>" Value="1"></asp:ListItem>
                                    <asp:ListItem Text="<%$ Resources: Default, YesListItem %>" Value="2"></asp:ListItem>
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:Literal ID="m_litDateFrom" runat="server" Text="<%$ Resources: SubscriberManagement, HotlinedFromLabel %>" />
                            </td>
                            <td>
                                <uc:HITSCalendar ID="dtFrom" runat="server" />
                            </td>
                            <td align="right">
                                <asp:Literal ID="m_litDateTo" runat="server" Text="<%$ Resources: SubscriberManagement, HotlinedToLabel %>" />
                            </td>
                            <td>
                                <uc:HITSCalendar ID="dtTo" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:Literal ID="Literal7" runat="server" Text="<%$ Resources: SubscriberManagement, LetterFromLabel %>" />
                            </td>
                            <td>
                                <uc:HITSCalendar ID="dtLetterFrom" runat="server" />
                            </td>
                            <td align="right">
                                <asp:Literal ID="Literal8" runat="server" Text="<%$ Resources: SubscriberManagement, LetterToLabel %>" />
                            </td>
                            <td>
                                <uc:HITSCalendar ID="dtLetterTo" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td style="height: 25px" nowrap align="right">
                                <asp:Literal ID="Literal12" runat="server" Text="<%$ Resources: Default, RecordsperpageLabel %>" />
                            </td>
                            <td style="height: 25px" nowrap align="left">
                                <asp:DropDownList ID="m_ddlPageSize" runat="server">
                                </asp:DropDownList>
                            </td>
                            <td></td>
                            <td></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <div style="text-align: center">
        <asp:Button ID="m_btnSetFilter" runat="server" Text="<%$ Resources: Default, ButtonSearch %>" CssClass="pagebutton"
            OnClick="m_btnSetFilter_Click" />
        <input id="m_btnClear" type="button" runat="server" value="<%$ Resources: Default, ButtonClear %>" class="pagebutton" />
    </div>
    <asp:Panel ID="m_pnlSearchResults" runat="server">
        <h2>
            <asp:Literal ID="Literal20" runat="server" Text="<%$ Resources: Default, LabelSearchResults %>" />
            <asp:Label ID="m_lblSuccessMessage" runat="server" CssClass="successmessage" /></h2>
        <asp:Label ID="m_lblNoCancellationResultsFound" Font-Bold="True" ForeColor="Red" runat="server"
            Visible="False" Text="<%$ Resources: Default, LabelNoResultsFound %>" />
    </asp:Panel>
    <asp:Panel ID="m_pnlCancellationGrid" Visible="False" runat="server">
        <h3>
            <asp:Literal ID="Literal23" runat="server" Text="<%$ Resources: Default, ResultsLabel %>" />
        </h3>
        <cc1:HitsSearchGridView CssClass="gvTable cs-table-border-fix" ID="m_gvHotlinedSubsriber" runat="server" AutoGenerateColumns="False" AllowPaging="True"
            OnRowDataBound="m_gvHotlinedSubsriber_RowDataBound"
            OnPageIndexChanged="m_gvHotlinedSubsriber_PageIndexChanged"
            OnPageIndexChanging="m_gvHotlinedSubsriber_PageIndexChanging"
            OnMenuItemCommand="m_gvHotlinedSubsriber_OnMenuItemCommand"
            ShowMenu="True" ShowSelectField="True"
            ShowDeSelectMenu="True" ShowPrintMenu="false"
            ShowSelectMenu="True" ShowExportMenu="false"
            ShowDeleteMenu="false" ShowSetStatus="False"
            ShowExportCSVWithSummary="false" ShowExportXMLWithSummary="false"
            ShowActivateMenu="False" ShowDeActivateMenu="False"
            ShowEmailMenu="False" ShowHotlineMenu="False"
            ShowDeHotlineMenu="False"
            CustomPagerID="HitsPager1"
            OnCustomPageIndexChanged="m_gvHotlinedSubsriber_PageIndexChanged"
            OnCustomPageIndexChanging="m_gvHotlinedSubsriber_PageIndexChanging"
            AtlasScriptManagerID=""
            ClientFunctionSetStatus=""
            CssClassCustomPaging="" CssClassMenu=""
            PropagateActionToChildID=""
            ShowExecuteMenu="false" Width="100%" ShowGenerate="true" ClientFunctionGenerateSelected="">
            <Columns>
                <asp:TemplateField>
                    <HeaderTemplate>
                        <asp:Literal runat="server" ID="Literal50" Text="<%$ Resources: SubscriberManagement, SubscriberHeader %>"></asp:Literal>
                        <br />
                        <uc:CustomSorter runat="server" ID="m_csName" SortExpression="FirstName" OnSortAscendingClicked="customSorter_SortClicked" OnSortDescendingClicked="customSorter_SortClicked"></uc:CustomSorter>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label runat="server" ID="m_lblName"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ItemStyle-HorizontalAlign="Center">
                    <HeaderTemplate>
                        <asp:Literal runat="server" ID="Literal51" Text="<%$ Resources: HandsetManagement, LabelMDN %>"></asp:Literal>
                        <br />
                        <uc:CustomSorter runat="server" ID="m_csMDN" SortExpression="MDN" OnSortAscendingClicked="customSorter_SortClicked" OnSortDescendingClicked="customSorter_SortClicked"></uc:CustomSorter>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label runat="server" ID="m_lblMDN"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ItemStyle-HorizontalAlign="Center">
                    <HeaderTemplate>
                        <asp:Literal runat="server" ID="Literal52" Text="<%$ Resources: SubscriberManagement, HotlineSinceHeader %>"></asp:Literal>
                        <br />
                        <uc:CustomSorter runat="server" ID="m_HotlineSince" SortExpression="HOTLINE_DATE" OnSortAscendingClicked="customSorter_SortClicked" OnSortDescendingClicked="customSorter_SortClicked"></uc:CustomSorter>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label runat="server" ID="m_lblHotlineSince"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ItemStyle-HorizontalAlign="Center">
                    <HeaderTemplate>
                        <asp:Literal runat="server" ID="Literal53" Text="<%$ Resources: SubscriberManagement, LetterDateHeader %>"></asp:Literal>
                        <br />
                        <uc:CustomSorter runat="server" ID="m_LetterDate" SortExpression="create_date" OnSortAscendingClicked="customSorter_SortClicked" OnSortDescendingClicked="customSorter_SortClicked"></uc:CustomSorter>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label runat="server" ID="m_lblLetterDate"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ItemStyle-HorizontalAlign="Center">
                    <HeaderTemplate>
                        <asp:Literal runat="server" ID="Literal54" Text="<%$ Resources: SubscriberManagement, GraceEndDateHeader %>"></asp:Literal>
                        <br />
                        <%--<uc:CustomSorter runat="server" ID="m_GraceEndDate" SortExpression="NumberOfDays" OnSortAscendingClicked="customSorter_SortClicked" OnSortDescendingClicked="customSorter_SortClicked"></uc:CustomSorter>--%>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label runat="server" ID="m_lblGraceEndDate"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ItemStyle-HorizontalAlign="Center">
                    <HeaderTemplate>
                        <asp:Literal runat="server" ID="Literal55" Text="<%$ Resources: SubscriberManagement, TermDateHeader %>"></asp:Literal>
                        <br />
                        <uc:CustomSorter runat="server" ID="m_csTermDate" SortExpression="TERM_DATE" OnSortAscendingClicked="customSorter_SortClicked" OnSortDescendingClicked="customSorter_SortClicked"></uc:CustomSorter>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label runat="server" ID="m_lblTermDate"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ItemStyle-HorizontalAlign="Center">
                    <HeaderTemplate>
                        <asp:Literal runat="server" ID="Literal33" Text="<%$ Resources: SubscriberManagement, CancelationLetterHeader %>"></asp:Literal>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:ImageButton runat="server" ID="m_lkCancellationLetter" OnClick="img_Click"
                            Width="25" Height="25" CausesValidation="false" Visible="false"></asp:ImageButton>
                        <asp:HiddenField runat="server" ID="m_cancelationLetterId" />
                        <asp:HiddenField runat="server" ID="m_subscriberId" />
                        <asp:HiddenField runat="server" ID="m_imageId" />
                        <asp:HiddenField runat="server" ID="m_cancelationLetterType" />
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField>
                    <ItemStyle CssClass="hide" />
                    <HeaderStyle CssClass="hide" />
                    <ItemTemplate>
                        <!-- In order for the Emailing Javascript to work, we must have a visible column with the
                                         email information.  We don't want to have to user see it though, so set the display to none. -->
                        <asp:HyperLink runat="server" CssClass="EmailBox" ID="m_hypEmail"></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <PagerTemplate>
                <cc1:HitsPager ID="HitsPager1" runat="server" GoButtonText="<%$ Resources: Default, GoButtonText %>" />
            </PagerTemplate>
            <PagerSettings Mode="NumericFirstLast" />
            <RowStyle HorizontalAlign="Left" />
            <HeaderStyle HorizontalAlign="Center" VerticalAlign="Top" />
            <EditRowStyle HorizontalAlign="Left" VerticalAlign="Top" />
        </cc1:HitsSearchGridView>
    </asp:Panel>
    <asp:ObjectDataSource ID="odsCancellationDataSource" runat="server" SelectMethod="SelectCancelationLetters"
        TypeName="SubscriberDataSource" EnablePaging="True" SelectCountMethod="SelectCount">
        <SelectParameters>
            <asp:SessionParameter Name="subscriberDataSearchCriteria" SessionField="SubscriberSearchData_SessionKey" Type="Object" />
            <asp:ControlParameter ControlID="m_gvHotlinedSubsriber" DefaultValue="1" Name="startRowIndex"
                PropertyName="PageIndex" Type="Int32" />
            <asp:Parameter DefaultValue="10" Name="maximumRows" Type="Int32" />
            <asp:SessionParameter Name="subscriberSortExpression" SessionField="SubscriberSortExpression_SessionKey" Type="Object" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <script type="text/javascript">
        Sys.Application.add_load(setStyle);

        function setStyle() {
            $('[id$=_ucClientCarrierDropDowns_ClientCarrierDropDownsTable]').attr('style', 'margin-right: auto');
            $('[id$=_dtFrom_m_txtDate]').attr('style', 'width: 200px');
            $('[id$=_dtTo_m_txtDate]').attr('style', 'width: 200px');
            $('[id$=_dtLetterFrom_m_txtDate]').attr('style', 'width: 200px');
            $('[id$=_dtLetterTo_m_txtDate]').attr('style', 'width: 200px');
            if (navigator.appName == 'Microsoft Internet Explorer') {
                var ua = navigator.userAgent;
                var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
                if (re.exec(ua) != null)
                    var rv = parseFloat(RegExp.$1);
                if (rv == 7.0)
                {
                    $('#client-dd-cancellationLetter').attr('style', 'margin-left: 39px');
                    $('[id$=_ucClientCarrierDropDowns_ClientCarrierDropDownsTable]').css('margin-right', '');
                }                    
                else if (rv == 8.0) {
                    $('#client-dd-cancellationLetter').attr('style', 'margin-left: 39px');
                } else if (rv > 8.0) {
                    $('#client-dd-cancellationLetter').attr('style', 'margin-left: 34px;');
                }
            } else if (navigator.appName == 'Netscape') {
                var usAg = navigator.userAgent;
                var reg = new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})");
                if (reg.exec(usAg) != null) {
                    var rvt = parseFloat(RegExp.$1);
                    if (rvt == 11.0 || rvt > 11.0) {
                        $('#client-dd-cancellationLetter').attr('style', 'margin-left: 34px;');
                    }
                }
            }
        }
    </script>
</asp:Content>
