﻿
$(document).ready(function () {
    $('#ddlregional_center').prop("disabled", true);
    $('#ddlstudy_center').prop("disabled", true);
    $('#ddlCourseType').prop("disabled", true);
    $('#ddlprog_name').prop("disabled", true);
    $('#ddlyear_sem').prop("disabled", true);
    $('#ddlnature_prog').prop("disabled", true);
    //Bind_Prospuctus();
    bind_state();
    bind_District();
    bind_District2();
    Bind_QualificationYears();
    $("#divhideshow_pros").hide();
});

// English to Hindi Transliteration
function Convert_Hindi(EnglishText) {
    $.ajax({
        type: "POST",
        url: 'https://www.google.com/inputtools/request?ime=transliteration_en_hi&text=' + EnglishText.value,
        dataType: "json",
        success: function (data) {
            if (EnglishText.id == "txtstudent_name_en") { document.getElementById("txtstudent_name_hn").value = data[1][0][1]; }
            if (EnglishText.id == "txtstudent_name_hn") { document.getElementById("txtstudent_name_hn").value = data[1][0][1]; }
            if (EnglishText.id == "txtfather_name_en") { document.getElementById("txtfather_name_hn").value = data[1][0][1]; }
            if (EnglishText.id == "txtfather_name_hn") { document.getElementById("txtfather_name_hn").value = data[1][0][1]; }
            if (EnglishText.id == "txtmother_name_en") { document.getElementById("txtmother_name_hn").value = data[1][0][1]; }
            if (EnglishText.id == "txtmother_name_hn") { document.getElementById("txtmother_name_hn").value = data[1][0][1]; }
        },
        error: function () {
            return true; console.log("Hindi Translation cannot be done.");
        }
    });
}

function Chk_address() {
    if (Chk_address_id.checked == true) {
        var cadd = document.getElementById("txtpaddress").value;
        var cstate = document.getElementById("ddlpstate").value;
        var cdist = document.getElementById("ddlpdistrict").value;
        var cpin = document.getElementById("txtppincode").value;
        var copyadd = cadd;
        var copystate = cstate;
        var copydist = cdist;
        var copypin = cpin;
        document.getElementById("txtcaddress").value = copyadd;
        document.getElementById("ddlcstate").value = copystate;
        document.getElementById("ddlcdistrict").value = copydist;
        document.getElementById("txtcpincode").value = copypin;
        $("#txtcaddress").attr('disabled', 'disabled');
        $("#ddlcstate").attr('disabled', 'disabled');
        $("#ddlcdistrict").attr('disabled', 'disabled');
        $("#txtcpincode").attr('disabled', 'disabled');
    }
    else if (Chk_address_id.checked == false) {
        document.getElementById("txtcaddress").value = '';
        document.getElementById("ddlcstate").value = '';
        document.getElementById("ddlcdistrict").value = '';
        document.getElementById("txtcpincode").value = '';
        $("#txtcaddress").removeAttr('disabled');
        $("#ddlcstate").removeAttr('disabled');
        $("#ddlcdistrict").removeAttr('disabled');
        $("#txtcpincode").removeAttr('disabled');
    }
}

function validateEmail($email) {
    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    return emailReg.test($email);
}

//function Bind_Prospuctus() {
//    $.ajax({
//        type: "POST",
//        url: "/Master/Select_Prospuctus",
//        contentType: "application/json; charset=utf-8",
//        dataType: 'JSON',
//        success: function (response) {
//            var htmldl = "";
//            htmldl = htmldl + "<option value = \"\">Please Select *</option>";
//            $('#ddlProspuctus_session').empty();
//            var obj = response;
//            for (var i = 0; i < obj.length; i++) {
//                htmldl = htmldl + "<option value = \"" + obj[i]['Prospuctus'] + "\">" + obj[i]['Prospuctus'] + "</option>";
//            }
//            $('#ddlProspuctus_session').append(htmldl);
//        },
//        complete: function () {

//        }
//    });
//}

