<%@ page language="C#" masterpagefile="~/Pages/Common/MasterPages/MainMasterPage_new.master" autoeventwireup="true" inherits="Pages_Attendance_SubjectwiseAttendance, App_Web_nh2irgi4" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="~/UserControls/GridViewPager/GridViewPager.ascx" TagName="GridViewPager"
    TagPrefix="uc1" %>
<%@ Register Src="~/UserControls/Common/ScreenGroup/ScreenGroup.ascx" TagName="ScreenGroupControl"
    TagPrefix="ScreenGroup" %>
<%@ Register Src="~/UserControls/DatePicker/DatePickerControl.ascx" TagName="DatePickerControl"
    TagPrefix="Date" %>
<%@ Register Src="~/UserControls/Common/EmployeeSearch/EmployeeSearch.ascx" TagName="EmployeeSearchControl"
    TagPrefix="hims" %>
<%@ Register Src="~/UserControls/DatePicker/DatePickerAutoPostBackControl.ascx" TagName="DatePickerAutoPostBackControl" TagPrefix="DPC" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <asp:UpdatePanel ID="IncidentLogUpdatePanel" runat="server" UpdateMode="Always">
        <ContentTemplate>
            <hims:EmployeeSearchControl ID="EmployeeSearch" Visible="false" runat="server" />
            <div id="divContentPage" class="divcontentpagemargin">
                <div class="dashBoardLeftCont">
                    <div class="himssuHeader3WireBox">
                        <div class="himssuHeader3WireBox">
                            <table>
                                <tr>
                                    <td>
                                        <div class="himsBoxContent">
                                            <div class="leftUlMenu">
                                                <ScreenGroup:ScreenGroupControl EnableViewState="true" ID="ScreenGroupControl" ScreenGroupId="110"
                                                    Visible="true" runat="server" />
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <div class="row whiteboxpaddingleft">
                            <div class="himssuHeader5WireBox card card-box">
                                <div class="himsBoxHeader card-head">
                                    <div class="leftdiv">
                                    </div>
                                    <div class="himsBoxTitle">
                                        <div class="headerText">
                                            <header>
                                                <i class="fas fa-edit"></i>
                                                <asp:Label ID="Label1" runat="server" Text="Apply"></asp:Label>
                                            </header>
                                        </div>
                                    </div>
                                </div>
                                <div class="himsBoxContent card-body">
                                    <asp:Panel ID="DetailPanel" runat="Server">
                                        <div class="contentHolder">
                                            <asp:Panel ID="SearchCriteriaPanel" runat="Server">
                                                <div class="col-md-12 pTop5 mt1 bg-lghtgrey radiobtn">
                                                    <div class="fLeft pRight5">
                                                        <asp:RadioButtonList runat="server" ID="AttendanceRadioButtonList" RepeatDirection="Horizontal"
                                                            AutoPostBack="true" OnSelectedIndexChanged="AttendanceRadioButtonList_OnSelectedIndexChanged">
                                                            <asp:ListItem Text="Division" Value="1" Selected="True"></asp:ListItem>
                                                            <asp:ListItem Text="Attendance Group" Value="2"></asp:ListItem>
                                                        </asp:RadioButtonList>
                                                    </div>
                                                </div>
                                                <div class="cBoth"></div>
                                                <div class="outerBox pTop5 col-md-3">
                                                    <div class="controlLabelWidth">
                                                        <asp:Label ID="SearchClassLabel" runat="server" Text="Class" SkinID="MandatoryLabel"></asp:Label>
                                                    </div>
                                                    <div class="fLeft pRight5">
                                                        <asp:DropDownList runat="server" ID="ClassDropDownList" SkinID="CustomWidthDropDownList"
                                                            CssClass="form-control" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()"
                                                            AutoPostBack="true" OnSelectedIndexChanged="ClassDropDownList_OnSelectedIndexChanged">
                                                        </asp:DropDownList>
                                                    </div>
                                                </div>
                                                <div id="DivisionDiv" runat="server" visible="false">
                                                    <div class="outerBox pTop5 col-md-3">
                                                        <div class="controlLabelWidth">
                                                            <asp:Label ID="SearchDivisionLabel" runat="server" Text="Division" SkinID="MandatoryLabel"></asp:Label>
                                                        </div>
                                                        <div class="fLeft pRight5">
                                                            <asp:DropDownList runat="server" ID="DivisionDropDownList" SkinID="CustomWidthDropDownList"
                                                                CssClass="form-control" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()"
                                                                AutoPostBack="true" OnSelectedIndexChanged="DivisionDropDownList_OnSelectedIndexChanged">
                                                            </asp:DropDownList>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div id="AttendanceGroupDiv" runat="server" visible="false">
                                                    <div class="outerBox pTop5 col-md-3">
                                                        <div class="controlLabelWidth">
                                                            <asp:Label ID="AttendanceGroupLabel" runat="server" Text="Attendance Group" SkinID="MandatoryLabel"></asp:Label>
                                                        </div>
                                                        <div class="fLeft pRight5">
                                                            <asp:DropDownList runat="server" ID="AttendanceGroupDropDownList" SkinID="CustomWidthDropDownList"
                                                                CssClass="form-control" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()"
                                                                OnSelectedIndexChanged="AttendanceGroupDropDownList_SelectedIndexChanged" AutoPostBack="true">
                                                            </asp:DropDownList>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="outerBox pTop5 col-md-3">
                                                    <div class="controlLabelWidth">
                                                        <asp:Label ID="AttendanceDateLabel" runat="server" Text="Attendance Date" SkinID="MandatoryLabel"></asp:Label>
                                                    </div>
                                                    <div class="fLeft pRight5">
                                                        <%--<Date:DatePickerControl DisplayDatePicker="true" ID="AttendanceDatePickerControl"
                                                            runat="server" />--%>
                                                        <DPC:DatePickerAutoPostBackControl ID="AttendanceDatePickerControl" runat="server" AutoPostBack="true" DisplayDatePicker="true" OnTextChanged="AttendanceDatePickerControl_OnTextChanged" />
                                                    </div>
                                                </div>
                                                <div class="outerBox pTop5 col-md-3">
                                                    <div class="controlLabelWidth">
                                                        <asp:Label ID="SubjectLabel" runat="server" Text="Subject" SkinID="MandatoryLabel"></asp:Label>
                                                    </div>
                                                    <div class="fLeft pRight5">
                                                        <asp:DropDownList runat="server" ID="SubjectDropDownList" SkinID="CustomWidthDropDownList"
                                                            CssClass="form-control" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()"
                                                            AutoPostBack="true" OnSelectedIndexChanged="SubjectDropDownList_OnSelectedIndexChanged">
                                                        </asp:DropDownList>
                                                    </div>
                                                </div>
                                                <div class="outerBox pTop5 col-md-3">
                                                    <div class="controlLabelWidth">
                                                        <asp:Label ID="PeriodNoLabel" runat="server" Text="Period No" SkinID="MandatoryLabel"></asp:Label>
                                                    </div>
                                                    <div class="fLeft pRight5">
                                                        <asp:DropDownList runat="server" ID="PeriodNoDropDownList" SkinID="CustomWidthDropDownList"
                                                            CssClass="form-control" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()">
                                                        </asp:DropDownList>
                                                    </div>
                                                </div>

                                                <div class="outerBox pTop5 col-md-3">
                                                    <div class="controlLabelWidth">
                                                        <asp:Label ID="EmployeeCodeLabel" runat="server" Text="Employee Code"></asp:Label>
                                                    </div>
                                                    <div class="fLeft pRight5 display-flex">
                                                        <asp:TextBox ID="EmployeeCodeTextBox" SkinID="CustomWidthTextBox" runat="server"
                                                            MaxLength="100" AutoPostBack="true" OnTextChanged="EmployeeCodeTextBox_TextChanged"> </asp:TextBox>
                                                        <asp:ImageButton SkinID="FindImage" ToolTip="Drug Search" ID="EmployeeCodeImageButton"
                                                            runat="server" ImageUrl="../../../../Images/icons/icon_find.gif" />
                                                        <asp:HiddenField ID="EmployeeIdHiddenField" runat="server" />
                                                    </div>
                                                </div>
                                                <div class="outerBox pTop5 col-md-3">
                                                    <div class="controlLabelWidth">
                                                        <asp:Label ID="EmployeeNameLabel" runat="server" Text="Employee Name"></asp:Label>
                                                    </div>
                                                    <div class="fLeft pRight5">
                                                        <asp:TextBox ID="EmployeeNameTextBox" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()"
                                                            SkinID="CustomWidthTextBox" runat="server" MaxLength="100"> </asp:TextBox>
                                                    </div>
                                                </div>

                                                <div class="outerBox pTop5 col-md-3">
                                                    <div class="fLeft">
                                                        <asp:CheckBox ID="StopAutoAlertCheckBox" runat="server" Text="Stop Auto Alert" />
                                                    </div>
                                                </div>

                                                <div class="outerBox col-md-3 pTop15">
                                                    <asp:CheckBox ID="ShowWithPhotoCheckBox" runat="server" AutoPostBack="false" Text="Show With Photo" class="pLeft5" />
                                                    <%--   <asp:Label ID="ShowWithPhotoLabel" runat="server" Text="Show With Photo"></asp:Label>--%>
                                                </div>
                                                <div id="RemarkDiv" runat="server" class="col-md-12  pTop5" visible="false">
                                                    <div class="alert  mt2 alert-info">
                                                        <i class="material-icons">info</i>
                                                        <b>Note : </b>Class and Division Filter not applicable if Attendance group filter
                                                                selected.
                                                    </div>
                                                </div>

                                                <div class="alignCenter pTop5 col-md-12">
                                                    <asp:Button ID="ApplyButton" Text="&#xf00c; Apply" runat="Server" OnClick="ApplyButton_Click"
                                                        SkinID="0" CssClass="btn-apply btn fas" />
                                                </div>
                                            </asp:Panel>
                                            <div id="Div1" class="himssuHeader7WireBox col-md-12 pTop5" runat="server"
                                                visible="false">
                                                <div id="GridViewPagerDiv" runat="server" visible="True">
                                                    <div class="himsBoxTitle">
                                                        <div class="gridHeaderText fLeft">
                                                            <asp:Label ID="TNoteLabel" Text="" runat="server" />
                                                            <asp:Label ForeColor="Red" ID="NoteLabel" Text="" runat="server" />
                                                        </div>
                                                    </div>
                                                    <div class="himsBoxTitle">

                                                        <div class="headerText fRight display-flex pb-1" style="margin-top: -33px;">
                                                            <div class="" style="width: 130px;">
                                                                <div class="controlLabelWidth">
                                                                    <asp:Label ID="Label2" runat="server" Text="Period No" SkinID="MandatoryLabel"></asp:Label>
                                                                </div>
                                                                <div class="fLeft pRight5">
                                                                    <asp:DropDownList runat="server" ID="ApplyDropDownList" SkinID="CustomWidthDropDownList"
                                                                        CssClass="form-control" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()">
                                                                    </asp:DropDownList>
                                                                </div>
                                                            </div>
                                                            <%--<asp:DropDownList ID="ApplyDropDownList" runat="server" AutoPostBack="True" CssClass="form-control" SkinID="CustomWidthDropDownList" Visible="true">
                                                                    </asp:DropDownList>&nbsp;&nbsp;&nbsp;&nbsp;--%>

                                                            <asp:Button ID="ApplyPeriodNoBoxButton" runat="server" SkinID="0"
                                                                Text="Apply Period"
                                                                CssClass="btn btn-apply mb-1" OnClick="ApplyPeriodNoBoxButton_Click" Visible="true" />
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="himsBoxContent table-responsive">
                                                    <div id="GridViewMessageDiv" class="himsBoxContentMsg" runat="server" visible="False">
                                                    </div>
                                                    <asp:GridView ID="StudentRegisterGridView" runat="server" AutoGenerateColumns="False"
                                                        EmptyDataText="No Records Found !!" OnRowDataBound="StudentRegisterGridView_RowDataBound"
                                                        AllowPaging="false" ShowHeader="true" DataKeyNames="AcademicId,AbsentReasonId,AttendanceTagId,IsDeleted"
                                                        CssClass="table table-striped table-bordered table-hover">
                                                        <Columns>
                                                            <asp:TemplateField HeaderStyle-HorizontalAlign="Center">
                                                                <HeaderTemplate>
                                                                    <label class="rt-chkbox rt-chkbox-outline">
                                                                        <asp:CheckBox ID="HeaderSelectCheckBox" runat="server" onClick="HeaderSelectCheckBoxCheck(this);" AutoPostBack="false" OnCheckedChanged="HeaderSelectCheckBox_OnCheckedChanged" />
                                                                        <span></span>
                                                                    </label>
                                                                </HeaderTemplate>
                                                                <ItemStyle HorizontalAlign="Center" Width="5%" />
                                                                <ItemTemplate>
                                                                    <label class="rt-chkbox rt-chkbox-outline">
                                                                        <asp:CheckBox ID="SelectCheckBox" runat="server" />
                                                                        <span></span>
                                                                    </label>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:BoundField DataField="Class" HeaderText="Class" ItemStyle-Width="10%" HeaderStyle-HorizontalAlign="Left"></asp:BoundField>
                                                            <asp:BoundField DataField="RollNo" HeaderText="Roll No" ItemStyle-Width="10%" HeaderStyle-HorizontalAlign="Left"></asp:BoundField>
                                                            <asp:BoundField DataField="Code" HeaderText="ID No" ItemStyle-Width="10%" HeaderStyle-HorizontalAlign="Left"></asp:BoundField>
                                                            <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="30%" HeaderStyle-HorizontalAlign="Left"></asp:BoundField>
                                                            <asp:TemplateField HeaderText="Photo" ItemStyle-Width="190px" HeaderStyle-HorizontalAlign="Center"
                                                                ItemStyle-HorizontalAlign="Center" ItemStyle-Wrap="true" Visible="false">
                                                                <ItemTemplate>
                                                                    <asp:Image ID="StudentPhoto" Height="60px" Width="60px" runat="server" ImageUrl='<%# Eval("StudentPhoto")%>' />
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField ItemStyle-Wrap="true" ItemStyle-Width="10%">
                                                                <HeaderTemplate>
                                                                    <label class="rt-chkbox rt-chkbox-outline">
                                                                        <asp:CheckBox ID="HeaderIsPresentCheckBox" runat="server" onClick="HeaderIsPresentCheckBoxCheck(this);" AutoPostBack="false" OnCheckedChanged="HeaderIsPresentCheckBox_OnCheckedChanged" />
                                                                        Present
                                                                        <span></span>
                                                                    </label>
                                                                </HeaderTemplate>
                                                                <ItemStyle HorizontalAlign="Center" />
                                                                <ItemTemplate>
                                                                    <label class="rt-chkbox rt-chkbox-outline">
                                                                        <asp:CheckBox ID="IsPresentCheckBox" runat="server" onClick="VariableCheckBoxClick(this);" Checked='<%# Bind("IsPresent") %>' OnCheckedChanged="IsPresentCheckBox_OnCheckedChanged" AutoPostBack="false" />
                                                                        <span></span>
                                                                    </label>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Absent Reason" ItemStyle-Width="10%" ItemStyle-Wrap="true"
                                                                HeaderStyle-HorizontalAlign="Left">
                                                                <ItemTemplate>
                                                                    <asp:DropDownList runat="server" ID="AbsentReasonDropDownList" SkinID="CustomWidthDropDownList"
                                                                        CssClass="form-control" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()">
                                                                    </asp:DropDownList>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Attendance" ItemStyle-Width="10%" ItemStyle-Wrap="true"
                                                                HeaderStyle-HorizontalAlign="Left">
                                                                <ItemTemplate>
                                                                    <asp:DropDownList runat="server" ID="AttendanceTagDropDownList" SkinID="CustomWidthDropDownList"
                                                                        CssClass="form-control" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()">
                                                                    </asp:DropDownList>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Sr. No." ItemStyle-Width="5%" ItemStyle-Wrap="true">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="SrNoLabel" runat="server"></asp:Label>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                        </Columns>
                                                        <PagerSettings Visible="False" />
                                                    </asp:GridView>
                                                </div>
                                            </div>
                                        </div>
                                    </asp:Panel>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <script data-main='<%=ResolveUrl("~/JavaScript/rjs/assign-organization")%>' src='<%=ResolveUrl("~/JavaScript/rjs/require.js")%>'></script>
    <script type="text/javascript">
        function checkAllRows(obj) {

            var objGridview = obj.parentNode.parentNode.parentNode;
            var list = objGridview.getElementsByTagName("input");

            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;
                    }
                }
            }
        }

        function checkUncheckHeaderCheckBox(obj) {
            var objRow = obj.parentNode.parentNode;
            var objGridView = objRow.parentNode;
            var list = objGridView.getElementsByTagName("input");
            for (var i = 0; i < list.length; i++) {
                var objHeaderChkBox = list[0];

                var checked = true;

                if (list[i].type == "checkbox" && list[i] != objHeaderChkBox) {
                    if (!list[i].checked) {
                        checked = false;
                        break;
                    }
                }
            }
            objHeaderChkBox.checked = checked;
        }

        //add for 27791 mantis start
        <%-- function HeaderSelectCheckBoxCheck(obj) {
            var table = document.getElementById('<%=StudentRegisterGridView.ClientID %>');
            var chkselect = false;
            if ($(obj).is(':checked'))
                chkselect = true;
            else
                chkselect = false;

            if (chkselect == true) {
                for (var i = 1; i < table.rows.length ; i++) {
                    if (table.rows[i].cells[6].innerText != "") {
                        var j = i + 1;
                        if (j < 10) {
                            $('#ctl00_CP_StudentRegisterGridView_ctl0' + j + '_SelectCheckBox').attr('checked', 'checked');
                            $('#ctl00_CP_StudentRegisterGridView_ctl0' + j + '_SelectCheckBox').prop('checked', true);
                        }
                        if (j > 9) {
                            $('#ctl00_CP_StudentRegisterGridView_ctl' + j + '_SelectCheckBox').attr('checked', 'checked');
                            $('#ctl00_CP_StudentRegisterGridView_ctl' + j + '_SelectCheckBox').prop('checked', true);
                        }
                    }
                }
            }
            else {
                for (var i = 1; i < table.rows.length ; i++) {
                    if (table.rows[i].cells[6].innerText != "") {
                        var j = i + 1;
                        if (j < 10) {
                            $('#ctl00_CP_StudentRegisterGridView_ctl0' + j + '_SelectCheckBox').removeAttr('checked');
                            $('#ctl00_CP_StudentRegisterGridView_ctl0' + j + '_SelectCheckBox').prop('checked', false);
                        }
                        if (j > 9) {
                            $('#ctl00_CP_StudentRegisterGridView_ctl' + j + '_SelectCheckBox').removeAttr('checked');
                            $('#ctl00_CP_StudentRegisterGridView_ctl' + j + '_SelectCheckBox').prop('checked', false);
                        }
                    }
                }
            }
        }--%>
        //added by dhananjay for mantis : 40557	
        function HeaderSelectCheckBoxCheck(obj) {
            // Get the closest table element (this assumes 'obj' is the checkbox that was clicked)
            var objGridview = obj.closest('table');

            // Get all checkbox inputs inside the table
            var list = objGridview.querySelectorAll("input[type='checkbox']");

            // Loop through all checkbox inputs
            for (var i = 0; i < list.length; i++) {
                var objRow = list[i].closest('tr');
                var dropdown = objRow.cells[6].querySelector('select');  // Get the <select> element in the 7th column

                // Check if the dropdown value is neither null nor empty
                if (dropdown && dropdown.value != null && dropdown.value.trim() !== "") {
                    // Check if the checkbox is part of the rows (exclude the header checkbox)
                    if (list[i].id.indexOf('SelectCheckBox') !== -1 && obj !== list[i]) {
                        // If the header checkbox is checked, check all the row checkboxes
                        list[i].checked = obj.checked;
                    }
                }
            }
        }
        //added by dhananjay for mantis : 40557	
        function VariableCheckBoxClick(obj) {
            var table = document.getElementById('ctl00_CP_StudentRegisterGridView');
            row = obj.parentNode.parentNode.parentNode.rowIndex + 1;
            rowindex = row - 1;
            var chkselect = false;
            if ($(obj).is(':checked'))
                chkselect = true;
            else
                chkselect = false;
            if (chkselect == true) {
                if (row < 10) {
                    $('#ctl00_CP_StudentRegisterGridView_ctl0' + row + '_AbsentReasonDropDownList').attr('disabled', 'disabled');
                    $('#ctl00_CP_StudentRegisterGridView_ctl0' + row + '_AbsentReasonDropDownList').val("-1");
                }
                if (row > 9) {
                    $('#ctl00_CP_StudentRegisterGridView_ctl' + row + '_AbsentReasonDropDownList').attr('disabled', 'disabled');
                    $('#ctl00_CP_StudentRegisterGridView_ctl' + row + '_AbsentReasonDropDownList').val("-1");
                }
            }
            else {
                if (row < 10) {
                    $('#ctl00_CP_StudentRegisterGridView_ctl0' + row + '_AbsentReasonDropDownList').removeAttr('disabled');
                }
                if (row > 9) {
                    $('#ctl00_CP_StudentRegisterGridView_ctl' + row + '_AbsentReasonDropDownList').removeAttr('disabled');
                }
            }
        }

        <%--  function HeaderIsPresentCheckBoxCheck(obj) {
            var table = document.getElementById('<%=StudentRegisterGridView.ClientID %>');
            var chkselect = false;
            if ($(obj).is(':checked'))
                chkselect = true;
            else
                chkselect = false;

            if (chkselect == true) {
                for (var i = 1; i < table.rows.length ; i++) {
                    if (table.rows[i].cells[6].innerText != "") {
                        var j = i +1;
                        if (j < 10) {
                            $('#ctl00_CP_StudentRegisterGridView_ctl0' + j + '_IsPresentCheckBox').attr('checked', 'checked');
                            $('#ctl00_CP_StudentRegisterGridView_ctl0' + j + '_IsPresentCheckBox').prop('checked', true);
                            $('#ctl00_CP_StudentRegisterGridView_ctl0' + j + '_AbsentReasonDropDownList').attr('disabled', 'disabled');
                            $('#ctl00_CP_StudentRegisterGridView_ctl0' + j + '_AbsentReasonDropDownList').val("-1");
                        }
                        if (j > 9) {
                            $('#ctl00_CP_StudentRegisterGridView_ctl' + j + '_IsPresentCheckBox').attr('checked', 'checked');
                            $('#ctl00_CP_StudentRegisterGridView_ctl' + j + '_IsPresentCheckBox').prop('checked', true);
                            $('#ctl00_CP_StudentRegisterGridView_ctl' + j + '_AbsentReasonDropDownList').attr('disabled', 'disabled');
                            $('#ctl00_CP_StudentRegisterGridView_ctl' + j + '_AbsentReasonDropDownList').val("-1");
                        }
                    }
                }
            }
            else {
                for (var i = 1; i < table.rows.length ; i++) {
                    if (table.rows[i].cells[6].innerText != "") {
                        var j = i+1;
                        if (j < 10) {
                            $('#ctl00_CP_StudentRegisterGridView_ctl0' + j + '_IsPresentCheckBox').removeAttr('checked');
                            $('#ctl00_CP_StudentRegisterGridView_ctl0' + j + '_IsPresentCheckBox').prop('checked', false);
                            $('#ctl00_CP_StudentRegisterGridView_ctl0' + j + '_AbsentReasonDropDownList').removeAttr('disabled');
                        }
                        if (j > 9) {
                            $('#ctl00_CP_StudentRegisterGridView_ctl' + j + '_IsPresentCheckBox').removeAttr('checked');
                            $('#ctl00_CP_StudentRegisterGridView_ctl' + j + '_IsPresentCheckBox').prop('checked', false);
                            $('#ctl00_CP_StudentRegisterGridView_ctl' + j + '_AbsentReasonDropDownList').removeAttr('disabled');
                        }
                    }
                }
            }
        }
        //add for 27791 mantis end--%>
        
        //added by dhananjay for mantis : 40557	
        function HeaderIsPresentCheckBoxCheck(obj) {
            // Get the closest table element (this assumes 'obj' is the checkbox that was clicked)
            var objGridview = obj.closest('table');

            // Get all checkbox inputs inside the table
            var list1 = objGridview.querySelectorAll("input[type='checkbox']");

            // Loop through all checkbox inputs
            for (var i = 0; i < list1.length; i++) {
                // Get the row containing the checkbox
                var objRow = list1[i].closest('tr');
                var dropdown = objRow.cells[6].querySelector('select');  // Get the <select> element in the 7th column

                // Check if the dropdown exists and has a value selected
                if (dropdown && dropdown.value != null && dropdown.value.trim() !== "") {
                    // Exclude the header checkbox and process the other checkboxes
                    if (list1[i].id.indexOf('IsPresentCheckBox') !== -1 && obj !== list1[i]) {
                        // If the header checkbox is checked, check all the row checkboxes and disable the dropdown
                        list1[i].checked = obj.checked;
                        if (obj.checked) {
                            dropdown.disabled = true;  // Disable dropdown if header checkbox is checked
                            dropdown.value = -1;
                        } else {
                            dropdown.disabled = false; // Enable dropdown if header checkbox is unchecked
                        }
                    }
                }
            }
        }

        //added by dhananjay for mantis : 40557	
    </script>
</asp:Content>
