<%@ page language="C#" masterpagefile="~/Pages/Common/MasterPages/MainMasterPage_new.master" autoeventwireup="true" inherits="Pages_StudentManagement_DivisionAllotment, App_Web_wcc3110r" 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" %>



<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <style type="text/css">
        input:disabled + input[type=image], input:read-only + a {
            pointer-events: visible;
            cursor: pointer !important;
        }
    </style>
    <asp:UpdatePanel ID="IncidentLogUpdatePanel" runat="server" UpdateMode="Always">
        <ContentTemplate>
            <div id="divContentPage" class="divcontentpagemargin">
                <div class="dashBoardLeftCont">
                    <div class="himssuHeader3WireBox">
                        <table>
                            <tr>
                                <td>
                                    <div class="himsBoxContent">
                                        <div class="leftUlMenu">
                                            <ScreenGroup:ScreenGroupControl EnableViewState="true" ID="ScreenGroupControl" ScreenGroupId="103"
                                                Visible="true" runat="server" />
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div class="whiteboxpaddingleft row">
                        <div class="himssuHeader2WireBox  card card-box">
                            <div class="himssuHeader1WireBox">
                                <div class="himsBoxHeader  card-head">
                                    <div class="leftdiv">
                                    </div>
                                    <div class="himsBoxTitle">
                                        <div class="headerText">
                                            <header>
                                                <i class="fas fa-search"></i>
                                                <asp:Label ID="Label1" runat="server" Text="Search"></asp:Label>
                                            </header>
                                        </div>
                                    </div>

                                    <div class="fRight mt-27 pagination display-flex">
                                        <asp:Button ID="BackButton" runat="Server" SkinID="0" CssClass="btn btn-back fas" Text="&#xf30a;  back" OnClick="BackButton_Click" Visible="false" />
                                    </div>
                                </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="SearchClassLabel" runat="server" Text="Class" SkinID="MandatoryLabel"></asp:Label>
                                                    </div>
                                                    <div class="fLeft pRight5">
                                                        <asp:DropDownList runat="server" ID="SearchClassDropDownList" SkinID="CustomWidthDropDownList"
                                                            CssClass="form-control" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()" AutoPostBack="true"
                                                            OnSelectedIndexChanged="SearchClassDropDownList_OnSelectedIndexChanged">
                                                        </asp:DropDownList>
                                                    </div>
                                                </div>
                                                <div class="outerBox pTop5 col-md-3">
                                                    <div class="controlLabelWidth">
                                                        <asp:Label ID="SearchDivisionLabel" runat="server" Text="Division"></asp:Label>
                                                    </div>
                                                    <div class="fLeft pRight5">
                                                        <asp:DropDownList runat="server" ID="SearchDivisionDropDownList" SkinID="CustomWidthDropDownList"
                                                            CssClass="form-control" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()">
                                                        </asp:DropDownList>
                                                    </div>
                                                </div>
                                                <div class="outerBox pTop5 col-md-3" runat="server" visible="false">
                                                    <div class="controlLabelWidth">
                                                        <asp:CheckBox ID="SearchIDNoNotAllotedCheckBox" runat="server" Text="ID No Not Alloted" />
                                                    </div>
                                                </div>
                                                <div class="cBoth"></div>
                                                <div class="col-md-12">
                                                    <div class="alert  mt2 alert-info">
                                                        <i class="material-icons">info</i> |&nbsp;
                                                        <asp:Label ID="RamarkLabel" runat="server" Text="Add ID No with . Dot separation (Eg. 2. 5. 10)" Font-Bold="true"></asp:Label>
                                                    </div>
                                                </div>
                                                <div class="cBoth"></div>
                                                <div class="outerBox pTop5 col-md-3">
                                                    <div class="controlLabelWidth">
                                                        <asp:Label ID="SearchCodeLabel" runat="server" Text="ID No"></asp:Label>
                                                    </div>
                                                    <div class="fLeft pRight5">
                                                        <asp:TextBox ID="SearchCodeTextBox" runat="server" onmouseleave="showHideTooltip()" SkinID="CustomWidthTextBox"
                                                            onmouseenter="showHideTooltip()"></asp:TextBox>
                                                    </div>
                                                </div>
                                                <div class="outerBox pTop5 col-md-3">
                                                    <div class="controlLabelWidth">
                                                        <asp:Label ID="SearchOrderByLabel" runat="server" Text="Order By"></asp:Label>
                                                    </div>
                                                    <div class="fLeft pRight5">
                                                        <asp:DropDownList runat="server" ID="SearchOrderByDropDownList" SkinID="CustomWidthDropDownList"
                                                            CssClass="form-control" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()">
                                                            <asp:ListItem Selected="True" Text="-Select-" Value="-1"></asp:ListItem>
                                                            <asp:ListItem Value="Code"></asp:ListItem>
                                                            <asp:ListItem Text="Surname" Value="LastName"></asp:ListItem>
                                                            <asp:ListItem Text="Name" Value="FirstName"></asp:ListItem>
                                                            <asp:ListItem Text="Roll No" Value="RollNo"></asp:ListItem>
                                                        </asp:DropDownList>
                                                    </div>
                                                </div>

                                                <div class="outerBox pTop5 col-md-3">
                                                    <div class="controlLabelWidth">
                                                        <asp:Label ID="SearchLastNameLabel" runat="server" Text="Surname"></asp:Label>
                                                    </div>
                                                    <div class="fLeft pRight5">
                                                        <asp:TextBox ID="SearchLastNameTextBox" runat="server" onmouseleave="showHideTooltip()" SkinID="CustomWidthTextBox"
                                                            Width="150px" onmouseenter="showHideTooltip()"></asp:TextBox>
                                                    </div>
                                                </div>
                                                <div class="outerBox pTop5 col-md-3">
                                                    <div class="controlLabelWidth">
                                                        <asp:Label ID="SearchFirstNameLabel" runat="server" Text="Name"></asp:Label>
                                                    </div>
                                                    <div class="fLeft pRight5">
                                                        <asp:TextBox ID="SearchFirstNameTextBox" runat="server" onmouseleave="showHideTooltip()" SkinID="CustomWidthTextBox"
                                                            onmouseenter="showHideTooltip()"></asp:TextBox>
                                                    </div>
                                                </div>

                                                <div class="col-md-12">
                                                    <div class="alert  mt2 alert-info">
                                                        <i class="material-icons">info</i> |&nbsp;
                                                        <asp:Label ID="Label2" runat="server" Text="Last Roll No. will be assigned to the new division students whose division is changed." Font-Bold="true"></asp:Label>
                                                    </div>
                                                </div>
                                                <div class="alignCenter col-md-12" style="padding-top: 15px;">
                                                    <asp:Button ID="SearchButton" SkinID="0" CssClass="btn-search btn fas" Text="&#xf002; Search" runat="Server" OnClick="SearchButton_Click" />
                                                    <asp:Button ID="ResetButton" SkinID="0" Text="&#xf0e2; Reset" CssClass="btn-reset btn fas" runat="Server" OnClick="ResetButton_Click" />
                                                    <asp:Button ID="ExportButton" runat="server" Text="&#xf093; Export" CssClass="fas btn btn-examcommon" SkinID="0" OnClick="ExportButton_Click" />
                                                    <a href="javascript:;" onclick="OpenFileUpload();" class="btn btn-browser">
                                                        <i class="fas fa-arrow-down"></i>Browse</a>
                                                    <asp:FileUpload ID="flUpload" runat="server" onChange="readURL(this);" ClientIDMode="Static" Style="display: none;" />

                                                    <asp:Button ID="ImportFromExcelButton" runat="server" Text="&#xf019; Import From Excel"
                                                        SkinID="0" CssClass="fas btn btn-examcommon" OnClick="ImportFromExcelButton_Click" />



                                                </div>
                                            </asp:Panel>
                                            <div id="Div1" class="himssuHeader7WireBox col-md-12" runat="server" visible="false">
                                                <div class="himsBoxHeader" id="GridViewPagerDiv" runat="server" visible="True">
                                                    <div class="leftdiv">
                                                    </div>
                                                    <div class="himsBoxTitle">
                                                        <div class="gridHeaderText fLeft">
                                                            <asp:Label ID="GridViewLabel" Text=""
                                                                runat="server" Font-Bold="True"
                                                                meta:resourcekey="GridViewLabelResource1" />
                                                        </div>
                                                    </div>
                                                    <div class="fRight display-flex">
                                                        <asp:TextBox ID="ApplyAllTextBox" runat="server" onmouseleave="showHideTooltip()" SkinID="CustomWidthTextBox"
                                                            onmouseenter="showHideTooltip()"></asp:TextBox>&nbsp;&nbsp;
                                                        <asp:Button ID="ApplyAllButton" Text="Apply All" SkinID="0" runat="Server" OnClick="ApplyAllButton_Click" CssClass="btn btn-apply" />
                                                    </div>
                                                </div>
                                                <div class="himsBoxContent col-md-12 pTop5 table-responsive">
                                                    <div id="GridViewMessageDiv" class="himsBoxContentMsg" runat="server"
                                                        visible="False">
                                                    </div>
                                                    <asp:GridView ID="AcademicGridView" runat="server" AutoGenerateColumns="False"
                                                        EmptyDataText="No Records Found !!" AllowPaging="false" ShowHeader="true" CssClass="table table-striped table-bordered table-hover"
                                                        DataKeyNames="Id,StudentId,DivisionId">
                                                        <Columns>
                                                            <asp:TemplateField HeaderText="Select" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="10%"
                                                                ItemStyle-Wrap="true">
                                                                <HeaderTemplate>
                                                                    <label class="rt-chkbox rt-chkbox-outline">
                                                                        <asp:CheckBox ID="HeaderSelectCheckBox" runat="server" Enabled="true" AutoPostBack="true"
                                                                            Visible="true" OnCheckedChanged="HeaderSelectCheckBox_checked" />
                                                                        <span></span>
                                                                    </label>
                                                                </HeaderTemplate>
                                                                <ItemStyle HorizontalAlign="Center" />
                                                                <ItemTemplate>
                                                                    <label class="rt-chkbox rt-chkbox-outline">
                                                                        <asp:CheckBox ID="SelectCheckBox" onclick="Check_Click(this);"
                                                                            runat="server" />
                                                                        <span></span>
                                                                    </label>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <%--  <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="50%" HeaderStyle-HorizontalAlign="Left"></asp:BoundField>--%>
                                                            <asp:TemplateField HeaderText="Name" ItemStyle-Width="25%" HeaderStyle-HorizontalAlign="Left">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="NameLabel" runat="server" ClientIDMode="Static" Text='<%# Bind("Name") %>'
                                                                        SkinID="CustomWidthLabel" ></asp:Label>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField ItemStyle-Width="5%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="CodeLabel" runat="server" ClientIDMode="Static" Text='<%#((Sapphire.Vidyalaya.BusinessEntity.Business.StudentManagementBE.Academic)Container.DataItem).Code %>'
                                                                        SkinID="CustomWidthLabel" ></asp:Label>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Roll No" ItemStyle-Width="10%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                                <ItemTemplate>
                                                                    <asp:UpdatePanel ID="ReceiptUpdatePanel" runat="server" UpdateMode="Conditional">
                                                                        <ContentTemplate>
                                                                            <asp:Label ID="RollNoLabel" runat="server" Text='<%# Bind("RollNo") %>'></asp:Label>
                                                                        </ContentTemplate>
                                                                        <Triggers>
                                                                            <asp:AsyncPostBackTrigger EventName="SelectedIndexChanged" ControlID="DivisionDropDownList" />
                                                                        </Triggers>
                                                                    </asp:UpdatePanel>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Division" ItemStyle-Width="10%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                                <ItemTemplate>
                                                                    <asp:DropDownList runat="server" ID="DivisionDropDownList" SkinID="CustomWidthDropDownList"
                                                                        CssClass="form-control" Width="100%" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()"
                                                                        OnSelectedIndexChanged="DivisionDropDownList_OnSelectedIndexChanged" AutoPostBack="false" Enabled="false" ClientIDMode="Static" onchange="handleDivisionChange(this)"><%--//Added Event onchange() And Change AutoPostBack->false by Dhananjay For Mantis  - 0034847--%>
                                                                    </asp:DropDownList>
                                                                </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="../../JavaScript/rjs/encrypt/division-allotment-encrypt" src="../../JavaScript/rjs/require.js"></script>--%>

    <script type="text/javascript">
        function Check_Click(obj) {
            var row = $(obj).closest('tr');
            if ($(obj).is(':checked')) {
                $(row).find('select').removeAttr('disabled');
            }
            else {
                $(row).find('select').prop('disabled', 'disabled');
                $(row).find('select').val('-1');
            }
        }
        //Added by Dhananjay For Mantis Start - 0034847
        function handleDivisionChange(dropdown) {


            var selectedValue = dropdown.value;
            var row = dropdown.closest('tr');
            var rowIndex = Array.from(row.parentNode.children).indexOf(row); // Get the zero-based index of the 

            var rollNoLabelId = 'ctl00_CP_AcademicGridView_ctl' + (rowIndex + 1).toString().padStart(2, '0') + '_RollNoLabel'; 
            var rollNoLabel = document.getElementById(rollNoLabelId);

            if (rollNoLabel) {
               rollNoLabel.innerText = "0";
            }
            var checkBoxes = document.querySelectorAll('#AcademicGridView .SelectCheckBox');
            checkBoxes.forEach(function (checkBox, index) {
                var divisionDropdown = document.querySelectorAll('#AcademicGridView .DivisionDropDownList')[index];
                if (checkBox.checked) {
                    divisionDropdown.disabled = false;
                } else {
                    divisionDropdown.disabled = true;
                }
            });
        }
        //Added by Dhananjay For Mantis End - 0034847
    </script>
    <script data-main='<%=ResolveUrl("~/JavaScript/rjs/division-allotment")%>' src='<%=ResolveUrl("~/JavaScript/rjs/require.js")%>'></script>
</asp:Content>
