<%@ page language="C#" masterpagefile="~/Pages/Common/MasterPages/MainMasterPage_new.master" autoeventwireup="true" inherits="Pages_InstituteManagement_DocumentMaster, App_Web_pnmrvy0i" title="DocumentMaster Master" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<%@ Register Src="~/UserControls/GridViewPager/GridViewPager.ascx" TagName="GridViewPager" TagPrefix="uc1" %>
<%@ Register Src="~/UserControls/Common/ScreenGroup/ScreenGroup.ascx" TagName="ScreenGroupControl" TagPrefix="ScreenGroup" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <asp:UpdatePanel runat="server" UpdateMode="Always">
        <ContentTemplate>
            <div id="divContentPage" class="divcontentpagemargin">

                <div class="dashBoardLeftCont" valign="top">
                    <div class="himssuHeader3WireBox">
                        <table width="0px" cellpadding="0" cellspacing="0">
                            <tr>
                                <td>
                                    <div class="himsBoxContent">
                                        <div class="leftUlMenu">
                                            <ScreenGroup:ScreenGroupControl EnableViewState="true" ID="ScreenGroupControl" ScreenGroupId="125"
                                                Visible="true" runat="server" />
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="row whiteboxpaddingleft">
                    <div class="himssuHeader5WireBox card card-box" id="SearchDiv" runat="server">
                        <div class="himsBoxHeader card-head">
                            <asp:Panel ID="Panel1" runat="server">
                                <div class="leftdiv">
                                </div>
                                <div class="himsBoxTitle">
                                    <div class="headerText">
                                        <header>
                                            <i class="fas fa-search"></i>
                                            <asp:Label ID="Label3" runat="server" Text="Search"></asp:Label>
                                        </header>
                                    </div>
                                    <div class="fRight mt-27">
                                        <asp:Button ID="AddNewButtonID" runat="server" OnClick="AddNewButton_Click" SkinID="0" CssClass="btn btn-add fas" Text="&#xf067; Add" />
                                    </div>
                                </div>
                            </asp:Panel>
                        </div>
                        <div class="himsBoxContent card-body">
                            <asp:Panel ID="DetailPanel" runat="Server">
                                <div class="contentHolder">
                                    <asp:Panel ID="SearchCriteriaPanel" runat="Server">
                                        <div class="outerBox pTop5 col-md-3">
                                            <div class="controlLabelWidth">
                                                <asp:Label ID="SearchSubmitDocumentFunctionalityLabel" Text="Document Functionality Type" runat="server"></asp:Label>
                                            </div>
                                            <div class="fLeft pRight5">
                                                <asp:DropDownList ID="SearchDocumentFunctionalityDropDownList" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()"
                                                    SkinID="CustomWidthDropDownList" CssClass="form-control" runat="Server">
                                                </asp:DropDownList>
                                            </div>
                                        </div>
                                        <div class="outerBox pTop5 col-md-3">
                                            <div class="controlLabelWidth">
                                                <asp:Label ID="SearchCodeLabel" Text="Document Name" runat="server"></asp:Label>
                                            </div>
                                            <div class="fLeft pRight5">
                                                <asp:TextBox ID="SearchDocumentNameTextBox" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()"
                                                    SkinID="CustomWidthTextBox" runat="Server" MaxLength="100"></asp:TextBox>
                                            </div>
                                        </div>

                                        <div class="cBoth">
                                        </div>
                                        <div class="alignCenter pTop5">
                                            <asp:Button ID="SearchButton" runat="Server" OnClick="SearchButton_Click" SkinID="0" CssClass="btn-search btn fas" Text="&#xf002; Search" />
                                            <asp:Button ID="ResetButton" runat="server" Text="&#xf0e2; Reset" CssClass="btn-reset btn fas" SkinID="0" OnClick="ResetButton_Click" />
                                        </div>
                                        <div class="cBoth">
                                        </div>
                                        <div class="spacer"></div>
                                    </asp:Panel>
                                    <div id="Div1" class="himssuHeader7WireBox col-md-12" runat="server">
                                        <div id="ReasonMasterDetailDiv" visible="false" runat="server">
                                            <div class="spacer">
                                                <asp:Image ID="Image3" runat="server" ImageUrl="~/Images/spacer.gif" />
                                            </div>
                                            <div class="himsBoxHeader" id="PatientRelationDiv" visible="false" runat="server">
                                                <div class="leftdiv">
                                                </div>
                                                <div class="himsBoxTitle" style="width: 99%">
                                                    <div align="right" class="fRight" style="margin-top: 0px;">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="himsBoxContent">
                                                <asp:UpdatePanel ID="MenuPlanDetailUpdatePanel" runat="server" UpdateMode="Always">
                                                    <ContentTemplate>
                                                        <div id="Div5" runat="server" visible="false">
                                                            <div id="Div4" runat="server" class="table-responsive">
                                                                <asp:GridView ID="DocumentMasterGridView" runat="server" Width="100%" AutoGenerateColumns="False"
                                                                    CssClass="table table-striped table-bordered table-hover" OnRowDataBound="DocumentMasterGridView_RowDataBound" OnPageIndexChanging="DocumentMasterGridView_PageIndexChanging"
                                                                    AllowPaging="false" PageSize="5" SkinID="" ShowHeader="True" PagerSettings-Visible="false"
                                                                    DataKeyNames="Id">
                                                                    <Columns>
                                                                        <asp:TemplateField ItemStyle-Width="5%" ItemStyle-HorizontalAlign="Center" ItemStyle-Wrap="true">
                                                                            <ItemTemplate>
                                                                                <asp:LinkButton ID="EditLinkButton" runat="server" CommandName="Select" OnClick="LinkButton_Click"
                                                                                    Text="Select" CausesValidation="false"></asp:LinkButton>
                                                                            </ItemTemplate>
                                                                        </asp:TemplateField>
                                                                        <asp:TemplateField HeaderText="DocumentFunctionality Type" ItemStyle-Width="190px" HeaderStyle-HorizontalAlign="Left"
                                                                            ItemStyle-Wrap="true">
                                                                            <ItemTemplate>
                                                                                <asp:Label ID="DocumentFunctionalityTypeLabel" CssClass="boxEllips"
                                                                                    runat="server" Text='<%# Bind("DocumentFunctionalityType") %>' Width="185px"></asp:Label>
                                                                            </ItemTemplate>
                                                                        </asp:TemplateField>
                                                                        <asp:TemplateField HeaderText="DocumentName" ItemStyle-Width="190px" HeaderStyle-HorizontalAlign="Left"
                                                                            ItemStyle-Wrap="true">
                                                                            <ItemTemplate>
                                                                                <asp:Label ID="DocumentNameLabel" CssClass="boxEllips"
                                                                                    runat="server" Text='<%# Bind("DocumentName") %>' Width="185px"></asp:Label>
                                                                            </ItemTemplate>
                                                                        </asp:TemplateField>
                                                                    </Columns>
                                                                </asp:GridView>
                                                            </div>
                                                        </div>
                                                    </ContentTemplate>
                                                </asp:UpdatePanel>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </asp:Panel>
                        </div>
                    </div>
                    <div class="himssuHeader1WireBox card card-box" id="DetailDiv" runat="server" visible="false">
                        <div class="himsBoxHeader card-head">
                            <div class="leftdiv">
                            </div>
                            <div class="himsBoxTitle">
                                <div class="headerText">
                                    <header>
                                        <i class="fas fa-cog"></i>
                                        <asp:Label ID="ReasonMasterDetailLabel" runat="server" Text="Maintenance"></asp:Label>
                                    </header>
                                </div>
                            </div>
                            <div class="fRight mt-27 pagination display-flex">
                                <%-- <table>
                                                <tr>
                                                    <td class="formLabel">
                                                        <div id="NumberOfRecordDiv" class="display-flex" runat="server" visible="true">
                                                            <asp:ImageButton AlternateText="First page" ToolTip="First page" ID="FirstRecordImageButton"
                                                                runat="server" ImageUrl="~/Images/arrowLlast.gif" CommandName="Page" CommandArgument="First"
                                                                OnClick="FirstRecordImageButton_Click" />
                                                            <asp:ImageButton AlternateText="Previous page" ToolTip="Previous page" ID="PreviousImageButton"
                                                                runat="server" ImageUrl="~/Images/arrowLeft.gif" CommandName="Page" CommandArgument="Prev"
                                                                OnClick="PreviousImageButton_Click" />
                                                            <asp:Label ID="LabelPage" runat="server" Text="Record " AssociatedControlID="ReCordNumber" />
                                                            <asp:Label ID="ReCordNumber" Font-Bold="true" SkinID="Dummy" runat="server"></asp:Label>
                                                            <asp:Label ID="ofLabel" Text="of" runat="server" />
                                                            <asp:Label ID="TotalRecord" runat="server" />
                                                            <asp:ImageButton AlternateText="Next page" ToolTip="Next page" ID="NextImageButtom"
                                                                runat="server" ImageUrl="~/Images/arrowRight.gif" CommandName="Page" CommandArgument="Next"
                                                                OnClick="NextImageButton_Click" />
                                                            <asp:ImageButton AlternateText="Last page" ToolTip="Last page" ID="LastRecordImageButton"
                                                                runat="server" ImageUrl="~/Images/arrowRLast.gif" CommandName="Page" CommandArgument="Last"
                                                                OnClick="LastRecordImageButton_Click" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <asp:Button ID="BackButton" runat="Server" OnClick="BackButton_Click" SkinID="0" CssClass="BackButton" Text="Back" />
                                                    </td>
                                                </tr>
                                            </table>--%>
                                <table>
                                    <tr>
                                        <td class="formLabel">
                                            <div id="NumberOfRecordDiv" class="display-flex" runat="server" visible="true">
                                                <asp:LinkButton AlternateText="First page" ToolTip="First page" ID="FirstRecordImageButton"
                                                    runat="server" CommandName="Page" CommandArgument="First"
                                                    OnClick="FirstRecordImageButton_Click" CssClass="btn btn-default gridviewpagerbuttonpadding">
                                                    <i class="fa fa-fast-backward"></i>
                                                </asp:LinkButton>
                                                <asp:LinkButton AlternateText="Previous page" ToolTip="Previous page" ID="PreviousImageButton"
                                                    runat="server" CommandName="Page" CommandArgument="Prev"
                                                    OnClick="PreviousImageButton_Click" CssClass="btn btn-default gridviewpagerbuttonpadding">
                                                    <i class="fa fa-play fa-rotate-180"></i>

                                                </asp:LinkButton>
                                                &nbsp;
                                                <asp:Label ID="LabelPage" runat="server" Text="Record " AssociatedControlID="ReCordNumber" />
                                                <asp:Label ID="ReCordNumber" Font-Bold="true" SkinID="Dummy" runat="server"></asp:Label>
                                                <asp:Label ID="ofLabel" Text="of" runat="server" />
                                                <asp:Label ID="TotalRecord" runat="server" />
                                                &nbsp;
                                                <asp:LinkButton AlternateText="Next page" ToolTip="Next page" ID="NextImageButtom"
                                                    runat="server" CssClass="btn btn-default gridviewpagerbuttonpadding" CommandName="Page" CommandArgument="Next"
                                                    OnClick="NextImageButton_Click">
                                                     <i class="fa fa-play"></i>
                                                </asp:LinkButton>

                                                <asp:LinkButton AlternateText="Last page" ToolTip="Last page" ID="LastRecordImageButton"
                                                    runat="server" CssClass="btn btn-default gridviewpagerbuttonpadding" CommandName="Page" CommandArgument="Last"
                                                    OnClick="LastRecordImageButton_Click">
                                                      <i class="fa fa-fast-forward"></i>
                                                </asp:LinkButton>
                                                &nbsp;  &nbsp; &nbsp;
                                            </div>
                                        </td>
                                        <td>
                                            <asp:Button ID="BackButton" runat="Server" OnClick="BackButton_Click" SkinID="0" CssClass="btn btn-back fas" Text="&#xf30a;  back" />
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                        <div class="himsBoxContent card-body">
                            <div class="contentHolder">

                                <div class="outerBox pTop5 col-md-3">
                                    <div class="controlLabelWidth">
                                        <asp:Label ID="Label1" Text="Document Functionality" runat="server" CssClass="mandatory"></asp:Label>
                                    </div>
                                    <div class="fLeft pRight5">
                                        <asp:DropDownList ID="DocumentFunctinalityDropDownList" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()"
                                            SkinID="CustomWidthDropDownList" CssClass="form-control" runat="Server" AutoPostBack="true" OnSelectedIndexChanged="DocumentFunctinalityDropDownList_SelectedIndexChanged">
                                        </asp:DropDownList>
                                    </div>
                                </div>

                                <div class="outerBox pTop5 col-md-3">
                                    <div class="controlLabelWidth">
                                        <asp:Label ID="Label2" Text="Document Name" runat="server" CssClass="mandatory"></asp:Label>
                                    </div>
                                    <div class="fLeft pRight5">
                                        <asp:TextBox ID="DocumentNameTextBox" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()"
                                            SkinID="CustomWidthTextBox" runat="Server" MaxLength="100"></asp:TextBox>
                                    </div>
                                    <asp:HiddenField ID="IdHiddenField" runat="server" />
                                </div>
                                <div class="cBoth"></div>
                                <div class="cBoth"></div>

                                <div id="Div3" runat="server" visible="true" class="col-md-12">
                                    <div id="Div2" class="himsBoxContentMsg" runat="server" visible="true">
                                    </div>
                                    <asp:GridView ID="SourceGridView" runat="server" AutoGenerateColumns="False" Visible="false"
                                        Width="25%" CssClass="table table-striped table-bordered table-hover" EmptyDataText="No Records Found !!"
                                        DataKeyNames="SourceId,SourceTypeId" OnRowDataBound="SourceGridView_RowDataBound">
                                        <Columns>
                                            <asp:TemplateField>
                                                <HeaderTemplate>
                                                    <label class="rt-chkbox rt-chkbox-outline">
                                                        <asp:CheckBox ID="HeaderIsSelectCheckBox" onclick="checkAllRows(this);" runat="server" />
                                                        <span></span>
                                                    </label>
                                                </HeaderTemplate>
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <ItemStyle HorizontalAlign="Center" />
                                                <ItemTemplate>
                                                    <label class="rt-chkbox rt-chkbox-outline">
                                                        <asp:CheckBox ID="IsSelectCheckBox" runat="server"  onclick="Check(this);" />
                                                        <asp:HiddenField ID="SourceIdHiddenHield" Value='<%#Eval("SourceId") %>' runat="server" />
                                                        <span></span>
                                                    </label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="Source" HeaderText="Class">
                                                <HeaderStyle HorizontalAlign="Left" />
                                                <ItemStyle Width="90%" />
                                            </asp:BoundField>
                                        </Columns>
                                        <PagerSettings Visible="False" />
                                    </asp:GridView>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <%--<script data-main="../../JavaScript/rjs/encrypt/division-master-encrypt" src="../../JavaScript/rjs/require.js"></script>--%>
    <script data-main='<%=ResolveUrl("~/JavaScript/rjs/division-master")%>' src='<%=ResolveUrl("~/JavaScript/rjs/require.js")%>'></script>
    <script type="text/javascript">
        function checkAllRows(obj) {
            var objGridview = obj.closest('table');
            var classname = '';
            var list = objGridview.getElementsByTagName("input");
            var count = 0;
            for (var i = 0; i < list.length; i++) {
                var objRow = list[i].parentNode.parentNode;
                if (list[i].type == "checkbox" && obj != list[i]) {
                    if (obj.checked) {
                        list[i].checked = true;
                    }
                    else {
                        list[i].checked = false;
                        Check(list[i]);
                    }
                }
            }
        }

        function Check(obj) {
            var table = document.getElementById('<%=SourceGridView.ClientID %>');
            ClassId = obj.nextElementSibling.value;
            var Id = document.getElementById('<%=IdHiddenField.ClientID %>').value;

            var chk = false;
            if ($(obj).is(':checked'))
                chk = true;
            else
                chk = false;

            $.ajax({
                type: "POST",
                url: "DocumentMaster.aspx/SelectCheckBoxChecked",
                data: JSON.stringify({ "Id": parseInt(Id), "ClassId": parseInt(ClassId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == -1) {
                        $(obj).attr('checked', 'checked');
                        $(obj).prop("checked", true);
                        alert('Document Uploaded for Class: ' + obj.parentNode.parentNode.nextElementSibling.innerText);
                    }
                }
            });
        }
    </script>
</asp:Content>
