0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 18.118.1.63


Current Path : /proc/thread-self/root/var/www/html/pgadm/js/
Upload File :
Current File : //proc/thread-self/root/var/www/html/pgadm/js/kusPhdAdm_04122018.js

var $host_url="http://"+window.location.host+"/"+window.location.pathname.split('/')[1]+"/"+window.location.pathname.split('/')[2]+"/app.php?a=";

var $host_url1 = "http://"+window.location.host+"/"+window.location.pathname.split('/')[1]+"/";

var gRgPerinfo;
var photo_path;
var sign_path;
let subdet = [];
let rgMultiMarks = [];
const months = ['January', 'February', 'March', 'April', 'May', 'June', 
				'July', 'August', 'September', 'October', 'November', 'December'];

// For loading the personal data of student in instruction page
function loadPerdata() {
	$.ajax({
		type: "POST",
		async: false,
		url:$host_url+'getstudentdetails',
		success: function getStudPerdataResponce(responce)
		{
			responce = eval('(' + responce + ')');
			response = responce.data;
			if(response.ffinsub == 'T')
			{
				$("#admEnt").hide();
			}
			if(response.mobile == 'T')
			{
				$("#admEnt").hide();
				$("#msg").html(response.msg);
			}
			var perdata = `<tr>
                <td colspan="3" ><b>Hi, ${ response.fname }</b></td>
                </tr>
                <tr>
                    <td width="15%">College</td><td width="2%"> : </td>
                    <td width="68%"> <b>${ response.college }</b></td>
                </tr>
                <tr>
                    <td>Degree</td><td width="2%"> : </td>
                    <td><b> ${ response.fdegree }</b> </td>
                </tr>
                <tr>
                    <td>Mobile Number</td><td width="2%"> : </td>
                    <td><b>${ response.fmobileno }</b></td>
                </tr>
                <tr>
                    <td>Email Id</td><td width="2%"> : </td>
                    <td><b>${ response.femail }</b> </td>
                </tr>`;
			$("#studinfo").html(perdata);
			$("#femail").val(response.femail);
		}
	});

}

