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

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <script>
        var GroupId;
        var BatchId;
        var DepartmentId;
        var classId;
        var DivisionId;
        var statusId;
        var ExamSubGroupId;
        var Header = [];
        var ReHeader;

        $(document).ready(function () {
            var myurl = window.location.href;
            var keyval = myurl.split('?')[1].split('&');
            OrgId = parseInt(keyval[0].split('=')[1].toString());
            Id = OrgId = parseInt(keyval[0].split('=')[1].toString());
            BatchId = parseInt(keyval[1].split('=')[1].toString());
            ExamSubGroupId = parseInt(keyval[2].split('=')[1].toString());
            DepartmentDataBind(BatchId, ExamSubGroupId);

        });
        function PageName() {
            window.location.href = "../MobileView/AssessmentDetailDashboard.aspx?OrgId=" + Id;
        }
        function HeaderDisplay(id) {
            if (id == 1) {
                document.getElementById("DepartHead").style.display = "block";
                document.getElementById("ClassHead").style.display = "none";
                document.getElementById("DivisionHead").style.display = "none";
                document.getElementById("StudentHead").style.display = "none";
                $("#Depart").hide();
                $("#division").hide();
                $("#class").hide();
                document.getElementById("HeaderTitle").innerHTML = ReHeader;
                Header = [];
            }
            else if (id == 2) {
                document.getElementById("DepartHead").style.display = "none";
                document.getElementById("ClassHead").style.display = "block";
                document.getElementById("DivisionHead").style.display = "none";
                document.getElementById("StudentHead").style.display = "none";
                $("#Student").hide();
                $("#Depart").show();
                $("#division").hide();
                $("#class").hide();
                var h1 = [Header[0], Header[1]];
                Header = h1;
            }
            else if (id == 3) {
                document.getElementById("DepartHead").style.display = "none";
                document.getElementById("ClassHead").style.display = "none";
                document.getElementById("DivisionHead").style.display = "block";
                document.getElementById("StudentHead").style.display = "none";
                $("#Depart").show();
                $("#division").hide();
                $("#class").show();
            }
        }

        function DepartmentDataBind(BatchId, ExamSubGroupId) {
            $.ajax({
                type: "POST",
                url: "BrightStudentList.aspx/DeptWiseBrightStdGet",
                data: JSON.stringify({ "BatchId": parseInt(BatchId), "ExamSubGroupId": parseInt(ExamSubGroupId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tlbDepartment = "";
                    //var totalpass = 0;
                    //var totalfail = 0;
                    if (obj != "") {
                        tlbDepartment += "<tr><th>Department</th><th>Class</th><th>Rank</th><th>Name</th><th>Roll No</th><th>Total Marks</th><th>Obtained Marks</th><th>Per %</th><th>Grade</th></tr>";
                        $.each(obj, function (i, item) {
                            tlbDepartment += "<tr><td><a onclick='ClassDataBind(" + item.GroupId + ",\"" + item.GroupName + " \", \"" + ExamSubGroupId + " \")'>" +
                                item.GroupName + "</a></td><td>" + item.Class + "</td><td>" + item.rn + "</td><td>" + item.Name + "</td><td>" + item.RollNo + "</td><td>" + item.TotalMarks + "</td><td>" + item.TotalObtain + "</td><td>" + item.Percentage + "</td><td>" + item.ResultGrade + "</td></tr>";
                            //totalpass += parseInt(item.PassStudent);
                            //totalfail += parseInt(item.FailStudent);
                        });
                        //tlbDepartment += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + totalpass + "</td><td style='font-weight:bold'>" + totalfail + "</td><td style='font-weight:bold'>" + (totalpass + totalfail) + "</td></tr>";

                        Header[0] = "<h3 class='page-title text-muted'><a href ='#' onclick='dashboardpage()'>Assessment Dashboard</a></h3>" +
                        "<div class='cBoth'></div>" + " <h5 class='page-title' ><a href='#' onclick='PageName()'>Bright Student List</a></h5>";

                        document.getElementById("HeaderTitle").innerHTML = Header;
                        ReHeader = document.getElementById("HeaderTitle").innerHTML;
                    }
                    else { tlbDepartment += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblDepartment").innerHTML = tlbDepartment;
                    document.getElementById("DepartHead").style.display = "block";
                    //document.getElementById("OrgHead").style.display = "none";
                    statusId = 1;
                }
            });
        }

        function dashboardpage() {
            window.location.href = "../MobileView/AssessmentDetailDashboard.aspx?OrgId=" + Id;
        }

        function ClassDataBind(GroupId, GroupName, ExamSubGroupId) {
            $.ajax({
                type: "POST",
                url: "BrightStudentList.aspx/ClassWiseBrightStdGet",
                data: JSON.stringify({ "BatchId": parseInt(BatchId), "DepartId": parseInt(GroupId), "ExamSubGroupId": parseInt(ExamSubGroupId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblClss = "";
                    //var totalpass = 0;
                    //var totalfail = 0;
                    Header[0] = ReHeader;
                    if (obj != "") {
                        tblClss += "<tr><th>Class Name</th><th>Student Rank</th><th>Student Name</th><th>Total Marks</th><th>Obtained Marks</th></tr>";
                        $.each(obj, function (i, item) {
                            tblClss += "<tr><td><a onclick='DivisionDataBind(" + item.GroupId + ",\"" + item.GroupName + " \", \"" + ExamSubGroupId + " \")'>" +
                                item.GroupName + "</a></td><td>" + item.Class + "</td><td>" + item.m + "</td><td>" + itme.Name + "</td><td>" + itme.TotalMarks + "</td><td>" + itme.TotalObtain + "</td></tr>";
                            //totalpass += parseInt(item.PassStudent);
                            //totalfail += parseInt(item.FailStudent);

                        });
                        Header[1] = " <h5 class='page-title' style='display:Block' id='Depart'><a href='#' onclick='HeaderDisplay(1)'>" + GroupName + "</a></h5>";
                        //tblClss += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + 'NA' + "</td><td style='font-weight:bold'>" + 'NA' + "</td><td style='font-weight:bold'>" + (totalpass + totalfail) + "</td></tr>";
                    }
                    else { tblClss += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblClss").innerHTML = tblClss;
                    document.getElementById("HeaderTitle").innerHTML = '';
                    $.each(Header, function (i, item) {
                        document.getElementById("HeaderTitle").innerHTML += Header[i];

                    });

                    document.getElementById("DepartHead").style.display = "none";
                    document.getElementById("ClassHead").style.display = "block";
                    statusId = 2;
                    console.log(Header);
                }
            });
        }
        function DivisionDataBind(GroupId, GroupName, ExamSubGroupId, PassStudent, FailStudent) {
            $.ajax({
                type: "POST",
                url: "BrightStudentList.aspx/DivWiseBrightStdGet",
                data: JSON.stringify({ "BatchId": parseInt(BatchId), "ClassId": parseInt(GroupId), "ExamSubGroupId": parseInt(ExamSubGroupId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tblDivision = "";
                    var totalpass = 0;
                    var totalfail = 0;
                    if (obj != "") {
                        tblDivision += "<tr><th>Division Name</th><th>Pass Student Count</th><th>Fail Student Count</th><th>Total Student Count</th></tr>";
                        $.each(obj, function (i, item) {
                            tblDivision += "<td>" + item.GroupName + "</td><td>" + item.PassStudent + "</td><td>" + item.FailStudent + "</td><td>" + (item.PassStudent + item.FailStudent) + "</td></tr>";
                            totalpass += parseInt(item.PassStudent);
                            totalfail += parseInt(item.FailStudent);
                        });
                        tblDivision += "<tr><td style='font-weight:bold'>Total</td><td style='font-weight:bold'>" + totalpass + "</td><td style='font-weight:bold'>" + totalfail + "</td><td style='font-weight:bold'>" + (totalpass + totalfail) + "</td></tr>";
                        Header[2] = " <h5 class='page-title' style='display:block'  id='class'><a href='#' onclick='HeaderDisplay(2)'>" + GroupName + "</a></h5>";
                    }
                    else { tblDivision += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblDivision").innerHTML = tblDivision;
                    document.getElementById("HeaderTitle").innerHTML = '';
                    $.each(Header, function (i, item) {
                        document.getElementById("HeaderTitle").innerHTML += Header[i];

                    });
                    document.getElementById("DepartHead").style.display = "none";
                    document.getElementById("ClassHead").style.display = "none";
                    document.getElementById("DivisionHead").style.display = "block";
                    statusId = 3;
                }
            });
        }

        function BackOrgFunction() {
            if (statusId == 2) {
                document.getElementById("DepartHead").style.display = "block";
                document.getElementById("ClassHead").style.display = "none";
                document.getElementById("DivisionHead").style.display = "none";
                $("#division").hide();
                statusId--;
            }
            else if (statusId == 3) {
                document.getElementById("DepartHead").style.display = "none";
                document.getElementById("ClassHead").style.display = "block";
                document.getElementById("DivisionHead").style.display = "none";
                $("#class").hide();
                $("#division").hide();
                var h1 = [Header[0], Header[1]];
                Header = h1;
                statusId--;
            }
            else {
                window.location.href = "../MobileView/AssessmentDetailDashboard.aspx?OrgId=" + OrgId;
            }

        }
        function DashBoard() { window.location.href = "../MobileView/DashBoard.aspx"; }
    </script>
    <asp:UpdatePanel ID="DoctorScheduleUpdatePanel" runat="server">
        <ContentTemplate>
             <div class="col-md-12 ptb12">
                <span class='btn btn-home btn-icon' onclick='DashBoard()' title='home'><span><i class='material-icons'>home</i></span></span>
                <input type="button" value="&#xf3e5;" id="bntBackOrg" onclick="BackOrgFunction()" skinid="0" class="float-right btn btn-back btn-icon fas" />
            </div>
            <div class="page-header row mb20">
                <div class="col-xl-12 col-sm-12 col-xs-12 border-bottom-inline xs-padd0">
                    <div class="main-topic inner" id="HeaderTitle">
                    </div>
                </div>
            </div>

           
            <div class="bg-white row center-block">
                <div class="container-fluid">
                    <div class="gutters-tiny push js-appear-enabled animated fadeIn overflow-hidden" data-toggle="appear">
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="DepartHead" style="display: none">
                            <h3 class="table-topic">Department Wise Count</h3>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <table id='tblDepartment' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="ClassHead" style="display: none">
                            <h3 class="table-topic">Class Wise Count</h3>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <table id='tblClass' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="himssuHeader1WireBox col-md-12 pTop5" id="DivisionHead" style="display: none">
                            <h3 class="table-topic">Division Wise Count</h3>
                            <div class='himsBoxContent'>
                                <div class='table-responsive'>
                                    <table id='tblDivision' class='table table-striped table-bordered'>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>