<%@ page title="Operators Insert/Update" language="C#" masterpagefile="~/MasterPage.master" autoeventwireup="true" inherits="Administration_Operators_OperatorsInsertUpdate, CardAccess.Web.UI_deploy" theme="Office2007Black" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script src='<%= ResolveUrl("~/Scripts/jquery-1.9.1.js") %>' type="text/javascript"></script>
    <script src='<%= ResolveUrl("~/Scripts/jquery-ui.js") %>' type="text/javascript"></script>
    <link href='<%= ResolveUrl("~/Content/jquery-ui.css") %>' rel="stylesheet"
        type="text/css" />

    <script id="igClientScript" type="text/javascript">
        function CheckAction(oToolbar, oButton, oEvent) {
            //Add code to handle your event here.
            if (oButton.getItem().get_text() == '<%=this.Cancel%>') {
            }
            else if (oButton.getItem().get_text() == '<%=this.Save %>') {
                var relID = document.getElementById("<%=txtLoginName.ClientID %>");
                var relLoginName = relID.value;

                var txtFirstName = document.getElementById("<%=txtFirstName.ClientID %>").value;
                var txtLastName = document.getElementById("<%=txtLastName.ClientID %>").value;

                var txtPassword = document.getElementById("<%=txtPassword.ClientID %>").value;
                var txtConfirmPassword = document.getElementById("<%=txtConfirmPassword.ClientID %>").value;

                var combo = $find("<%=cboRole.ClientID %>");
                var index = combo.get_selectedItemIndex();
                var comVal;
                if (index >= 0) {
                    comVal = combo.get_selectedItem().get_value();
                }
                if (relLoginName.trim().length <= 0) {
                    alert("<%= this.LoginNameRequired %>");
                    $find('<%=txtLoginName.ClientID %>').setFocus();
                    oButton.set_cancel(true);
                }
                else if (txtFirstName.trim().length <= 0) {
                    alert("<%= this.OperFirstName %>");
                    $find('<%=txtFirstName.ClientID %>').setFocus();
                    oButton.set_cancel(true);
                }
                else if (txtLastName.trim().length <= 0) {
                    alert("<%= this.OperLastName %>");
                    $find('<%=txtLastName.ClientID %>').setFocus();
                    oButton.set_cancel(true);
                }
                else if (txtPassword.trim().length <= 0) {
                    alert("<%= this.PassswordNewEmpty %>");
                    $find('<%=txtPassword.ClientID %>').setFocus();
                    oButton.set_cancel(true);
                }
                else if (("<%=AddingNew %>" == "True") && (comVal == undefined || comVal.length <= 0)) {
                    alert("<%=this.RoleRequired%>");
                    oButton.set_cancel(true);
                }
                else if (txtPassword != txtConfirmPassword) {
                    alert("<%=this.PasswordConfirmed%>");
                    $find('<%=txtPassword.ClientID %>').setFocus();
                    oButton.set_cancel(true);
                }
            }            
            //Setup Privileges
            else if (oToolbar.getItems().getItem(3).get_isActive()) {
                var nLocation = "SetupPrivileges.aspx";
                setTimeout(function () { window.location = nLocation }, 500);
            }
        }
        function invalidatePassword() {
            var dialog = $("<div title='Confirmation'><p><%=GetInvalidatePassword %></p></div>").dialog({
                modal: true,
                buttons: {
                    "Yes": function () {
                        console.log('YES');
                        $.ajax({
                            type: "POST",
                            url: "OperatorsInsertUpdate.aspx/DoInvalidatePassword",
                            data: JSON.stringify({actionType: 'YES'}),
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            cache: false,
                            async: false,
                            success: function (msg) {
                                dialog.dialog('close');
                                $find('<%=txtPassword.ClientID %>').set_enabled(true);
                                $find('<%=txtConfirmPassword.ClientID %>').set_enabled(true);
                                $find('<%=txtPassword.ClientID %>').set_text('');
                                $find('<%=txtConfirmPassword.ClientID %>').set_text('');
                            },
                            error: function (data, status, jqXHR) {
                            }
                        });
                    },
                    "No": function () {
                        console.log('NO');
                        $.ajax({
                            type: "POST",
                            url: "OperatorsInsertUpdate.aspx/DoInvalidatePassword",
                            data: JSON.stringify({actionType: 'NO'}),
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            cache: false,
                            async: false,
                            success: function (msg) {
                                dialog.dialog('close');
                            },
                            error: function (data, status, jqXHR) {
                            }
                        });
                    },
                    "Cancel": function () {
                        dialog.dialog('close');
                    }
                }
            });
            return false;
        }

        function openImportPersonForm() {
            var width = 700;
            var height = 500;
            var x = 0; var y = 0;
            if (screen) {
                x = (screen.width - width) / 2;
                y = (screen.height - height) / 2;
            }

            var winArgs = 'toolbar=0,menubar=0,location=0,status=0,resizable=no,fullscreen=no,scrollbars=no,width=' + width + ',height=' + height + ',left=' + x + ',top=' + y;
            var win = window.open("ImportPerson.aspx", "", winArgs);
            win.focus();
        }

        function fillPersonInfo(lastName, firstName, Phone) {
            $find('<%=txtLastName.ClientID %>').set_text(lastName);
            $find('<%=txtFirstName.ClientID %>').set_text(firstName);
            $find('<%=txtPhoneNo.ClientID %>').set_text(Phone);
        }

    </script>
    <asp:UpdatePanel ID="upEditorToolbar" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <AEL:ConfigurationEditorToolBar ID="ConfigurationEditorToolBar1" runat="server" ClientSideEvent_Click="CheckAction"
                OnCancel="editorToolbar_OnCancel" OnSave="ConfigurationEditorToolBar1_OnSave">
            </AEL:ConfigurationEditorToolBar>
        </ContentTemplate>
    </asp:UpdatePanel>
    <div>
        <table cellpadding="0" cellspacing="0" style="width: 100%;">
            <tr>
                <td>
                    <asp:UpdatePanel ID="WebAsyncRefreshPanel1" runat="server">
                        <ContentTemplate>
                            <ig:WebTab ID="tbOperator" runat="server" SelectedTab="0" Style="width: 100% !important;
                                min-width: 100% !important;">
                                <Tabs>
                                    <ig:ContentTabItem Text="General" Style="min-height: 350px;">
                                        <Template>
                                            <igmisc:WebGroupBox ID="gboLoginInformation" runat="server" Text="Login Information"
                                                BackColor="Transparent">
                                                <Template>
                                                    <table cellpadding="0" cellspacing="3">
                                                        <tr valign="top">
                                                            <td style="width: 350px;">
                                                                <table cellpadding="1" cellspacing="2" width="100%">
                                                                    <tr>
                                                                        <td style="width: 125px;">
                                                                            <asp:Label ID="lblLoginName" Text="Login Name" runat="server"></asp:Label>
                                                                        </td>
                                                                        <td style="width: auto;">
                                                                            <ig:WebTextEditor ID="txtLoginName" runat="server" Width="198px">
                                                                            </ig:WebTextEditor>
                                                                        </td>
                                                                        <td>
                                                                            &nbsp;
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label ID="lblPassword" Text="Password" runat="server"></asp:Label>
                                                                        </td>
                                                                        <td>
                                                                            <ig:WebTextEditor ID="txtPassword" runat="server" TextMode="Password" Width="198px">
                                                                            </ig:WebTextEditor>
                                                                        </td>
                                                                        <td>
                                                                            &nbsp;
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label ID="lblConfirmPassword" Text="Confirm Password" runat="server"></asp:Label>
                                                                        </td>
                                                                        <td>
                                                                            <ig:WebTextEditor ID="txtConfirmPassword" runat="server" TextMode="Password" Width="198px">
                                                                            </ig:WebTextEditor>
                                                                        </td>
                                                                        <td>
                                                                            &nbsp;
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label ID="lblLogoffTime" Text="Logoff Time" runat="server"></asp:Label>
                                                                        </td>
                                                                        <td>
                                                                            <ig:WebNumericEditor ID="txtLogoffTime" runat="server" Width="198px">
                                                                                <Buttons SpinButtonsDisplay="OnRight" CustomButtonDisplay="None">
                                                                                </Buttons>
                                                                            </ig:WebNumericEditor>
                                                                        </td>
                                                                        <td>
                                                                            <asp:Label ID="lblLogoffMinutes" Text="Minute(s)" runat="server"></asp:Label>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label ID="lblAutoAckTime" Text="Auto Ack Time" runat="server"></asp:Label>
                                                                        </td>
                                                                        <td>
                                                                            <ig:WebNumericEditor ID="txtAutoAckTime" runat="server" Width="198px">
                                                                                <Buttons SpinButtonsDisplay="OnRight" CustomButtonDisplay="None">
                                                                                </Buttons>
                                                                            </ig:WebNumericEditor>
                                                                        </td>
                                                                        <td>
                                                                            <asp:Label ID="lblAutoAckTimeSeconds" Text="Second(s)" runat="server"></asp:Label>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label ID="lblRole" Text="Role" runat="server"></asp:Label>
                                                                        </td>
                                                                        <td>
                                                                            <ig:WebDropDown ID="cboRole" runat="server" DisplayMode="DropDown" EnableDropDownAsChild="false"
                                                                                Width="200px">
                                                                            </ig:WebDropDown>
                                                                        </td>
                                                                        <td>
                                                                            &nbsp;
                                                                        </td>
                                                                    </tr>
                                                                    <tr style="display: none;">
                                                                        <td>
                                                                            <asp:Label ID="lblPartitionGroup" Text="Partition Group" runat="server"></asp:Label>
                                                                        </td>
                                                                        <td>
                                                                            <ig:WebDropDown ID="cboPartitionGroup" runat="server" DisplayMode="DropDownList"
                                                                                Width="200px" EnableDropDownAsChild="false" EnableMultipleSelection="True" 
                                                                                MultiSelectValueDelimiter=" | ">
                                                                                <ClientEvents />
                                                                            </ig:WebDropDown>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                            <td style="width: 300px;">
                                                                <table>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:CheckBox ID="chkEnabled" runat="server" Text="Enabled" />
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:CheckBox ID="chkAdministrator" runat="server" Text="Administrator" />
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:CheckBox ID="chkDisableAutoLogoff" runat="server" Text="Disable Auto Logoff" />
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <div id="divChangeInvalidatePass" runat="server" style="float: left; width: 230px;" class="ig_Office_2007ReportPreViewBg">
                                                                                <asp:LinkButton ID="btnChangeInvalidatePassword" Style="margin-top: 10px; text-decoration: none;
                                                                                    color: #033E82" runat="server">Change/Invalidate Password</asp:LinkButton>
                                                                            </div>
                                                                            <br />
                                                                            <br />
                                                                            <br />
                                                                            <asp:Label ID="lblChangeInvlidatePasswordMessage" Text="To change Password: Invalidate the password and enter new password at next login.\nOnly administrator users are allowed to Setup Roles and Partitions."
                                                                                runat="server"></asp:Label>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                            <td style="width: 200px;">
                                                                <igmisc:WebGroupBox ID="grbManualControlPriv" runat="server" Text="Manual Control Privilege"
                                                                    BackColor="Transparent">
                                                                    <Template>
                                                                        <asp:CheckBoxList ID="chkListManualControlPriv" runat="server">
                                                                        </asp:CheckBoxList>
                                                                    </Template>
                                                                </igmisc:WebGroupBox>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </Template>
                                            </igmisc:WebGroupBox>
                                        </Template>
                                    </ig:ContentTabItem>
                                    <ig:ContentTabItem Text="Personal" Style="min-height: 350px;">
                                        <Template>
                                            <igmisc:WebGroupBox ID="gboPersonalInformation" runat="server" Text="Personal Information"
                                                BackColor="Transparent">
                                                <Template>
                                                    <table style="width: 100%">
                                                        <tr valign="top">
                                                            <td>
                                                                <table>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label ID="lblFirstName" runat="server" Text="First Name"></asp:Label>
                                                                        </td>
                                                                        <td>
                                                                            <ig:WebTextEditor ID="txtFirstName" runat="server" Width="198px">
                                                                            </ig:WebTextEditor>
                                                                        </td>
                                                                        <td>
                                                                            <asp:Label ID="lblLastName" runat="server" Text="Last Name"></asp:Label>
                                                                        </td>
                                                                        <td>
                                                                            <ig:WebTextEditor ID="txtLastName" runat="server" Width="198px">
                                                                            </ig:WebTextEditor>
                                                                        </td>
                                                                        <td>
                                                                            <div style="float: left; width: 230px;" class="ig_Office_2007ReportPreViewBg">
                                                                                <asp:LinkButton ID="btnImportPersonalInformation" Style="margin-top: 10px; text-decoration: none;
                                                                                    color: #033E82" runat="server">Import Personal Information</asp:LinkButton>
                                                                            </div>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label ID="lblPhoneNo" runat="server" Text="Phone No:"></asp:Label>
                                                                        </td>
                                                                        <td>
                                                                            <ig:WebTextEditor ID="txtPhoneNo" runat="server" Width="198px">
                                                                            </ig:WebTextEditor>
                                                                        </td>
                                                                        <td>
                                                                            &nbsp;
                                                                        </td>
                                                                        <td>
                                                                            &nbsp;
                                                                        </td>
                                                                        <td>
                                                                            &nbsp;
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:CheckBox ID="chkEnableSMS" runat="server" Checked="false" Text="Enable SMS"
                                                                                AutoPostBack="true" OnCheckedChanged="chkEnableSMS_CheckedChanged" />
                                                                        </td>
                                                                        <td colspan="3">
                                                                            <igmisc:WebGroupBox ID="gboEnableSMS" runat="server" Text="" BackColor="Transparent">
                                                                                <Template>
                                                                                    <table>
                                                                                        <tr>
                                                                                            <td style="width: 100px;">
                                                                                                <asp:Label ID="lblSMSProvider" runat="server" Text="Provider"></asp:Label>
                                                                                            </td>
                                                                                            <td>
                                                                                                <ig:WebDropDown ID="cboSMSProvider" runat="server" DisplayMode="DropDown" EnableDropDownAsChild="false"
                                                                                                    Width="200px">
                                                                                                </ig:WebDropDown>
                                                                                            </td>
                                                                                        </tr>
                                                                                    </table>
                                                                                </Template>
                                                                            </igmisc:WebGroupBox>
                                                                        </td>
                                                                        <td>
                                                                            &nbsp;
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:CheckBox ID="chkEnablePaging" runat="server" Checked="false" Text="Enable Paging"
                                                                                AutoPostBack="true" OnCheckedChanged="chkEnablePaging_CheckedChanged" />
                                                                        </td>
                                                                        <td colspan="3">
                                                                            <igmisc:WebGroupBox ID="gboEnablePaging" runat="server" Text="" BackColor="Transparent">
                                                                                <Template>
                                                                                    <table>
                                                                                        <tr>
                                                                                            <td style="width: 100px;">
                                                                                                <asp:Label ID="lblPagerNo" runat="server" Text="Pager No"></asp:Label>
                                                                                            </td>
                                                                                            <td>
                                                                                                <ig:WebTextEditor ID="txtPagerNo" runat="server" Width="200px">
                                                                                                </ig:WebTextEditor>
                                                                                            </td>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <td style="width: 100px;">
                                                                                                <asp:Label ID="lblPagingProvider" runat="server" Text="Provider"></asp:Label>
                                                                                            </td>
                                                                                            <td>
                                                                                                <ig:WebDropDown ID="cboPagingProvider" runat="server" DisplayMode="DropDown" EnableDropDownAsChild="false"
                                                                                                    Width="200px">
                                                                                                </ig:WebDropDown>
                                                                                            </td>
                                                                                        </tr>
                                                                                    </table>
                                                                                </Template>
                                                                            </igmisc:WebGroupBox>
                                                                        </td>
                                                                        <td>
                                                                            &nbsp;
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:CheckBox ID="chkEnableEmail" runat="server" Checked="false" Text="Enable Email"
                                                                                AutoPostBack="true" OnCheckedChanged="chkEnableEmail_CheckedChanged" />
                                                                        </td>
                                                                        <td colspan="3">
                                                                            <igmisc:WebGroupBox ID="gboEnableEmail" runat="server" Text="" BackColor="Transparent">
                                                                                <Template>
                                                                                    <table>
                                                                                        <tr>
                                                                                            <td style="width: 100px;">
                                                                                                <asp:Label ID="lblEmail" runat="server" Text="Email"></asp:Label>
                                                                                            </td>
                                                                                            <td>
                                                                                                <ig:WebTextEditor ID="txtEmail" runat="server" Width="200px">
                                                                                                </ig:WebTextEditor>
                                                                                            </td>
                                                                                        </tr>
                                                                                    </table>
                                                                                </Template>
                                                                            </igmisc:WebGroupBox>
                                                                        </td>
                                                                        <td>
                                                                            &nbsp;
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </Template>
                                            </igmisc:WebGroupBox>
                                        </Template>
                                    </ig:ContentTabItem>
                                    <ig:ContentTabItem Text="Partitions" Style="min-height: 350px;">
                                        <Template>
                                            <table style="width: 100%;">
                                                <tr valign="top">
                                                    <td style="width: 400px;">
                                                        <igmisc:WebGroupBox ID="gboAvailablePartitions" runat="server" Text="Available Partitions"
                                                            Height="350" BackColor="Transparent">
                                                            <Template>
                                                                <ig:WebDataGrid ID="grdAvailablePartitions" runat="server" EnableDataViewState="true"
                                                                    EnableViewState="true" AutoGenerateColumns="false" OnInitializeRow="grdAvailablePartitions_OnInitializeRow">
                                                                    <EmptyRowsTemplate>
                                                                        <%=EmptyRowTemplateMsg %>
                                                                    </EmptyRowsTemplate>
                                                                    <Columns>
                                                                        <ig:BoundDataField DataFieldName="PartitionName" Key="PartitionName" Width="400">
                                                                        </ig:BoundDataField>
                                                                        <ig:BoundDataField DataFieldName="PartitionID" Key="PartitionId" Hidden="true">
                                                                        </ig:BoundDataField>
                                                                    </Columns>
                                                                    <Behaviors>
                                                                        <ig:Activation Enabled="true">
                                                                        </ig:Activation>
                                                                        <ig:Selection CellClickAction="Row" RowSelectType="Single">
                                                                        </ig:Selection>
                                                                    </Behaviors>
                                                                </ig:WebDataGrid>
                                                            </Template>
                                                        </igmisc:WebGroupBox>
                                                    </td>
                                                    <td style="vertical-align: middle; text-align: center; width: 50px;">
                                                        <div style="float: left;" class="ig_Office_2007ReportPreViewBg">
                                                            <asp:LinkButton ID="btnNext" Style="margin-top: 10px; text-decoration: none; color: #033E82"
                                                                runat="server" OnClick="btnNext_Click">></asp:LinkButton>
                                                        </div>
                                                        <br />
                                                        <br />
                                                        <br />
                                                        <div style="float: left;" class="ig_Office_2007ReportPreViewBg">
                                                            <asp:LinkButton ID="btnPrevious" Style="margin-top: 10px; text-decoration: none;
                                                                color: #033E82" runat="server" OnClick="btnPrevious_Click"><</asp:LinkButton>
                                                    </td>
                                                    <td style="width: 400px;">
                                                        <igmisc:WebGroupBox ID="gboAssignedPartitions" runat="server" Text="Assigned Partitions"
                                                            Height="350" BackColor="Transparent">
                                                            <Template>
                                                                <ig:WebDataGrid ID="grdAssignedPartitions" runat="server" EnableDataViewState="true"
                                                                    EnableViewState="true" AutoGenerateColumns="false" OnInitializeRow="grdAssignedPartitions_OnInitializeRow">
                                                                    <EmptyRowsTemplate>
                                                                        <%=EmptyRowTemplateMsg %>
                                                                    </EmptyRowsTemplate>
                                                                    <Columns>
                                                                        <ig:BoundDataField DataFieldName="PartitionName" Key="PartitionName" Width="400">
                                                                        </ig:BoundDataField>
                                                                        <ig:BoundDataField DataFieldName="PartitionID" Key="PartitionId" Hidden="true">
                                                                        </ig:BoundDataField>
                                                                    </Columns>
                                                                    <Behaviors>
                                                                        <ig:Activation Enabled="true">
                                                                        </ig:Activation>
                                                                        <ig:Selection CellClickAction="Row" RowSelectType="Single">
                                                                        </ig:Selection>
                                                                    </Behaviors>
                                                                </ig:WebDataGrid>
                                                            </Template>
                                                        </igmisc:WebGroupBox>
                                                    </td>
                                                </tr>
                                            </table>
                                        </Template>
                                    </ig:ContentTabItem>
                                    <ig:ContentTabItem Text="Event Viewing" Style="min-height: 350px;">
                                        <Template>
                                            <igmisc:WebGroupBox ID="gboEventViewing" runat="server" Text=""
                                                BackColor="Transparent">
                                                <Template>
                                                    <table style="vertical-align: middle; height: 300px">
                                                        <tr>
                                                            <td>
                                                                <asp:Label ID="lblNoRetainView" runat="server" Text="Number of Events to Retain in View"></asp:Label>
                                                            </td>
                                                            <td>
                                                                <ig:WebNumericEditor ID="txtNoRetainView" runat="server" Width="140px">
                                                                    <Buttons SpinButtonsDisplay="OnRight" CustomButtonDisplay="None">
                                                                    </Buttons>
                                                                </ig:WebNumericEditor>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </Template>
                                            </igmisc:WebGroupBox>
                                        </Template>
                                    </ig:ContentTabItem>
                                </Tabs>
                            </ig:WebTab>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
