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

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">

    <script src="../../App_Themes/newTheme/js/jquery-3.3.1.min.js"></script>
    <script src="../../JavaScript/Chart.min.js"></script>

    <script>
        var Id;
        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());

            $.ajax({
                type: "POST",
                url: "TotalPercentageAnalysis.aspx/GetOrgId",
                data: JSON.stringify({ "Id": Id }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    Header[0] = "<h5 class='page-title'><a href='#' onclick='dashboardpage()'>" + obj[0][1].value + "</a></h5>" +
                    " <h5 class='page-title' ><a href='#' onclick='PageName()'>Total Percentage Analysis</a></h5>";
                    $("#HeaderLabel").text("Assessment Dashboard");
                    document.getElementById("HeaderTitle").innerHTML = Header;
                    ReHeader = document.getElementById("HeaderTitle").innerHTML;
                }
            });

            DepartmentDataBind(Id, 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("roundgraphdivDept").style.display = "block";
                document.getElementById("roundgraphdivClass").style.display = "none";
                document.getElementById("roundgraphdivDivision").style.display = "none";
                $("#Depart").hide();
                $("#classdiv").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("roundgraphdivDept").style.display = "none";
                document.getElementById("roundgraphdivClass").style.display = "block";
                document.getElementById("roundgraphdivDivision").style.display = "none";
                $("#Depart").show();
                $("#classdiv").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("roundgraphdivDept").style.display = "none";
                document.getElementById("roundgraphdivClass").style.display = "none";
                document.getElementById("roundgraphdivDivision").style.display = "block";
                $("#Depart").show();
                $("#classdiv").show();
            }
        }

        function DepartmentDataBind(Id, BatchId, ExamSubGroupId) {
            $.ajax({
                type: "POST",
                url: "TotalPercentageAnalysis.aspx/DeptWiseStdPerGet",
                data: JSON.stringify({ "OrgId": Id, "BatchId": parseInt(BatchId), "ExamSubGroupId": parseInt(ExamSubGroupId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    var obj = (result.d);
                    var tlbDepartment = "";
                    var total = 0;
                    var finaltotal = 0;
                    if (obj != "") {
                        //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()'>Total Percentage Analysis</a></h5>";
                        document.getElementById("HeaderTitle").innerHTML = Header;
                        ReHeader = document.getElementById("HeaderTitle").innerHTML;

                        var newObj = {};
                        var keyCount = 0;
                        tlbDepartment += "<tr>";
                        for (var item in obj[0]) {
                            var columnsIn = obj[0][item];
                            if (columnsIn.key === "GroupId") { continue; }
                            else if (columnsIn.key == "GroupTitle") { continue; }
                            else if (columnsIn.key == "GroupName" || columnsIn.key == "Department Name") {
                                newObj[keyCount++] = { "Department Name": "Total" };
                                tlbDepartment += "<th>Department Name</th>";
                            }
                            else {
                                tlbDepartment += "<th>" + columnsIn.key + "</th>";
                                newObj[keyCount] = {};
                                newObj[keyCount++][columnsIn.key] = 0;
                            }
                        }

                        tlbDepartment += "<th>Total</th></tr>";
                        keyCount = 1;
                        $.each(obj, function (i, item) {
                            tlbDepartment += "<tr>";
                            var groupId = "";
                            var groupname = "";
                            for (var key in item) {
                                if (item[key].key === "GroupId") {
                                    groupId = item[key].value;
                                }
                                if (item[key].key === "GroupName") {
                                    groupname = item[key].value;
                                }
                            }
                            for (var key in item) {
                                if (item[key].key !== "GroupId") {
                                    if (item[key].key === "GroupName") {
                                        if (item[key].value !== "null" && item[key].value !== undefined && item[key].value !== null) {
                                            tlbDepartment += "<td><a onclick='ClassDataBind(" + groupId + ",\"" + groupname + " \")'>" + item[key].value + "</a></td>";
                                        }
                                    }
                                    if (item[key].key !== "GroupTitle") {
                                        if (item[key].key !== "GroupName") {
                                            if (item[key].value === null || item[key].value === undefined) { item[key].value = 0; }
                                            tlbDepartment += "<td>" + item[key].value + "</td>";

                                            if (item[key].key !== "Department Name" && item[key].key !== "GroupName") {
                                                if (item[key].value !== "null" && item[key].value !== undefined && item[key].value !== null) {
                                                    for (var key1 in newObj[keyCount]) {
                                                        if (item[key].key == key1) {
                                                            newObj[keyCount][key1] += parseInt(item[key].value)
                                                        }
                                                        keyCount++;
                                                    }
                                                    total += parseInt(item[key].value);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            tlbDepartment += "<td>" + total + "</td></tr>";
                            keyCount = 1;
                            finaltotal += total;
                            total = 0;
                        });
                        tlbDepartment += "<tr>";
                        for (var item in newObj) {
                            var columnsIn = newObj[item];
                            for (var key in columnsIn) {
                                if (key === "GroupId") { continue; }
                                else if (key == "GroupTitle") { continue; }
                                else if (key == "Department Name") {
                                    tlbDepartment += "<th>" + columnsIn[key] + "</th>";
                                }
                                else {
                                    tlbDepartment += "<th>" + columnsIn[key] + "</th>";
                                }
                            }
                        }
                        tlbDepartment += "<th>" + finaltotal + "</th></tr>";
                    }
                    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("roundgraphdivDept").style.display = "block";
                    statusId = 1;

                    var dataPoint = [];
                    var lables = [];
                    var chartdata = [];
                    var dataPoint1 = [];
                    var lables1 = [];
                    var chartdata1 = [];
                    var lbl = [];
                    var locationlbl = [];
                    var colcnt = 0, rowcnt = 0;
                    colcnt = $('#tblDepartment tr:first').find("th").length - 1;
                    rowcnt = $('#tblDepartment tr').length - 1;
                    $('#roundgraphdivDept').show();
                    $('#round1graphdivDept').show();
                    $('#tblDepartment tbody tr:not(:last-child)').each(function (index) {
                        $(this).find('th,td:not(:last-child)').each(function (index2) {
                            if ($(this).is('th')) {
                                if (index2 != 0 && index2 != colcnt) {
                                    //alert(index2 + ' ' + colcnt)
                                    //debugger;
                                    lables.push(this.innerHTML);
                                }
                            } else if ($(this).is('td')) {
                                if (index2 != 0) {
                                    dataPoint.push(this.innerHTML);
                                } else if (index2 == 0) {
                                    locationlbl.push(this.innerText);
                                }
                            }
                        });
                        if (lables.length > 0 && dataPoint.length > 0) {
                            chartdata.push({
                                label: locationlbl,
                                fillColor: "red",
                                strokeColor: "blue",
                                pointColor: "green",
                                backgroundColor: ["#FF6384", "#36A2EB", "#FFCE56", "#D35400", "#CD5C5C", "#cc65fe", "#196F3D", "#5499C7", "#E67E22",
                                  "#27AE60", "#F08080", "#996633", "#0000cc", "#FFA07A", "#16A085", "#512E5F", "#7D6608", "#1B4F72", "#008080",
                                  "#FF00FF", "#01DF01", "#ff0000", "#00ffff", "#cc6699", "#cccc00", "#993300", "#333399", "#ff99ff", "#006600", "#ffff00",
                                "#003366", "#00ccff", "#ff9900", "#cc0066", "#ccccff", "#660066", "#000000"],
                                borderWidth: 1,
                                data: dataPoint
                            });
                            dataPoint = [];
                            locationlbl = [];
                        }
                    });
                    var data = {
                        labels: lables,
                        datasets: chartdata
                    };
                    $('#myTotalDept').remove();
                    $('#roundgraphDept').append('<canvas id="myTotalDept"></canvas>');
                    var ctx = $("#myTotalDept").get(0).getContext('2d');
                    var opt = {
                        responsive: true,
                        legend: {
                            position: 'top',
                        },
                        scales: {
                            yAxes: [{
                                ticks: {
                                    beginAtZero: true
                                }
                            }]
                        },
                        "hover": {
                            "animationDuration": 0
                        },
                        "animation": {
                            "duration": 1,
                            "onComplete": function () {
                                var chartInstance = this.chart,
                                  ctx = chartInstance.ctx;
                                   ctx.font = "10px Arial";          
                                // ctx.font = Chart.helpers.fontString(Chart.defaults.global.defaultFontSize, Chart.defaults.global.defaultFontStyle, Chart.defaults.global.defaultFontFamily);
                                ctx.textAlign = 'center';
                                ctx.textBaseline = 'bottom';

                                this.data.datasets.forEach(function (dataset, i) {
                                    var meta = chartInstance.controller.getDatasetMeta(i);
                                    meta.data.forEach(function (bar, index) {
                                        var data = dataset.data[index];
                                        ctx.fillText(data, bar._model.x, bar._model.y);
                                    });
                                });
                            },
                        },
                    };
                    var myNewChart5 = new Chart(ctx, {
                        type: "bar",
                        data: data,
                        options: opt,
                    });
                }
            });
        }

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

        function ClassDataBind(GroupId, GroupName) {
            $.ajax({
                type: "POST",
                url: "TotalPercentageAnalysis.aspx/ClassWiseStdPercGet",
                data: JSON.stringify({ "OrgId": OrgId, "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 tblClass = "";
                    var total = 0;
                    var finaltotal = 0;
                    Header[0] = ReHeader;
                    if (obj != "") {
                        Header[1] = " <h5 class='page-title' style='display:Block' id='Depart'><a href='#' onclick='HeaderDisplay(1)'>" + GroupName + "</a></h5>";

                        var newObj = {};
                        var keyCount = 0;
                        tblClass += "<tr>";
                        for (var item in obj[0]) {
                            var columnsIn = obj[0][item];
                            if (columnsIn.key === "GroupId") { continue; }
                            else if (columnsIn.key == "GroupTitle") { continue; }
                            else if (columnsIn.key == "GroupName" || columnsIn.key == "Class Name") {
                                newObj[keyCount++] = { "Class Name": "Total" };
                                tblClass += "<th>Class Name</th>";
                            }
                            else {
                                tblClass += "<th>" + columnsIn.key + "</th>";
                                newObj[keyCount] = {};
                                newObj[keyCount++][columnsIn.key] = 0;
                            }
                        }

                        tblClass += "<th>Total</th></tr>";
                        keyCount = 1;
                        $.each(obj, function (i, item) {
                            tblClass += "<tr>";
                            var groupId = "";
                            var groupname = "";
                            for (var key in item) {
                                if (item[key].key === "GroupId") {
                                    groupId = item[key].value;
                                }
                                if (item[key].key === "GroupName") {
                                    groupname = item[key].value;
                                }
                            }
                            for (var key in item) {

                                if (item[key].key !== "GroupId") {
                                    if (item[key].key === "GroupName") {
                                        if (item[key].value !== "null" && item[key].value !== undefined && item[key].value !== null) {
                                            tblClass += "<td><a onclick='DivisionDataBind(" + groupId + ",\"" + groupname + " \")'>" + item[key].value + "</a></td>";
                                        }
                                    }
                                    if (item[key].key !== "GroupTitle") {
                                        if (item[key].key !== "GroupName") {
                                            if (item[key].value === null || item[key].value === undefined) { item[key].value = 0; }
                                            tblClass += "<td>" + item[key].value + "</td>";

                                            if (item[key].key !== "Class Name" && item[key].key !== "GroupName") {
                                                if (item[key].value !== "null" && item[key].value !== undefined && item[key].value !== null) {
                                                    for (var key1 in newObj[keyCount]) {
                                                        if (item[key].key == key1) {
                                                            newObj[keyCount][key1] += parseInt(item[key].value)
                                                        }
                                                        keyCount++;
                                                    }
                                                    total += parseInt(item[key].value);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            tblClass += "<td>" + total + "</td></tr>";
                            keyCount = 1;
                            finaltotal += total;
                            total = 0;
                        });
                        tblClass += "<tr>";
                        for (var item in newObj) {
                            var columnsIn = newObj[item];
                            for (var key in columnsIn) {
                                if (key === "GroupId") { continue; }
                                else if (key == "GroupTitle") { continue; }
                                else if (key == "Class Name") {
                                    tblClass += "<th>" + columnsIn[key] + "</th>";
                                }
                                else {
                                    tblClass += "<th>" + columnsIn[key] + "</th>";

                                }
                            }
                        }
                        tblClass += "<th>" + finaltotal + "</th></tr>";
                    }

                    else { tblClass += "<tr><td colspan='8' class='record'>No records found..!!</td></tr>"; }
                    document.getElementById("tblClass").innerHTML = tblClass;
                    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";
                    document.getElementById("roundgraphdivDept").style.display = "none";
                    document.getElementById("roundgraphdivClass").style.display = "block";
                    statusId = 2;

                    var dataPoint = [];
                    var lables = [];
                    var chartdata = [];
                    var dataPoint1 = [];
                    var lables1 = [];
                    var chartdata1 = [];
                    var lbl = [];
                    var locationlbl = [];
                    var colcnt = 0, rowcnt = 0;
                    colcnt = $('#tblClass tr:first').find("th").length - 1;
                    rowcnt = $('#tblClass tr').length - 1;
                    $('#roundgraphdivClass').show();
                    $('#round1graphdivClass').show();
                    $('#tblClass tbody tr:not(:last-child)').each(function (index) {
                        $(this).find('th,td:not(:last-child)').each(function (index2) {
                            if ($(this).is('th')) {
                                if (index2 != 0 && index2 != colcnt) {
                                    //alert(index2 + ' ' + colcnt)
                                    //debugger;
                                    lables.push(this.innerHTML);
                                }
                            } else if ($(this).is('td')) {
                                if (index2 != 0) {
                                    dataPoint.push(this.innerHTML);
                                } else if (index2 == 0) {
                                    locationlbl.push(this.innerText);
                                }
                            }
                        });
                        if (lables.length > 0 && dataPoint.length > 0) {
                            chartdata.push({
                                label: locationlbl,
                              fillColor: "red",
                                strokeColor: "blue",
                                pointColor: "green",
                                backgroundColor: ["#FF6384", "#36A2EB", "#FFCE56", "#D35400", "#CD5C5C", "#cc65fe", "#196F3D", "#5499C7", "#E67E22",
                                  "#27AE60", "#F08080", "#996633", "#0000cc", "#FFA07A", "#16A085", "#512E5F", "#7D6608", "#1B4F72", "#008080",
                                  "#FF00FF", "#01DF01", "#ff0000", "#00ffff", "#cc6699", "#cccc00", "#993300", "#333399", "#ff99ff", "#006600", "#ffff00",
                                "#003366", "#00ccff", "#ff9900", "#cc0066", "#ccccff", "#660066", "#000000"],
                                borderWidth: 1,
                                data: dataPoint
                            });
                            dataPoint = [];
                            locationlbl = [];
                        }
                    });
                    var data = {
                        labels: lables,
                        datasets: chartdata
                    };
                    $('#myTotalClass').remove();
                    $('#roundgraphClass').append('<canvas id="myTotalClass"></canvas>');
                    var ctx = $("#myTotalClass").get(0).getContext('2d');
                    var opt = {
                        responsive: true,
                        legend: {
                            position: 'top',
                        },
                        scales: {
                            yAxes: [{
                                ticks: {
                                    beginAtZero: true
                                }
                            }]
                        },
                        "hover": {
                            "animationDuration": 0
                        },
                        "animation": {
                            "duration": 1,
                            "onComplete": function () {
                                var chartInstance = this.chart,
                                  ctx = chartInstance.ctx;
                                    ctx.font = "10px Arial";
                               // ctx.font = Chart.helpers.fontString(Chart.defaults.global.defaultFontSize, Chart.defaults.global.defaultFontStyle, Chart.defaults.global.defaultFontFamily);
                                ctx.textAlign = 'center';
                                ctx.textBaseline = 'bottom';

                                this.data.datasets.forEach(function (dataset, i) {
                                    var meta = chartInstance.controller.getDatasetMeta(i);
                                    meta.data.forEach(function (bar, index) {
                                        var data = dataset.data[index];
                                        ctx.fillText(data, bar._model.x, bar._model.y);
                                    });
                                });
                            },
                        },
                    };
                    var myNewChart5 = new Chart(ctx, {
                        type: "bar",
                        data: data,
                        options: opt,
                    });
                }
            });
        }
        function DivisionDataBind(GroupId, GroupName) {
            $.ajax({
                type: "POST",
                url: "TotalPercentageAnalysis.aspx/DivWiseStdPercGet",
                data: JSON.stringify({ "OrgId": OrgId, "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 total = 0;
                    var finaltotal = 0;
                    if (obj != "") {
                        Header[2] = " <h5 class='page-title' style='display:block'  id='classdiv'><a href='#' onclick='HeaderDisplay(2)'>" + GroupName + "</a></h5>";
                        var newObj = {};
                        var keyCount = 0;
                        tblDivision += "<tr>";
                        for (var item in obj[0]) {
                            var columnsIn = obj[0][item];
                            if (columnsIn.key === "GroupId") { continue; }
                            else if (columnsIn.key == "GroupTitle") { continue; }
                            else if (columnsIn.key == "GroupName" || columnsIn.key == "Division Name") {
                                newObj[keyCount++] = { "Division Name": "Total" };
                                tblDivision += "<th>Division Name</th>";
                            }
                            else {
                                tblDivision += "<th>" + columnsIn.key + "</th>";
                                newObj[keyCount] = {};
                                newObj[keyCount++][columnsIn.key] = 0;
                            }
                        }

                        tblDivision += "<th>Total</th></tr>";
                        keyCount = 1;
                        $.each(obj, function (i, item) {
                            tblDivision += "<tr>";
                            var groupId = "";
                            var groupname = "";
                            for (var key in item) {
                                if (item[key].key === "GroupId") {
                                    groupId = item[key].value;
                                }
                                if (item[key].key === "GroupName") {
                                    groupname = item[key].value;
                                }
                            }
                            for (var key in item) {

                                if (item[key].key !== "GroupId") {
                                    if (item[key].key === "GroupName") {
                                        if (item[key].value !== "null" && item[key].value !== undefined && item[key].value !== null) {
                                            tblDivision += "<td>" + item[key].value + "</td>";
                                        }
                                    }
                                    if (item[key].key !== "GroupTitle") {
                                        if (item[key].key !== "GroupName") {
                                            if (item[key].value === null || item[key].value === undefined) { item[key].value = 0; }
                                            tblDivision += "<td>" + item[key].value + "</td>";

                                            if (item[key].key !== "Division Name" && item[key].key !== "GroupName") {
                                                if (item[key].value !== "null" && item[key].value !== undefined && item[key].value !== null) {
                                                    for (var key1 in newObj[keyCount]) {
                                                        if (item[key].key == key1) {
                                                            newObj[keyCount][key1] += parseInt(item[key].value)
                                                        }
                                                        keyCount++;
                                                    }
                                                    total += parseInt(item[key].value);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            tblDivision += "<td>" + total + "</td></tr>";
                            keyCount = 1;
                            finaltotal += total;
                            total = 0;
                        });
                        tblDivision += "<tr>";
                        for (var item in newObj) {
                            var columnsIn = newObj[item];

                            for (var key in columnsIn) {
                                if (key === "GroupId") { continue; }
                                else if (key == "GroupTitle") { continue; }
                                else if (key == "Division Name") {
                                    tblDivision += "<th>" + columnsIn[key] + "</th>";
                                }
                                else {
                                    tblDivision += "<th>" + columnsIn[key] + "</th>";

                                }
                            }
                        }
                        tblDivision += "<th>" + finaltotal + "</th></tr>";
                    }

                    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";
                    document.getElementById("roundgraphdivDivision").style.display = "block";
                    document.getElementById("roundgraphdivClass").style.display = "none";

                    statusId = 3;

                    var dataPoint = [];
                    var lables = [];
                    var chartdata = [];
                    var dataPoint1 = [];
                    var lables1 = [];
                    var chartdata1 = [];
                    var lbl = [];
                    var locationlbl = [];
                    var colcnt = 0, rowcnt = 0;
                    colcnt = $('#tblDivision tr:first').find("th").length - 1;
                    rowcnt = $('#tblDivision tr').length - 1;
                    $('#roundgraphdivDivision').show();
                    $('#round1graphdivDivision').show();
                    $('#tblDivision tbody tr:not(:last-child)').each(function (index) {
                        $(this).find('th,td:not(:last-child)').each(function (index2) {
                            if ($(this).is('th')) {
                                if (index2 != 0 && index2 != colcnt) {
                                    //alert(index2 + ' ' + colcnt)
                                    //debugger;
                                    lables.push(this.innerHTML);
                                }
                            } else if ($(this).is('td')) {
                                if (index2 != 0) {
                                    dataPoint.push(this.innerHTML);
                                } else if (index2 == 0) {
                                    locationlbl.push(this.innerText);
                                }
                            }
                        });
                        if (lables.length > 0 && dataPoint.length > 0) {
                            chartdata.push({
                                label: locationlbl,
                                fillColor: "red",
                                strokeColor: "blue",
                                pointColor: "green",
                                backgroundColor: ["#FF6384", "#36A2EB", "#FFCE56", "#D35400", "#CD5C5C", "#cc65fe", "#196F3D", "#5499C7", "#E67E22",
                                  "#27AE60", "#F08080", "#996633", "#0000cc", "#FFA07A", "#16A085", "#512E5F", "#7D6608", "#1B4F72", "#008080",
                                  "#FF00FF", "#01DF01", "#ff0000", "#00ffff", "#cc6699", "#cccc00", "#993300", "#333399", "#ff99ff", "#006600", "#ffff00",
                                "#003366", "#00ccff", "#ff9900", "#cc0066", "#ccccff", "#660066", "#000000"],
                                borderWidth: 1,
                                data: dataPoint
                            });
                            dataPoint = [];
                            locationlbl = [];
                        }
                    });
                    var data = {
                        labels: lables,
                        datasets: chartdata
                    };
                    $('#myTotalDivision').remove();
                    $('#roundgraphDivision').append('<canvas id="myTotalDivision"></canvas>');
                    var ctx = $("#myTotalDivision").get(0).getContext('2d');
                    var opt = {
                        responsive: true,
                        legend: {
                            position: 'top',
                        },
                        scales: {
                            yAxes: [{
                                ticks: {
                                    beginAtZero: true
                                }
                            }]
                        },
                        "hover": {
                            "animationDuration": 0
                        },
                        "animation": {
                            "duration": 1,
                            "onComplete": function () {
                                var chartInstance = this.chart,
                                  ctx = chartInstance.ctx;
                                  ctx.font = "10px Arial";
                                //ctx.font = Chart.helpers.fontString(Chart.defaults.global.defaultFontSize, Chart.defaults.global.defaultFontStyle, Chart.defaults.global.defaultFontFamily);
                                ctx.textAlign = 'center';
                                ctx.textBaseline = 'bottom';

                                this.data.datasets.forEach(function (dataset, i) {
                                    var meta = chartInstance.controller.getDatasetMeta(i);
                                    meta.data.forEach(function (bar, index) {
                                        var data = dataset.data[index];
                                        ctx.fillText(data, bar._model.x, bar._model.y);
                                    });
                                });
                            },
                        },
                    };
                    var myNewChart5 = new Chart(ctx, {
                        type: "bar",
                        data: data,
                        options: opt,
                    });
                }
            });
        }

        function BackOrgFunction() {
            if (statusId == 2) {
                document.getElementById("DepartHead").style.display = "block";
                document.getElementById("ClassHead").style.display = "none";
                document.getElementById("DivisionHead").style.display = "none";
                document.getElementById("roundgraphdivDept").style.display = "block";
                document.getElementById("roundgraphdivClass").style.display = "none";
                document.getElementById("roundgraphdivDivision").style.display = "none";
                $("#Depart").hide();
                statusId--;
            }
            else if (statusId == 3) {
                document.getElementById("DepartHead").style.display = "none";
                document.getElementById("ClassHead").style.display = "block";
                document.getElementById("DivisionHead").style.display = "none";
                document.getElementById("roundgraphdivDept").style.display = "none";
                document.getElementById("roundgraphdivClass").style.display = "block";
                document.getElementById("roundgraphdivDivision").style.display = "none";
                $("#classdiv").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="page-header row mb20">
                <div class="col-xl-12 col-sm-12 col-xs-12 border-bottom-inline padd-0">
                    <div class="col-md-12 ptb12 d-inline-flex">
                        <span class='btn btn-home btn-icon' onclick='DashBoard()' title='home'><span><i class='material-icons'>home</i></span></span>
                        <label class="header-topic justify-content-center" id="HeaderLabel"></label>
                        <input type="button" value="&#xf3e5;" id="bntBackOrg" onclick="BackOrgFunction()" skinid="0" class="float-right btn btn-back btn-icon fas" />
                    </div>
                    <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 Student Count</h3>
                            <div class="center-block">
                                <div class="col-md-9 pTop15" id="roundgraphdivDept" style="display: none">
                                    <div class="panel panel-info">
                                        <div class="panel-heading">
                                            <b><span id="spnOLDRound1"></span></b>
                                        </div>
                                        <div id="roundgraphDept" class="overflow-scroll">
                                            <canvas id="myTotalDept"></canvas>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <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 Student Count</h3>
                            <div class="center-block">
                                <div class="col-md-9  pTop15" id="roundgraphdivClass" style="display: none">
                                    <div class="panel panel-info">
                                        <div class="panel-heading">
                                            <b><span id="spnOLDRound2"></span></b>
                                        </div>
                                        <div id="roundgraphClass" class="overflow-scroll">
                                            <canvas id="myTotalClass"></canvas>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <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 Student Count</h3>
                            <div class="center-block">
                                <div class="col-md-9  pTop15" id="roundgraphdivDivision" style="display: none">
                                    <div class="panel panel-info">
                                        <div class="panel-heading">
                                            <b><span id="spnOLDRound3"></span></b>
                                        </div>
                                        <div id="roundgraphDivision">
                                            <canvas id="myTotalDivision"></canvas>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <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>