function loadMasters()
{
	login();
	$('#personal_det').show();
	$('#success_card').hide();
	verify = 1;
	$.ajax({
		type: "POST",
		async: false,
		url:$host_url+'getcmsdropdownmenuvalues',
		success: function GetCMSDropDownMenuValuesResponce(responce)
		{
			responce = eval('(' + responce + ')');				
			
			var states = ['Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chhattisgarh',
			'Goa', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand',
			'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Manipur', 'Meghalaya',
			'Mizoram', 'Nagaland', 'Odisha', 'Punjab', 'Rajasthan', 'Sikkim', 'Tamil Nadu',
			'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal',
			'Andaman and Nicobar Islands', 'Chandigarh', 'Dadra and Nagar Haveli', 'Daman and Diu',
			'Lakshadweep', 'National Capital Territory of Delhi', 'Puducherry (Pondicherry)'];
			
			var state_options = '<option value="">--Select--</option>';
			states.forEach(function(state) {
				state_options += `<option value="${state}">${state}</option>`;
			});

			$('.selstate').html(state_options);

			$('#stuMobileno').val(responce.data.fmobileno);
			$('#idDob').val(responce.data.fdob);
			 
			var gender = responce.data.perdetl['gender'];
			if(gender != "")
			{
				var $radios = $('input:radio[name=gender]');
				$radios.filter('[value='+gender+']').prop('checked', true);
			}

			var month_options = '<option value="">--Select--</option>';
			months.forEach(function(month) {
				month_options += `<option value="${month}">${month}</option>`;
			});

			$('.month').html(month_options);

			var option = '<option value="">--Select--</option>';
			for (var j=2018;j>1980;j--) 
			{
				option += "<option value='"+j+"'>"+j+"</option>";
			} 
			$(".year").append(option);

			var serv_arr = responce.data['category'];
			var serv_title = '';
			FillDropdownValues(serv_arr,'idCategory',serv_title);
			
			//loadUpload();
			var serv_arr = responce.data['college'];
			var serv_title = '';
			FillDropdownValues(serv_arr,'idCollege',serv_title);

			var serv_arr = responce.data['boards'];
			var serv_title = '';
			FillDropdownValues(serv_arr,'idUnvName',serv_title);

			var serv_arr = responce.data['degree'];
			var serv_title = '';
			FillDropdownValues(serv_arr,'idDegree',serv_title);
			

			if(responce.data.percnt >0)
			{

				var datastring = "&college="+responce.data.perdetl['idCollege'];

				var datastring = "&college="+responce.data.perdetl['idCollege']+"&degree="+responce.data.perdetl['idDegree'];
				if(responce.data.perdetl['studphoto'] != "")
				{
					photo_path = responce.data.perdetl['studphoto'];
					$("#frmFileUpload").hide();
					$("#studphoto_img").attr('src', $host_url1+''+responce.data.perdetl['studphoto'])
					$("#studphoto").show();
				}
				if(responce.data.perdetl['studsign'] != "")
				{
					sign_path = responce.data.perdetl['studsign'];
					$("#signatureUpload").hide();
					$("#studsign_img").attr('src', $host_url1+''+responce.data.perdetl['studsign']);
					$("#studsign").show();
				}
				var combination = responce.data.perdetl['idDegComb'];
				$.ajax({
					type: "POST",
					async: true,
					data: datastring,
					url:$host_url+'getcombinationdetailsdetails',
					success: function GetdegreedetailsResponce(responce)
					{
						responce = eval('(' + responce + ')');				
						var serv_arr = responce.data['mascomb'];
						var serv_title = '';
						FillDropdownValues(serv_arr,'idDegComb',serv_title);
						$("#idDegComb").val(combination);
					}
				});

				loadeditSubjectdet(responce.data.perdetl['idDegree'],responce.data.perdetl['idDegComb'], responce.data.perdetl['fappno']);

				$("#idPerDet input[type=text],#idPerDet select").each(function()
				{
					if($(this).attr('id') != 'stuMobileno' && $(this).attr('id') != 'idDob')
					$(this).val(responce.data.perdetl[$(this).attr('id')]);
				});

				$("#idPrevDet input[type=text],#idPrevDet select,#idPrevDet textarea").each(function()
				{
					$(this).val(responce.data.perdetl[$(this).attr('id')]);
				});

				$('#fappno').val(responce.data.perdetl['fappno']);
				loadedituploads(responce.data.perdetl['idDegree'],responce.data.perdetl['idCollege'],responce.data.perdetl['fappno']);
				$("#idDegree").val(responce.data.fdegree);
			}
			else
			{
				$('#idCollege').val(responce.data.fcollcode);
				$("#idDegree").val(responce.data.fdegree);
				loadSubjectCombdet();
				loaduploads();
			}	

		}
	});
}

function changePhoto()
{
	$("#frmFileUpload").show();
	$("#studphoto").hide();
}

function changeSign()
{
	$("#signatureUpload").show();
	$("#studsign").hide();
}

function getBoardDet(obj)
{
	if(obj.value == '') {
		alert("Select a Board");
		return;
	}
	var datastring = "boardCode="+obj.value;

	$.blockUI({ message: "<img src='img/Loading_icon.gif' border='0'>" });
	$.ajax({
		type: "POST",
		async: false,
		data: datastring,
		url:$host_url+'getboarddetails',
		success: function GetdegreedetailsResponce(responce)
		{
			$.unblockUI();
			responce = eval('(' + responce + ')');
			var boardDet = responce.data['boardDet'];
			if(obj.id == 'idSchBoard')
			{

				$("#idSchState").val(boardDet['fboardsate']);
				$("#idSchBoardAdd").val(boardDet['faddress']);
				$("#idSchoolBoardPhone").val(boardDet['fphoneno']);
			}
			else
			{
				$("#idUnvState").val(boardDet['fboardsate']);
				$("#idUnvAdd").val(boardDet['faddress']);
				$("#idUnvPhone").val(boardDet['fphoneno']);
			}

		}
	});
}

function getdegreedetails()
{

	var datastring = "&college="+$('#idCollege').val();
	
	$.blockUI({ message: "<img src='img/Loading_icon.gif' border='0'>" });
	$.ajax({
		type: "POST",
		async: false,
		data: datastring,
		url:$host_url+'getdegreedetails',
		success: function GetdegreedetailsResponce(responce)
		{
			$.unblockUI();
			responce = eval('(' + responce + ')');				
			var serv_arr = responce.data['degree'];
			var serv_title = '';
			FillDropdownValues(serv_arr,'idDegree',serv_title);
		}
	});
}


