
$(document).ready(function() 
{ 	
	$('#resetPwdTable').mDatatable({});
	$('#formResetPassword').hide() ;
	$('#btnResetPwdClear').button().bind('click',clearResetPwd) ;
	$('#btnResetPwd').button().bind('click',resetPassword) ;
	
	clearResetPwd() ;
}) ;

function closeResetPwd() {
	$('#formResetPassword').hide('slow') ;
}
function clearResetPwd() {
	$('#lblResetPwdId').text("") ;
	$('#lblResetPwdName').text("") ;
	$('#lblResetPwdFull').text("") ;
	$('#lblResetPwdLogin').text("") ;
	//$('#btnResetPwd').prop('disabled','disabled') ;
	

}
function resetPassword() {
	if (validateResetPwd()) {
		var data = { "type": C_NEW, "id": $('#lblResetPwdId').text() } ;
		var url = "request.pzx?c=" + resetpwd_url + "&d=" + new Date().getTime() ;
		callServer(url,"json",data,onResetPwdResponse,null) ;
	}
}
function editResetPwd(id,obj) {
	var data = { "type": C_GET,"id": id} ;
	var url = "request.pzx?c=" + resetpwd_url + "&d=" + new Date().getTime();		
	callServer(url,"json",data,showResetPwd,null) ;
}

function showResetPwd(obj,resp) {
	if (resp.status == C_OK) {
		$('#formResetPassword').show('slow') ;
		$('#lblResetPwdId').text(resp.data.id) ;
		$('#lblResetPwdName').text(resp.data.name) ;
		$('#lblResetPwdFull').text(resp.data.fullname) ;
		$('#lblResetPwdLogin').text(resp.data.login) ;
		$('#btnResetPwd').prop('disabled','') ;
	}
	else {
		swal.fire("System Message",resp.mesg) ;
	}
}
function onResetPwdResponse(obj,resp) {
	if (resp.status == C_OK) {
		swal.fire("System Message",resp.mesg) ;
		closeResetPwd();
		clearResetPwd();
	}
	else 
		swal.fire("Error",resp.mesg) ;
}
function validateResetPwd() {
	return true ;
}