function Bind_Fees(fees) {
    var course_fees = fees;
    $.ajax({
        type: "POST",
        url: "/Master/show_fees",
        data: "{course_fees: '" + course_fees + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: 'JSON',
        success: function (response) {
            var obj = response;
            let programme_fee = obj[0]['programme_fee']
            let fees = parseInt((programme_fee * 20) / 100);
            var total_Fees = parseInt(programme_fee) + fees;
            $('#ProgFees').text (total_Fees);
            //alert(parseInt(programme_fee) + parseInt(fees));
            //$('#ProgFees').text(obj[0]['programme_fee']);
            $("#ddlnature_prog option[value='" + obj[0]['sem_year'] + "']").attr('selected', 'selected');
            $('#ddlmedium').empty();
            var obj = response;
            var htmldl = '';
            for (var i = 0; i < obj.length; i++) {
                if (obj[i]['medium'] == '1') {
                    htmldl = htmldl + "<option value = '1'\">Hindi</option>";
                }
                else if (obj[i]['medium'] == '2') {
                    htmldl = htmldl + "<option value = '2'\">English</option>";
                }

                else if (obj[i]['medium'] == '3') {
                    htmldl = htmldl + "<option value = '3'\">Urdu</option>";
                }
                else {
                    htmldl = htmldl + "<option value='' selected>Please Select</option>";
                    htmldl = htmldl + "<option value = '4'\">Hindi</option>";
                    htmldl = htmldl + "<option value = '5'\">English</option>";
                }
            }
            $('#ddlmedium').append(htmldl);

            //$("#ddlmedium option[value='" + obj[0]['medium'] + "']").attr('selected', 'selected');
        },
        complete: function () {
        }
    });
}

function Bind_QualificationYears() {
    $.ajax({
        type: "POST",
        url: "/Master/Select_EduYears",
        contentType: "application/json; charset=utf-8",
        dataType: 'JSON',
        success: function (response) {
            var htmldl = "";
            htmldl = htmldl + "<option value = \"\">Please Select *</option>";
            $('#10_year').empty();
            $('#12_year').empty();
            $('#UG_year').empty();
            $('#graduate_year').empty();
            $('#txtother_year').empty();
            var obj = response;
            for (var i = 0; i < obj.length; i++) {
                htmldl = htmldl + "<option value = \"" + obj[i]['all_years'] + "\">" + obj[i]['all_years'] + "</option>";
            }
            $('#10_year').append(htmldl);
            $('#12_year').append(htmldl);
            $('#UG_year').append(htmldl);
            $('#graduate_year').append(htmldl);
            $('#txtother_year').append(htmldl);
        },
        complete: function () {
        }
    });
}

function bind_state() {
    $.ajax({
        type: "POST",
        url: "/Master/Select_state",
        contentType: "application/json; charset=utf-8",
        dataType: 'JSON',
        success: function (response) {
            var htmldl = "";
            htmldl = htmldl + "<option value = \"\">Please Select *</option>";
            $('#ddlpstate', '#ddlcstate').empty();

            var obj = response;
            for (var i = 0; i < obj.length; i++) {
                htmldl = htmldl + "<option value = \"" + obj[i] + "\">" + obj[i] + "</option>";
            }
            $('#ddlpstate').append(htmldl);
            $('#ddlcstate').append(htmldl);
        },
        complete: function () {
        }
    });
}

function bind_District() {
    var state = $('#ddlpstate').val();
    $.ajax({
        type: "POST",
        url: "/Master/Select_District",
        data: "{state: '" + state + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: 'JSON',
        success: function (response) {
            let htmldl = "";
            htmldl = htmldl + "<option value = \"\">Please Select *</option>";
            $('#ddlpdistrict').empty();
            var obj = response;
            for (var i = 0; i < obj.length; i++) {
                htmldl = htmldl + "<option value = \"" + obj[i] + "\">" + obj[i] + "</option>";
            }
            $('#ddlpdistrict').append(htmldl);
            $('#ddlcdistrict').append(htmldl);
        },
        complete: function () {
        }
    });
}

function bind_District2() {
    var state2 = $('#ddlcstate').val();
    $.ajax({
        type: "POST",
        url: "/Master/Select_District",
        data: "{state: '" + state2 + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: 'JSON',
        success: function (response) {
            let htmldl = "";
            htmldl = htmldl + "<option value = \"\">Please Select *</option>";
            $('#ddlcdistrict').empty();
            var obj = response;
            for (var i = 0; i < obj.length; i++) {
                htmldl = htmldl + "<option value = \"" + obj[i] + "\">" + obj[i] + "</option>";
            }
            $('#ddlcdistrict').append(htmldl);
        },
        complete: function () {
        }
    });
}