function loadSubjectCombdet()
{
	var datastring = "&college="+$('#idCollege').val()+"&degree="+$('#idDegree').val();
	
	$.blockUI({ message: "<img src='img/Loading_icon.gif' border='0'>" });
	$.ajax({
		type: "POST",
		async: true,
		data: datastring,
		url:$host_url+'getcombinationdetailsdetails',
		success: function GetdegreedetailsResponce(responce)
		{
			$.unblockUI();
			responce = eval('(' + responce + ')');				
			var serv_arr = responce.data['mascomb'];
			var serv_title = '';
			FillDropdownValues(serv_arr,'idDegComb',serv_title);
		}
	});
}

function calcPercent()
{
	if($("#maxmarks").val() == '')
	{
		alert("Enter Maximum Marks");
		return;
	}
	if($("#secmarks").val() == '')
	{
		alert("Enter Secured Marks");
		return;
	}
	$("#percentage").val(
		(
			(parseFloat($("#secmarks").val())*100)
			/parseFloat($("#maxmarks").val())
		).toFixed(2));
}

var totsub;

function loadSubjectdet()
{
	var datastring = "&degree="+$('#idDegree').val()+"&combcode="+$('#idDegComb').val();
	
	$.blockUI({ message: "<img src='img/Loading_icon.gif' border='0'>" });
	$.ajax({
		type: "POST",
		async: true,
		data: datastring,
		url:$host_url+'loadSubjectdet',
		success: function loadSubjectdetResponce(responce)
		{
			$.unblockUI();
			responce = eval('(' + responce + ')');				
			var subtable = `<style type = "text/css">
			.table-sub tbody tr td {
				padding : 2px;
				vertical-align:middle;
				border: 1px solid #949494;
				text-align: center;
			}	
			.table-sub thead tr td {
				text-align: center;
			}
			</style>
			<table class='table table-bordered table-striped table-sub'>
					<thead>
						<tr class = "bg-cyan">
							<td style = "width :10%">Sl. No.</td>
							<td style = "width : 15%;" >Sub. Code</td>
							<td style = "width : 75%;">Subject Name</td>
						</tr>
					</thead>
					<tbody>`;

			totsub = responce.data['totsub'];
			var mresults = responce.data['mresults'];
			var rresults = responce.data['rresults'];
			var rresults_arr = responce.data['rresults'];
			var mtotalsub = responce.data['mtotalsub'];
			//var rresults = rresults['subname'];
			var remainsub = totsub - mtotalsub;
			
		//	console.log(rresults);
			
			subject_options = '<option value="">--Select Subject--</option>';
			rresults.forEach(function(rresults) {
				
				subject_options += `<option value="${rresults['fsubcode']}">${rresults['fsubname']}</option>`;
			});
			var x = 1;
			if(mtotalsub != 0)
			{	
				var j = 0;
				for(var i = 1; i<=mtotalsub;i++)
				{
					subtable += `<tr>
							<td>${i}</td>
							<td class="subcode">${mresults[j]['fsubcode']}</td>
							<td style = "text-align:left;"> ${mresults[j]['fsubname']}</td></tr>`;	
					x++;
					j++;
				}
				
			}

			if(remainsub > 0)
			{
				var j = 0;
				for(var z = x; z<=totsub;z++)
				{
					subtable += `<tr>
							<td>${z}</td>
							<td class="subcode" id = "subcode_${z}"></td>
							<td ><select style="padding-left: 0px;" id = "sub_${z}" class = "form-control" onchange = "getsubname('${z}', this)" >${subject_options}</select></td></tr>`;
					j++;	
				}
				
			}
			//console.log(subtable);
			$('#subdet').html(subtable);
		}
	});
}


