
$(document).ready(function () {

    GetExamSubGroup();
    GetClass();

    //getstudentDetail();
    $('#ctl00_CP_HostelMasterTabContainer_AttedanceTabPanel_AttendanceTypeDropDownList').empty();
    $('#Atddiv').hide();
    $('#Subjectatdiv').hide();
});

function GetClass() {
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetClass",
        data: '{}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            //var datas = "[" + (data.d) + "]";
            $('#ClassDropdown').html(data.d);
            $(".select-dropdown").remove();
            //$("#ClassDropdown").css("display", "block");
            //$("#ClassDropdown").css("background-color", "#3f51b5");
            getstudentDetail();

            getHealthCheckupStudentGet();

            getStudentSibling();
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function getstudentDetail() {

    var AcademicId = $("#ClassDropdown").val();
    $.ajax({

        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/getstudentDetail",
        data: '{}',
        data: "{'AcademicId':'" + AcademicId + "'}",
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {

            var datas = $.parseJSON(data.d);
            if (datas.ActivateSUId == true) {
                $("#SUIDLabel").html(datas.SUId);
            }
            else {
                $("#SUIdSpan").hide();
            }
            $("#NameLabel").html(datas.StudentName);
            $("#BatchNameLabel").html(datas.AcademicYear);
            $("#ClassDivisionLabel").html(datas.ClassDiv);
            $("#CodeLabel").html(datas.Code);
            $("#RollNoLabel").html(datas.RollNo);
            $("#TeacherFullNameLabel").html(datas.TeacherFullName);
            $("#TeacherDesignationLabel").html(datas.TeacherDesignation);
            $("#TeacherQualificationLabel").html(datas.TeacherQualification);
            $("#AdmissionStandardLabel").html(datas.AdmissionStandard);
            $("#AdmissionDateLabel").html(datas.AdmissionDate);
            $("#PreviousSchoolLabel").html(datas.PreviousSchool);
            $("#StudentCategoryLabel").html(datas.StudentAdmissionCategory);
            $("#RepeaterLabel").html(datas.RepeatCount);
            $("#IsTransferLabel").html(datas.IsTransfer);
            $("#IsCertificateHolderCheckBox").html(datas.IsCertificateHolder);
            $("#TransferFromLabel").html(datas.TransferFrom);
            $("#IsCertificateHolderLabel").html(datas.CertificateName);
            $("#IsTFWSLabel").html(datas.TransferFrom);
            $("#MaritalStatusLabel").html(datas.MaritalStatus);
            $("#SSCBoardLabel").html(datas.SSCBoard);
            $("#SSCSchooolLabel").text(datas.SSCSchool);
            $("#SSCPassingYearLabel").text(datas.SSCPassingYear);
            $("#SSCOutOfMarksLabel").html(datas.SSCOutOfMarks);
            $("#SSCObtainMarksLabel").html(datas.SSCObtainMarks);
            $("#SSCMathMarksLabel").html(datas.SSCMathMarks);
            $("#SSCMathOutOfMarksLabel").html(datas.SSCMathOutOfMarks);
            $("#SSCPercentageLabel").html(datas.SSCPercentage);
            $("#HSCBoardLabel").html(datas.HSCBoard);
            $("#HSCSchoolLabel").html(datas.HSCSchool);
            $("#HSCPassingYearLabel").html(datas.HSCPassingYear);
            $("#HSCObtainMarksLabel").html(datas.HSCObtainMarks);
            $("#HSCPercentageLabel").html(datas.HSCPercentage);
            $("#HSCPhysicsMarksLabel").html(datas.HSCPhysicsMarks);
            $("#HSCPhysicsOutOfMarksLabel").html(datas.HSCPhysicsOutOfMarks);
            $("#HSCChemistryMarksLabel").html(datas.HSCChemistryMarks);
            $("#HSCChemistryOutOfMarksLabel").html(datas.HSCChemistryOutOfMarks);
            $("#HSCMathMarksLabel").html(datas.HSCMathMarks);
            $("#HSCMathOutOfMarksLabel").html(datas.HSCMathOutOfMarks);
            $("#HSCBiologyMarksLabel").html(datas.HSCBiologyMarks);
            $("#HSCBiologyOutOfMarksLabel").html(datas.HSCBiologyOutOfMarks);
            $("#PCMMarksLabel").html(datas.PCMMarks);
            $("#PCBMarksLabel").html(datas.PCBMarks);
            $("#JEERollNoLabel").html(datas.JEERollNo);
            $("#JEEMeritNoLabel").html(datas.JEEMeritNo);
            $("#JEEMeritMarksLabel").html(datas.JEEMeritMarks);
            $("#JEEOutOfMarksLabel").html(datas.JEEOutOfMarks);
            $("#DiplomaBoardLabel").html(datas.DiplomaBoard);
            $("#DiplomaCollegeLabel").html(datas.DiplomaCollege);
            $("#DiplomaPassingYearLabel").text(datas.DiplomaPassingYear);
            $("#DiplomaObtainMarksLabel").html(datas.DiplomaObtainMarks);
            $("#DiplomaPercentageLabel").html(datas.DiplomaPercentage);
            $("#DiplomaOutOfMarksLabel").html(datas.DiplomaOutOfMarks);
            $("#ApplicationNoLabel").html(datas.ApplicationNo);
            $("#AdmissionRoundLabel").html(datas.AdmissionRound);
            $("#DateOfBirthLabel").html(datas.DateOfBirth);
            $("#BirthDateInWordLabel").html(datas.BirthDateInWord);
            $("#BirthPlaceLabel").html(datas.BirthPlace);
            $("#BirthDistrictLabel").html(datas.BirthDistrict);
            $("#GenderLabel").html(datas.Gender);
            $("#ReligionLabel").html(datas.Religion);
            $("#FamilyCasteLabel").html(datas.FamilyCast);
            $("#CategoryLabel").html(datas.CasteCategory);
            $("#MotherTongueLabel").html(datas.MotherTongue);
            $("#NationalityLabel").html(datas.Nationality);
            $("#ParentEmailLabel").html(datas.ParentEmail);
            $("#ParentContactNoLabel").html(datas.ParentContactNo);
            $("#StudentEmailLabel").html(datas.StudentEmail);
            $("#StudentContactNoLabel").html(datas.StudentContactNo);
            $("#WhatsappContactNumberLabel").html(datas.WhatsAppContactNo);
            $("#PresentAddressLabel").html(datas.PresentAddress);
            $("#PresentCityLabel").html(datas.PresentCity);
            $("#PresentStateLabel").html(datas.PresentState);
            $("#PresentZipCodeLabel").html(datas.PresentZipCode);
            $("#PresentContactNoLabel").html(datas.PresentContactNo);
            $("#EmergencyAddressLabel").html(datas.EmergencyAddress);
            $("#EmergencyCityLabel").html(datas.EmergencyCity);
            $("#EmergencyStateLabel").html(datas.EmergencyState);
            $("#EmergencyZipCodeLabel").html(datas.EmergencyZipCode);
            $("#EmergencyContactNoLabel").html(datas.EmergencyContactNo);
            $("#PermanentAddressLabel").html(datas.PermanentAddress);
            $("#PermanentCityLabel").html(datas.PermanentCity);
            $("#PermanentStateLabel").html(datas.PermanentState);
            $("#PermanentZipCodeLabel").html(datas.PermanentZipCode);
            $("#PermanentContactNoLabel").html(datas.PermanentContactNo);
            $("#BusRouteLabel").html(datas.BusRoute);
            $("#Label24").html(datas.BusRouteDestination);
            $("#Label33").html(datas.VehicleName);
            $("#Label34").html(datas.VehicleRegistrationNumber);
            $("#Label35").html(datas.TypeOfVehicle);
            $("#BusRouteDestinationLabel").html(datas.DriverName);
            $("#Label21").html(datas.DriverMobileNo);
            $("#Label22").html(datas.ConductorName);
            $("#Label23").html(datas.ConductorMobileNo);
            $("#Label25").html(datas.DropRoute);
            $("#Label30").html(datas.DropDestination);
            $("#Label36").html(datas.DropVehicleName);
            $("#Label37").html(datas.DropVehicleRegistrationNumber);
            $("#Label38").html(datas.DropTypeOfVehicle);
            $("#Label26").html(datas.DropRouteDriverName);
            $("#Label27").html(datas.DropRouteDriverMobileNo);
            $("#Label28").html(datas.DropRouteConductorName);
            $("#Label29").html(datas.DropRouteConductorMobileNo);
            $("#UidnumberLabel").html(datas.UIDNumber);
            $("#AdhaarnumberLabel").html(datas.AdhaarNumber);
            $("#FatherNameLabel").html(datas.FatherName);
            $("#FatherQualificationLabel").html(datas.FatherQualification);
            $("#FatherOccupationLabel").html(datas.FatherOccupation);
            $("#FatherContactNoLabel").html(datas.FatherContactNo);
            $("#FatherMailLabel").html(datas.FatherMail);
            $("#FatherOfficeAddressLabel").html(datas.FatherOfficeAddress);
            $("#FatherDesignationLabel").html(datas.FatherDesignation);
            $("#FatherOrganizationLabel").html(datas.FatherOrganization);
            $("#Label5").html(datas.MotherName);
            $("#Label8").text(datas.MotherQualification);
            $("#Label9").html(datas.MotherOccupation);
            $("#Label10").html(datas.MotherContactNo);
            $("#Label11").html(datas.MotherMail);
            $("#Label12").html(datas.MotherOfficeAddress);
            $("#MotherDesignationLabel").html(datas.MotherDesignation);
            $("#MotherOrganizationLabel").html(datas.MotherOrganization);
            $("#RelationshipLabel").html(datas.RelationShip);
            $("#RelativeNameLabel").html(datas.RelativeName);
            $("#RelativeQualificationLabel").html(datas.RelativeQualification);
            $("#RelativeOccupationLabel").html(datas.RelativeOccupation);
            $("#RelativeContactNoLabel").html(datas.RelativeContactNo);
            $("#RelativeMailLabel").html(datas.RelativeMail);
            $("#RelativeOfficeAddressLabel").html(datas.RelativeOfficeAddress);
            $("#RelativeDesignationLabel").html(datas.RelativeDesignation);
            $("#RelativeOrganizationLabel").html(datas.RelativeOrganization);
            $("#Hostel").html(datas.UIDNumber);
            $("#AdhaarnumberLabel").html(datas.AdhaarNumber);
            $("#FatherNameLabel").html(datas.FatherName);
            $("#FatherQualificationLabel").html(datas.FatherQualification);
            $("#FatherOccupationLabel").html(datas.FatherOccupation);
            $("#FatherContactNoLabel").html(datas.FatherContactNo);
            $("#FatherMailLabel").html(datas.FatherMail);
            $("#FatherOfficeAddressLabel").html(datas.FatherOfficeAddress);
            $("#RelationshipLabel").html(datas.RelationShip);
            $("#RelativeNameLabel").html(datas.RelativeName);
            $("#RelativeQualificationLabel").html(datas.RelativeQualification);
            $("#RelativeOccupationLabel").html(datas.RelativeOccupation);
            $("#RelativeContactNoLabel").html(datas.RelativeContactNo);
            $("#RelativeMailLabel").html(datas.RelativeMail);
            $("#RelativeOfficeAddressLabel").html(datas.RelativeOfficeAddress);
            $("#SiblingName1Label").html(datas.SiblingName1);
            $("#SiblingInstitue1Label").html(datas.SiblingInstitue1);
            $("#SiblingClass1Label").html(datas.SiblingClass1);
            $("#SiblingAge1Label").html(datas.SiblingAge1);
            $("#SiblingRelation1Label").html(datas.SiblingRelation1);
            $("#SiblingName2Label").html(datas.SiblingName2);
            $("#SiblingInstitue2Label").html(datas.SiblingInstitue2);
            $("#SiblingClass2Label").html(datas.SiblingClass2);
            $("#SiblingAge2Label").html(datas.SiblingAge2);
            $("#SiblingRelation2Label").html(datas.SiblingRelation2);
            $("#SiblingName3Label").html(datas.SiblingName3);
            $("#SiblingInstitue3Label").html(datas.SiblingInstitue3);
            $("#SiblingClass3Label").html(datas.SiblingClass3);
            $("#SiblingAge3Label").html(datas.SiblingAge3);
            $("#SiblingRelation3Label").html(datas.SiblingRelation3);
            $("#BloodGroupLabel").text(datas.BloodGroup);
            $("#IdentificationLabel").html(datas.IdentificationMark);
            $("#FamilyDoctorNameLabel").html(datas.FamilyDoctorName);
            $("#FamilyDoctorContactNoLabel").html(datas.FamilyDoctorContactNo);
            $("#IsPysicalDeformityLabel").html(datas.IsPysicalDeformity);
            $("#PysicalDeformityRemarkLabel").html(datas.PysicalDeformityRemark);
            $("#IsMajorIllnessLabel").html(datas.IsMajorIllness);
            $("#MajorIllnessRemarkLabel").html(datas.MajorIllnessRemark);
            $("#IsAllergyLabel").html(datas.IsAllergy);
            $("#AllergyRemarkLabel").html(datas.AllergyRemark);
            $("#IsPastHistoryLabel").html(datas.IsPastHistory);
            $("#PastHistoryRemarkLabel").html(datas.PastHistoryRemark);
            $("#HostelLabel").html(datas.Hostel);
            $("#RoomNoLabel").html(datas.RoomNo);
            $("#WardenNameLabel").html(datas.WardenName);
            $("#WardenPhoneNoLabel").html(datas.WardenPhoneNo);
            $("#WardenExtNoLabel").html(datas.WardenExtNo);
            $("#WardenMobileNoLabel").html(datas.WardenMobileNo);
            $("#AssignedRoomByLabel").html(datas.AssignedRoomBy);
            $("#AssignedRoomByPhoneNoLabel").html(datas.AssignedRoomByPhoneNo);
            $("#AssignedRoomByExtNoLabel").html(datas.AssignedRoomByExtNo);
            $("#AssignedRoomByMobileNoLabel").html(datas.AssignedRoomByMobileNo);
            $("#HouseLabel").html(datas.House);
            $("#BankbranchLabel").html(datas.BankBranch);
            $("#AccountNumbeLabel").html(datas.BankAccountNumber);
            $("#BankNameLabel").html(datas.BankName);
            $("#IFSCCodeLabel").html(datas.BankIFSCCode);
            $("#PassportNumberLabel").text(datas.PassportNumber);
            $("#PassportTypeLabel").html(datas.PassportType);
            $("#PassportCountryCodeLabel").html(datas.PassportCountryCode);
            $("#Class9Label").html(datas.Class9BoardRegistrationNumber);
            $("#Class11Label").html(datas.Class11BoardRegistrationNumber);
            $("#ClubLabel").html(datas.ClubName);
            $("#StudentGroupLabel").html(datas.StudentGroup);
            $("#StudentOtherGroupLabel").html(datas.StudentOtherGroup);
            $("#CustomTagLabel").html(datas.CustomTag);
            $("#CustomGroupLabel").html(datas.CustomGroup);

            $("#WhatsappContactNoLabel").html(datas.WhatsAppContactNo);
            if (datas.StudentPhoto != '')
                $("#StudentPhotoImg").attr('src', 'data:image/jpg;base64,' + datas.StudentPhoto);
            else
                $("#StudentPhotoImg").attr('src', '../../Images/BoyNoImage.png');
            if (datas.TeacherPhoto != '')
                $("#TeacherPhotoImg").attr('src', 'data:image/jpg;base64,' + datas.TeacherPhoto);
            else
                $("#TeacherPhotoImg").attr('src', '../../Images/BoyNoImage.png');
            if (datas.FatherPhoto != '')
                $("#FatherPhotoImg").attr('src', 'data:image/jpg;base64,' + datas.FatherPhoto);
            else
                $("#FatherPhotoImg").attr('src', '../../Images/BoyNoImage.png');
            if (datas.RelativePhoto != '')
                $("#RelativePhotoImg").attr('src', 'data:image/jpg;base64,' + datas.RelativePhoto);
            else
                $("#RelativePhotoImg").attr('src', '../../Images/BoyNoImage.png');
            if (datas.MotherPhoto != '')
                $("#MotherPhotoImg").attr('src', 'data:image/jpg;base64,' + datas.MotherPhoto);
            else
                $("#MotherPhotoImg").attr('src', '../../Images/GirlNoImage.png');


            $("#PreviousStandardLabel").html(datas.PreviousStandard);

            if (datas.RepeatCount > 1) {
                $("#RepeaterLabel").html('<b>Repeater : </b>' + datas.RepeatCount);
            }
            else {
                $("#RepeaterLabel").html('');
            }
            if (datas.InactiveDate = " 01/01/0001") {
                $("#InactiveDateLabel").html('');
            }
            else {
                $("#InactiveDateLabel").html(datas.InactiveDate);
            }
            if (datas.LeftDate == "01/01/0001") {
                $("#LeftDateLabel").html('');
            }
            else {
                $("#LeftDateLabel").html(datas.LeftDate);
            }
            if (datas.AdmissionDate == "01/01/0001")
                $("#AdmissionDateLabel").html('');
            else
                $("#AdmissionDateLabel").html(datas.AdmissionDate);
            $("#LeftStandardLabel").html(datas.LeftStandard);
            $("#LcNumberLabel").html(datas.LCNumber);
            if (datas.LCDate = " 01/01/0001")
                $("#LcDateLabel").html('');
            else
                $("#LcDateLabel").html(datas.LCDate);
            if (datas.PassportExpiryDate == " 01/01/0001") {
                $("#PassportExpiryDateLabel").html('');
            }
            else {
                $("#PassportExpiryDateLabel").html(datas.PassportExpiryDate);
            }
            if (datas.PassportIssueDate == " 01/01/0001")
                $("#PassportIssueDateLabel").html('');
            else
                $("#PassportIssueDateLabel").html(datas.PassportIssueDate);
            if (datas.IsDisplayCollegeDetail == true) {
                $('#CollegeAdmissonDetailDiv').show();
            }
            else {
                $('#CollegeAdmissonDetailDiv').hide();
            }
            if (datas.IsDisplaySSCResultDDetail == true)
                $('#SSCresultdetailDiv').show();
            else
                $('#SSCresultdetailDiv').hide();
            if (datas.IsDisplayCollegeDetail == true) {
                $('#CollegeAdmissonDetailDiv').show();
            }
            else {
                $('#CollegeAdmissonDetailDiv').hide();
            }
            if (datas.IsDisplayHSCResultDetail == true)
                $('#HSCResultDetailDiv').show();
            else
                $('#HSCResultDetailDiv').hide();
            if (datas.IsDisplayJeeDetail == true)
                $('#JeeDetailDiv').show();
            else
                $('#JeeDetailDiv').hide();
            if (datas.IsDisplayDiplomaDetail == true)
                $('#DiplomaDetailDiv').show();
            else
                $('#DiplomaDetailDiv').hide();
            if (datas.IsDisplayTransportDetail == true)
                $('#TransportDetailDiv').show();
            else
                $('#TransportDetailDiv').hide();
            if (datas.IsDisplayGOVREGNoDetail == true)
                $('#GovRegDetailDiv').show();
            else
                $('#GovRegDetailDiv').hide();
            if (datas.IsDisplayFamilyDetail == true)
                $('#FamilyDetailDiv').show();
            else
                $('#FamilyDetailDiv').hide();

            if (datas.IsDisplaySiblingDetail == false) {

                $('#SiblingDetailDiv').hide();
            }
            else {
                $('#SiblingDetailDiv').show();
            }

            if (datas.IsDisplayHealthDetail == false)
                $('#HealthDetailDiv').hide();
            else
                $('#HealthDetailDiv').show();

            if (datas.IsDisplayClubDetail == false)
                $('#ClubDetailDiv').hide();

            else
                $('#ClubDetailDiv').show();
            if (datas.IsDisplayHostelDetail == true)
                $('#HostelDetailsDiv').show();
            else
                $('#HostelDetailsDiv').hide();
            if (datas.IsDisplayBankDetail == true)
                $('#BankDetailDiv').show();
            else
                $('#BankDetailDiv').hide();
            if (datas.IsDisplayPassportDetail == true)
                $('#PassportDetailDiv').show();
            else
                $('#PassportDetailDiv').hide();
            if (datas.IsDisplayCBSEREGDetail == true)
                $('#CBSERegDetailDiv').show();
            else
                $('#CBSERegDetailDiv').hide();
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}
function getExamDetail() {
    $('#dvExamGridDiv').css('text-align', 'center');
    var AcademicId = $('#ClassDropdown').val();
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/getExamDetail",
        data: '{"AcademicId":"' + AcademicId + '"}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            window.setTimeout(function () {
                var datas = $.parseJSON(data.d);
                if (datas.EmpGrid == '') {
                    $('#dvExamGridDiv').html('<tr><td colspan="9">No Record found !</td><tr>');
                }
                else {
                    $('#dvExamGridDiv').html(datas.EmpGrid);

                }
                $('#ctl00_CP_HostelMasterTabContainer_AttedanceTabPanel_AttendanceTypeDropDownList').empty();
                $('#Atddiv').hide();
                $('#Subjectatdiv').hide();
            }, 500);
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function SelectResult(obj, ExamId) {
    var AcademicId = $('#ClassDropdown').val();

    $.ajax({

        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/SelectResult",
        data: '{"ExamId":"' + ExamId + '", "AcademicId":"' + AcademicId + '"}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            var datas = $.parseJSON(data.d)
            openpopup();
            if (datas.ResultGrid == '') {

                $('#StudentresultDiv').show();
                $('#dvstudentresultGridDiv').html('<tr><td colspan="9">No Record found !</td><tr>');
            }
            else {
                $('#StudentresultDiv').show();
                $('#dvstudentresultGridDiv').html(datas.ResultGrid);
            }
            $('#ctl00_CP_HostelMasterTabContainer_AttedanceTabPanel_AttendanceTypeDropDownList').empty();
            var dataPoint = [];
            var lables = [];
            var chartdata = [];
            var dataPoint1 = [];
            var lables1 = [];
            var chartdata1 = [];
            var lbl = [];
            var locationlbl = [];
            var colcnt = 0;
            //colcnt = $('#dvstudentresultGridDiv tbody th').length - 1;
            //$('#roundgraphdivPerformance').show();
            $('#dvstudentresultGridDiv tr').each(function (index) {
                if (index >= 0) {
                    $(this).find('td').each(function (index2) {
                        if (index2 == 0) {
                            if ($(this).is('td')) {
                                lables.push(this.innerHTML);
                                locationlbl.push(this.innerText);
                            }
                        }
                        else if (index2 == 3) {
                            if ($(this).is('td')) {
                                debugger;
                                dataPoint.push(this.innerText);
                            }
                        }
                        $("table.tr").not(this).hide();
                    });
                }
            });
            console.log(dataPoint);
            if (lables.length > 0 && dataPoint.length > 0) {
                chartdata.push({
                    label: locationlbl.slice(0, locationlbl.length),
                    fillColor: "rgba(220,220,220,0.2)",
                    strokeColor: "rgba(220,220,220,1)",
                    pointColor: "rgba(220,220,220,1)",
                    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.slice(0, dataPoint.length)

                });
                //dataPoint = [];
                // locationlbl = [];
            }
            var data = {
                labels: locationlbl.slice(0, locationlbl.length),
                datasets: chartdata
            };
            $('#mySubjectPerformance').remove();
            $('#dvresultpopup .modal-body').append('<canvas id="mySubjectPerformance" style="width:800px;padding-top: 40px"></canvas>');
            var ctx = $("#mySubjectPerformance").get(0).getContext('2d');
            var opt = {
                responsive: false,
                legend: false,
                scales: {
                    yAxes: [{
                        ticks: {
                            beginAtZero: true,
                            fontSize: 10
                        }
                    }],
                    xAxes: [{
                        ticks: {
                            beginAtZero: true,
                            fontSize: 10
                        }
                    }]
                },
                "hover": {
                    "animationDuration": 0
                },
                "animation": {
                    "duration": 1,
                    "onComplete": function () {
                        var chartInstance = this.chart,
                        ctx = chartInstance.ctx;
                        ctx.font = "1px Arial";
                        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,
            });

            $('#Atddiv').hide();
            $('#Subjectatdiv').hide();

        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function GetExamDetailList(ExamId, AcademicId) {
    //alert("hello");
    var obj = {
        "AcademicId": AcademicId,
        "ExamId": ExamId
    };
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/Student360View.aspx/GetSubjectWiseExamList",
        data: JSON.stringify(obj),
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            //alert(data.d);
            openpopup1();
            $('#StudentExamDetailsdiv').innerHTML = data.d;
            if (data.d != '') {

                $('#ctl00_CP_HostelMasterTabContainer_AssesmentTabPanel_StudentExamDetailsdiv').css('display', '');
                $('#ctl00_CP_HostelMasterTabContainer_AssesmentTabPanel_StudentExamDetailsdiv').html(data.d);
                var dataPoint = [];
                var lables = [];
                var chartdata = [];
                var dataPoint1 = [];
                var lables1 = [];
                var chartdata1 = [];
                var lbl = [];
                var locationlbl = [];
                var colcnt = 0;
                colcnt = $('#ExamDataTbl tbody th').length - 1;
                //$('#roundgraphdivPerformance').show();
                $('#ExamDataTbl tbody tr').each(function (index) {
                    if (index >= 2) {
                        $(this).find('td').each(function (index2) {
                            if (index2 == 0) {
                                if ($(this).is('td')) {
                                    lables.push(this.innerHTML);
                                    locationlbl.push(this.innerText);
                                }
                            }
                            else if (index2 == 2) {
                                if ($(this).is('td')) {
                                    debugger;
                                    dataPoint.push(this.innerText);
                                }
                            }
                            $("table.tr").not(this).hide();
                        });
                    }
                });
                console.log(dataPoint);
                if (lables.length > 0 && dataPoint.length > 0) {
                    chartdata.push({
                        label: locationlbl.slice(0, locationlbl.length),
                        fillColor: "rgba(220,220,220,0.2)",
                        strokeColor: "rgba(220,220,220,1)",
                        pointColor: "rgba(220,220,220,1)",
                        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.slice(0, dataPoint.length)

                    });
                    //dataPoint = [];
                    // locationlbl = [];
                }
                var data = {
                    labels: locationlbl.slice(0, locationlbl.length),
                    datasets: chartdata
                };
                $('#mySubjectPerformance').remove();
                $('#ctl00_CP_HostelMasterTabContainer_AssesmentTabPanel_StudentExamDetailsdiv').append('<canvas id="mySubjectPerformance" style="width:800px;padding-top: 40px"></canvas>');
                var ctx = $("#mySubjectPerformance").get(0).getContext('2d');
                var opt = {
                    responsive: false,
                    legend: false,
                    scales: {
                        yAxes: [{
                            ticks: {
                                beginAtZero: true,
                                fontSize: 10
                            }
                        }],
                        xAxes: [{
                            ticks: {
                                beginAtZero: true,
                                fontSize: 10
                            }
                        }]
                    },
                    "hover": {
                        "animationDuration": 0
                    },
                    "animation": {
                        "duration": 1,
                        "onComplete": function () {
                            var chartInstance = this.chart,
                            ctx = chartInstance.ctx;
                            ctx.font = "1px Arial";
                            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,
                });
            }
            else {
                $("#ctl00_CP_HostelMasterTabContainer_AssesmentTabPanel_StudentExamDetailsdiv").css('display', 'none');
                $('#ctl00_CP_HostelMasterTabContainer_AssesmentTabPanel_StudentExamDetailsdiv').innerHTML = "<table id='ExamDataTbl' class='table table-striped table-bordered table-hover'><tbody><tr><td>No Records Found !!</td></tr></tbody>";
            }


        }
    });
}
function SetAll() {

    $('.numbersOnly').focusin(function () {

        $('.tooltip1').remove();
        //debugger;
        var title = $(this).attr('title');
        var t1 = "";
        var t2 = "";
        t1 = $(this).closest(".max_obtain_mark").find(".MaxMarks").html();
        t2 = $(this).closest(".max_obtain_mark").find(".ObtainMarks").html();

        title = t1 + ' | ' + t2;
        var position = $(this).offset();
        var top = parseInt(position.top) + 22;
        var left = parseInt(position.left);
        $('<p class="tooltip1" style="left:' + left + 'px;top:' + top + 'px"></p>')
        .text(title)
        .appendTo('body')
        .fadeIn('slow');

    }).mouseleave(function () {
        $(this).attr('title', $(this).data('tipText'));
        $('.tooltip1').remove();
    });

}
function GetActivityDetails() {
    var AcademicId = $('#ClassDropdown').val();
    $('#dvActivityGridDiv').css('text-align', 'center');
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetActivityDetails",
        data: '{"AcademicId":"' + AcademicId + '"}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            window.setTimeout(function () {
                var datas = $.parseJSON(data.d);
                if (datas.activitygrid == '') {
                    $('#dvActivityGridDiv').html('<tr><td colspan="9">No Record found !</td><tr>');
                }
                else {
                    $('#dvActivityGridDiv').html(datas.activitygrid);

                }
                $('#ctl00_CP_HostelMasterTabContainer_AttedanceTabPanel_AttendanceTypeDropDownList').empty();
                $('#Atddiv').hide();
                $('#Subjectatdiv').hide();
                GetbehaviourDeatil();
                GetEventDetails();
            }, 500);
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function GetbehaviourDeatil() {
    var AcademicId = $('#ClassDropdown').val();

    $('#dvBehaviourGridDiv').css('text-align', 'center');
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetbehaviourDeatil",
        data: '{"AcademicId":"' + AcademicId + '"}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            window.setTimeout(function () {
                var datas = $.parseJSON(data.d);
                if (datas.behaviourgrid == '') {
                    $('#dvBehaviourGridDiv').html('<tr><td colspan="9">No Record found !</td><tr>');
                }
                else {
                    $('#dvBehaviourGridDiv').html(datas.behaviourgrid);
                }
                $('#ctl00_CP_HostelMasterTabContainer_AttedanceTabPanel_AttendanceTypeDropDownList').empty();
                $('#Atddiv').hide();
                $('#Subjectatdiv').hide();
            }, 500);
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function GetFeeDeatil() {
    var AcademicId = $('#ClassDropdown').val();
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetFeeDeatil",
        data: '{"AcademicId":"' + AcademicId + '"}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            $('#ctl00_CP_HostelMasterTabContainer_AttedanceTabPanel_AttendanceTypeDropDownList').empty();
            $('#Atddiv').hide();
            $('#Subjectatdiv').hide();

            window.setTimeout(function () {
                var datas = $.parseJSON(data.d);

                if (datas.Feegrid == '') {
                    $('#dvFeeGridDiv').html('<tr><td colspan="10">No Record found !</td><tr>');
                    $('#dvReceiptGridDiv').html('<tr><td colspan="9">No Record found !</td><tr>');
                    $('#dvFeeCancelGridDiv').html('<tr><td colspan="9">No Record found !</td><tr>');
                    $('#dvChargeListGridDiv').html('<tr><td colspan="7">No Record found !</td><tr>');
                    $('#dvDepositAdjustmentGridDiv').html('<tr><td colspan="7">No Record found !</td><tr>');
                    $('#dvDepositRefundGridDiv').html('<tr><td colspan="6">No Record found !</td><tr>');
                }
                else {
                    $('#dvFeeGridDiv').html(datas.Feegrid);
                    getReceiptList();
                    GetCancelReciptlist();
                    GetChargeReceiptViewList();
                    GetDepositAdjustmentViewList();
                    GetDepositRefundViewList();
                }

            }, 500);
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}
function getReceiptList() {
    var AcademicId = $('#ClassDropdown').val();
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/getReceiptList",
        data: '{"AcademicId":"' + AcademicId + '"}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            window.setTimeout(function () {
                var datas = $.parseJSON(data.d)
                if (datas.Receiptgrid == '') {
                    $('#dvReceiptGridDiv').html('<tr><td colspan="9">No Record found !</td><tr>');
                }
                else {
                    $('#dvReceiptGridDiv').html(datas.Receiptgrid)
                }

            }, 500);
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function GetAttedanceType() {
    // alert("hi");
    var AcademicId = $('#ClassDropdown').val();

    $('#ctl00_CP_HostelMasterTabContainer_AttedanceTabPanel_AttendanceTypeDropDownList').empty();
    $('#Atddiv').hide();
    $('#Subjectatdiv').hide();
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetAttedanceType",
        data: '{"AcademicId":"' + AcademicId + '"}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            window.setTimeout(function () {

                var ddlCustomers = $("#ctl00_CP_HostelMasterTabContainer_AttedanceTabPanel_AttendanceTypeDropDownList");
                $('#ctl00_CP_HostelMasterTabContainer_AttedanceTabPanel_AttendanceTypeDropDownList').empty();
                //$('#ctl00_CP_HostelMasterTabContainer_AttedanceTabPanel_AttendanceTypeDropDownList').append("<option value='0'>- Select -</option>");
                $.each(data.d, function () {
                    ddlCustomers.append($("<option></option>").val(this['Value']).html(this['Text']));
                });

                GetAttedanceDeatil();

            }, 500);
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function GetAttedanceDeatil() {
    //  alert("hi");
    var AcademicId = $('#ClassDropdown').val();

    $('#dvAttedanceGridDiv').css('text-align', 'center');
    $('#dvsubjectGridDiv').css('text-align', 'center');
    var AttendanceTypeId = $("#ctl00_CP_HostelMasterTabContainer_AttedanceTabPanel_AttendanceTypeDropDownList").val();


    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetAttedanceDeatil",
        data: '{"AttendanceTypeId":"' + AttendanceTypeId + '","AcademicId":"' + AcademicId + '"}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            window.setTimeout(function () {
                var datas = $.parseJSON(data.d);
                if (AttendanceTypeId == 5) {
                    $('#Atddiv').hide();
                    $('#Subjectatdiv').show();
                    if (datas.SubjectGrid == '') {
                        $('#dvsubjectGridDiv').html('<tr><td colspan="9">No Record found !</td><tr>');
                    }
                    else {
                        $('#dvsubjectGridDiv').html(datas.SubjectGrid);
                    }
                }
                else {

                    $('#Atddiv').show();
                    $('#Subjectatdiv').hide();
                    if (datas.AttedanceGrid == '') {
                        $('#dvAttedanceGridDiv').html('<tr><td colspan="9">No Record found !</td><tr>');
                    }
                    else {
                        $('#dvAttedanceGridDiv').html(datas.AttedanceGrid);
                    }

                }

            }, 500);
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function LoadingMsg(msg1, msg2) {
    $('.hls-bg').show();
    $('#spnmain1msg').html(msg1);
    $('#spnmain2msg').html(msg2);
    $('#dvresultpopup').show();
}
function CloseLoading() {
    $('.hls-bg').hide();
    $('#dvresultpopup').hide();
}
function Closepopup() {
    $('.hls-bg').hide();
    $('#dvresultpopup').hide();
}
function openpopup() {
    LoadingMsg('Loading Details', '<b>Please Wait ...</b>');
    window.setTimeout(function () {
        CloseLoading();
        $('.hls-bg').show();
        $('#dvresultpopup').show();
    }, 500);
}

