<%@ control language="VB" autoeventwireup="false" inherits="RCC_Voice_CC_DirectRoutingWizard, MachSol.MachPanel.Web" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="EM" %>
<%@ Register Assembly="MachSol.MachPanel.Utility" Namespace="MachSol.MachPanel.Utility" TagPrefix="EM" %>
<%@ Register Src="~/Template/GVPager.ascx" TagName="Pager" TagPrefix="EM" %>
<%@ Register Src="~/RCC/O365/CC/TenantMissingServicePrincipalControl.ascx" TagName="TenantServicePrincipalError" TagPrefix="EM" %>

<asp:Panel ID="Pnl_DirectRouting" runat="server" CssClass="row">

    <div class="col-xs-12">

        <div class="products-step">

            <span id="Div_Step1" runat="server" nowrap="true" class="label label-success">
                <asp:LinkButton ID="lb_Step1" runat="server" Text='<%$ Resources:Content, String31 %>' />
            </span>
            <span id="Div_Step2" runat="server" nowrap="true" class="label label-default">
                <asp:LinkButton ID="lb_Step2" runat="server" Text='<%$ Resources:Content, strMicrosoft365 %>' />
            </span>
            <span id="Div_Step3" runat="server" nowrap="true" class="label label-default">
                <asp:LinkButton ID="lb_Step3" runat="server" Text='<%$ Resources:Content, strPrerequisites %>' />
            </span>

            <span id="Div_Step4" runat="server" nowrap="true" class="label label-default">
                <asp:LinkButton ID="lb_Step4" runat="server" Text='<%$ Resources:Content, Activation %>' />
            </span>
            <span id="Div_Step5" runat="server" nowrap="true" class="label label-default">
                <asp:LinkButton ID="lb_Step5" runat="server" Text='<%$ Resources:Content, strUserAssignment %>' />
            </span>

        </div>

        <div class="col-xs-12" style="color: red; margin: 15px 0px;" id="Div_Message" runat="server">
        </div>

        <asp:Panel ID="Pnl_Step1" runat="server">
            <div class="row">
                <div class="col-xs-12">

                    <div class="card">

                        <div class="header hide d-none">
                            <h3>
                                <asp:Literal ID="Literal45" runat="server" Text="<%$ Resources:Content,strIntroduction %>"></asp:Literal>
                            </h3>
                        </div>
                        <div class="body directrouting">

                            <p class="m-t-15">
                                <asp:Literal ID="ltlWelcomeMsg" runat="server" Text="<%$ Resources:Content,strWelcomeTeamMessage %>"></asp:Literal>
                              <%--~/RCC/Clients/ServiceSubscription.aspx?Sub=1&CID=3756--%>
                                <%--<asp:LinkButton ID="Link" runat="server" Text='<%$ Resources:Content,strLink %>' CssClass="btn btn-primary waves-effect"></asp:LinkButton>--%>
                                <%--<a href="#" id="link" runat="server" text='<%$ Resources:Content,strLink %>' target="_blank">link.</a>--%>
                            </p>
                            <%--<p>
                                <%= Resources.Content.strStepOneProceed %>
                            </p>--%>


                            <div class="row">
                                <div class="col-sm-3 col-xs-12">
                                    <asp:Button ID="Btn_StepOneNext" CausesValidation="false" runat="server" Text='<%$ Resources:Content,strNext %>' class="btn btn-primary waves-effect" />
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </asp:Panel>

        <asp:Panel ID="Pnl_Configuration" runat="server">
            <%-- <div class="panel-group" id="AS_DirectRoutingTenantConfig" role="tablist" aria-multiselectable="true">
                <div class="col-xs-12" role="tab" id="SH_DirectRoutingTenantConfig">--%>
            <div class="row" runat="server" id="DivStepOne">
                <div class="col-xs-12">


                    <div class="card">
                        <div class="header hide d-none">
                            <h3>
                                <asp:Literal ID="Ltl_ConfigStep1" runat="server" Text="<%$ Resources:Content,strGrantConsent %>">:</asp:Literal>
                            </h3>
                        </div>

                        <div class="body directrouting">

                            <p class="m-t-15">
                                <%= Resources.Content.strUserLoginO365Msg %>
                                <asp:Literal ID="LtlCompanyName" runat="server" Text=""></asp:Literal>@your_companyname.onmicrosoft.com
                                            <%= Resources.Content.strUserLoginO365Msg2 %>
                            </p>
                            <div class="row">
                                <div class="col-sm-3 col-xs-12 row-label">
                                    <asp:Literal ID="Literal47" runat="server" Text='<%$ Resources:Content,strUserloginName %>' />:
                                </div>
                                <div class="col-sm-4 col-xs-12">
                                    <div class="form-group">
                                        <div class="form-line">
                                            <asp:TextBox ID="TxBx_Tenantadminlogin" runat="server"></asp:TextBox>
                                        </div>
                                    </div>
                                </div>

                                <asp:Button ID="Btn_AdminLoginChangeHandler" runat="server" Text="" CssClass="btn-dummy btn-hide hide" />
                            </div>
                            <div class="row">
                                <%--<div class="col-sm-3 col-xs-12">
                                </div>--%>
                                <div class=" col-xs-12">
                                    <asp:Literal ID="Literal1" runat="server" Text='<%$ Resources:Content,strLoginAsAdminMsg %>' />
                                </div>
                            </div>
                            <br />
                            <div class="row">
                                <div class="col-sm-5 col-xs-12">
                                </div>
                                <div class="col-sm-5 col-xs-12">
                                    <%--<p>
                                        <%= Resources.Content.strNewBrowserMsg %>
                                    </p>
                                    <br />--%>

                                    <EM:UpdatePanelInlineScriptControl ID="UpdatePanelInlineScriptControl1" runat="server">

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

                                            $(document).ready(function () {
                                                if ($("a[id$='Lbtn_GrantAdminConsent']").length > 0)
                                                    O365GrantHelpIconPopover($("a[id$='Lbtn_GrantAdminConsent']").get(0).id, '<%= Resources.Content.StrO365ConsentHelpTitle %>', '<%= Resources.Content.StrO365ConsentHelpContent %>');
                                            });

                                        </script>
                                    </EM:UpdatePanelInlineScriptControl>



                                    <a href="javascript:void(0)" id="Lbtn_GrantAdminConsent" runat="server" class="btn btn-primary waves-effect" style="margin-top: -10px;">
                                        <b>
                                            <asp:Literal ID="Ltrl_StrTenantManagementConsentButton" runat="server" Text='<%$Resources:Content, StrTenantManagementConsentButton %>' /></b>
                                    </a>

                                </div>
                            </div>
                            <br>
                            <div class="row">
                                <div class="col-sm-3 col-xs-12">
                                </div>
                                <div class="col-sm-5 col-xs-12">
                                    <img src="/images/MicrosoftTeamsConsent-image.png" width="400px" alt="Consent" />
                                </div>
                            </div>




                        </div>

                    </div>
                </div>
            </div>



            <%-- </div>
            </div>--%>

            <%--<div class="panel-group" id="AS_DirectRouting" role="tablist" aria-multiselectable="true" runat="server">--%>

            <%--   </div>--%>

            <div class="panel-group" runat="server" id="AS_ForwardingHistory" role="tablist" aria-multiselectable="true" visible="false">
                <div class="col-xs-12" role="tab" id="SH_ForwardingHistory">
                    <div class="card">
                        <div class="header" role="button" data-toggle="collapse" data-parent="#AS_ForwardingHistory" href="#<%= CSB_ForwardingHistory.ClientID%>" aria-expanded="true" aria-controls="SH_ForwardingHistory">
                            <h3>
                                <%= Resources.Content.strTrunkSettings%>                                                                                                                                 
                            </h3>
                        </div>
                        <div id="CSB_ForwardingHistory" runat="server" class="body panel-collapse collapse" role="tabpanel" aria-labelledby="SH_ForwardingHistory" aria-expanded="false">
                            <div class="row">
                                <div class="body">
                                    <div class="row" id="DivForwardingNumber" runat="server">
                                        <div class="col-sm-3 col-xs-12">
                                            <asp:Literal ID="Literal9" runat="server" Text='<%$ Resources:Content,strForwardCallHistory %>' />:
                                        </div>
                                        <div class="col-sm-1 col-xs-12">
                                            <asp:CheckBox ID="ChBx_ForwardCallHistory" Checked="true" Text=" " OnClick="oncheckchange(this.checked);" runat="server" />
                                        </div>
                                        <div class="col-sm-8 col-xs-12">
                                            <asp:Literal ID="Literal11" runat="server" Text='<%$ Resources:Content,strCallForwardingMsg %>' />
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-3 col-xs-12">
                                        </div>
                                        <div class="col-sm-2 col-xs-12">
                                            <asp:Button ID="btn_ApplyForwardCallHistory" runat="server" CausesValidation="false" Text='<%$ Resources:Content,GN0001189 %>' class="btn btn-primary waves-effect btnAction" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </asp:Panel>

        <asp:Panel ID="Pnl_Step3" runat="server" Visible="false">

            <%--  <ajax:UpdatePanel ID="UP_Step3" runat="server" UpdateMode="Conditional">
                <ContentTemplate>--%>

            <div class="row" id="DivWait" runat="server">
                <div class="col-xs-12">
                    <div class="card" style="height: 300px;">

                        <div class="col-xs-12 text-center p-t-90">
                            <h3>
                                <asp:Literal ID="Literal4" runat="server" Text='<%$Resources:Content, strWorkingOnIt %>' />
                            </h3>
                        </div>

                    </div>
                </div>
            </div>


            <asp:Button ID="Btn_Step3DummyButton" runat="server" Text="" CssClass="btn-dummy btn-hide hide" />


            <div class="row" runat="server" id="divStep3DummyButtonWork" visible="false">
                <div class="col-xs-12">

                    <div class="card">
                        <div class="header hide d-none">
                            <h3>
                                <asp:Literal ID="Literal46" runat="server" Text="<%$ Resources:Content,strPrerequisites %>"></asp:Literal>
                            </h3>
                        </div>



                        <div class="body">

                            <div class="row">
                                <div class="col-xs-12 ">
                                    <span class="p-l-15"><%= Resources.Content.strBeforeWeBegin %></span>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-xs-12">

                                    <asp:Literal ID="Ltl_PreRequesitsMsg" runat="server"></asp:Literal>
                                    <img id="ImgChkOneNo" visible="false" runat="server" src="~/Images/icons/No1.gif" />
                                    <img id="ImgChkOneYes" visible="false" runat="server" src="~/Images/icons/Yes1.gif" />
                                    <span><%= Resources.Content.strUserRightsAccess %></span>

                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-12">

                                    <img id="ImgChkTwoNo" visible="false" runat="server" src="~/Images/icons/No2.gif" />
                                    <img id="ImgChkTwoYes" visible="false" runat="server" src="~/Images/icons/Yes2.gif" />
                                    <span><%= Resources.Content.strUserLicenseNotAvailabe %></span>

                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-12">

                                    <img id="ImgChkThreeNo" visible="false" runat="server" src="~/Images/icons/No3.gif" />
                                    <img id="ImgChkThreeYes" visible="true" runat="server" src="~/Images/icons/Yes3.gif" />
                                    <span><%= Resources.Content.strPhoneSystemOrE5Forcalling %></span>

                                </div>
                            </div>
                            <div class="row" runat="server" id="Div_SorryMsg" visible="false">
                                <div class="col-xs-12  p-l-15">
                                    <p style="color: red; font-weight: bold" class="p-l-15">
                                        <asp:Literal ID="tll_Sorry" runat="server" Text='<%$ Resources:Content,strCheckFailed %>'></asp:Literal>
                                    </p>
                                    <p class="p-l-15">
                                        <asp:Literal ID="ltl_CheckMsg" runat="server" Text='<%$ Resources:Content,strCheckItems %>'></asp:Literal><br />
                                        <img id="Img1" runat="server" visible="false" src="~/Images/icons/No2.gif" />
                                        <asp:Literal ID="Ltl_Step3Message2" runat="server" Visible="false" Text=''></asp:Literal>
                                        <br />
                                        <img id="Img2" runat="server" visible="false" src="~/Images/icons/No3.gif" />
                                        <asp:Literal ID="Ltl_Step3Message3" runat="server" Visible="false" Text=''></asp:Literal>
                                    </p>
                                </div>
                            </div>

                            <div class="row">

                                <div class="col-sm-5 col-xs-12" id="divWelldoneProceed" runat="server" visible="false">
                                    <p class="p-l-15 font-bold">
                                        <asp:Literal ID="Literal5" runat="server" Text="<%$ Resources:Content,strWelldoneProceed %>"></asp:Literal>
                                    </p>
                                </div>
                                <div class="col-sm-6 col-xs-12">
                                    <asp:Button ID="btn_Step3Next" CausesValidation="false" runat="server" Text='<%$ Resources:Content,strNext %>' class="btn btn-primary waves-effect" />
                                </div>
                            </div>


                        </div>
                    </div>
                </div>
            </div>

            <%--  </ContentTemplate>
            </ajax:UpdatePanel>--%>
        </asp:Panel>

        <asp:Panel ID="Pnl_Step4" runat="server" Visible="false">


            <div class="row">
                <div class="col-xs-12" id="Div_ConfigStep2" runat="server">
                    <%--role="tab" id="SH_DirectRouting"--%>
                    <div class="card">
                        <div class="header hide d-none">
                            <%--role="button" data-toggle="collapse" data-parent="#AS_DirectRouting" href="#<%= CSB_DirectRouting.ClientID%>" aria-expanded="true" aria-controls="SH_DirectRouting">--%>
                            <h3>
                                <asp:Literal ID="Ltl_ConfigStep2" runat="server" Text="<%$ Resources:Content,StrDomain %>"></asp:Literal>
                            </h3>
                        </div>
                        <%--<div id="CSB_DirectRouting" runat="server" class="body panel-collapse collapse" role="tabpanel" aria-labelledby="SH_DirectRouting" aria-expanded="false">--%>

                        <div class="body">


                            <div class="row">
                                <div class="col-sm-3 col-xs-12 row-label">
                                    *
                              <asp:Literal ID="Literal44" runat="server" Text='<%$ Resources:Content,strDomain %>' />:
                                </div>
                                <div class="col-sm-3 col-xs-12">
                                    <div class="form-group">
                                        <div class="form-line">
                                            <asp:TextBox ID="TxBx_Domain" runat="server"></asp:TextBox>
                                        </div>
                                    </div>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
                                        ControlToValidate="TxBx_Domain"
                                        Display="None" ValidationGroup="ConfigureDirectRouting" SetFocusOnError="True"></asp:RequiredFieldValidator>
                                </div>
                                <div class="col-sm-3 col-xs-12 row-label">
                                    <%-- Do not change this text value. --%>
                                    <asp:Label ID="lblDomain" runat="server" Text='.customers.machcloud.com' />
                                    <%-- <asp:Label ID="lblDomain" runat="server" Text='.justfordemo.com' />--%>
                                </div>
                                <div class="col-sm-3 col-xs-12">
                                    <asp:Button ID="Btn_Create" class="btn btn-primary waves-effect" ValidationGroup="ConfigureDirectRouting" CausesValidation="true" runat="server" Text='<%$ Resources:Content,strVerify %>' />
                                    <%-- <asp:Button ID="Btn_Validate" Visible="false" CausesValidation="false" runat="server" Text='<%$ Resources:Content,strValidate %>' class="btn btn-primary waves-effect" />--%>
                                </div>
                            </div>


                            <div class="row" id="DivTxtRecord" runat="server" visible="false">
                                <div class="col-sm-3 col-xs-12 row-label">
                                    <asp:Literal ID="Literal48" runat="server" Text='<%$ Resources:Content,TxtRecord %>' />:
                                </div>
                                <div class="col-sm-3 col-xs-12">
                                    <asp:Label ID="lblTxtRecord" runat="server"></asp:Label>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-xs-12">
                                    <asp:Button ID="Btn_Reset" Visible="false" CausesValidation="false" runat="server" Text='<%$ Resources:Content,Lync298 %>' class="btn btn-primary waves-effect btnAction" />
                                    <asp:Button ID="btn_Remove" Visible="false"  CausesValidation="false" runat="server" Text='<%$ Resources:Content,strRemove %>' OnClientClick="return confirm('All assignments will be removed, are you sure to remove?');window.location = window.location.href.toString().replace('&callbackok=1','');" class="btn btn-primary waves-effect btnAction" />
                                    <asp:ValidationSummary ID="ValidationSummary2" runat="server" ShowMessageBox="true" ShowSummary="false"
                                        ValidationGroup="ConfigureDirectRouting" HeaderText="<%$ Resources:Content,EM000001%>" />
                                </div>
                            </div>
                        </div>



                        <%-- </div>--%>
                    </div>
                </div>
            </div>
        </asp:Panel>

        <asp:Panel ID="Pnl_Step5" runat="server" Visible="false">
            <div class="row">
                <div class="col-xs-12">

                    <div class="card">
                        <%-- <div class="header">
                        <h3>
                            <asp:Literal ID="Literal49" runat="server" Text="<%$ Resources:Content,strPrerequisites %>"></asp:Literal>
                        </h3>
                    </div>--%>

                        <div class="body">

                            <div class="row" id="DivActivate" runat="server" visible="false">
                                <div class="col-sm-3 col-xs-12 row-label">
                                    <asp:Literal ID="Literal2" runat="server" Text='<%$ Resources:Content,strActivateDirectRouting %>' />:
                                </div>
                                <div class="col-sm-3 col-xs-12">
                                    <div class="form-group">
                                        <div class="form-line">
                                            <asp:TextBox ID="Txbx_User" runat="server" Enabled="false"></asp:TextBox>
                                            <asp:HiddenField ID="HdnObjectId" runat="server" />
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-3 col-xs-12">
                                    <asp:DropDownList ID="ddl_Licences" runat="server"></asp:DropDownList>
                                </div>
                                <%-- <div class="col-sm-3 col-xs-12">
                                    <asp:Button ID="Btn_Assign" CausesValidation="false" runat="server" Text='<%$ Resources:Content,strAssignSub %>' class="btn btn-primary waves-effect" />
                                </div>--%>
                            </div>
                            <div class="row" id="DivActivateMsg" runat="server" visible="false">
                                <div class="col-sm-3 col-xs-12 row-label">
                                </div>
                                <div class="col-sm-6 col-xs-12">
                                    <asp:Literal ID="Literal3" runat="server" Text='<%$ Resources:Content,strSelectPropLicForUserMsg %>' />
                                </div>
                                <div class="col-sm-3 col-xs-12">
                                </div>

                            </div>
                            <div class="row" id="DivAssignBtn" runat="server" visible="false">
                                <div class="col-sm-3 col-xs-12 row-label">
                                </div>
                                <div class="col-sm-6 col-xs-12">
                                    <asp:Button ID="Btn_Assign" CausesValidation="false" runat="server" Text='<%$ Resources:Content,strAssignSub %>' class="btn btn-primary waves-effect btnAction" />
                                </div>
                                <div class="col-sm-3 col-xs-12">
                                </div>

                            </div>
                            <div class="row" id="DivCompleted" runat="server" visible="false">
                                <div class="col-sm-1 col-xs-12 row-label">
                                </div>
                                <div class="col-sm-10 col-xs-12">
                                    <div id="divIcnCompleted" class="p-t-2"></div>
                                    <%--glyphicon glyphicon-ok-sign pull-left color-success--%>

                                    <asp:Label ID="lblCompleted" runat="server" Text='<%$ Resources:Content,strDRCompleteMsg %>' />
                                </div>
                                <div class="col-sm-1 col-xs-12 row-label">
                                </div>
                            </div>
                            <div class="row" id="DivOperations" runat="server" visible="false">
                                <div class="col-sm-3 col-xs-12 row-label">
                                </div>
                                <div class="col-sm-3 col-xs-12">
                                    <asp:Button ID="Btn_Save" Visible="false" CausesValidation="true" runat="server" Text='<%$ Resources:Content,strGoToUserAssign %>' class="btn btn-primary waves-effect btnAction" />

                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </asp:Panel>



    </div>

    <EM:TenantServicePrincipalError ID="TenantServicePrincipalError1" runat="server" />

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



        function oncheckchange(checked) {
            var btn = document.getElementById("<%=btn_ApplyForwardCallHistory.ClientID%>")
            btn.disabled = false;
        }

        function CheckUserIsOnMicrosoft(Msg, IncMsg, PasswordRequried, PMsg) {
            var TxBx = document.getElementById("<%=TxBx_Tenantadminlogin.ClientID%>");
            <%--var TxBxP = document.getElementById("<%=TxBx_Tenantadminpassword.ClientID%>");--%>
            if (!TxBx.value.toLowerCase().includes(".onmicrosoft.")) {
                alert(Msg);
                TxBx.focus();
                return false;
            }

            var emailPat = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
            var emailid = TxBx.value;
            var matchArray = emailid.match(emailPat);
            if (matchArray == null) {
                alert(IncMsg);
                document.getElementById("<%=TxBx_Tenantadminlogin.ClientID %>").focus();
                return false;
            }

            //if (PasswordRequried == "1") {

            //    if (TxBxP.value.trim() == "") {
            //        alert(PMsg);
            //        TxBxP.focus();
            //        return false;
            //    }

            //}


            return true;
        }


    </script>

    <script type="text/javascript">
        function HideConfigDiv(DivWait, DivConf) {
            var DivWaitEle = document.getElementById(DivWait);
            var DivConfEle = document.getElementById(DivConf);
            DivWaitEle.style.display = '';
            DivConfEle.style.display = 'none';
        }

    </script>
</asp:Panel>