function loadeditSubjectdet(degree,combination,appno)
{
	var datastring = "&degree="+degree+"&combcode="+combination+"&appno="+appno;
	
	$.blockUI({ message: "<img src='img/Loading_icon.gif' border='0'>" });
	$.ajax({
		type: "POST",
		async: true,
		data: datastring,
		url:$host_url+'loadeditSubjectdet',
		success: function loadeditSubjectdetResponce(responce)
		{
			$.unblockUI();
			responce = eval('(' + responce + ')');				
			var subtable = `<style type = "text/css">
			.table-sub tbody tr td {
				padding : 2px;
				vertical-align:middle;
				border: 1px solid #949494;
				text-align: center;
			}	
			.table-sub thead tr td {
				text-align: center;
			}
			</style>
			<table class='table table-bordered table-striped table-sub'>
					<thead>
						<tr class = "bg-cyan">
							<td style = "width :10%">Sl. No.</td>
							<td style = "width : 15%;" >Sub. Code</td>
							<td style = "width : 75%;">Subject Name</td>
						</tr>
					</thead>
					<tbody>`;

			totsub = responce.data['totsub'];
			var mresults = responce.data['mresults'];
			var rresults = responce.data['rresults'];
			var rresults_arr = responce.data['rresults'];
			var mtotalsub = responce.data['mtotalsub'];
			var option_sub = responce.data['option_sub'];
			var i = 0;
			var options = [];
			for(var sub of option_sub)
			{
				options.push(sub['fsubcode']);
			}

			//var rresults = rresults['subname'];
			var remainsub = totsub - mtotalsub;
			
			//console.log(rresults_arr[0]['fsubname']);

			var x = 1;
			if(mtotalsub != 0)
			{	
				var j = 0;
				for(var i = 1; i<=mtotalsub;i++)
				{
					subtable += `<tr>
							<td>${i}</td>
							<td class="subcode">${mresults[j]['fsubcode']}</td>
							<td style = "text-align:left;"> ${mresults[j]['fsubname']}</td></tr>`;	
					var value = mresults[j]['fsubcode'];
					
					options = options.filter(function(item) { 
					    return item !== value
					});
					x++;
					j++;

				}
				
			}

			var i = 0;
			var subject_options = [];
			
			var subject_option = '<option value="">--Select Subject--</option>'
				rresults.forEach(function(rresults) {
					subject_option += `<option value="${rresults['fsubcode']}">
						${rresults['fsubname']}
						</option>`;
				});

			if(option_sub.length == 0 || options.length == 0)
			{
				var subject_option = '<option value="">--Select Subject--</option>'
				rresults.forEach(function(rresults) {
					subject_option += `<option value="${rresults['fsubcode']}">
						${rresults['fsubname']}
						</option>`;
				});
			}
			else
			{
				for(var sub of options){
					subject_options[i] = '<option value="">--Select Subject--</option>'
					rresults.forEach(function(rresults) {
						if(rresults['fsubcode'] == sub)
						{
							subject_options[i] += `<option selected="selected" 
							value="${rresults['fsubcode']}">${rresults['fsubname']}
							</option>`;
							
						}
						else {
							subject_options[i] += `<option value="${rresults['fsubcode']}">
							${rresults['fsubname']}
							</option>`;
						}
					});
					i++;
				}
			}
			if(remainsub > 0)
			{
				var j = 0;
				for(var z = x; z<=totsub;z++)
				{
					if(option_sub.length == 0 || options.length == 0 || options[j] == undefined)
					{
						
						subtable += `<tr>
								<td>${z}</td>
								<td class="subcode" id = "subcode_${z}"></td>
									<td ><select value="" style="padding:0px 3px !important;" 
									id = "sub_${z}" class = "form-control" 
									onchange = "getsubname('${z}', this)" >
									${subject_option}</select></td>
								</tr>`;
						
					}
					else
					{
						subtable += `<tr>
								<td>${z}</td>
								<td class="subcode" id = "subcode_${z}">${options[j]}</td>
									<td ><select value="${options[j]}" style="padding:0px 3px !important;" 
									id = "sub_${z}" class = "form-control" 
									onchange = "getsubname('${z}', this)" >
									${subject_options[j]}</select></td>
								</tr>`;

					}
					j++;
				}
				
			}
			//console.log(subtable);
			$('#subdet').html(subtable);
			var i = 0;
			for(var sub of options)
			{
				z++;
				$('#subcode_'+z).html(sub);
				$('#sub_'+z).val(sub);
			}

		}
	});
}





var selSubArr = [];

function getsubname(id, obj)
{
	//console.log(obj.value);
	if(obj.value == "")
		alert("Subject Should be selected");
	
	if(!in_array(obj.value,selSubArr)) 
	{
		selSubArr.push(obj.value);		
		$('#subcode_'+id).html(obj.value);
	}
	else
	{
		alert("Subject already selected");
	}
}

