<%@ page title="" language="VB" masterpagefile="~/Template/Master.master" autoeventwireup="false" inherits="Admin_System_SMSSettings, MachSol.MachPanel.Web" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="EM" %>
<%@ Register Src="~/Template/GVPager.ascx" TagName="Pager" TagPrefix="EM" %>
<%@ Register Assembly="MachSol.MachPanel.Utility" Namespace="MachSol.MachPanel.Utility" TagPrefix="EM" %>
<%@ Register Assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="System.Web.UI" TagPrefix="cc1" %>

<asp:Content ID="Content5" ContentPlaceHolderID="CPH_Content" runat="Server">
    <script type="text/javascript" language="javascript">
        function CallUpdate() {
            var CtrlDDL = document.getElementById('<%=Ddl_SMSVariablesHtml.ClientID%>');
            var CtrlSMSBody = document.getElementById('<%=TxBx_SMSBody.ClientID%>');
            if (CtrlDDL.value != '0') {
                insertTextAtCursor(CtrlSMSBody, CtrlDDL.value);
                setTimeout(function () { CtrlDDL.selectedIndex = 0; $(CtrlDDL).trigger('change'); }, 500);
            }
        }
        function insertTextAtCursor(myField, myValue) {
            //alert(myValue);
            //IE support
            if (document.selection) {
                myField.focus();
                sel = document.selection.createRange();
                sel.text = myValue;
            }
            //MOZILLA and others
            else if (myField.selectionStart || myField.selectionStart == '0') {
                var startPos = myField.selectionStart;
                var endPos = myField.selectionEnd;
                myField.value = myField.value.substring(0, startPos)
                    + myValue
                    + myField.value.substring(endPos, myField.value.length);
                myField.selectionStart = startPos + myValue.length;
                myField.selectionEnd = startPos + myValue.length;
            } else {
                myField.value += myValue;
            }
        }

    </script>

    <div class="col-xs-12">
        <div class="card">
            <%--<div class="header">
                <h2>
                    <asp:Literal ID="Ltl_SubsInfo" runat="server" Text="<%$ Resources:Content,thirdPartyAuthentication %>" /></h2>
            </div>--%>
            <div class="body">
                <ajax:UpdatePanel ID="UP_2FASettings" runat="server">
                    <ContentTemplate>
                        <EM:TabContainer ID="TC_Settings" runat="server" OnClientActiveTabChanged="loadTabPanel">

                            <EM:TabPanel ID="Tab_ThirdParty" runat="server" HeaderText="<%$ Resources:Content, strSMSAPISettings%>">
                                <ContentTemplate>
                                    <asp:Button ID="Btn_Tab0" runat="server" Style="display: none;" />
                                    <asp:Panel ID="Pnl_TabContent0" runat="server">

                                        <div class="row" id="Pnl_TwilioProviders" runat="server">

                                            <div class="col-xs-12">
                                                <EM:MPGridView ID="GV_SMSProvider" DataKeyNames="SMSProviderID" CssClass="table table-bordered table-striped table-hover" runat="server"
                                                    EmptyDataText='<%$ Resources:Content, GN00001375 %>' AutoGenerateColumns="false">

                                                    <Columns>

                                                        <asp:TemplateField HeaderText='<%$ Resources:Content,GN000171%>' HeaderStyle-CssClass="col-xs-4" ItemStyle-CssClass="col-xs-4">
                                                            <ItemTemplate>
                                                                <asp:Label ID="LBL_ProviderName" runat="server" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText='<%$ Resources:Content,GN000171%>' HeaderStyle-CssClass="col-xs-4" ItemStyle-CssClass="col-xs-4">
                                                            <ItemTemplate>
                                                                <asp:Label ID="LBL_Enabled" runat="server" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText='<%$ Resources:Content,GN0000360%>' HeaderStyle-CssClass="col-xs-2" ItemStyle-CssClass="col-xs-2">
                                                            <ItemTemplate>
                                                                <asp:LinkButton ID="LB_Edit" Text='<%$ Resources:Content,GN0000276%>' class="btn btn-primary waves-effect" CommandName="EditRow" runat="server" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                    </Columns>
                                                </EM:MPGridView>
                                            </div>

                                        </div>
                                        <div class="row" id="Pnl_Twilio" runat="server" visible="false">
                                            <div class="col-xs-12">
                                                <div class="card">
                                                    <div class="header">
                                                        <h3><%= Resources.Content.TwilioAPISettings%></h3>
                                                    </div>
                                                    <div class="body">
                                                        <div class="row">
                                                            <div class="col-sm-2 col-xs-12 row-label">
                                                                <label>*<asp:Literal ID="Literal2" runat="server" Text='<%$ Resources:Content, AccountSID%>' EnableViewState="false" />:</label>
                                                            </div>
                                                            <div class="col-sm-4 col-xs-12">
                                                                <div class="form-group">
                                                                    <div class="form-line">
                                                                        <asp:TextBox ID="TxBx_AccountSID" MaxLength="50" runat="server" Text=""></asp:TextBox>
                                                                        <asp:RequiredFieldValidator ID="Rfv_1" runat="server" ControlToValidate="TxBx_AccountSID"
                                                                            Display="None" SetFocusOnError="True" Enabled="false" ValidationGroup="2FA"></asp:RequiredFieldValidator>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-sm-2 col-xs-12 row-label">
                                                                <label>*<asp:Literal ID="Literal1" runat="server" Text='<%$ Resources:Content, AuthToken%>' EnableViewState="false" />:</label>
                                                            </div>
                                                            <div class="col-sm-4 col-xs-12">
                                                                <div class="form-group">
                                                                    <div class="form-line">
                                                                        <asp:TextBox ID="TxBx_AuthToken" MaxLength="50" runat="server" Text=""></asp:TextBox>
                                                                        <asp:RequiredFieldValidator ID="Rfv_2" runat="server" ControlToValidate="TxBx_AuthToken"
                                                                            Display="None" SetFocusOnError="True" Enabled="false" ValidationGroup="2FA"></asp:RequiredFieldValidator>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-sm-2 col-xs-12 row-label">
                                                                <label>*<asp:Literal ID="Literal17" runat="server" Text='<%$ Resources:Content, String1027%>' EnableViewState="false" />:</label>
                                                            </div>
                                                            <div class="col-sm-4 col-xs-12">
                                                                <div class="form-group">
                                                                    <div class="form-line">
                                                                        <asp:TextBox ID="TxBx_PhoneNumber" MaxLength="50" runat="server" Text=""></asp:TextBox>
                                                                        <asp:RequiredFieldValidator ID="Rfv_3" runat="server" ControlToValidate="TxBx_PhoneNumber"
                                                                            Display="None" SetFocusOnError="True" Enabled="false" ValidationGroup="2FA"></asp:RequiredFieldValidator>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row" runat="server" visible="false">
                                                            <div class="col-sm-2 col-xs-12 row-label">
                                                                <label>*<asp:Literal ID="Literal6" runat="server" Text='<%$ Resources:Content, strEnabled%>' EnableViewState="false" />:</label>
                                                            </div>
                                                            <div class="col-sm-4 col-xs-12">
                                                                <asp:CheckBox ID="ChBx_Enabled" Text=" " runat="server" />
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-sm-2 col-xs-12 row-label">
                                                                <label>*<asp:Literal ID="Literal18" runat="server" Text='<%$ Resources:Content, TwilioAPIUrl%>' EnableViewState="false" />:</label>
                                                            </div>
                                                            <div class="col-sm-4 col-xs-12">
                                                                <div class="form-group">
                                                                    <div class="form-line">
                                                                        <asp:TextBox ID="TxBx_APIUrl" MaxLength="400" runat="server" Text=""></asp:TextBox>
                                                                        <asp:RequiredFieldValidator ID="Rfv_6" runat="server" ControlToValidate="TxBx_APIUrl"
                                                                            Display="None" SetFocusOnError="True" Enabled="false" ValidationGroup="2FA"></asp:RequiredFieldValidator>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-5 col-xs-12">
                                                                <asp:Button ID="Btn_Send" runat="server" ValidationGroup="2FA" class="btn btn-primary waves-effect" Text="<%$ Resources:Content,SendTestSMS %>" />
                                                            </div>
                                                        </div>

                                                        <div class="row">
                                                            <div class="col-xs-12">
                                                                <asp:ValidationSummary ID="VS_SaveSettings" ValidationGroup="2FA" DisplayMode="BulletList"
                                                                    ShowSummary="false" ShowMessageBox="true" HeaderText="<%$ Resources:Content,EM000001%>"
                                                                    runat="server" />
                                                                <asp:Button ID="Btn_SaveSettings" ValidationGroup="2FA" class="btn btn-primary waves-effect btnAction" runat="server" Text='<%$ Resources:Content,GN0000949 %>' />
                                                                <asp:Button ID="Btn_SMSCancel" class="btn btn-primary waves-effect" Visible="false" CausesValidation="false" runat="server" Text="<%$ Resources:Content,GN0000572%>" />
                                                            </div>
                                                        </div>


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

                                    </asp:Panel>
                                </ContentTemplate>
                            </EM:TabPanel>

                            <EM:TabPanel ID="Tab_TFAS" runat="server" HeaderText="<%$ Resources:Content, SMSTemplates%>">
                                <ContentTemplate>
                                    <asp:Button ID="Btn_Tab1" runat="server" Style="display: none;" />
                                    <asp:Panel ID="Pnl_TabContent1" runat="server" Visible="false">



                                        <div class="row" id="Pnl_TemplateListing" runat="server">
                                            <div class="col-xs-12">
                                                <div class="card">
                                                    <div class="header">
                                                        <h3><%= Resources.Content.SMSTemplates%></h3>
                                                    </div>
                                                    <div class="body">
                                                        <div class="row">
                                                            <div class="col-xs-12">
                                                                <asp:Button class="btn btn-primary waves-effect btnAction" ID="Btn_AddTemplate" runat="server" Text="<%$ Resources:Content,String200%>" />
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-xs-12">
                                                                <asp:GridView ID="GV_SMSTemplates" DataKeyNames="Id, LanguageId" CssClass="table table-bordered table-striped table-hover" runat="server"
                                                                    EmptyDataText='<%$ Resources:Content, GN00001375 %>' AllowPaging="true" AutoGenerateColumns="false">
                                                                    <Columns>
                                                                        <asp:BoundField DataField="TemplateName" HeaderText="<%$ Resources:Content,String273%>" HeaderStyle-CssClass="col-xs-4" ItemStyle-CssClass="col-xs-4" />
                                                                        <asp:TemplateField HeaderText="<%$ Resources:Content,GN0000976%>" HeaderStyle-CssClass="col-xs-3" ItemStyle-CssClass="col-xs-3">
                                                                            <ItemTemplate>
                                                                                <asp:Label ID="Lbl_Purpose" runat="server" />
                                                                            </ItemTemplate>
                                                                        </asp:TemplateField>
                                                                        <asp:BoundField DataField="LanguageName" HeaderText="<%$ Resources:Content,GN00003000%>" HeaderStyle-CssClass="col-xs-3" ItemStyle-CssClass="col-xs-3" />
                                                                        <asp:TemplateField HeaderText='<%$ Resources:Content,GN000171%>' HeaderStyle-CssClass="col-xs-1" ItemStyle-CssClass="col-xs-1" Visible="false">
                                                                            <ItemTemplate>
                                                                                <asp:Label ID="Img_IsDefaultTemplate" runat="server" />
                                                                            </ItemTemplate>
                                                                        </asp:TemplateField>
                                                                        <asp:TemplateField HeaderText='<%$ Resources:Content,GN0000360%>' HeaderStyle-CssClass="col-xs-2" ItemStyle-CssClass="col-xs-2">
                                                                            <ItemTemplate>
                                                                                <asp:LinkButton ID="LB_Edit" Text='<%$ Resources:Content,GN0000276%>' class="btn btn-primary waves-effect" CommandName="EditRow" runat="server" />
                                                                                <asp:LinkButton ID="LB_Delete" Text='<%$ Resources:Content,GN0000278%>' class="btn btn-primary waves-effect btnAction" CommandName="DeleteRow" runat="server" />
                                                                                <EM:ConfirmButtonExtender ID="CBE_Remove" ConfirmText="<%$ Resources:Content,DGN1119974%>"
                                                                                    TargetControlID="LB_Delete" runat="server">
                                                                                </EM:ConfirmButtonExtender>
                                                                            </ItemTemplate>
                                                                        </asp:TemplateField>
                                                                    </Columns>
                                                                    <%--PagerTemplate Start--%>
                                                                    <PagerTemplate>
                                                                        <EM:Pager ID="Pager1" runat="server" />
                                                                    </PagerTemplate>
                                                                    <%--PagerTemplate End--%>
                                                                </asp:GridView>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row" id="Pnl_AddEditTemplate" runat="server" visible="false">
                                            <div class="col-xs-12">
                                                <div class="card">
                                                    <div class="header">
                                                        <h3>
                                                            <asp:Literal ID="Ltr_Heading" runat="server" Text='<%$ Resources:Content, String200%>' EnableViewState="false" /></h3>
                                                    </div>
                                                    <div class="body">
                                                        <div class="row">
                                                            <div class="col-sm-2 col-xs-12 row-label">
                                                                <label>*<asp:Literal ID="Literal3" runat="server" Text='<%$ Resources:Content, String273%>' EnableViewState="false" />:</label>
                                                            </div>
                                                            <div class="col-sm-4 col-xs-12">
                                                                <div class="form-group">
                                                                    <div class="form-line">
                                                                        <asp:TextBox ID="TxBx_Name" MaxLength="100" runat="server" Text=""></asp:TextBox>
                                                                        <asp:RequiredFieldValidator ID="Rfv_4" runat="server" ControlToValidate="TxBx_Name"
                                                                            Display="None" SetFocusOnError="True" ValidationGroup="Template"></asp:RequiredFieldValidator>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-sm-2 col-xs-12 row-label">
                                                                <label>*<asp:Literal ID="Literal4" runat="server" Text='<%$ Resources:Content, SMSBody%>' EnableViewState="false" />:</label>
                                                            </div>
                                                            <div class="col-sm-8 col-xs-12">
                                                                <div class="form-group">
                                                                    <asp:TextBox ID="TxBx_SMSBody" runat="server" Height="150px" Width="100%" TextMode="MultiLine"
                                                                        MaxLength="500"></asp:TextBox>
                                                                    <asp:RequiredFieldValidator ID="Rfv_5" runat="server" ControlToValidate="TxBx_SMSBody"
                                                                        Display="None" SetFocusOnError="True" ValidationGroup="Template"></asp:RequiredFieldValidator>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-sm-2 col-xs-12 row-label">
                                                                <label>*<asp:Literal ID="Literal5" runat="server" Text='<%$ Resources:Content, InsertVariable%>' EnableViewState="false" />:</label>
                                                            </div>
                                                            <div class="col-sm-4 col-xs-12">
                                                                <div class="form-group">
                                                                    <asp:DropDownList ID="Ddl_SMSVariablesHtml" onchange='CallUpdate()' runat="server">
                                                                        <asp:ListItem Text="<%$ Resources:Content,SMI91%>" Value="0" />
                                                                        <asp:ListItem Text="%CompanyName%" />
                                                                        <asp:ListItem Text="%CompanyWebsiteUrl%" />
                                                                        <asp:ListItem Text="%UserName%" />
                                                                        <asp:ListItem Text="%PINCode%" />
                                                                        <asp:ListItem Text="%ValidUpto%" />
                                                                    </asp:DropDownList>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-sm-2 col-xs-12 row-label">
                                                                <label>*<asp:Literal ID="Literal7" runat="server" Text='<%$ Resources:Content, GN00003000%>' EnableViewState="false" />:</label>
                                                            </div>
                                                            <div class="col-sm-4 col-xs-12">
                                                                <div class="form-group">
                                                                    <asp:DropDownList ID="Ddl_Language" runat="server">
                                                                    </asp:DropDownList>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-sm-2 col-xs-12 row-label">
                                                                <label>*<asp:Literal ID="Literal9" runat="server" Text='<%$ Resources:Content, GN0000976%>' EnableViewState="false" />:</label>
                                                            </div>
                                                            <div class="col-sm-4 col-xs-12">
                                                                <div class="form-group">
                                                                    <asp:DropDownList ID="Ddl_Purpose" runat="server" AutoPostBack="true">
                                                                        <asp:ListItem Text='<%$ Resources:Content, strTwoFactorAuth%>' Value="1" Selected="True"></asp:ListItem>
                                                                        <asp:ListItem Text='<%$ Resources:Content, GN00008005%>' Value="2"></asp:ListItem>
                                                                    </asp:DropDownList>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row" runat="server" visible="false">
                                                            <div class="col-sm-2 col-xs-12 row-label">
                                                                <label>*<asp:Literal ID="Literal8" runat="server" Text='<%$ Resources:Content, GN000171%>' EnableViewState="false" />:</label>
                                                            </div>
                                                            <div class="col-sm-4 col-xs-12">
                                                                <div class="form-group">
                                                                    <asp:CheckBox ID="Cb_IsDefault" runat="server" Text=" " checked="false"/>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-xs-12">
                                                                <asp:ValidationSummary ID="ValidationSummary1" ValidationGroup="Template" DisplayMode="BulletList"
                                                                    ShowSummary="false" ShowMessageBox="true" HeaderText="<%$ Resources:Content,EM000001%>" runat="server" />
                                                                <asp:Button ID="Btn_SaveTemplate" class="btn btn-primary waves-effect btnAction" ValidationGroup="Template" runat="server" Text="<%$ Resources:Content,GN0000281%>" />
                                                                <asp:Button ID="Btn_Cancel" class="btn btn-primary waves-effect" CausesValidation="false" runat="server" Text="<%$ Resources:Content,GN0000572%>" />
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>


                                    </asp:Panel>
                                </ContentTemplate>
                            </EM:TabPanel>

                        </EM:TabContainer>
                    </ContentTemplate>
                </ajax:UpdatePanel>
            </div>
        </div>
    </div>
    <asp:Button ID="Btn_Dummy2" Style="display: none" runat="server" />
    <asp:Panel ID="Pnl_GetPhone" CssClass="width-modal-popup-auto" runat="server" Style="display: none;">
        <div class="card">
            <div class="header">
                <h2>
                    <asp:Literal ID="Literal15" runat="server" Text="<%$ Resources:Content,MobileNumber %>"
                        EnableViewState="false" /></h2>
            </div>
            <div class="body">
                <div class="row">
                    <div class="col-sm-4 col-xs-12 row-label">
                        <label>
                            <asp:Literal ID="Literal16" runat="server" Text="<%$ Resources:Content,MobileForTestSMS %>"
                                EnableViewState="false" />:</label>
                    </div>
                    <div class="col-sm-4 col-xs-12">
                        <div class="form-group">
                            <div class="form-line">
                                <asp:TextBox ID="TxBx_MobileNumber" MaxLength="20" runat="server"></asp:TextBox>
                            </div>
                        </div>

                        <div class="form-group row-label">
                            <asp:Literal ID="L1" runat="server" EnableViewState="false" Text="<%$ Resources:Content,E164Format %>"></asp:Literal>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <asp:Button ID="Btn_Pop_OK" runat="server" class="btn btn-primary waves-effect" Text="<%$ Resources:Content,DGN1110199 %>" />
                        <asp:Button ID="Btn_Pop_Cancel" class="btn btn-primary waves-effect" runat="server" Text="<%$ Resources:Content,GN0000572 %>" />
                    </div>
                </div>
            </div>
        </div>
    </asp:Panel>
    <EM:ModalPopupExtender runat="server" ID="MPE_Phone" OkControlID="Btn_Pop_OK"
        CancelControlID="Btn_Pop_Cancel" OnOkScript="onOk()" BackgroundCssClass="modalBackground" DropShadow="false"
        PopupControlID="Pnl_GetPhone" TargetControlID="Btn_Dummy2">
    </EM:ModalPopupExtender>

    <script type="text/javascript">
        function onOk() {
            if (document.getElementById('ctl00_CPH_Content_TxBx_MobileNumber').value != '') {
                __doPostBack('ctl00$CPH_Content$Btn_Pop_OK', '');
            }
            else {
                alert("Please enter mobile number.");
                $find('ctl00_CPH_Content_MPE_Phone').show();
            }

        }

    </script>
</asp:Content>