$('#ddlprog_name').change(function () {
    Bind_Fees($('#ddlprog_name').val());
    ($('#ddlprog_name').val());
});

function Subject_check() {
    var fk_course_id = $('#ddlprog_name').val();
    var paperyear = $('#ddlyear_sem').val();
    var cheksubcode = $("input[id^=chksub]:checked").map(function () {
        return this.value;
    }).get().join(',');
    if (cheksubcode == "") {
        alertify.alert('Please choose subjects..!');
        return false;
    }

    var sub_list = "";
    var grp_a_item = "0";
    var grp_a_limit = $('#group_a_limit').val();
    $("#tbl_sub_list_1 :input:checkbox").each(function (index, data) {
        if (data.checked) {
            var deny = "hfdeny-" + data.value;
            var Subject_Name = "lbl-" + data.value;
            sub_list += $('#' + Subject_Name).text() + "#" + data.value + "#" + fk_course_id + "#" + paperyear + "#" + $('#' + deny).val() + "$";
            grp_a_item = parseInt(grp_a_item) + 1;
        }
    });

    // GROUP B
    var grp_b_item = "0";
    var grp_b_limit = $('#group_b_limit').val();

    $("#tbl_sub_list_2 :input:checkbox").each(function (index, data) {
        if (data.checked) {
            var deny = "hfdeny-" + data.value;
            var Subject_Name = "lbl-" + data.value;
            sub_list += $('#' + Subject_Name).text() + "#" + data.value + "#" + fk_course_id + "#" + paperyear + "#" + $('#' + deny).val() + "$";
            grp_b_item = parseInt(grp_b_item) + 1;
        }
    });
    var max_sub = $("#max_subject").val();

    if (parseInt(grp_a_item) + parseInt(grp_b_item) != parseInt(max_sub)) {
        alertify.alert(max_sub + ' subject require to continue!'); return false;
    }

    else if (grp_a_limit < grp_a_item) { alertify.alert('Only ' + grp_a_limit + ' subject allow from Group A!'); return false; }
    else if (parseInt(grp_b_limit) < parseInt(grp_b_item)) { alertify.alert('Only ' + grp_b_limit + ' subject allow from Group B!'); return false; }

    $.ajax({
        type: "POST",
        url: "/Master/Subject_check",
        data: "{Subject_Name: '" + sub_list + "', course_id: '" + fk_course_id + "' , subcode: '" + cheksubcode + "' , paper_year: '" + paperyear + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: 'JSON',
        beforeSend: function () {
            $('#pnlStudent').block({ message: '<h1><img src="https://exam22.rmlauexams.in/images/busy.gif" style="height:50px;width5;"/> Please Wait...</h1>' });
        },
        success: function (response) {
            if (response) {
                if (response.status) {
                    add_paper_call();
                }
                else {
                    alertify.alert(response.responseText);
                }
            }
        },
        complete: function () {
            setTimeout(
                function () {
                    $('#pnlStudent').unblock();
                }, 1000);
        }
    });
}