function homeLink()
{
	var r = confirm("Do You Want To Logout!");
	if (r == true) 
	{
	    window.location.href = "index.html";

	} else 
	{
		
	}
}


function in_array(needle, haystack, argStrict) {
 
    var key = '', strict = !!argStrict;

    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    }
    return false;
}

function getFeeDetail()
{
	var category = $('#idCategory').val();
	
	if($('#idCategory').val()=='')
	{
		return;
	}

	var datastring = "&category="+category;
	
	$.ajax(
	{
		type: "POST",
		data: datastring,
		url: $host_url+'getfeedetl',
		success: function getFeeDetailResponce(responce)
		{
			responce = eval('(' + responce + ')');	
			sum = responce.data['sum'];
			$('#sum').val(sum);
		}
	});
}

var gSubarray;
function getSubjectDetail()
{
	var degree = $('#idDegree').val();
	if($('#idDegree').val()=='')
	{
		return;
	}
	var datastring = "&degree="+degree;
	
	$.ajax({
		type: "POST",
		data: datastring,
		url: $host_url+'getsubjectdet',
		success: function getsubjectdetResponce(responce)
		{
			responce = eval('(' + responce + ')');	
			$('#subdet').html(responce.data['html']);
			//var arr = $.map(responce.data['subject'], function(el) { return el });
			gSubarray = JSON.stringify(responce.data['subject']);
			$('#idPaperTitle').css('display', 'block');
		}
	});
}


function validateApplication()
{
	var errcount = 0;
	jsonObj = [];
	gRgPerinfo = '';	
	subdet = [];
	rgMultiMarks = [];
	missing_fields = [];

	if(photo_filename === undefined && photo_path == undefined)
	{
		$('#photo_err').addClass('hasError');
		missing_fields.push("Student Photo");
    	errcount++;
	}
	else
	{
		$('#photo_err').removeClass('hasError');
		item = {}
    	item ["id"] = 'photo_path';
    	item ["value"] = photo_filename;
    	//console.log(photo_filename);
    	jsonObj.push(item);
	}

	if(sign_filename === undefined && sign_path == undefined)
	{
		$('#sign_err').addClass('hasError');
		missing_fields.push("Student Signature");
    	errcount++;
	}
	else
	{
		$('#sign_err').removeClass('hasError');
		item = {}
    	item ["id"] = 'sign_path';
    	item ["value"] = sign_filename;
    	jsonObj.push(item);
	}

	//validate and read values of text and select boxes
	$("#idPerDet input[type=text],#idPerDet select").each(function(){
		if($(this).val()=="" && !in_array($(this).attr('id'), nonMandFields))
		{
			$(this).closest('.form-group').find('.fieldError').addClass('hasError');
			errcount++;
			missing_fields.push($(this).attr('name'));
		}
		else
		{
			$(this).closest('.form-group').find('.fieldError').removeClass('hasError');
			item = {};
	        item ["id"] = $(this).attr('id');
	        item ["value"] = $(this).val();
	 		jsonObj.push(item);
		}
	});
	//validate and read values of Radio buttons
	
	
	if(!$('input[name="gender"]').is(':checked'))
	{
		$('input[name="gender"]').closest('.form-group').find('.fieldError').addClass('hasError');
		missing_fields.push("gender");
		errcount++;
	}
	else
	{
		
		$('input[name="gender"]').closest('.form-group').find('.fieldError').removeClass('hasError');			
		value = $('input[name="gender"]:checked').val();
		item = {}
    	item ["id"] = "gender";
    	item ["value"] = value.toUpperCase();
    	jsonObj.push(item);
	}


	$("#idPrevDet input[type=text],#idPrevDet select,#idPrevDet textarea").each(function(){
		if($(this).val()=="" &&($(this).attr('id') != 'adhar' && $(this).attr('id') != 'landline'))
		{
			$(this).closest('.form-group').find('.fieldError').addClass('hasError');
			errcount++;
			missing_fields.push($(this).attr('name'));
		}
		else
		{
			$(this).closest('.form-group').find('.fieldError').removeClass('hasError');
			item = {};
	        item ["id"] = $(this).attr('id');
	        item ["value"] = $(this).val();
	 		jsonObj.push(item);
		}
	});


	$('#subdet table tr td.subcode').each((i, el) => {
		subdet.push($(el).html());
		if($(el).html() == '')
			missing_fields.push("Subject "+i);
	});

	$("#uploaddet input[type=hidden]").each(function(){
		var item = {};
		item ["id"] = $(this).attr('id');
		item ["value"] = $(this).val();
		jsonObj.push(item);
	});

	var html_string = '';
	for(let field of missing_fields)
	{
		html_string += "<li style='padding: 0px; margin: 0px;'>"+field+"</li>";
	}
	if(missing_fields.length > 0)
	{
		swal({
	        title: "The following fields are missing",
	        text: `<div class="col-md-12">
	        <ol style="color: red;text-align:left;">${html_string}</ol></div>`,
	        html: true,
	        showCancelButton: false,
	        confirmButtonColor: "#5495ff",
	        confirmButtonText: "OK",
	        closeOnConfirm: false
	    });
	}

	subdet       = JSON.stringify(subdet);
	gRgPerinfo   = JSON.stringify(jsonObj);

	gRgPerinfo   = encodeURI(JSON.stringify(jsonObj));

	rgMultiMarks = JSON.stringify(rgMultiMarks);
	return errcount;
}