//for subexam detail
function openpopup1() {
    LoadingMsg1('Loading Details', '<b>Please Wait ...</b>');
    window.setTimeout(function () {
        CloseLoading();
        $('.hls-bg').show();
        $('#ctl00_CP_HostelMasterTabContainer_AssesmentTabPanel_dvexamdetailpopup').show();
    }, 1000);
}
function LoadingMsg1(msg1, msg2) {
    $('.hls-bg').show();
    $('#spnmain1msg').html(msg1);
    $('#spnmain2msg').html(msg2);
    $('#ctl00_CP_HostelMasterTabContainer_AssesmentTabPanel_dvexamdetailpopup').show();
}
function CloseLoading1() {
    $('.hls-bg').hide();
    $('#ctl00_CP_HostelMasterTabContainer_AssesmentTabPanel_dvexamdetailpopup').hide();
}
function Closepopup1() {
    $('.hls-bg').hide();
    $('#ctl00_CP_HostelMasterTabContainer_AssesmentTabPanel_dvexamdetailpopup').hide();
}

function GetLibraryDeatil() {
    var AcademicId = $('#ClassDropdown').val();
    $.ajax({

        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetLibraryDeatil",
        data: '{"AcademicId":"' + AcademicId + '"}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            var datas = $.parseJSON(data.d)
            if (datas.Bookgrid == '') {

                $('#dvBookGridDiv').show();
                $('#dvBookGridDiv').html('<tr><td colspan="9">No Record found !</td><tr>');
            }
            else {
                $('#dvBookGridDiv').show();
                $('#dvBookGridDiv').html(datas.Bookgrid);
            }
            $('#ctl00_CP_HostelMasterTabContainer_AttedanceTabPanel_AttendanceTypeDropDownList').empty();
            $('#Atddiv').hide();
            $('#Subjectatdiv').hide();
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}
function GetAlertDeatil(ContactId, Email) {

    var AcademicId = $('#ClassDropdown').val();

    var Contact = $('#ParentContactNoLabel').html();
    var email = $('#ParentEmailLabel').html();
    if (Contact == '' || Contact == null)
        Contact = '';
    else
        Contact = $('#ParentContactNoLabel').html();
    if (email == null || email == '') {
        email = '';
    }
    else
        email = $('#ParentEmailLabel').html();

    var AlertMode = 0;
    if ($("#ctl00_CP_HostelMasterTabContainer_TabPanel1_SMSList").hasClass("icon active") == true)
        AlertMode = 2;
    else if ($("#ctl00_CP_HostelMasterTabContainer_TabPanel1_EmailList").hasClass("icon active") == true)
        AlertMode = 1;
    else if ($("#ctl00_CP_HostelMasterTabContainer_TabPanel1_WhatsAppList").hasClass("icon active") == true) {
        AlertMode = 4;
        Contact = $('#WhatsappContactNoLabel').html();
        if (Contact == '' || Contact == null)
            Contact = '';
        else
            Contact = $('#WhatsappContactNoLabel').html();
    }
    else if ($("#ctl00_CP_HostelMasterTabContainer_TabPanel1_NotificationList").hasClass("icon active") == true)
        AlertMode = 3;

    LoadingMsg('Loading Details', '<b>Please Wait ...</b>');
    $.ajax({

        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetAlertDeatil",
        data: "{ 'ContactId':'" + Contact + "', 'Email': '" + email + "', 'AcademicId': '" + AcademicId + "', 'AlertModeId': '" + AlertMode + "'}",
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            var datas = $.parseJSON(data.d)
            if (datas.Alertgrid == '') {

                $('#dvAlertGridDiv').show();
                $('#dvAlertGridDiv').html('<tr><td colspan="9">No Record found !</td><tr>');
            }
            else {
                $('#dvAlertGridDiv').show();
                $('#dvAlertGridDiv').html(datas.Alertgrid);
            }
            $('#ctl00_CP_HostelMasterTabContainer_AttedanceTabPanel_AttendanceTypeDropDownList').empty();
            $('#Atddiv').hide();
            $('#Subjectatdiv').hide();
            CloseLoading();
        },
        error: function (xhr, status, error) {

            CloseLoading();
            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}
function GetCancelReciptlist() {

    var AcademicId = $('#ClassDropdown').val();

    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetCancelReciptlist",
        contentType: "application/json; charset=utf-8",
        data: '{"AcademicId":"' + AcademicId + '"}',
        dataType: "json",
        success: function (data) {
            var datas = $.parseJSON(data.d);
            window.setTimeout(function () {
                if (datas.cancellist == '') {
                    $('#dvFeeCancelGridDiv').show();
                    $('#dvFeeCancelGridDiv').html('<tr><td colspan="9">No Record found !</td><tr>');
                }
                else {
                    $('#dvFeeCancelGridDiv').show();
                    $('#dvFeeCancelGridDiv').html(datas.cancellist);
                }
            }, 500);
        },
        error: function (XHR, errStatus, errorThrown) {
            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function GetExamSubGroup() {
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetExamSubGroup",
        data: '{}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            var datas = "[" + (data.d) + "]";
            datas = $.parseJSON(datas);
            if (datas != "") {
                $('#ExamSubGroupDropdown').html(datas[0].Result);
            }
            GetPerformanceDetail();
            GetSubject();
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function GetSubject() {
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetSubject",
        data: '{}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            var datas = "[" + (data.d) + "]";
            datas = $.parseJSON(datas);
            if (datas != "") {
                $('#SubjectDropdown').html(datas[0].Result);
            }
            GetSubjectPerformanceDetail();
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function GetPerformanceDetail() {

    var ExamSubGroupId = $('#ExamSubGroupDropdown').val();
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetPerformanceDetail",
        data: JSON.stringify({ "ExamSubGroupId": parseInt(ExamSubGroupId) }),
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            var datas = "[" + (data.d) + "]";
            window.setTimeout(function () {
                if (datas != "") {
                    $('#PerformanceDiv').html('');
                    $('#PerformanceDiv').append('<tr><th style="width:50%">Class</th><th style="width:50%">Exam Percentage</th></tr>');
                    $.each($.parseJSON(datas), function (i, item) {
                        var Class, Percentage;
                        Class = item.Class;
                        Percentage = item.Percentage;
                        $('#PerformanceDiv').append('<tr><td>' + Class + '</td><td>' + Percentage + '</td></tr>');
                    });

                    if (datas == "") {
                        $('#PerformanceDiv').html('');
                        $('#PerformanceDiv').append('<tr><td>No Record found !</td><tr>');
                    }

                    var dataPoint = [];
                    var lables = [];
                    var chartdata = [];
                    var dataPoint1 = [];
                    var lables1 = [];
                    var chartdata1 = [];
                    var lbl = [];
                    var locationlbl = [];
                    var colcnt = 0;
                    colcnt = $('#PerformanceDivhead tbody th').length - 1;
                    $('#roundgraphdivPerformance').show();
                    $('#PerformanceDivhead tbody tr').each(function (index) {
                        $(this).find('th,td').each(function (index2) {
                            if ($(this).is('th')) {
                                if (index2 != 0) {
                                    lables.push(this.innerHTML);
                                }
                            }
                            else if ($(this).is('td')) {
                                if (index2 != 0) {
                                    if (colcnt == index2) {
                                        dataPoint.push(this.innerHTML);
                                    }
                                } else if (index2 == 0) {
                                    locationlbl.push(this.innerText);
                                }
                            }
                            $("table.tr").not(this).hide();
                        });
                    });
                    console.log(dataPoint);
                    if (lables.length > 0 && dataPoint.length > 0) {
                        chartdata.push({
                            label: locationlbl.slice(0, locationlbl.length),
                            fillColor: "rgba(220,220,220,0.2)",
                            strokeColor: "rgba(220,220,220,1)",
                            pointColor: "rgba(220,220,220,1)",
                            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.slice(0, dataPoint.length)

                        });
                        //dataPoint = [];
                        // locationlbl = [];
                    }
                    var data = {
                        labels: locationlbl.slice(0, locationlbl.length),
                        datasets: chartdata
                    };
                    $('#myTotalPerformance').remove();
                    $('#roundgraphPerformance').append('<canvas id="myTotalPerformance" style="width:550px;"></canvas>');
                    var ctx = $("#myTotalPerformance").get(0).getContext('2d');
                    var opt = {
                        responsive: false,
                        legend: false,
                        scales: {
                            yAxes: [{
                                ticks: {
                                    beginAtZero: true,
                                    fontSize: 10
                                }
                            }],
                            xAxes: [{
                                ticks: {
                                    beginAtZero: true,
                                    fontSize: 10
                                }
                            }]
                        },
                        "hover": {
                            "animationDuration": 0
                        },
                        "animation": {
                            "duration": 1,
                            "onComplete": function () {
                                var chartInstance = this.chart,
                                ctx = chartInstance.ctx;
                                ctx.font = "1px Arial";
                                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,
                    });
                }


            }, 500);
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });

}

function GetSubjectPerformanceDetail() {

    var ExamSubGroupId = $('#ExamSubGroupDropdown').val();
    var SubjectId = $('#SubjectDropdown').val();

    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetSubjectPerformanceDetail",
        data: JSON.stringify({ "ExamSubGroupId": parseInt(ExamSubGroupId), "SubjectId": parseInt(SubjectId) }),
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            var datas = "[" + (data.d) + "]";
            window.setTimeout(function () {
                if (datas != "") {
                    $('#SubjectDiv').html('');
                    $('#SubjectDiv').append('<tr><th style="width:50%">Class</th><th style="width:50%">Subject Percentage</th></tr>');
                    $.each($.parseJSON(datas), function (i, item) {
                        var Class, Obtain;
                        Class = item.Class;
                        Obtain = item.Obtain;
                        $('#SubjectDiv').append('<tr><td>' + Class + '</td><td>' + Obtain + '</td></tr>');
                    });

                    if (datas == "") {
                        $('#SubjectDiv').html('');
                        $('#SubjectDiv').append('<tr><td>No Record found !</td><tr>');
                    }

                    var dataPoint = [];
                    var lables = [];
                    var chartdata = [];
                    var dataPoint1 = [];
                    var lables1 = [];
                    var chartdata1 = [];
                    var lbl = [];
                    var locationlbl = [];
                    var colcnt = 0;
                    colcnt = $('#SubjectDivhead tbody th').length - 1;
                    $('#roundgraphdivSubject').show();
                    $('#SubjectDivhead tbody tr').each(function (index) {
                        $(this).find('th,td').each(function (index2) {
                            if ($(this).is('th')) {
                                if (index2 != 0) {
                                    lables.push(this.innerHTML);
                                }
                            }
                            else if ($(this).is('td')) {
                                if (index2 != 0) {
                                    if (colcnt == index2) {
                                        dataPoint.push(this.innerHTML);
                                    }
                                } else if (index2 == 0) {
                                    locationlbl.push(this.innerText);
                                }
                            }
                            $("table.tr").not(this).hide();
                        });
                    });
                    console.log(dataPoint);
                    if (lables.length > 0 && dataPoint.length > 0) {
                        chartdata.push({
                            label: locationlbl.slice(0, locationlbl.length),
                            fillColor: "rgba(220,220,220,0.2)",
                            strokeColor: "rgba(220,220,220,1)",
                            pointColor: "rgba(220,220,220,1)",
                            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.slice(0, dataPoint.length)

                        });
                        //dataPoint = [];
                        // locationlbl = [];
                    }
                    var data = {
                        labels: locationlbl.slice(0, locationlbl.length),
                        datasets: chartdata
                    };
                    $('#myTotalSubject').remove();
                    $('#roundgraphSubject').append('<canvas id="myTotalSubject" style="width:550px;"></canvas>');
                    var ctx = $("#myTotalSubject").get(0).getContext('2d');
                    var opt = {
                        responsive: false,
                        legend: false,
                        scales: {
                            yAxes: [{
                                ticks: {
                                    beginAtZero: true,
                                    fontSize: 10
                                }
                            }],
                            xAxes: [{
                                ticks: {
                                    beginAtZero: true,
                                    fontSize: 10
                                }
                            }]
                        },
                        "hover": {
                            "animationDuration": 0
                        },
                        "animation": {
                            "duration": 1,
                            "onComplete": function () {
                                var chartInstance = this.chart,
                                ctx = chartInstance.ctx;
                                ctx.font = "1px Arial";
                                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,
                    });
                }


            }, 500);
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });

}

function GetSMSAlert() {
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_SMSList").addClass("active");
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_EmailList").removeClass("active");
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_WhatsAppList").removeClass("active");
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_NotificationList").removeClass("active");

    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_AlertTypeLabel")[0].innerHTML = "Alert Type: SMS";

    GetAlertDeatil();
}

function GetEmailAlert() {
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_SMSList").removeClass("active");
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_EmailList").addClass("active");
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_WhatsAppList").removeClass("active");
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_NotificationList").removeClass("active");

    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_AlertTypeLabel")[0].innerHTML = "Alert Type: Email";

    GetAlertDeatil();
}

function GetWhatsAppAlert() {
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_SMSList").removeClass("active");
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_EmailList").removeClass("active");
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_WhatsAppList").addClass("active");
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_NotificationList").removeClass("active");

    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_AlertTypeLabel")[0].innerHTML = "Alert Type: WhatsApp";

    GetAlertDeatil();
}

function GetNotificationAlert() {
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_SMSList").removeClass("active");
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_EmailList").removeClass("active");
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_WhatsAppList").removeClass("active");
    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_NotificationList").addClass("active");

    $("#ctl00_CP_HostelMasterTabContainer_TabPanel1_AlertTypeLabel")[0].innerHTML = "Alert Type: Notification";

    GetAlertDeatil();
}

function getStudentSibling() {
    $("#studentsibling").css('text-align', 'center');
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/Student360View.aspx/getStudentSiblingDetail",
        data: '{}',
        contentType: 'application/json;charset=utf-8',
        dataType: "json",
        success: function (data) {
            $('#studentsibling').html('');
            var tableData = '<table border="1"  width="100%"   Id="Table_"><tr> <td width="20%" style="background:#38445a;color:#fff;border-color:#38445a;">Sibling Organization</td>' + '<td style="background:#38445a;color:#fff;border-color:#38445a;">Sibling Code</td>' + '<td style="background:#38445a;color:#fff;border-color:#38445a;">Sibling Name</td>' + '<td style="background:#38445a;color:#fff;border-color:#38445a;">Sibling Class</td>' + '<td style="background:#38445a;color:#fff;border-color:#38445a;">Sibling Status</td></tr>';     // Mantis Id : 0036426
            var datas = $.parseJSON(data.d);
            for (var i = 0; i < datas.length; i++) {
                tableData += '<tr style="padding:0pt 1pt 0pt"><td style="color:Black;">' + datas[i].OrganizationName + '</td><td style="color:Black;">' + datas[i].Code + '</td><td style="color:Black;">' + datas[i].Name + '</td><td style="color:Black;">' + datas[i].DivDept + '</td><td style="color:Black;">' + datas[i].StatusName + '</td></tr>';
            }
            tableData += '</table>';
            $('#studentsibling').append(tableData);
        }
    });
}

function GetChargeReceiptViewList() {

    var AcademicId = $('#ClassDropdown').val();
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetChargeReceiptViewList",
        contentType: "application/json; charset=utf-8",
        data: '{"AcademicId":"' + AcademicId + '"}',
        dataType: "json",
        success: function (data) {
            var datas = $.parseJSON(data.d);
            window.setTimeout(function () {
                if (datas.FeeChargeListGrid == '') {
                    $('#dvChargeListGridDiv').show();
                    $('#dvChargeListGridDiv').html('<tr><td colspan="7">No Record found !</td></tr>');
                }
                else {
                    $('#dvChargeListGridDiv').show();
                    $('#dvChargeListGridDiv').html(datas.FeeChargeListGrid);
                }
            }, 500);
        },
        error: function (XHR, errStatus, errorThrown) {
            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}
function GetDepositAdjustmentViewList() {

    var AcademicId = $('#ClassDropdown').val();

    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetDepositAdjustmentViewList",
        contentType: "application/json; charset=utf-8",
        data: '{"AcademicId":"' + AcademicId + '"}',
        dataType: "json",
        success: function (data) {
            var datas = $.parseJSON(data.d);
            window.setTimeout(function () {
                if (datas.FeeDepositAdjustmentGrid == '') {
                    $('#dvDepositAdjustmentGridDiv').show();
                    $('#dvDepositAdjustmentGridDiv').html('<tr><td colspan="7">No Record found !</td><tr>');
                }
                else {
                    $('#dvDepositAdjustmentGridDiv').show();
                    $('#dvDepositAdjustmentGridDiv').html(datas.FeeDepositAdjustmentGrid);
                }
            }, 500);
        },
        error: function (XHR, errStatus, errorThrown) {
            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}
function GetDepositRefundViewList() {

    var AcademicId = $('#ClassDropdown').val();

    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetDepositRefundViewList",
        contentType: "application/json; charset=utf-8",
        data: '{"AcademicId":"' + AcademicId + '"}',
        dataType: "json",
        success: function (data) {
            var datas = $.parseJSON(data.d);
            window.setTimeout(function () {
                if (datas.FeeDepositRefundGrid == '') {
                    $('#dvDepositRefundGridDiv').show();
                    $('#dvDepositRefundGridDiv').html('<tr><td colspan="6">No Record found !</td><tr>');
                }
                else {
                    $('#dvDepositRefundGridDiv').show();
                    $('#dvDepositRefundGridDiv').html(datas.FeeDepositRefundGrid);
                }
            }, 500);
        },
        error: function (XHR, errStatus, errorThrown) {
            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function GetEventDetails() {
    var AcademicId = $('#ClassDropdown').val();

    $('#dvEventDetailsGridDiv').css('text-align', 'center');
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetEventDetails",
        data: '{"AcademicId":"' + AcademicId + '"}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            window.setTimeout(function () {
                var datas = $.parseJSON(data.d);
                if (datas.EventAttendanceGrid == '') {
                    $('#dvEventDetailsGridDiv').html('<tr><td colspan="9">No Record found !</td><tr>');
                }
                else {
                    $('#dvEventDetailsGridDiv').html(datas.EventAttendanceGrid);
                }
                $('#ctl00_CP_HostelMasterTabContainer_AttedanceTabPanel_AttendanceTypeDropDownList').empty();
                $('#Atddiv').hide();
                $('#Subjectatdiv').hide();
            }, 500);
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}
/*Added form mantis : 33824 by Nilesh*/
function GetPDCViewList() {
    var AcademicId = $('#ClassDropdown').val();
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetPDCViewList",
        data: '{"AcademicId":"' + AcademicId + '"}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            window.setTimeout(function () {
                var datas = $.parseJSON(data.d)
                if (datas.NewAndPendingGrid == '') {
                    $('#dvNewAndPendingGridDiv').show();
                    $('#dvNewAndPendingGridDiv').html('<tr><td colspan="8">No Record found !</td><tr>');
                }
                else {
                    $('#dvNewAndPendingGridDiv').show();
                    $('#dvNewAndPendingGridDiv').html(datas.NewAndPendingGrid)                    
                }
                GetPDCClearViewList();

            }, 500);
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function GetPDCClearViewList() {
    var AcademicId = $('#ClassDropdown').val();
    $.ajax({
        type: "POST",
        url: "/Pages/StudentManagement/StudentView.aspx/GetPDCClearViewList",
        data: '{"AcademicId":"' + AcademicId + '"}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            window.setTimeout(function () {
                var datas = $.parseJSON(data.d)
                if (datas.ClearedPaymentGrid == '') {
                    $('#dvClearedPaymentGridDiv').show();
                    $('#dvClearedPaymentGridDiv').html('<tr><td colspan="9">No Record found !</td><tr>');
                }
                else {
                    $('#dvClearedPaymentGridDiv').show();
                    $('#dvClearedPaymentGridDiv').html(datas.ClearedPaymentGrid)
                }

            }, 500);
        },
        error: function (xhr, status, error) {

            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}