function add_paper_call() {

    var fk_course_id = $('#ddlprog_name').val();
    var paperyear = $('#ddlyear_sem').val();
    var Prospuctus = $('#ddlProspuctus_session').val();
    var cheksubcode = $("input[id^=chksub]:checked").map(function () {
        return this.value;
    }).get().join(',');
    var sub_list = "";
    if (cheksubcode == "") {
        alertify.alert('Please choose subjects..!');
        return false;
    }

    // GROUP A 
    var grp_a_item = "0";
    var grp_a_limit = $('#group_a_limit').val();
    $("#tbl_sub_list_1 :input:checkbox").each(function (index, data) {
        if (data.checked) {
            var deny = "hfdeny-" + data.value;
            var Subject_Name = "lbl-" + data.value;
            sub_list += $('#' + Subject_Name).text() + "#" + data.value + "#" + fk_course_id + "#" + paperyear + "#" + $('#' + deny).val() + "$";
            grp_a_item = parseInt(grp_a_item) + 1;
        }
    });
    // GROUP B
    var grp_b_item = "0";
    var grp_b_limit = $('#group_b_limit').val();
    $("#tbl_sub_list_2 :input:checkbox").each(function (index, data) {
        if (data.checked) {
            var deny = "hfdeny-" + data.value;
            var Subject_Name = "lbl-" + data.value;
            sub_list += $('#' + Subject_Name).text() + "#" + data.value + "#" + fk_course_id + "#" + paperyear + "#" + $('#' + deny).val() + "$";
            grp_b_item = parseInt(grp_b_item) + 1;

        }
    });


    $.ajax({
        type: "POST",
        url: "/Master/Add_Subject_Paper_Yearly_List",
        data: "{Subject_Name: '" + sub_list + "', course_id: '" + fk_course_id + "' , subcode: '" + cheksubcode + "' , paper_year: '" + paperyear + "' , Prospuctus:'" + Prospuctus + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: 'JSON',
        beforeSend: function () {
            $('#pnlStudent').block({ message: '<h1><img src="http://exam22.rmlauexams.in/images/busy.gif" style="height:50px;width5;"/> Please Wait...</h1>' });
        },
        success: function (response) {
            if (response) {

                $('#tbl_paper_list').empty();
                var thead = '<tr style="background-color: darkblue; color: white; font-size: 13px; font-weight: bold;"><td>Sr No.</td><td>Semesters</td><td>Paper</td><td>Paper Type</td><td>Credit</td><td></td></tr>';
                var tbody = '';
                var sno = '0';
                $.each(response, function () {
                    sno = parseInt(sno) + 1;
                    var paper_id = this['pk_paper_ID'];
                    let paper_logic = this['optional_group_id'];
                    tbody = tbody + '<tr>';
                    tbody = tbody + '<td>' + sno + '<input name="paper_id"  type="hidden" value="' + paper_id + '"/></td>';
                    
                    if (this['sr_semsetercount'] != "0") {
                        if (this['sr_semsetercount'] == "1")
                            tbody = tbody + '<td style="font-weight: bold; font-size: 13px;">First Semester</td>';
                        else if (this['sr_semsetercount'] == "2")
                            tbody = tbody + '<td style="font-weight: bold; font-size: 13px;">Second Semester</td>';
                        else if (this['sr_semsetercount'] == "3")
                            tbody = tbody + '<td style="font-weight: bold; font-size: 13px;">Third Semester</td>';
                        else if (this['sr_semsetercount'] == "4")
                            tbody = tbody + '<td style="font-weight: bold; font-size: 13px;">Fourth Semester</td>';
                        else if (this['sr_semsetercount'] == "5")
                            tbody = tbody + '<td style="font-weight: bold; font-size: 13px;">Fifth Semester</td>';
                        else if (this['sr_semsetercount'] == "6")
                            tbody = tbody + '<td style="font-weight: bold; font-size: 13px;">Six Semester</td>';
                    }
                    else
                        tbody = tbody + '<td style="font-weight: bold; font-size: 13px;">Yearly</td>';
                    tbody = tbody + '<td>' + this['paper_coursecode'] + ' - ' + this['paper_name'] + '</td>';
                    if (this['is_optional'] == "1")
                        tbody = tbody + '<td style="font-weight: bold; font-size: 13px;">Optional Paper</td>';
                    else {
                        tbody = tbody + '<td style="font-weight: bold; font-size: 13px;">Compulsory</td>';
                    }
                    tbody = tbody + '<td>' + this['paper_credits'] + '<input name="paper_type" type="hidden" id="hfpapertype-' + paper_id + '" value="' + this['is_optional'] + '" /></td>';

                    if (this['is_optional'].toString() == "1") {
                        tbody += '<td><div class="custom-control custom-checkbox col-md-4 mb-3" style="float:left"><input type="checkbox" name="chkpaper_' + paper_logic + '" id="chkpaper_' + paper_logic + '" value="' + paper_id + '"  />';
                        tbody += '<input name="paper_logic" type="hidden" id="hfpaperlogic_' + paper_logic + '" value="' + paper_logic + '" /><input type="hidden" id="hfpaperlimit_' + paper_logic + '" value="' + this['required_paper'] + '" /></td>';
                    }
                    else {
                        tbody += '<td></td>';
                    }
                    tbody = tbody + '</tr>';
                });
                $('#tbl_paper_list').append(thead);
                $('#tbl_paper_list').append(tbody);
            }
            else {
                alertify.error(response.responseText);
            }
        },
        complete: function () {
            setTimeout(
                function () {
                    $('#pnlStudent').unblock();
                }, 1000);
        }
    });
    //$("#btnsubmit").attr('disabled', 'disabled');
}

