function updatePrediction() {
	HoldOn.open({
		theme: "sk-bounce",
		message: "Please wait...."
	});
	var activity = $("input[name='activity[]']").map(function () {
		return $(this).val().trim();
	}).get();
	if (activity.length === 0) {
		HoldOn.close();
		Swal.fire('Still no activities!');
		return false;
	}
	var newTime = $("input[name='newTime[]']").map(function () {
		return $(this).val().trim();
	}).get();
	var oldTime = $("input[name='oldTime[]']").map(function () {
		return $(this).val().trim();
	}).get();



	var activityArr = [];
	var hourArr = [];
	var change_id = [];
	for (i = 0; i < activity.length; i++) {
		if (newTime[i] !== oldTime[i]) {
			activityArr.push(activity[i]);
			hourArr.push(newTime[i]);
			change_id.push(i);
		}
	}
	if (activityArr.length === 0) {
		HoldOn.close();
		Swal.fire('No Change Detected!');
		return false;
	}

	if (activityArr.length === hourArr.length) {

		$.ajax({
			url: base_urlJs+"Supervisor_Contoller/addTimeAjax",
			type: "post",
			data: {activityArr: activityArr, hourArr: hourArr},
			success: function (data) {
				var st = JSON.parse(data);
				if (st) {
					HoldOn.close();
					Swal.fire(
						'Success!',
						'Successfully Updated.',
						'success'
					);
					for (x = 0; x < change_id.length; x++) {
						console.log("oldTime_" + change_id[x]);
						console.log(hourArr[x]);
						$("#oldTime_" + change_id[x]).val(hourArr[x]);
					}
					return true;
				}
			},
			error: function (jqXhr) {
				if (jqXhr.status == 400) { //Validation error or other reason for Bad Request 400
					var json = $.parseJSON(jqXhr.responseText);
					Swal.fire(
						'Error!',
						'Invalid data.',
						'error'
					);

				} else {
					Swal.fire(
						'Error!',
						'Internal Server Error.',
						'error'
					);
				}
			}
		});


	}
	HoldOn.close();
}


function updateData() {
	HoldOn.open({
		theme: "sk-bounce",
		message: "Updating...."
	});
	var act=$("#act").val();
	var sup_exp_tar=$("#sup_exp_tar").val();
	var sup_value=$("#sup_value").val();
	var sup_monitor=$("#sup_monitor").val();
	var sup_monitor_frqu=$("#sup_monitor_frqu").val();
	var sup_suggestion=$("#sup_suggestion").val()
	var data = {
		'act': act,
		'sup_exp_tar': sup_exp_tar,
		'sup_value':sup_value,
		'sup_monitor':sup_monitor,
		'sup_monitor_frqu':sup_monitor_frqu,
		'sup_suggestion':sup_suggestion
	}

	$.ajax({
		url: base_urlJs+"Supervisor_Contoller/updateSupActivityDetail",
		type: "post",
		data: data,
		success: function (data) {
			var st = JSON.parse(data);
			if (st) {
				$('#myModal').modal('toggle');
				HoldOn.close();
				Swal.fire(
					'Success!',
					'Successfully Updated.',
					'success'
				);

			}else {
				Swal.fire(
					'Error!',
					'Internal server Error.',
					'error'
				);
			}
		},
		error: function (jqXhr) {
			if (jqXhr.status == 400) { //Validation error or other reason for Bad Request 400
				var json = $.parseJSON(jqXhr.responseText);
				console.log(json);
			}
		}
	});
}

function loadDataToModel(activity) {
	HoldOn.open({
		theme: "sk-bounce",
		message: "Please wait...."
	});
	$("#ac_modal-title").html(activity)
	clearModelData();
	$.ajax({
		url: base_urlJs+"Supervisor_Contoller/loadSupActivityDetail",
		type: "get",
		data: {activity: activity},
		success: function (data) {
			var dt = JSON.parse(data);
			console.log(dt[0]);
			setData(activity,dt[0]['sup_exp_tar'],dt[0]['sup_value'],dt[0]['sup_monitor'],dt[0]['sup_monitor_frqu'],dt[0]['sup_suggestion'])
			HoldOn.close();
		},
		error: function (jqXhr) {
			console.log(jqXhr)
		}
	});
}
function clearModelData() {
	$("#act").val("");
	$("#sup_exp_tar").val("");
	$("#sup_value").val("0");
	$("#sup_monitor").val("");
	$("#sup_monitor_frqu").val("");
	$("#sup_suggestion").val("");
}
function setData(act,sup_exp_tar,sup_value,sup_monitor,sup_monitor_frqu,sup_suggestion) {
	$("#act").val(act);
	$("#sup_exp_tar").val(sup_exp_tar);
	$("#sup_value").val(sup_value);
	$("#sup_monitor").val(sup_monitor);
	$("#sup_monitor_frqu").val(sup_monitor_frqu);
	$("#sup_suggestion").val(sup_suggestion);
}
