<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GetEmailIdsPopup.aspx.cs" MaintainScrollPositionOnPostback="true"
    ValidateRequest="false" Inherits="Masters_GetEmailIds" %>

<%@ Register Assembly="DevExpress.Web.v14.2" Namespace="DevExpress.Web"
    TagPrefix="dxe" %>
<%@ Register Src="~/UserControls/TA_uc_OrganizationLevels.ascx" TagName="OrganizationLevel"
    TagPrefix="uc" %>
<%@ Register TagPrefix="dxGridview" Namespace="DevExpress.Web" Assembly="DevExpress.Web.v14.2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" runat="server" id="htmlGetEmail">
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=document.documentMode;" />
    <title>TimeCheck</title>

    <link id="stylebootstrap" rel="stylesheet" runat="server" type="text/css" />
    <link id="stylefontawesome" rel="stylesheet" runat="server" type="text/css" />
   <link id="styleAdminLTE" rel="stylesheet" runat="server" type="text/css" />
   <link id="stylecustom" rel="stylesheet" runat="server" type="text/css" />  
   <link id="stylefonts" rel="stylesheet" runat="server" type="text/css" />  
    <link id="styleselect2" rel="stylesheet" runat="server" type="text/css" />    
    <link id="styleGrid" rel="stylesheet" runat="server" type="text/css" />   
    <link id="styleAutocomp" rel="stylesheet" runat="server" type="text/css" />     

    <script language="javascript" src="../js/jquery-1.7.2.js" type="text/javascript"></script>

    <script language="javascript" type="text/javascript" src="../js/Popup.js"></script>

    <script language="javascript" type="text/javascript" src="../js/chkbox_delete.js"></script>

    <script language="javascript" src="../js/jquery.min.js" type="text/javascript"></script>

    <script language="javascript" src="../js/fancydropdown.js" type="text/javascript"></script>

    <script language="javascript" src="../js/jquery.min.js" type="text/javascript"></script>

    <script src="../plugins/jQuery/jQuery-2.1.4.min.js" type="text/javascript"></script>

    <script src="../plugins/select2/select2.full.min.js"></script>

    <script type="text/javascript">
        function GetEmailList(Type) {
            //alert(Type);
            var EmailList;
            if (Type == "CC") {
                if (window.opener != null) {
                    EmailList = window.opener.parent.aspnetForm['ctl00_BodyContentPH_txtApprovalCC'].value;
                    document.forms['aspnetForm'].elements['txtAddCC'].value = EmailList;
                }
            }
            else {
                if (window.opener != null) {
                    EmailList = window.opener.parent.aspnetForm['ctl00_BodyContentPH_txtApprovalTO'].value;
                    document.forms['aspnetForm'].elements['txtAddCC'].value = EmailList;
                }
            }
        }
    </script>