function bind_subject() {
    var collegename = $('#ddlstudy_center').val();
    var course = $('#ddlprog_name').val();
    var paperyear = $('#ddlyear_sem').val();
    var Prospuctus = $('#ddlProspuctus_session').val();
    var printmsg = '';
    var printmsg1 = '';

    $.get("/Master/Select_college_subject_yearly", { center_id: collegename, course_id: course, paper_year: paperyear, Prospuctus: Prospuctus, Subject_Group: 'Group-A' }, function (response) {
        $('#tbl_sub_list_1').empty();
        var tbody = '';
        if (course == 17) {
            tbody += '<h6 style= "padding-left: 17px; font-weight: bold;color: #a40000;">GROUP A:</h6>';
        }
        $.each(response, function () {
            $("#max_subject").val(this['Subject_count']);
            $('#group_a_limit').val(this['Group_Selection']);

            var Sub_College_ID = this['PK_Sub_College_ID'];
            var Subject_count = this['Subject_count'];
            var hash = this['subject_code'];
            var name = this['Subject_Name'];

            if (this['is_active'] == true) {
                tbody += '<div class="col-md-3" style="font-weight:bold;"><label id = "lbl-' + hash + '" class="custom-control-label" for= "checkbox-' + hash + '" > ' + name + '</label ></div>';
                tbody += '<div class="custom-control custom-checkbox col-md-1">' + '<input type="checkbox" name="chksub_' + Subject_count + '" id="chksub_' + Subject_count + '" value="' + this['subject_code'] + '"  />' + '</div>';
                tbody += '<td style="display:none;"><input name="sub"  type="hidden" value="' + Sub_College_ID + '"/></td>';
                tbody += '<td><input name="Subject_count" type="hidden" id="hfSubject_countlogic_' + Subject_count + '" value="' + Subject_count + '" /><input type="hidden" id="hfsublimit_' + Subject_count + '" value="' + Subject_count + '" /></td>';
                tbody += '<input type="hidden" id="hfdeny-' + hash + '" value="' + this['Subject_code_deny'] + '" /></div>';
            }
            else {
                tbody += '<td></td>';
            }
        });
        $('#tbl_sub_list_1').append(tbody);
    });
    
    $.get("/Master/Select_college_subject_yearly", { center_id: collegename, course_id: course, paper_year: paperyear, Prospuctus: Prospuctus, Subject_Group: 'Group-B' }, function (response) {
        $('#tbl_sub_list_2').empty();
        var tbody = '';
         if (course == 17) {
            tbody += '<h6 style= "padding-left: 17px; font-weight: bold;color: #a40000;">GROUP B:</h6>';
        }
        $.each(response, function () {
            $('#group_b_limit').val(this['Group_Selection']);
            var Sub_College_ID = this['PK_Sub_College_ID'];
            var Subject_count = this['Subject_count'];
            var hash = this['subject_code'];
            var name = this['Subject_Name'];

            if (this['is_active'] == true) {
                tbody += '<div class="col-md-3" style="font-weight:bold;"><label id = "lbl-' + hash + '" class="custom-control-label" for= "checkbox-' + hash + '" > ' + name + '</label ></div>';
                tbody += '<div class="custom-control custom-checkbox col-md-1">' + '<input type="checkbox" name="chksub_' + Subject_count + '" id="chksub_' + Subject_count + '" value="' + this['subject_code'] + '"  />' + '</div>';
                tbody += '<td style="display:none;"><input name="sub"  type="hidden" value="' + Sub_College_ID + '"/></td>';
                tbody += '<td><input name="Subject_count" type="hidden" id="hfSubject_countlogic_' + Subject_count + '" value="' + Subject_count + '" /><input type="hidden" id="hfsublimit_' + Subject_count + '" value="' + Subject_count + '" /></td>';
                tbody += '<input type="hidden" id="hfdeny-' + hash + '" value="' + this['Subject_code_deny'] + '" /></div>';
            }
            else {
                tbody += '<td></td>';
            }
        });
        if (tbody == '') { tbody += '<td></td>'; }
        tbody = tbody + '<div class="container" style="width:250px;"><td><input type="Button" id="add_paper" value="Add Paper" class="btn btn-primary" style="width:98px;text-align: center;margin: auto;margin-top: 45px; margin-left: 13px;" onclick="Subject_check()"></td></div>';
        $('#tbl_sub_list_2').append(tbody);
    });
    if (course == 17) {
        $('#printmsg').empty();
        printmsg += 'Note : B.A II & III Year के सन्दर्भ मे - छात्र, कृपया केवल उन्हीं विषयों का चयन करें जो पिछली कक्षा के वर्ष में चुने गए थे। विषय गलत चुने जाने पर जिम्मेदारी छात्र की होगी।(Student , Can kindly select only those subjects which was choosen in previus class year. In case of wrong choice of the subject, the responsibility will be of the student.)';
        
        $('#printmsg').append(printmsg);
    }
    else {
        printmsg += '<td></td>';
    }
}