var gAppNo;

function saveApplication()
{
	//let error = validateApplication();
	if(validateApplication() > 0)
	{
		alert("Fill All the details");
		return;
	}
	var fappno = $('#fappno').val();
	var datastring =  'personal_info='+gRgPerinfo+"&pRgSubjects="+subdet+"&rgMultiMarks="+rgMultiMarks+"&fappno="+fappno+"&final=T";
	$.blockUI({ message: "<img src='img/Loading_icon.gif' border='0'>" });
	$.ajax({
		type: "POST",
		data:datastring,
		url:$host_url+'savephdApplication',
		success: function(responce)
		{
			$.unblockUI();
			
			responce = eval('(' + responce + ')');
			if(responce.error_code === -1)
			{	
				$('#challanBtn').hide();
				$('#paytmBtn').hide();
			}	
			else
			{
				var app_no = responce.data['app_no'];
				$('#sbmchallan').hide();
				$('#makepayment').show();
				$('#dapp_no').append(app_no);
				gAppNo = app_no;
				
			}
			$('#app_msg').append(responce.data['message']);
			$('#personal_det').hide();
			$('#opt_course_det').hide();
			$('#upload_doc_det').hide();
			$('#sslc_doc_det').hide();
			$('#degree_doc_det').hide();
			$('#success_card').show();
		}	
	});
}

const nonMandFields = [ 'adhar', 'pmobileno', 'income'];

