<%@ Page Language="C#" MasterPageFile="~/masterpages/eDashboard.master" AutoEventWireup="true" CodeBehind="POPManagerNew.aspx.cs"
    Inherits="WebSite.site.HITS.POPManager.POPManagerNew" Title="eSecuritel: Proof Of Purchase Manager" Culture="auto" %>


<%@ 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 Src="~/Controls/POP/HIPManagerPOP.ascx" TagName="ManagerPOPControl" TagPrefix="uc" %>
<%@ Register Assembly="eSecuritel.HITS.UI.Components" Namespace="eSecuritel.HITS.UI.Components" TagPrefix="cc1" %>
<%@ Register Src="~/Controls/ClientCarrierDropDowns.ascx" TagName="ClientCarrierDropDowns" TagPrefix="uc1" %>
<%@ Register TagPrefix="eSecuritelHITSControls" Namespace="WebSite.Controls" Assembly="WebSite" %>


<asp:Content ID="Content2" 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: PopManagerManagement, ProofOfPurchaseManagerLabel %>" />
                </h1>
            </td>
            <td align="right">
                <span class='failuremessage'>
                    <asp:Label ID="m_lblFailureMessage" 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: #d4deee" id="m_pnlMasterSearchCriteria">
                <table class="gvTable" cellspacing="0" cellpadding="0" border="0">
                    <tbody>
                        <tr>
                            <td align="right" colspan="2">
                                <uc1:ClientCarrierDropDowns
                                    ID="ucClientCarrierDropDowns"
                                    runat="server"
                                    OrientationOfDropDowns="Vertical"
                                    DropDownWidth="138" LabelWidth="155"
                                    DefaultCarrierText="<%$ Resources: Default, HeaderListItemAll %>"
                                    ShowOnlyDirectBilling="true"
                                    OnCarrierChanged="ucClientCarrierDropDowns_OnCarrierChanged"
                                    OnClientChanged="ucClientCarrierDropDowns_OnClientChanged" />
                            </td>
                            <td nowrap="noWrap" align="right">
                                <asp:Literal ID="Literal6" runat="server" Text="<%$ Resources: HandsetManagement, LabelMDNColon %>" />
                            </td>
                            <td nowrap="noWrap">
                                <asp:TextBox ID="txtMDN" runat="server" TextAlign="Left" />
                            </td>
                        </tr>

                        <tr>
                            <td align="right">
                                <asp:Literal ID="m_litDateFrom" runat="server" Text="<%$ Resources: PopManagerManagement, CreatedFromLabel %>" />
                            </td>
                            <td>
                                <uc:HITSCalendar ID="dtFrom" runat="server" />
                            </td>
                            <td align="right">
                                <asp:Literal ID="m_litDateTo" runat="server" Text="<%$ Resources: PopManagerManagement, CreatedToLabel %>" />
                            </td>
                            <td>
                                <uc:HITSCalendar ID="dtTo" runat="server" />
                            </td>
                        </tr>

                        <tr>
                            <td nowrap="noWrap" align="right">
                                <asp:Literal ID="Literal4" runat="server" Text="<%$ Resources: PopManagerManagement, PopStatusLabel %>" />
                            </td>
                            <td nowrap="noWrap">
                                <asp:DropDownList ID="ddlHandsetStatus" runat="server" AutoPostBack="true" TextAlign="Left">
                                    <asp:ListItem Text="<%$ Resources: Default, ListItemAll %>" Value="0" />
                                    <asp:ListItem Text="<%$ Resources: SubscriberManagement, AwaitingSubscriberListItem %>" Value="1512" />
                                    <%-- Exists in Fulfillment as WaitingForPop = 318--%>
                                    <asp:ListItem Text="<%$ Resources: PopManagerManagement, InReviewListItem %>" Value="1513" />
                                    <%-- Exists in Fulfillment as InReviewPop = 319--%>
                                    <asp:ListItem Text="<%$ Resources: PopManagerManagement, AcceptedListItem %>" Value="1514" />
                                    <%-- Exists in Fulfillment as AcceptedPop = 320--%>
                                    <asp:ListItem Text="<%$ Resources: PopManagerManagement, RejectedListItem %>" Value="1515" />
                                    <%-- Only exists in Handset status --%>
                                    <asp:ListItem Text="<%$ Resources: PopManagerManagement, FulfilledListItem %>" Value="321" />
                                    <%-- Only exists in Fulfillment status --%>
                                </asp:DropDownList>
                            </td>
                            <td></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td style="height: 25px" nowrap="nowrap" align="right">
                                <asp:Literal ID="Literal12" runat="server" Text="<%$ Resources: Default, RecordsperpageLabel %>" />
                            </td>
                            <td style="height: 25px">
                                <asp:DropDownList ID="m_ddlPageSize" runat="server">
                                    <asp:ListItem Text="20" Value="20" />
                                    <asp:ListItem Text="50" Value="50" />
                                    <asp:ListItem Text="100" Value="100" />
                                    <asp:ListItem Text="<%$ Resources: Default, ListItemAll %>" Value="0" />
                                </asp:DropDownList>
                            </td>
                            <td></td>
                            <td></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <div style="padding-left: 275px">
        <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_lblNoPopResultsFound" Font-Bold="True" ForeColor="Red" runat="server"
            Visible="False" Text="<%$ Resources: Default, LabelNoResultsFound %>" />

    </asp:Panel>
    <asp:Panel ID="m_pnlPOPGrid" Visible="False" runat="server">

        <%-- <h3>
            <asp:Literal ID="Literal23" runat="server" Text="Results" />
        </h3>--%>

        <asp:UpdatePanel ID="udpPOPGrid" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <div style="margin: 10px; display: none" id="divLoading">
                    <asp:Image ID="Image2" runat="server" ImageUrl="~/images/ajax-loader.gif" />
                    <asp:Label ID="Label2" runat="server" Text="<%$ Resources: Default, LabelLoadingEllipses %>"></asp:Label>
                </div>
                <cc1:HitsSearchGridView ID="m_gvPopManager" runat="server" AutoGenerateColumns="False" AllowPaging="True"
                    OnRowDataBound="m_gvPopManager_RowDataBound"
                    OnPageIndexChanged="m_gvPopManager_PageIndexChanged"
                    OnPageIndexChanging="m_gvPopManager_PageIndexChanging"
                    ShowMenu="True" ShowSelectField="false"
                    ShowDeSelectMenu="false" ShowPrintMenu="false"
                    ShowSelectMenu="false" ShowExportMenu="false"
                    ShowDeleteMenu="false" ShowSetStatus="False"
                    ShowExportCSVWithSummary="false" ShowExportXMLWithSummary="false"
                    ShowActivateMenu="False" ShowDeActivateMenu="False"
                    ShowEmailMenu="False" ShowHotlineMenu="False"
                    ShowDeHotlineMenu="False"
                    ShowGenerate="false"
                    CustomPagerID="HitsPager1"
                    OnCustomPageIndexChanged="m_gvPopManager_PageIndexChanged"
                    OnCustomPageIndexChanging="m_gvPopManager_PageIndexChanging"
                    AtlasScriptManagerID=""
                    ClientFunctionSetStatus=""
                    CssClassCustomPaging="" CssClassMenu=""
                    PropagateActionToChildID=""
                    ShowExecuteMenu="false" Width="100%" ClientFunctionGenerateSelected="">
                    <Columns>
                        <asp:TemplateField>
                            <HeaderTemplate>
                                <asp:Literal runat="server" ID="Literal5" Text="<%$ Resources: PopManagerManagement, ClientHeaderText %>"></asp:Literal>
                                <br />
                                <uc:CustomSorter runat="server" ID="m_csClientName" SortExpression="CompanyName" OnSortAscendingClicked="customSorter_SortClicked" OnSortDescendingClicked="customSorter_SortClicked"></uc:CustomSorter>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:Label runat="server" ID="m_lblClient"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <HeaderTemplate>
                                <asp:Literal runat="server" ID="Literal50" Text="<%$ Resources: SubscriberManagement, HeaderTextSubscriber %>"></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>
                            <HeaderTemplate>
                                <asp:Literal runat="server" ID="Literal52" Text="<%$ Resources: ModelManagement, LabelMakeAndModel %>"></asp:Literal>
                                <br />
                                <uc:CustomSorter runat="server" ID="m_MakeAndModel" SortExpression="ModelName" OnSortAscendingClicked="customSorter_SortClicked" OnSortDescendingClicked="customSorter_SortClicked"></uc:CustomSorter>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:Label runat="server" ID="m_lblMakeModel"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-HorizontalAlign="Center">
                            <HeaderTemplate>
                                <asp:Literal runat="server" ID="Literal55" Text="<%$ Resources: HandsetManagement, LabelESN %>"></asp:Literal>
                                <br />
                                <uc:CustomSorter runat="server" ID="m_csESN" SortExpression="ESN" OnSortAscendingClicked="customSorter_SortClicked" OnSortDescendingClicked="customSorter_SortClicked"></uc:CustomSorter>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:Label runat="server" ID="m_lblESN"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-HorizontalAlign="Center">
                            <HeaderTemplate>
                                <asp:Literal runat="server" ID="Literal53" Text="<%$ Resources: PopManagerManagement, PopStatusHeaderText %>"></asp:Literal>
                                <br />
                                <uc:CustomSorter runat="server" ID="m_HandsetStatus" SortExpression="HandsetStatusName" OnSortAscendingClicked="customSorter_SortClicked" OnSortDescendingClicked="customSorter_SortClicked"></uc:CustomSorter>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:Label runat="server" ID="m_lblHandsetStatus"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-HorizontalAlign="Center">
                            <HeaderTemplate>
                                <asp:Literal runat="server" ID="Literal54" Text="<%$ Resources: PopManagerManagement, SubmitDateHeaderText %>"></asp:Literal>
                                <br />
                                <uc:CustomSorter runat="server" ID="m_csSubmitDate" SortExpression="SubmitDate" OnSortAscendingClicked="customSorter_SortClicked" OnSortDescendingClicked="customSorter_SortClicked"></uc:CustomSorter>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:Label runat="server" ID="m_lblSubmitDate"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField ItemStyle-HorizontalAlign="Center">
                            <HeaderTemplate>
                                <asp:Literal runat="server" ID="Literal33" Text="<%$ Resources: PopManagerManagement, HIPManagerHeaderText %>"></asp:Literal>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <%--<asp:ImageButton runat="server" ID="m_lkHIPManager" OnClick="img_Click" 
                                             Width="25" Height="25" CausesValidation="false"  Visible="false"  ></asp:ImageButton>--%>
                                <asp:HiddenField runat="server" ID="m_CarrierId" />
                                <asp:HiddenField runat="server" ID="m_ModelId" />
                                <asp:HiddenField runat="server" ID="m_HandsetId" />
                                <asp:HiddenField runat="server" ID="m_FullfillmentModel" />
                                <asp:HiddenField runat="server" ID="m_LAId" />
                                <asp:HiddenField runat="server" ID="m_SubscriberId" />
                                <asp:HiddenField runat="server" ID="m_ESN" />
                                <asp:HiddenField runat="server" ID="m_MDN" />

                                <asp:ImageButton ID="ibtnHIPManager" runat="server"
                                    ToolTip="<%$ Resources: PopManagerManagement, HIPManagerToolTip %>" Height="24px" Width="24px"
                                    BackColor="White" Visible="false" OnClick="ibtnHIPManager_Click" class="loading" />

                            </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>
                <uc:ManagerPOPControl ID="ucManagerPOPControl" runat="server" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
    <asp:ObjectDataSource ID="odsPOPDataSource" runat="server" SelectMethod="Select" SelectCountMethod="SelectCount"
        TypeName="PopManagerDataSource" EnablePaging="True">
        <SelectParameters>
            <asp:SessionParameter Name="objPopSearchDataCriteria" SessionField="PopSearchData_SessionKey" Type="Object" />
            <asp:ControlParameter ControlID="m_gvPopManager" DefaultValue="1" Name="startRowIndex"
                PropertyName="PageIndex" Type="Int32" />
            <asp:Parameter DefaultValue="10" Name="maximumRows" Type="Int32" />
            <asp:SessionParameter Name="popSortExpression" SessionField="PopSortExpression_SessionKey" Type="Object" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <style type="text/css">
        html, body
        {
            height: 100%;
        }

        body
        {
            padding: 0;
            margin: 0;
        }

        #silverlightControlHost
        {
            height: 660px;
            overflow: hidden;
            text-align: center;
        }

        .style1
        {
            width: 210px;
        }
    </style>
    <script type="text/javascript">
        function ResizeObject(height) {
            var host = document.getElementById("silverlightControlHost");
            if (document.documentElement.clientHeight < height) {
                host.style.height = height + "px";
            }
            else {
                host.style.height = document.documentElement.clientHeight.toString() + "px";
            }
        }
    </script>

    <script type="text/javascript" src="../../../script/Silverlight.js"></script>
    <script type="text/javascript">
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null && sender != 0) {
                appSource = sender.getHost().Source;
            }

            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
                return;
            }

            var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n";

            errMsg += "Code: " + iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " + args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }
        $(function () {
            $('#wrapper').on('click', '.loading', function () {
                // var loading = $(this).parents('td').find('.divLoading');
                $('#divLoading').css("display", "block");
            });
        });

    </script>

</asp:Content>