$('#ddlyear_sem').change(function () {
    bind_subject();
});

function formatDate(date) {
    var d = new Date(date),
        month = '' + (d.getMonth() + 1),
        day = '' + d.getDate(),
        year = d.getFullYear();
    if (month.length < 2) month = '0' + month;
    if (day.length < 2) day = '0' + day;
    return [year, month, day].join('-');
}

//function txt_selection(id, value) {
//    $('#' + id).attr('disabled', 'disabled');
//    if (value === "")
//    {$('#' + id).removeAttr('disabled');}
//    $('#' + id).val(value);
//}

$('#btnformsubmit').click(function () {
    var Prospuctus = $('#ddlProspuctus_session').val();
    var enrollment_no = $('#txtenrollNo').val();
    if (Prospuctus == '') {
        alertify.alert("Please select your prospectus Session!");
        return false;
    }
    if (enrollment_no == '') {
        alertify.alert("Please enter enrollment no!");
        return false;
    }
    if (enrollment_no != '' && Prospuctus != '') {
        $("#divhideshow_pros").show();
    }
    //if ((($("#txtenrollNo").val()).substring(0, 3) == '211') ||( ($("#txtenrollNo").val()).substring(0, 2) == '91')) {
    $.ajax({
        type: "POST",
        url: "/Master/Bind_details_Re_Adm_Student",
        data: "{enrollment_no: '" + enrollment_no + "',Prospuctus: '" + Prospuctus + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: 'JSON',
        beforeSend: function () { },
        async: false,
        success: function (response) {
            if (response.length > 0) {
                $('#txtenrollNo').prop("disabled", true);
                $.each(response, function () {
                    $('#ddlregional_center').append('<option value="' + this.fk_regional_id + '">' + this.name + '</option>');
                    $('#ddlstudy_center').append('<option value="' + this.fk_study_center + '">' + this.study_center_name + '</option>');
                    $('#ddlCourseType').append('<option value="' + this.course_type + '">' + this.course_type_name + '</option>');
                    $('#ddlprog_name').append('<option value="' + this.fk_course_id + '">' + this.programme_name + '</option>');
                    $("#ddlyear_sem").val(this['course_year']);
                    Bind_Fees($('#ddlprog_name').val());
                    //$("#ddlyear_sem").val(parseInt(this['course_year']) + 1).trigger('change');
                 
                    bind_subject();
                    $("#ddlmedium").val(this['course_medium']);
                    if (this['student_name_english'] != null && this['father_name_english'] != null && this['mother_name_english'] != null) {
                        $("#txtstudent_name_en").val(this['student_name_english']).trigger('change');
                        $("#txtfather_name_en").val(this['father_name_english']).trigger('change');
                        $("#txtmother_name_en").val(this['mother_name_english']).trigger('change');
                        $('#txtstudent_name_en').prop("disabled", true);
                        $('#txtfather_name_en').prop("disabled", true);
                        $('#txtmother_name_en').prop("disabled", true);
                        
                    }
                    else {
                        $('#txtstudent_name_en').prop("disabled", false);
                        $('#txtfather_name_en').prop("disabled", false);
                        $('#txtmother_name_en').prop("disabled", false);
                    }
                    //if (this['dob'] != null) {
                        var c = this['dob'];
                        $("#dob").val(formatDate(moment(c).format()));
                        //$('#dob').prop("disabled", true);
                    //}
                    //else {
                        //$('#dob').prop("disabled", false);
                    //}
                    if (this['aadhar_no'] != null) {
                        $("#txtaadhar").val(this['aadhar_no']);
                        $('#txtaadhar').prop("disabled", true);
                    }
                    else {
                        $('#txtaadhar').prop("disabled", false);
                    }
                    if (this['email_id'] != null) {
                        $("#txtemail").val(this['email_id']);
                        $('#txtemail').prop("disabled", true);
                    }
                    else {
                        $('#txtemail').prop("disabled", false);
                    }
                    if (this['category'] != null) { $("#ddlcategory").val(this['category']); $('#ddlcategory').prop("disabled", true); }
                    else { $('#ddlcategory').prop("disabled", false); }
                    if (this['category'] != null) { $("#ddlcategory").val(this['category']); $('#ddlcategory').prop("disabled", true); }
                    else { $('#ddlcategory').prop("disabled", false); }
                    if (this['gender'] != null) { $("#ddlgender").val(this['gender']); $('#ddlgender').prop("disabled", true); }
                    else { $('#ddlgender').prop("disabled", false); }
                    if (this['subcategory'] != null) { $("#ddl_securityservices").val(this['subcategory']); $('#ddl_securityservices').prop("disabled", true); }
                    else { $('#ddl_securityservices').prop("disabled", false); }
                    if (this['is_handicapped'] != null) { $("#ddlph").val(this['is_handicapped']); $('#ddlph').prop("disabled", true); }
                    else { $('#ddlph').prop("disabled", false); }
                    if (this['handicapped_type'] != null) { $("#ddlph_cat").val(this['handicapped_type']); $('#ddlph_cat').prop("disabled", true); }
                    else { $('#ddlph_cat').prop("disabled", false); }


                    if (this['religion'] != null) { $("#ddlreligion").val(this['religion']); $('#ddlreligion').prop("disabled", true); }
                    else { $('#ddlreligion').prop("disabled", false); }
                    if (this['territory'] != null) { $("#ddlterritory").val(this['territory']); $('#ddlterritory').prop("disabled", true); }
                    else { $('#ddlterritory').prop("disabled", false); }
                    if (this['nationality'] != null) { $("#ddlnationality").val(this['nationality']); $('#ddlnationality').prop("disabled", true); }
                    else { $('#ddlnationality').prop("disabled", false); }


                    if (this['mobile_no'] != null) { $("#txtMobile_No").val(this['mobile_no']); $('#txtMobile_No').prop("disabled", true); }
                    else { $('#txtMobile_No').prop("disabled", false); }
                    
                    $("#txtpaddress").val(this['p_addess']);
                    $("#ddlpstate").val(this['p_state']);
                    $("#ddlpdistrict").val(this['p_districtcity']);

                    if (this['p_pincode'] != null) { $("#txtppincode").val(this['p_addess']); $('#txtppincode').prop("disabled", true); }
                    else { $('#txtppincode').prop("disabled", false); }

                    $("#txtcaddress").val(this['m_addess']);
                    $("#ddlcstate").val(this['m_state']);
                    bind_District2();
                    $("#ddlcdistrict").val(this['m_districtcity']);
                    $("#txtcpincode").val(this['m_pincode']);

                    if (this['is_employed'] == true) {
                        $("#ddlemp_details").val("1").trigger('change');
                        $("#txtorghid").show();
                        $("#txtorghid1").show();
                    }
                    else {
                        $("#ddlemp_details").val("0").trigger('change');
                    }
                    if (this['emp_organisation'] != null) { $("#txtorg").val(this['emp_organisation']); $('#txtorg').prop("disabled", true); }
                    else { $('#txtorg').prop("disabled", false); }
                    if (this['emp_designation'] != null) { $("#txtdesig").val(this['emp_designation']); $('#txtdesig').prop("disabled", true); }
                    else { $('#txtdesig').prop("disabled", false); }

                    if (this['ssc_vboard'] != null) { $("#10_board").val(this['ssc_vboard']); $('#10_board').prop("disabled", true); }
                    else { $('#10_board').prop("disabled", false); }
                    if (this['ssc_year'] != null) { $("#10_year").val(this['ssc_year']); $('#10_year').prop("disabled", true); }
                    else { $('#10_year').prop("disabled", false); }
                   
                    $("#txthssub").val(this['ssc_subject']);
                    $("#10_max").val(this['ssc_max_marks']);
                    $("#10_min").val(this['ssc_obt_marks']);

                    if (this['ssc_percentage'] != null) { $("#10_Percentage").val(this['ssc_percentage']); $('#10_Percentage').prop("disabled", true); }
                    else { $('#10_Percentage').prop("disabled", false); }
                    if (this['ssc_division'] != null) { $("#10_division").val(this['ssc_division']); $('#10_division').prop("disabled", true); }
                    else { $('#10_division').prop("disabled", false); }

                    if (this['hsc_vboard'] != null) { $("#inter_board").val(this['hsc_vboard']); $('#inter_board').prop("disabled", true); }
                    else { $('#inter_board').prop("disabled", false); }
                    if (this['hsc_year'] != null) { $("#12_year").val(this['hsc_year']).trigger('change'); $('#12_year').prop("disabled", true); }
                    else { $('#12_year').prop("disabled", false); }

                    $("#txtimsub").val(this['hsc_subject']);
                    $("#inter_max").val(this['hsc_max_marks']);
                    $("#inter_min").val(this['hsc_obt_marks']);

                    if (this['hsc_percentage'] != null) { $("#inter_Percentage").val(this['hsc_percentage']); $('#inter_Percentage').prop("disabled", true); }
                    else { $('#inter_Percentage').prop("disabled", false); }
                    if (this['hsc_division'] != null) { $("#inter_Division").val(this['hsc_division']); $('#inter_Division').prop("disabled", true); }
                    else { $('#inter_Division').prop("disabled", false); }

                    if (this['ug_board'] != null) { $("#UG_board").val(this['ug_board']); $('#UG_board').prop("disabled", true); }
                    else { $('#UG_board').prop("disabled", false); }
                    if (this['ug_year'] != null) { $("#UG_year").val(this['ug_year']).trigger('change'); $('#UG_year').prop("disabled", true); }
                    else { $('#UG_year').prop("disabled", false); }
                   
                    $("#txtugsub").val(this['ug_subject']);

                    $("#ug_max").val(this['ug_max_marks']);
                    $("#ug_min").val(this['ug_obt_marks']);

                    
                    if (this['ug_percentage'] != null) { $("#ug_Percentage").val(this['ug_percentage']); $('#ug_Percentage').prop("disabled", true); }
                    else { $('#ug_Percentage').prop("disabled", false); }
                    if (this['ug_division'] != null) { $("#ug_Division").val(this['ug_division']); $('#ug_Division').prop("disabled", true); }
                    else { $('#ug_Division').prop("disabled", false); }

                    if (this['pg_board'] != null) { $("#graduate_board").val(this['pg_board']); $('#graduate_board').prop("disabled", true); }
                    else { $('#graduate_board').prop("disabled", false); }
                    if (this['pg_year'] != null) { $("#graduate_year").val(this['pg_year']).trigger('change'); $('#graduate_year').prop("disabled", true); }
                    else { $('#graduate_year').prop("disabled", false); }
                    
                    $("#txtgrdsub").val(this['pg_subject']);
                    $("#graduate_max").val(this['pg_max_marks']);
                    $("#graduate_min").val(this['pg_obt_marks']);
                    if (this['pg_percentage'] != null) { $("#graduate_Percentage").val(this['pg_percentage']); $('#graduate_Percentage').prop("disabled", true); }
                    else { $('#graduate_Percentage').prop("disabled", false); }
                    if (this['pg_division'] != null) { $("#graduate_Division").val(this['pg_division']); $('#graduate_Division').prop("disabled", true); }
                    else { $('#graduate_Division').prop("disabled", false); }

                    $("#txtother_board").val(this['other_board']);
                    $("#txtother_year").val(this['other_year']).trigger('change');
                    $("#txtothersub").val(this['other_subject']);
                    $("#txtother_max").val(this['other_max_marks']);
                    $("#txtother_min").val(this['other_obt_marks']);
                    $("#txtother_Percentage").val(this['other_percentage']);
                    $("#txtother_Division").val(this['other_division']);

                    //$("#photo_preview").attr('src', this['student_photo'].replace('~', 'http://uprtouexam.in/..'));
                    //$("#photo_preview").attr('fname', this['student_photo']);

                    //$("#sign_preview").attr('src', this['student_signature'].replace('~', 'http://uprtouexam.in/..'));
                    //$("#sign_preview").attr('fname', this['student_signature']);

                    //if (this['p_pincode'] == this['m_pincode']) {
                    //    $("#Chk_address_id").prop('checked', true);
                    //    Chk_address();
                    //}
                });
                $("#divhideshow_pros").show();
            }
            else {
                 alertify.alert('Enrollment No Not Found')
                $("#divhideshow_pros").hide();
            }
        },
        complete: function () { }
    });
});