function savetmpApplication()
{
	//let error = validateApplication();
	var errcount = 0;
	jsonObj = [];
	gRgPerinfo = '';	
	subdet = [];
	rgMultiMarks = [];
	//validate and read values of text and select boxes
	var missing_fields = [];
	item = {}
	item ["id"] = 'photo_path';
	item ["value"] = photo_filename;
	jsonObj.push(item);
	if(photo_filename == undefined && photo_path == undefined)
		missing_fields.push("Student Photo");

	if(sign_filename == undefined && sign_path == undefined)
		missing_fields.push("Student Signature");

	$('#sign_err').removeClass('hasError');
	item = {}
	item ["id"] = 'sign_path';
	item ["value"] = sign_filename;
	jsonObj.push(item);

	$("#idPerDet input[type=text],#idPerDet select").each(function()
	{
		item = {};
        item ["id"] = $(this).attr('id');
        item ["value"] = $(this).val();
 		jsonObj.push(item);

 		if($(this).val() == '' && !in_array($(this).attr('id'), nonMandFields))
 		{
 			missing_fields.push($(this).attr('name'));
 		}
		
	});

	//validate and read values of Radio buttons
	var radio_names = ['gender'];
	for(var i=0;i<radio_names.length;i++)
	{
		if(!$('input[name="'+radio_names[i]+'"]').is(':checked'))
		{
			$('input[name="'+radio_names[i]+'"]').closest('.form-group').find('.fieldError').addClass('hasError');
			errcount++;
			missing_fields.push(radio_names[i]);
		}
		else
		{
			$('input[name="'+radio_names[i]+'"]').closest('.form-group').find('.fieldError').removeClass('hasError');			
			value = $('input[name="'+radio_names[i]+'"]:checked').val();
			item = {}
	    	item ["id"] = radio_names[i];
	    	item ["value"] = value.toUpperCase();
	    	jsonObj.push(item);
		}
	}
	
	$("#idPrevDet input[type=text],#idPrevDet select,#idPrevDet textarea").each(function(){
		item = {};
        item ["id"] = $(this).attr('id');
        item ["value"] = $(this).val();
 		jsonObj.push(item);
 		if($(this).val() == '')
 		{
 			missing_fields.push($(this).attr('name'));
 		}
	});


	$('#subdet table tr td.subcode').each((i, el) => {
		subdet.push($(el).html());
		if($(el).html() == '')
			missing_fields.push("Subject "+i);
	});


	$("#uploaddet input[type=hidden]").each(function(){
		var item = {};
		item ["id"] = $(this).attr('id');
		item ["value"] = $(this).val();
		jsonObj.push(item);
	});
	
	var html_string = '';
	for(let field of missing_fields)
	{
		html_string += "<li style='padding: 0px; margin: 0px;'>"+field+"</li>";
	}
	var html = "";
	var msg = "";
	if(missing_fields.length > 0)
	{
		html = `<div class="col-md-12">
			        <ol style="color: red;text-align:left;">${html_string}</ol></div>`
		msg = "The Following fields are missing";
	}
	subdet       = JSON.stringify(subdet);
	gRgPerinfo   = JSON.stringify(jsonObj);
	rgMultiMarks = JSON.stringify(rgMultiMarks);

	var fappno = $('#fappno').val();

	var datastring =  'personal_info='+gRgPerinfo+"&pRgSubjects="+subdet+"&rgMultiMarks="+rgMultiMarks+"&fappno="+fappno+"&final=F";
	console.log(datastring);
	$.blockUI({ message: "<img src='img/Loading_icon.gif' border='0'>" });
	$.ajax({
		type: "POST",
		data:datastring,
		url:$host_url+'savephdApplication',
		success: function(responce)
		{
			$.unblockUI();
			
			responce = eval('(' + responce + ')');
			if(responce.error_code === 0)
			{	
				swal({
			        title: `Updated successfully. Unless the final submission is made application will not be submitted to the university. ${msg}`,
			        text: html,
			        html: true,
			        showCancelButton: false,
			        confirmButtonColor: "#5495ff",
			        confirmButtonText: "OK",
			        closeOnConfirm: false
			    });
				$('#fappno').val(responce.data.app_no);
				return;
			}	
			else
			{
				alert('Updation Failed');
				return;
			}
		}	
	});
}


function FillDropdownValues(arr,ele_name,def_title)
{
	document.getElementById(ele_name).options.length=0;
	
	var option = "<option value=''>--Select--</option>";
	for (let value of arr) {
		option += "<option value='"+value.int_code+"'>"+value.val+"</option>";
	} 
	$("#"+ele_name).html(option);
}


function acceptNumbersOnlyForModule(evt)
{
	var charCode;
    if (window.event)
        charCode = window.event.keyCode;   //if IE
    else
        charCode = evt.which; //if firefox
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;
    return true;	
}

function charKeydown(evt){
	var charCode;
    if (window.event)
        charCode = window.event.keyCode;  //for IE
    else
        charCode = evt.which;  //for firefox
    if (charCode == 32) //for &lt;space&gt; symbol
        return true;
    if (charCode > 31 && charCode < 65) //for characters before 'A' in ASCII Table
        return false;
    if (charCode > 90 && charCode < 97) //for characters between 'Z' and 'a' in ASCII Table
        return false;
    if (charCode > 122) //for characters beyond 'z' in ASCII Table
        return false;
    return true;
}

function addCurrencyDelimeter(obj) {
	var nStr = $(obj).val();
	var num = parseInt(nStr);
	num = num.toLocaleString('en-IN')
   
	$(obj).val(num);
}

function autoFilladd()
{
	if($('#basic_checkbox_1').is(':checked'))
	{
		$('#cadd1').val($('#padd1').val());
		$('#cadd2').val($('#padd2').val());
		$('#cadd3').val($('#padd3').val());
		$('#cdistrict').val($('#pdistrict').val());
		$('#cpincode').val($('#ppincode').val());
		$('#cstate').val($('#pstate').val());
	}
	else
	{
		$('#cadd1').val('');
		$('#cadd2').val('');
		$('#cadd3').val('');
		$('#cdistrict').val('');
		$('#cpincode').val('');
		$('#cstate').val('');
	}
}

