<%@ page language="C#" masterpagefile="~/MasterFile/TimeCheck.master" autoeventwireup="true" inherits="Master_TA_UI_Master_TitleFirstList, App_Web_gow0hzbs" %>

<%@ Register TagPrefix="dxGridview" Namespace="DevExpress.Web" Assembly="DevExpress.Web.v14.2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPH" runat="Server">
    <div class="content-header">
        <h1 style="background-image: url('../dist/img/Designation.png'); background-repeat: no-repeat; padding-left: 35px">
            <asp:Label ID="lbl_HeaderDesignation" runat="server"></asp:Label>
        </h1>
        <asp:SiteMapPath ID="site" runat="server" CssClass="breadcrumb">
            <NodeStyle CssClass="active" />
        </asp:SiteMapPath>
    </div>
    <div class="content">
        <div style="display: none">
            <div class="emp-filter">
                <div class="row form-group">
                    <div class="col-md-2">
                        <asp:Label ID="lbl_Designation" runat="server"></asp:Label>
                    </div>
                    <div class="col-md-10">
                        <asp:TextBox onpaste="return true" ID="txt_Designation" Text="" runat="server" CssClass="form-control"
                            MaxLength="50" onkeypress="return chkMaxLen(event,this,50,MaxLength);"></asp:TextBox>
                    </div>
                </div>
                <div class="row form-group">
                    <div class="col-md-12">
                        <div class="pull-right">
                            <asp:LinkButton ID="btn_Search" runat="server" OnClick="btn_Search_Click" CssClass="btn src-btn fa fa-search">
                            </asp:LinkButton>
                            <asp:LinkButton ID="btn_Clear" runat="server" OnClick="btn_Clear_Click" CssClass="btn clr-btn fa fa-refresh">
                            </asp:LinkButton>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-horizontal">
            <div class="border-table new-space" style="margin-top: 0px">
                <div class="row form-group">
                    <div class="col-md-12">
                        <asp:HiddenField ID="hdnSelectRow" runat="server" />
                        <asp:HiddenField ID="hdnGetAllid" runat="server" />
                        <dxGridview:ASPxGridView ID="GridView1" EnableCallBacks="false" runat="server" ClientInstanceName="GridView1"
                            AutoGenerateColumns="false" KeyFieldName="TitleId" OnHtmlRowCreated="GridView1_HtmlRowCreated"
                            DataSourceID="ObjectDataSource1" Width="100%" Settings-HorizontalScrollBarMode="Auto" ViewStateMode="Enabled">
                            <Columns>
                                <dxGridview:GridViewDataColumn VisibleIndex="0" Width="30px" HeaderStyle-VerticalAlign="Middle"
                                    HeaderStyle-HorizontalAlign="Center" CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center">
                                    <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)"
                                            disabled='<%#DataBinder.Eval(Container.DataItem,"flag").ToString()=="1" %>' accesskey='<%# Eval("TitleId") %>' />
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="TitleId" VisibleIndex="4" Visible="false">
                                    <DataItemTemplate>
                                        <asp:Label ID="lbl_DesgID" runat="server" Text=' <%# Eval("TitleId")%>'></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn Caption="Designation Name" FieldName="TitleName"
                                    VisibleIndex="1" Width="300px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblTitleName" runat="server" Text='<%# Eval("TitleName") %>' CssClass="dxlabel"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="TitleDescription" VisibleIndex="2"
                                    Width="273px">
                                    <DataItemTemplate>
                                        <asp:Label ID="Label2" runat="server" Text='<%# Eval("TitleDescription") %>' CssClass="dxlabel"></asp:Label>
                                        <%-- width: 284px;--%>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="LevelName" VisibleIndex="5" Width="250px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblCompanyName" runat="server" Text='<%# Bind("LevelName") %>' CssClass="dxlabel"></asp:Label>
                                        <%--width: 156px;--%>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center" VisibleIndex="6"
                                    CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center" Width="35px">
                                    <Settings AllowAutoFilter="false" />
                                    <DataItemTemplate>
                                        <a data-toggle="modal" title='<%# Session["View"] %>' data-placement="top" data-target="#myModal" onclick="return navi('TA_UI_Master_TitleFirstView.aspx?TitleId=<%# Eval("TitleId") %>')"
                                            href="#"><span class="btn btn-defalut view-icons"></span></a>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                                <dxGridview:GridViewDataColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center" VisibleIndex="7"
                                    CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center" Width="35px">
                                    <Settings AllowAutoFilter="false" />
                                    <DataItemTemplate>
                                        <asp:LinkButton ID="btnEdit" runat="server" ToolTip='<%# Session["Edit"] %>' data-toggle="tooltip"
                                            OnClick="EditLinkButton_Click" CommandName='<%# Eval("TitleId") %>' data-placement="top"
                                            CssClass="btn btn-defalut edit-icons" Style="color: #3C8DBC"></asp:LinkButton>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                                <dxGridview:GridViewDataColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center" VisibleIndex="8"
                                    CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center" Width="35px">
                                    <Settings AllowAutoFilter="false" />
                                    <DataItemTemplate>
                                        <asp:LinkButton ID="btnDelete" runat="server" ToolTip='<%# Session["Delete"] %>' data-toggle="tooltip"
                                            OnClick="btn_delete_Click_1" CommandName='<%# Eval("TitleId") %>' data-placement="top"
                                            CssClass="btn btn-defalut del-icons" Style="color: Red" OnClientClick="return Delete_Conf();"></asp:LinkButton>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                                <dxGridview:GridViewDataTextColumn Visible="false" FieldName="Grade_Name" VisibleIndex="9" Width="86px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblGrade_Name" runat="server" Text='<%# Bind("Grade_Name") %>' CssClass="dxlabel"></asp:Label>
                                        <%--width: 156px;--%>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn Visible="false" FieldName="Grade_Level" VisibleIndex="10" Width="86px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblGrade_Level" runat="server" Text='<%# Bind("Grade_Level") %>' CssClass="dxlabel"></asp:Label>
                                        <%--width: 156px;--%>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                            </Columns>
                            <ClientSideEvents CustomizationWindowCloseUp="function(s, e) { UpdateCustomizationWindowValue(); }" />
                            <SettingsPager PageSize="20">
                                <PageSizeItemSettings Visible="true" ShowAllItem="true" Items="10,20,50,100,200" />
                            </SettingsPager>
                            <Settings ShowFilterRow="true" ShowFilterRowMenu="true" HorizontalScrollBarMode="Auto" ShowGroupPanel="true" VerticalScrollBarMode="Hidden" VerticalScrollableHeight="400" />
                            <SettingsText EmptyDataRow="No Records Found" />
                            <SettingsCustomizationWindow Enabled="True" />
                            <SettingsBehavior AutoExpandAllGroups="True" ColumnResizeMode="Control" />
                            <SettingsBehavior AllowDragDrop="true" />
                        </dxGridview:ASPxGridView>
                        <dxGridview:ASPxGridViewExporter ID="ASPxGridViewExporter1" runat="server" GridViewID="GridView1">
                            <PageFooter Right="[Page # of Pages #]">
                            </PageFooter>
                        </dxGridview:ASPxGridViewExporter>
                        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OnSelecting="ObjectDataSource1_Selecting"
                            SelectMethod="SelectTitleFirstDetails" TypeName="cls_Master_Title">
                            <SelectParameters>
                                <asp:SessionParameter Name="UserGroupName" SessionField="UserGroupName" Type="String" />
                                <asp:Parameter Name="Designation" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                        <div id="myModal" class="modal modal-default fade" role="dialog">
                            <div class="modal-dialog" style="min-width: 85%;">
                                <!-- Modal content-->
                                <div class="modal-content" style="margin-top: 100px">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" style="border-radius: 50px;">
                                            &times;</button>
                                        <h4 class="modal-title">
                                            <asp:Label ID="lblDataView" runat="server" Text="Data View"></asp:Label>
                                        </h4>
                                    </div>
                                    <div class="modal-body">
                                        <iframe id="iframePopup" runat="server" scrolling="auto" width="100%" height="230px"
                                            style="border-style: none"></iframe>
                                    </div>
                                    <div class="modal-footer" style="display: none">
                                        <button type="button" class="btn btn-primary pull-right" data-dismiss="modal">
                                            Close</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="pull-right-button">
                            <asp:LinkButton ID="btn_add" CssClass="btn add-btn fa-plus" runat="server" OnClick="btn_add_Click" />
                            <asp:LinkButton ID="btn_Delete" CssClass="btn btn-block btn-success fa fa-trash-o"
                                runat="server" CausesValidation="False" OnClick="btn_Delete_Click" OnClientClick="return confirmdelete(this.form);"
                                Style="display: none" />
                            <asp:LinkButton ID="btn_Restore" runat="server" CausesValidation="true" CssClass="btn btn-block btn-info fa fa-undo"
                                OnClientClick="return RestoreData();" OnClick="btn_Restore_Click" Style="display: none" />
                            <asp:HiddenField ID="hdnDeletedData" runat="server" />
                            <asp:LinkButton ID="btn_PermanentDelete" runat="server" CausesValidation="true" CssClass="btn save-btn fa-trash-o"
                                OnClientClick="return Permanentconfirmdelete(this.form);" OnClick="btn_PermanentDelete_Click" />
                            <asp:LinkButton ID="btnCustWindow" runat="server" CssClass="btn save-btn fa-folder-open-o"
                                        Text="&nbsp;&nbsp;Field Lists" OnClientClick="ShowHideCustomizationWindow();"></asp:LinkButton>
                            <asp:LinkButton ID="btnExport" CommandName="excel" runat="server" CssClass="btn del-btn fa-file-excel-o" OnClick="btnExport_Click">
                            </asp:LinkButton>
                            <asp:LinkButton ID="btnExportPdf" CommandName="pdf" runat="server" CssClass="btn del-btn fa-file-pdf-o" OnClick="btnExport_Click">
                            </asp:LinkButton>
                            
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <script type="text/javascript" language="javascript">
            function OnInit(s, e) {

                AdjustSize();
            }
            function OnEndCallback(s, e) {
                AdjustSize();
            }

            function AdjustSize() {

                var height = Math.max(0, document.documentElement.clientHeight);
                var width = Math.max(0, document.documentElement.clientWidth);
                grid.SetHeight(height);
            }
            function navi(loc) {
                document.getElementById('ctl00_BodyContentPH_iframePopup').src = loc;
                return false;
            }
            function Delete_Conf() {
                //Alert_AreyousuretoDelete
                return confirm('Are you sure to Delete ?');
            }
            var MaxLength = "Maximum length is ";
            function MaxLengthh(maxLength) {
                MaxLength = maxLength;
            }
            function SelectAllOnThisPage(chkSelectAll) {
                var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
                var hdnSelectAll = document.getElementById('<%= hdnGetAllid.ClientID %>');
                if (chkSelectAll.checked == true) {
                    for (var i = 0; i < GridView1.pageRowCount; i++) {
                        if (document.getElementById('ctl00_BodyContentPH_GridView1_cell' + (i + GridView1.visibleStartIndex) + '_0_chkSelect').disabled == false) {
                            document.getElementById('ctl00_BodyContentPH_GridView1_cell' + (i + GridView1.visibleStartIndex) + '_0_chkSelect').checked = true;
                            var hdnUserId = document.getElementById('ctl00_BodyContentPH_GridView1_cell' + (i + GridView1.visibleStartIndex) + '_0_chkSelect').accessKey;
                            var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
                            var removeId = hdnSelectRow.value.split(",");
                            if (hdnUserId != "" && !Array.contains(removeId, hdnUserId)) {
                                if (hdnSelectRow.value != "")
                                    hdnSelectRow.value += ",";
                                hdnSelectRow.value += hdnUserId;
                            }
                        }
                    }
                }
                else {
                    for (var i = 0; i < GridView1.pageRowCount; i++) {
                        document.getElementById('ctl00_BodyContentPH_GridView1_cell' + (i + GridView1.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 != "" && !Array.contains(removeId, hdnUserId)) {
                        if (hdnSelectRow.value != "")
                            hdnSelectRow.value += ",";
                        hdnSelectRow.value += hdnUserId;
                    }
                    var varTotalCheckedCount = 0; var varTotalEnabled = 0;
                    for (var i = 0; i < GridView1.pageRowCount; i++) {
                        if (document.getElementById('ctl00_BodyContentPH_GridView1_cell' + (i + GridView1.visibleStartIndex) + '_0_chkSelect').disabled == false) {
                            varTotalEnabled = varTotalEnabled + 1;
                        }
                        if (document.getElementById('ctl00_BodyContentPH_GridView1_cell' + (i + GridView1.visibleStartIndex) + '_0_chkSelect').checked)
                            varTotalCheckedCount = varTotalCheckedCount + 1;
                    }
                    if (varTotalCheckedCount == varTotalEnabled)
                        document.getElementById('ctl00_BodyContentPH_GridView1_header0_chkSelectAll').checked = true;
                    else
                        document.getElementById('ctl00_BodyContentPH_GridView1_header0_chkSelectAll').checked = false;
                }
                else {
                    if (Array.contains(removeId, hdnUserId)) {
                        Array.remove(removeId, hdnUserId);
                    }
                    hdnSelectRow.value = removeId;
                    document.getElementById('ctl00_BodyContentPH_GridView1_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 = GridView1.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;
                    }
                }
            }
            function UpdateCustomizationWindowValue() {
                var element = document.getElementById("btnCustWindow");
                if (element == null) return;
                element.value = (GridView1.IsCustomizationWindowVisible() ? "Hide" : "Show") + " Customization Window";
            }
            function ShowHideCustomizationWindow() {
                if (GridView1.IsCustomizationWindowVisible())
                    GridView1.HideCustomizationWindow();
                else GridView1.ShowCustomizationWindow();
                UpdateCustomizationWindowValue();
            }
        </script>

    </div>
</asp:Content>