</head>
<body oncontextmenu="return false" style="overflow: auto">
    <form id="aspnetForm" runat="server">
        <asp:ScriptManager ID="upscript" runat="server">
        </asp:ScriptManager>
        <div class="content" style="overflow: auto">
            <div class="emp-filter">
                <div class="row">
                    <div class="col-md-12">
                        <div class="form-horizontal">
                            <asp:UpdatePanel ID="upOrgLevel" runat="server" UpdateMode="Conditional">
                                <ContentTemplate>
                                    <asp:PlaceHolder ID="PlaceHolderLateEntry" runat="server">
                                        <uc:OrganizationLevel ID="ucOrganizationLevel" runat="server" />
                                    </asp:PlaceHolder>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                            <div class="row form-group">
                                <div class="col-md-5">
                                    <div align="left">
                                        <asp:Label ID="lblError" Visible="true" runat="server" Style="color: #ff0000"></asp:Label>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="pull-right-button">
                                        <asp:LinkButton ID="butGo" CssClass="btn save-btn fa-angle-right" runat="server"
                                            CausesValidation="False" OnClick="butGo_Click" />
                                    </div>
                                </div>
                            </div>
                            <div class="row" style="margin-top: 15px; margin-bottom: 15px;">
                                <div class="col-md-12">
                                    <asp:HiddenField ID="hdnSelectRow" runat="server" />
                                    <asp:HiddenField ID="hdnGetAllid" runat="server" />
                                    <asp:HiddenField ID="hdnDeletedData" runat="server" />
                                    <div class="table-responsive">
                                        <dxGridview:ASPxGridView ID="grv_Employee" EnableCallBacks="false" runat="server"
                                            ClientInstanceName="grv_Employee" AutoGenerateColumns="false" KeyFieldName="Employee_Id"
                                            Width="100%" OnHtmlRowPrepared="grv_Employee_HtmlRowPrepared">
                                            <Columns>
                                                <dxGridview:GridViewDataColumn VisibleIndex="0" Width="30px">
                                                    <Settings AllowAutoFilter="False" />
                                                    <HeaderTemplate>
                                                        <input id="chkSelectAll" runat="server" type="checkbox" onclick="SelectAllOnThisPage(this)" />
                                                    </HeaderTemplate>
                                                    <DataItemTemplate>
                                                        <input id="chkSelect" runat="server" type="checkbox" onclick="SelectOnRow(this)"
                                                            accesskey='<%# Eval("Employee_Id") %>' />
                                                    </DataItemTemplate>
                                                    <HeaderStyle HorizontalAlign="Center" Wrap="True" VerticalAlign="Middle" />
                                                    <CellStyle HorizontalAlign="Center" VerticalAlign="Middle">
                                                    </CellStyle>
                                                </dxGridview:GridViewDataColumn>
                                                <dxGridview:GridViewDataTextColumn Visible="False" FieldName="Employee_Id" Caption="Employee Id">
                                                    <DataItemTemplate>
                                                        <asp:Label ID="lbl_EmpId" Text='<%# Eval("Employee_Id")%>' runat="server"></asp:Label>
                                                    </DataItemTemplate>
                                                    <HeaderStyle HorizontalAlign="Center" ForeColor="White" Wrap="True" BackColor="#5172AD" />
                                                </dxGridview:GridViewDataTextColumn>
                                                <dxGridview:GridViewDataTextColumn Width="80px" FieldName="Employee_Code_Id" Caption="Employee Id"
                                                    VisibleIndex="1">
                                                    <DataItemTemplate>
                                                        <asp:Label ID="lbl_EmpCodeId" Text='<%# Eval("Employee_Code_Id")%>' runat="server"></asp:Label>
                                                    </DataItemTemplate>
                                                    <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                                </dxGridview:GridViewDataTextColumn>
                                                <dxGridview:GridViewDataTextColumn Width="250px" FieldName="Employee Name" Caption="Employee Name"
                                                    VisibleIndex="2">
                                                    <DataItemTemplate>
                                                        <asp:Label ID="lbl_EmpName" Text='<%# Eval("Employee Name")%>' runat="server"></asp:Label>
                                                    </DataItemTemplate>
                                                    <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                                </dxGridview:GridViewDataTextColumn>
                                                <dxGridview:GridViewDataTextColumn Width="100px" FieldName="TitleName" Caption="Designation"
                                                    VisibleIndex="3">
                                                    <DataItemTemplate>
                                                        <asp:Label ID="lbl_Designation" Text='<%# Eval("TitleName")%>' runat="server"></asp:Label>
                                                    </DataItemTemplate>
                                                    <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                                </dxGridview:GridViewDataTextColumn>
                                                <dxGridview:GridViewDataTextColumn FieldName="EmailId" Caption="Email Id" VisibleIndex="4"
                                                    Width="250px">
                                                    <DataItemTemplate>
                                                        <asp:Label ID="lbl_EmailId" Text='<%# Eval("EmailId")%>' runat="server"></asp:Label>
                                                    </DataItemTemplate>
                                                    <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                                </dxGridview:GridViewDataTextColumn>
                                            </Columns>
                                            <SettingsPager PageSize="10">
                                            </SettingsPager>
                                            <SettingsText EmptyDataRow="No Records Found" />
                                            <Settings ShowFilterRow="true" />
                                            <SettingsBehavior SortMode="Value" AllowSort="true" AllowDragDrop="true" />
                                            <Styles AlternatingRow-CssClass="table-bg">
                                            </Styles>
                                        </dxGridview:ASPxGridView>
                                    </div>
                                </div>
                            </div>
                            <div id="trAddCC">
                                <div class="row form-group" style="margin-top: 20px">
                                    <div class="col-md-12">
                                        <div class="pull-right-button">
                                            <asp:LinkButton ID="btnAddCC" runat="server" CssClass="btn add-btn fa-plus" Text="&nbsp;&nbsp;Add CC"
                                                OnClick="btnAddCC_Click" />
                                            <asp:LinkButton ID="btnClear" runat="server" CssClass="btn clr-btn fa-refresh" Text="&nbsp;&nbsp; Clear"
                                                OnClick="btnClear_Click" />
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <div class="col-md-12">
                                        <asp:TextBox ID="txtAddCC" runat="server" TextMode="MultiLine" CssClass="form-control"
                                            Style="resize: none;" Width="100%"></asp:TextBox>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-12">
                                <div class="pull-right-button">
                                    <asp:LinkButton ID="btn_Ok" CssClass="btn save-btn fa-check-circle-o" runat="server"
                                        CausesValidation="False" OnClick="btn_Ok_Click" />
                                    <asp:LinkButton ID="btn_Back" runat="server" CssClass="btn save-btn fa-angle-left"
                                        OnClientClick="return CloseWindow();" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div>

            <script type="text/javascript" language="javascript">
                function CloseWindow() {
                    parent.$('#myModal').modal('hide');
                }

                function contains(arr, findValue) {
                    var i = arr.length;
                    while (i--) {
                        if (arr[i] === findValue)
                            return true;
                    }
                    return false;
                }
                function remove(arrayName, arrayElement) {
                    for (var i = 0; i < arrayName.length; i++) {
                        if (arrayName[i] == arrayElement)
                            arrayName.splice(i, 1);
                    }
                }
                function SelectAllOnThisPage(chkSelectAll) {
                    var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
                    var hdnSelectAll = document.getElementById('<%= hdnGetAllid.ClientID %>');
                    if (chkSelectAll.checked == true) {
                        for (var i = 0; i < grv_Employee.pageRowCount; i++) {
                            if (document.getElementById('grv_Employee_cell' + (i + grv_Employee.visibleStartIndex) + '_0_chkSelect').disabled == false) {
                                document.getElementById('grv_Employee_cell' + (i + grv_Employee.visibleStartIndex) + '_0_chkSelect').checked = true;
                                var hdnUserId = document.getElementById('grv_Employee_cell' + (i + grv_Employee.visibleStartIndex) + '_0_chkSelect').accessKey;
                                var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
                                var removeId = hdnSelectRow.value.split(",");
                                if (hdnUserId != "" && !contains(removeId, hdnUserId)) {
                                    if (hdnSelectRow.value != "")
                                        hdnSelectRow.value += ",";
                                    hdnSelectRow.value += hdnUserId;
                                }
                            }
                        }
                    }
                    else {
                        for (var i = 0; i < grv_Employee.pageRowCount; i++) {
                            document.getElementById('grv_Employee_cell' + (i + grv_Employee.visibleStartIndex) + '_0_chkSelect').checked = false;
                        }
                        hdnSelectRow.value = '';
                    }
                }
                function SelectOnRow(chkOnSelect) {
                    var hdnUserId = chkOnSelect.accessKey;
                    var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
        var removeId = hdnSelectRow.value.split(",");
        if (chkOnSelect.checked) {
            if (hdnUserId != "" && !contains(removeId, hdnUserId)) {
                if (hdnSelectRow.value != "")
                    hdnSelectRow.value += ",";
                hdnSelectRow.value += hdnUserId;
            }
            var varTotalCheckedCount = 0;
            var varTotalEnabled = 0;
            for (var i = 0; i < grv_Employee.pageRowCount; i++) {
                if (document.getElementById('grv_Employee_cell' + (i + grv_Employee.visibleStartIndex) + '_0_chkSelect').disabled == false) {
                    varTotalEnabled = varTotalEnabled + 1;
                }
                if (document.getElementById('grv_Employee_cell' + (i + grv_Employee.visibleStartIndex) + '_0_chkSelect').checked)
                    varTotalCheckedCount = varTotalCheckedCount + 1;
            }
            if (varTotalCheckedCount == varTotalEnabled)
                document.getElementById('grv_Employee_header0_chkSelectAll').checked = true;
            else
                document.getElementById('grv_Employee_header0_chkSelectAll').checked = false;
        }
        else {
            if (contains(removeId, hdnUserId)) {
                remove(removeId, hdnUserId);
            }
            hdnSelectRow.value = removeId;
            document.getElementById('grv_Employee_header0_chkSelectAll').checked = false;
        }
    }
    var Norecordsavailable = "No records available ";
    var AreyousuretoRestore = "Are you sure to Restore? ";
    var Selecteddataisnotindeletedstatus = "Selected data is not in deleted status ";
    var Selectdatatorestore = "Select data to restore ";
    var Nodeletedrecordsavailable = "No deleted records available ";
    function RestoreAlert(norecordsavailable, areyousuretoRestore, selecteddataisnotindeletedstatus, selectdatatorestore, nodeletedrecordsavailable) {
        Norecordsavailable = norecordsavailable;
        AreyousuretoRestore = areyousuretoRestore;
        Selecteddataisnotindeletedstatus = selecteddataisnotindeletedstatus;
        Selectdatatorestore = selectdatatorestore;
        Nodeletedrecordsavailable = nodeletedrecordsavailable;
    }
    function RestoreData() {
        var rowscount = grv_Employee.pageRowCount;
        if (rowscount == 0) {
            alert(Norecordsavailable);
            return false;
        }
        var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
        var DeleteDataRow = document.getElementById('<%= hdnDeletedData.ClientID %>');
        if (DeleteDataRow.value != '') {
            if (hdnSelectRow.value != '') {
                var selectedRow = new Array();
                selectedRow = hdnSelectRow.value.split(",");
                var deletedRow = new Array();
                deletedRow = DeleteDataRow.value.split(",");
                var Status = false;
                for (var i = 0; i < selectedRow.length; i++) {
                    //alert(selectedRow[i]);
                    if (Array.contains(deletedRow, selectedRow[i])) {
                        Status = true;
                    }
                }
                if (Status == true) {
                    return confirm(AreyousuretoRestore);
                }
                else {
                    alert(Selecteddataisnotindeletedstatus);
                    return false;
                }
            }
            else {
                alert(Selectdatatorestore);
                return false;
            }
        }
        else {
            if (hdnSelectRow.value == '') {
                alert(Nodeletedrecordsavailable);
                return false;
            }
            else {
                alert(Selecteddataisnotindeletedstatus);
                return false;
            }
        }
    }
            </script>

            <script>
                $(".select2").select2();
            </script>

        </div>
    </form>
</body>
</html>