function rePrintApplication()
{
	// $.blockUI({ message: "<img src='img/Loading_icon.gif' border='0'>" });
	$.ajax({
		type: "POST",
		async: false,
		url:$host_url+'rePrintApplication',
		success: function(responce)
		{
			// $.unblockUI();
			responce = eval('(' + responce + ')');
			if(responce.error_code == 0)
			{
				gAppNo = responce.appno;
				makePayment();
			}
			else {
				alert("Application can be printed only after final submission is made");
			}
		}
	});

} 


function makePayment()
{
	window.location.href=$host_url+"printApplication&app_no="+gAppNo;
}

function PrintApplicationFormpaytmNETBANKING(pAppNo)
{
	$host_url = "http://oasis.logisys.org/kus/phdadm/app.php?&a=";
	window.location.href=$host_url+"PrintApplicationFormSBM&app_no="+pAppNo;
}

function getpercentage()
{
	var maxmarks =  parseInt($('#idUnvMaxMarks').val());
	var secmarks = parseInt($('#idUnvSecMarks').val());

		


	if($("#idUnvMaxMarks").val() == '')
	{
		return;
	}
	if($("#idUnvSecMarks").val() == '')
	{
		return;
	}


	if(maxmarks < secmarks)
	{
		alert('Maximum Marks less than Secured Marks');
		return;
	}

	$("#idUnvPerc").val(
		(
			(parseFloat($("#idUnvSecMarks").val())*100)
			/parseFloat($("#idUnvMaxMarks").val())
		).toFixed(2));


}


function submitquery()
{

	if($('#fmessage').val() == '')
	{
		swal({
			title: `Please enter message`,
			showCancelButton: false,
			confirmButtonColor: "#5495ff",
			confirmButtonText: "OK",
			closeOnConfirm: false
		});
		return;
	}

	if($('#fsubject').val() == '')
	{
		swal({
			title: `Please enter subject`,
			showCancelButton: false,
			confirmButtonColor: "#5495ff",
			confirmButtonText: "OK",
			closeOnConfirm: false
		});
		return;
	}

	if($('#femail').val() == '')
	{
		swal({
			title: `Please enter Email`,
			showCancelButton: false,
			confirmButtonColor: "#5495ff",
			confirmButtonText: "OK",
			closeOnConfirm: false
		});
		return;
	}	
//	
	var datastring =  'fmessage='+$('#fmessage').val()+"&fsubject="+$('#fsubject').val()+"&femail="+$('#femail').val();
	$.blockUI({ message: "<img src='img/Loading_icon.gif' border='0'>" });
	$.ajax({
		type: "POST",
		data:datastring,
		url:$host_url+'submitquery',
		success: function(responce)
		{
			$.unblockUI();
			
			responce = eval('(' + responce + ')');
			if(responce.error_code === 0)
			{	
				swal({
			        title: `Query has been submitted successfully. <br> Your query number is <b>${responce.data}</b>. <br> keep this number for future reference.<br>You will get email comunication on this issue.`,
			        html: true,
			        showCancelButton: false,
			        confirmButtonColor: "#5495ff",
			        confirmButtonText: "OK",
			        closeOnConfirm: false
			    });
			    $('#fmessage').val('');
			    $('#fsubject').val('');
			    closeForm();
				return;
			}	
			else if(responce.error_code === -2)
			{
				swal({
			        title: `${responce.data}`,
			        showCancelButton: false,
			        confirmButtonColor: "#5495ff",
			        confirmButtonText: "OK",
			        closeOnConfirm: false
			    });
			     $('#fmessage').val('');
			    $('#fsubject').val('');
			    logout();
				return;
			}else
			{
				swal({
			        title: `${responce.data}`,
			        showCancelButton: false,
			        confirmButtonColor: "#5495ff",
			        confirmButtonText: "OK",
			        closeOnConfirm: false
			    });
			     $('#fmessage').val('');
			    $('#fsubject').val('');
			    closeForm();
				return;
			}
		}	
	});
}


function logout()
{
	
	window.location.href = "index.html";

}