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

<%@ Register Assembly="GroupRadioButton" Namespace="Vladsm.Web.UI.WebControls" TagPrefix="EM" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="EM" %>

<asp:Content ID="Content7" ContentPlaceHolderID="CPH_Content" runat="Server">

    <script type="text/javascript" language="javascript">
        function DelRule() {
            if (window.confirm("This rule might be used in other pop accounts also.\n Are you sure you want to delete?") == true) {
                return true;
            }
            else
                return false;
        }

        function fun(HF_RuleIdVal, RuleID, RuleType, RuleName, whereClause, whereClauseValue, ForwardDepID, AssignTo, StatusID, PriorityID, HF_Edit) {

            var HF_RuleId = document.getElementById(HF_RuleIdVal);
            HF_RuleId.value = RuleID;

            var HF_EditRuleId = document.getElementById(HF_Edit);
            HF_EditRuleId.value = RuleID;

            var array = HF_RuleIdVal.split('HF_RuleId');
            var TxBx_RuleName = document.getElementById(array[0] + 'TxBx_RuleName');
            TxBx_RuleName.value = RuleName;

            var DDL_AssignTo = document.getElementById(array[0] + 'DDL_AssignTo');

            var DDL_Forward = document.getElementById(array[0] + 'DDL_Forward');

            var Tr_RowHide = document.getElementById(array[0] + 'Tr_RowHide');

            var N = DDL_Forward.options.length;
            var DDL_SetStatus = document.getElementById(array[0] + 'DDL_SetStatus');
            var O = DDL_SetStatus.options.length;
            var DDL_OverridePriority = document.getElementById(array[0] + 'DDL_OverridePriority');
            var P = DDL_OverridePriority.options.length;

            DDL_AssignTo.selectedIndex = -1;
            DDL_Forward.selectedIndex = -1;
            DDL_SetStatus.selectedIndex = -1;
            DDL_OverridePriority.selectedIndex = -1

            for (k = 0; k < N; k++) {
                if (DDL_Forward.options[k].value == ForwardDepID) {
                    DDL_Forward.options[k].selected = true;
                }
            }

            for (l = 0; l < O; l++) {
                if (DDL_SetStatus.options[l].value == StatusID) {
                    DDL_SetStatus.options[l].selected = true;
                }
            }

            for (m = 0; m < P; m++) {
                if (DDL_OverridePriority.options[m].value == PriorityID) {
                    DDL_OverridePriority.options[m].selected = true;
                }
            }

            if (RuleType == 0) {
                var TxBx_Contains = document.getElementById(array[0] + 'TxBx_Contains');
                TxBx_Contains.value = whereClauseValue;
                var DDL_Where = document.getElementById(array[0] + 'DDL_Where');
                var M = DDL_Where.options.length;
                DDL_Where.selectedIndex = -1;
                for (j = 0; j < M; j++) {
                    if (DDL_Where.options[j].value == whereClause) {
                        DDL_Where.options[j].selected = true;
                    }
                }
                Tr_RowHide.style.display = '';

            }
            else {
                Tr_RowHide.style.display = 'none';

            }

            var HF_AgentId = document.getElementById(array[0] + 'HF_AgentId');
            var LBX_Agents = document.getElementById(array[0] + 'LBX_Agents');
            HF_AgentId.value = -1;
            var I = 1;
            for (l = 0; l < LBX_Agents.length; l += 1) {
                if (DDL_Forward.value == LBX_Agents.options[l].value) {
                    var optText = LBX_Agents.options[l].innerHTML;
                    array = optText.split(';');
                    DDL_AssignTo.options[I] = new Option(array[1], array[0]);
                    I += 1;
                }
            }
            DDL_AssignTo.options[0].selected = true;

            var L = DDL_AssignTo.options.length;
            for (i = 0; i < L; i++) {
                if (DDL_AssignTo.options[i].value == AssignTo) {
                    DDL_AssignTo.options[i].selected = true;
                }
            }

            $object('MP1')._show();
            return false;
        }

        function DepartmentChange(Id) {
            var DDL_AssignTo = document.getElementById(Id);
            DDL_AssignTo.options.length = 1;//Resized to one element.
            var array = Id.split('DDL_AssignTo');
            var HF_AgentId = document.getElementById(array[0] + 'HF_AgentId');
            var LBX_Agents = document.getElementById(array[0] + 'LBX_Agents');
            var DDL_Forward = document.getElementById(array[0] + 'DDL_Forward');
            HF_AgentId.value = -1;
            var I = 1;
            for (l = 0; l < LBX_Agents.length; l += 1) {
                if (DDL_Forward.value == LBX_Agents.options[l].value) {
                    var optText = LBX_Agents.options[l].innerHTML;
                    array = optText.split(';');
                    DDL_AssignTo.options[I] = new Option(array[1], array[0]);
                    I += 1;
                }
            }
            DDL_AssignTo.options[0].selected = true;
        }
        function PopAgentChange(Id) {
            var DDL_AssignTo = document.getElementById(Id);
            var array = Id.split('DDL_AssignTo');
            var HF_AgentId = document.getElementById(array[0] + 'HF_AgentId');
            HF_AgentId.value = DDL_AssignTo.value;
        }

        function onOk() {
            var oSelect = document.getElementById('ctl00_CPH_Content_DDL_AssignTo');
            oSelect.selectedIndex = 0;
            __doPostBack('ctl00$CPH_Content$Btn_Pop_OK', '');
            //      __doPostBack('ctl00$RightContentPlaceHolder$GV_TicketList$ctl02$LBtn_Del','')
        }
        function onCancel() {
            var oSelect = document.getElementById('ctl00_CPH_Content_DDL_AssignTo');
            oSelect.selectedIndex = 0;
            //__doPostBack('ctl00$RightContentPlaceHolder$Btn_Pop_Cancel','');
            //      __doPostBack('ctl00$RightContentPlaceHolder$GV_TicketList$ctl02$LBtn_Del','')
        }

    </script>
    <asp:Panel ID="Pnl_Add" runat="server" DefaultButton="Btn_Add">
        <div class="col-xs-12">
            <div class="card">
                <div class="header">
                    <h3>
                        <asp:Literal ID="Ltl_AddIMAPAccount" runat="server" EnableViewState="false" Text='<%$ Resources:Content,AddIMAPAccount %>'></asp:Literal>
                    </h3>
                </div>

                <div class="body">
                    <div class="row">
                        <div class="col-sm-3 col-xs-12 row-label">
                            <asp:Literal ID="Literal10" runat="server" EnableViewState="false" Text='<%$ Resources:Content,String408 %>'></asp:Literal>:
                        </div>
                        <div class="col-sm-4 col-xs-12">
                            <div class="form-group">
                                <asp:RadioButtonList ID="Rbl_AccountType" runat="server" RepeatDirection="Horizontal" AutoPostBack="true">
                                    <asp:ListItem Selected="True" Text="<%$ Resources:Content,SPLA04 %>" Value="0"></asp:ListItem>
                                    <asp:ListItem Text="<%$ Resources:Content,OAuthForOffice365 %>" Value="1"></asp:ListItem>
                                </asp:RadioButtonList>
                            </div>
                        </div>
                        <div class="col-sm-5 col-xs-12 row-label">
                            <asp:HyperLink ID="Hl_KBArticle" runat="server" Target="_blank" NavigateUrl="https://kb.machsol.com/Knowledgebase/55776/MachPanel-HelpDesk-Configuration-using-OAuth-based-POP-Account" Text="<%$ Resources:Content, OAuthAccountConfiguration %>"></asp:HyperLink>
                        </div>
                    </div>
                    <div id="div_Basic" runat="server">
                        <div class="row">
                            <div class="col-sm-3 col-xs-12 row-label">
                                *
                <asp:Literal ID="Div1" runat="server" EnableViewState="false" Text='<%$ Resources:Content,GN0000491 %>'></asp:Literal>:
                            </div>

                            <div class="col-sm-4 col-xs-12">
                                <div class="form-group">
                                    <div class="form-line">
                                        <asp:TextBox ID="TxBx_PopEmail" runat="server" MaxLength="64"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="Rfv_PopEmail" ValidationGroup="add" ControlToValidate="TxBx_PopEmail"
                                            Display="none" runat="server"></asp:RequiredFieldValidator>
                                        <%--<asp:RegularExpressionValidator ID="Rev_PopEmail" ControlToValidate="TxBx_PopEmail"
                                            runat="server" ValidationExpression="<%$ Resources:MPRegex,EmailAddress%>"
                                            SetFocusOnError="true" Display="None" ErrorMessage='<%$ Resources:Content,GN0000592 %>'
                                            ValidationGroup="add"></asp:RegularExpressionValidator>--%>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-3 col-xs-12 row-label">
                                *
                <asp:Literal ID="Div2" runat="server" EnableViewState="false" Text='<%$ Resources:Content,IMAPServer %>' />:
                            </div>

                            <div class="col-sm-4 col-xs-12">
                                <div class="form-group">
                                    <div class="form-line">
                                        <asp:TextBox ID="TxBx_PopServer" runat="server" MaxLength="255"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="Rfv_PopServer" ValidationGroup="add" ControlToValidate="TxBx_PopServer"
                                            Display="none" runat="server" ErrorMessage=''></asp:RequiredFieldValidator>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-3 col-xs-12 row-label">
                                *
                <asp:Literal ID="Div3" runat="server" EnableViewState="false" Text='<%$ Resources:Content,GN0000565 %>' />:
                            </div>

                            <div class="col-sm-4 col-xs-12">
                                <div class="form-group">
                                    <div class="form-line">
                                        <asp:TextBox ID="TxBx_PopPort" runat="server" MaxLength="30" Text="<%$ Resources:Content,GN0001140%>"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="Rfv_PopPort" ValidationGroup="add" ControlToValidate="TxBx_PopPort"
                                            Display="none" runat="server" ErrorMessage=''></asp:RequiredFieldValidator>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-4 col-xs-12">
                                <div class="form-group">
                                    <asp:CheckBox ID="ChBx_SSLEnable" Text="<%$ Resources:Content,SSLEnabled%>" runat="server" />
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-3 col-xs-12 row-label">
                                *
                <asp:Literal ID="Div4" runat="server" EnableViewState="false" Text='<%$ Resources:Content,GN0000567 %>' />:
                            </div>

                            <div class="col-sm-4 col-xs-12">
                                <div class="form-group">
                                    <div class="form-line">
                                        <asp:TextBox ID="TxBx_PopUser" runat="server" MaxLength="100"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="Rfv_PopUser" ValidationGroup="add" ControlToValidate="TxBx_PopUser"
                                            Display="none" runat="server" ErrorMessage=''></asp:RequiredFieldValidator>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-3 col-xs-12 row-label">
                                *
                <asp:Literal ID="Label1" runat="server" EnableViewState="false" Text='<%$ Resources:Content,GN0000569 %>' />:
                            </div>

                            <div class="col-sm-4 col-xs-12">
                                <div class="form-group">
                                    <div class="form-line">
                                        <asp:TextBox ID="TxBx_PopPassword" runat="server" TextMode="Password"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="Rfv_PopPassword" runat="server" ControlToValidate="TxBx_PopPassword"
                                            Display="none" ErrorMessage="" ValidationGroup="add"></asp:RequiredFieldValidator>
                                        <asp:CompareValidator ID="Cv_PopPassword" runat="server" ErrorMessage="<%$ Resources:Content,DGN1110005 %>"
                                            ValidationGroup="add" ControlToCompare="TxBx_PopPassword" ControlToValidate="TxBx_PopPassword2"
                                            Display="None"></asp:CompareValidator>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-5 col-xs-12">
                                <asp:Literal ID="Ltl_LeaveBlankMsg" runat="server" Text="<%$ Resources:Content,GN00001530%>"
                                    EnableViewState="false"></asp:Literal>
                            </div>

                        </div>
                        <div class="row">
                            <div class="col-sm-3 col-xs-12 row-label">
                                *
                <asp:Literal ID="Div5" runat="server" EnableViewState="false" Text='<%$ Resources:Content,GN0001196 %>' />:
                            </div>

                            <div class="col-sm-4 col-xs-12">
                                <div class="form-group">
                                    <div class="form-line">
                                        <asp:TextBox ID="TxBx_PopPassword2" runat="server" TextMode="Password"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="Rfv_ConfirmPassword" ValidationGroup="add" ControlToValidate="TxBx_PopPassword2"
                                            Display="none" runat="server" ErrorMessage='<%$ Resources:Content,DGN1110005 %>'></asp:RequiredFieldValidator>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="div_O365" runat="server">
                        <div class="row">
                            <div class="col-sm-3 col-xs-12 row-label">
                                *
                <asp:Literal ID="Literal4" runat="server" EnableViewState="false" Text='<%$ Resources:Content,ClientId %>'></asp:Literal>:
                            </div>
                            <div class="col-sm-4 col-xs-12">
                                <div class="form-group">
                                    <div class="form-line">
                                        <asp:TextBox ID="TxBx_ClientId" runat="server" MaxLength="250"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="Rfv_ClientId" ValidationGroup="add" ControlToValidate="TxBx_ClientId"
                                            Display="none" runat="server"></asp:RequiredFieldValidator>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-3 col-xs-12 row-label">
                                *
                <asp:Literal ID="Literal5" runat="server" EnableViewState="false" Text='<%$ Resources:Content,TenantId %>'></asp:Literal>:
                            </div>
                            <div class="col-sm-4 col-xs-12">
                                <div class="form-group">
                                    <div class="form-line">
                                        <asp:TextBox ID="TxBx_TenantId" runat="server" MaxLength="250"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="Rfv_TenantId" ValidationGroup="add" ControlToValidate="TxBx_TenantId"
                                            Display="none" runat="server"></asp:RequiredFieldValidator>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-3 col-xs-12 row-label">
                                *
                <asp:Literal ID="Literal6" runat="server" EnableViewState="false" Text='<%$ Resources:Content,ClientSecret %>'></asp:Literal>:
                            </div>
                            <div class="col-sm-4 col-xs-12">
                                <div class="form-group">
                                    <div class="form-line">
                                        <asp:TextBox ID="TxBx_ClientSecret" runat="server" MaxLength="450"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="Rfv_ClientSecret" ValidationGroup="add" ControlToValidate="TxBx_ClientSecret"
                                            Display="none" runat="server"></asp:RequiredFieldValidator>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-3 col-xs-12 row-label">
                                *
                <asp:Literal ID="Literal7" runat="server" EnableViewState="false" Text='<%$ Resources:Content,USM0061 %>'></asp:Literal>:
                            </div>
                            <div class="col-sm-4 col-xs-12">
                                <div class="form-group">
                                    <div class="form-line">
                                        <asp:TextBox ID="TxBx_UserName" runat="server" MaxLength="250"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="Rfv_UserName" ValidationGroup="add" ControlToValidate="TxBx_UserName"
                                            Display="none" runat="server"></asp:RequiredFieldValidator>
                                        <%--<asp:RegularExpressionValidator ID="Rev_UserName" ControlToValidate="TxBx_UserName"
                                            runat="server" ValidationExpression="<%$ Resources:MPRegex,EmailAddress%>"
                                            SetFocusOnError="true" Display="None" ErrorMessage='<%$ Resources:Content,GN0000592 %>'
                                            ValidationGroup="add"></asp:RegularExpressionValidator>--%>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-3 col-xs-12 row-label">
                                *
                <asp:Literal ID="Literal8" runat="server" EnableViewState="false" Text='<%$ Resources:Content,Exch099 %>'></asp:Literal>:
                            </div>
                            <div class="col-sm-4 col-xs-12">
                                <div class="form-group">
                                    <div class="form-line">
                                        <asp:TextBox ID="TxBx_Scope" runat="server" MaxLength="250" PlaceHolder="https://outlook.office365.com/.default"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="Rfv_Scope" ValidationGroup="add" ControlToValidate="TxBx_Scope"
                                            Display="none" runat="server"></asp:RequiredFieldValidator>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-3 col-xs-12 row-label">
                                *
                <asp:Literal ID="Literal9" runat="server" EnableViewState="false" Text='<%$ Resources:Content,HostAddress %>'></asp:Literal>:
                            </div>
                            <div class="col-sm-4 col-xs-12">
                                <div class="form-group">
                                    <div class="form-line">
                                        <asp:TextBox ID="TxBx_HostAddress" runat="server" PlaceHolder="outlook.office365.com" MaxLength="250"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="Rfv_HostAddress" ValidationGroup="add" ControlToValidate="TxBx_HostAddress"
                                            Display="none" runat="server"></asp:RequiredFieldValidator>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-3 col-xs-12 row-label">
                            <asp:Literal ID="Literal1" runat="server" EnableViewState="false" Text='<%$ Resources:Content,MoveParsedEmail %>' />:
                        </div>
                        <div class="col-sm-4 col-xs-12">
                            <div class="form-group">
                                <asp:CheckBox ID="CB_MoveParsedEmail" runat="server" Text=" " Checked="true"></asp:CheckBox>
                            </div>
                        </div>
                        <div class="col-sm-5 col-xs-12 row-label">
                            <asp:Literal ID="Literal3" runat="server" Text='<%$ Resources:Content,ParseNotice %>' />
                        </div>
                    </div>
                    <div class="row" id="Tr_ParsedEmailFolder" runat="server">
                        <div class="col-sm-3 col-xs-12 row-label">
                            *<asp:Literal ID="Literal2" runat="server" EnableViewState="false" Text='<%$ Resources:Content,ParsedEmailFolder %>' />:
                        </div>

                        <div class="col-sm-4 col-xs-12">
                            <div class="form-group">
                                <div class="form-line">
                                    <asp:TextBox ID="TxBx_ParsedEmailFolder" runat="server" MaxLength="100"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RFV_TxBx_ParsedEmailFolder" ValidationGroup="add" ControlToValidate="TxBx_ParsedEmailFolder"
                                        Display="none" runat="server" ErrorMessage=''></asp:RequiredFieldValidator>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-xs-12">
                            <div class="card">
                                <div class="header">
                                    <div class="displayInlineBlock">
                                        <h3>
                                            <%= Resources.Content.SMI0407%>                                                                                                                                 
                                        </h3>
                                    </div>
                                    <asp:LinkButton ID="LnkBtn_Create" Text='<%$ Resources:Content,SM400037 %>' CssClass="btn btn-primary waves-effect pull-right m-t--4px btnAction" runat="server"></asp:LinkButton>
                                </div>
                                <div class="body">
                                    <div class="row">
                                        <div class="col-xs-12">
                                            <table class="table table-bordered table-striped table-hover table-responsive">
                                                <tr>
                                                    <th id="ChkBx_Rule" class="col-xs-10">
                                                        <asp:Literal ID="Lit1" runat="server" Text='<%$ Resources:Content,GN0000573 %>'></asp:Literal>
                                                    </th>
                                                    <th class="col-xs-2">
                                                        <asp:Literal ID="Lit2" runat="server" Text='<%$ Resources:Content,GN0000368 %>'>
                                                        </asp:Literal>
                                                    </th>
                                                </tr>

                                                <asp:Repeater ID="Rep_Rules" runat="server">
                                                    <ItemTemplate>
                                                        <tr>
                                                            <td class="col-xs-10">
                                                                <EM:GroupRadioButton ID="RB_Rule" runat="server" CssClass="vertical-align-middle" />&nbsp;
                                                <label id="Div_Rule" runat="server" class="display-inline"></label>
                                                                <input type="hidden" id="Hidden_ChkBoxID" runat="server" />
                                                            </td>
                                                            <td class="col-xs-2">
                                                                <asp:LinkButton ID="LB_Edit" runat="server" SkinID="LinkButtonEdit" Text="<%$ Resources:Content,GN0000276 %>" CssClass="btn btn-primary"></asp:LinkButton>
                                                                <asp:LinkButton ID="LB_Delete" runat="server" SkinID="linkButtonDelete" Text='<%$ Resources:Content,GN0000377 %>' CssClass="btn btn-primary btnAction"></asp:LinkButton>
                                                            </td>
                                                        </tr>
                                                    </ItemTemplate>
                                                </asp:Repeater>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-xs-12">
                            <asp:Button ID="Btn_Add" ValidationGroup="add" SkinID="saveButton" runat="server" Text='<%$ Resources:Content,GN0000281 %>' CssClass="btn btn-primary btnAction" />
                            <asp:Button ID="Btn_Cancel" SkinID="cancelButton" runat="server" Text='<%$ Resources:Content,GN0000572 %>' PostBackUrl="~/RCC/helpdesk/popaccounts.aspx" CssClass="btn btn-primary" />
                            <asp:ValidationSummary ID="ValidationSummary3" ValidationGroup="add" ShowMessageBox="true" HeaderText="<%$ Resources:Content,EM000001 %>" ShowSummary="false" runat="server" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </asp:Panel>
</asp:Content>
