function load_problem_type_form(){
	$("#modal_body_add_prob_type").load("module/ground_water/problem_type_form.php");
	
}
function load_problem_type_list(){
	$("#problem_type_datatable").load("module/ground_water/problem_type_datatable.php");
}

function save_problem_type(){
	var problem_type = $("#problem_type_name").val();
	var operation = "insert";
	var dataStr = "problem_type_name="+problem_type+"&operation="+operation;
	
	if(problem_type=="") {
		toastr.error("Problem Type Cannot Be Blank");
		$("#problem_type_name").focus();
		return false;
	} else {
		//alert(dataStr);
		$.ajax({
			type:"post" ,
			url:"module/ground_water/problem_type_crud.php" ,
			data:dataStr ,
			cache:false ,
			success:function(st){
				if(st=="1") {
					toastr.success('Problem Type Information Successfully Saved.');
					$('#modal_add_prob_type').modal('hide');
					load_problem_type_list();	
				}else{
					toastr.error('Failed to Save Problem Type. Please Try Again');
				}
			}
		});	
	}
}

function load_edit_form(id){
	var dataStr = "id="+id;
	//alert(dataStr);
	$("#modal_body_edit_prob_type").load("module/ground_water/problem_type_edit_form.php",dataStr);
}

function update_problem_type(){
	var operation = "update";
	var sel_pt_id = $("#sel_pt_id").val();
	var e_problem_type_name = $("#e_problem_type_name").val();
	var e_status = $("#e_status").val();
	var dataStr = "problem_type_name="+e_problem_type_name+"&status="+e_status+"&id="+sel_pt_id+"&operation="+operation;
	
	if(e_problem_type_name=="") {
		toastr.error("Problem Type Cannot Be Blank");
		$("#e_problem_type_name").focus();
		return false;
	} else {
		//alert(dataStr);
		$.ajax({
			type:"post" ,
			url:"module/ground_water/problem_type_crud.php" ,
			data:dataStr ,
			cache:false ,
			success:function(st){
				//alert(st);
				if(st=="1") {
					toastr.success('Problem Type Information Updated Successfully Saved.');
					$('#modal_edit_prob_type').modal('hide');
					load_problem_type_list();	
				}else{
					toastr.error('Failed to Update Problem Type. Please Try Again');
				}
			}
		});
	}
}

function delete_problem_type(id){
	var problem_type = $("#problem_type_name").val();
	operation = "delete";
	form = 'problemTypeForm';
	dataStr = $('#'+form).serialize();
	dataStr = "id="+id+"&operation="+operation;
	//alert(dataStr);
	var result = confirm("Are you sure you want to delete data?");
	if (!result) {
		//Logic to delete the item
	} else {
		$.ajax({
			type:"post" ,
		   //	url:"login_check.php" ,
		   url:"module/ground_water/problem_type_crud.php" ,
			data:dataStr ,
			cache:false ,
			success:function(st){
				//alert(st);
				if(st=="1") {
					toastr.success('Problem Type Information Updated Successfully Saved.');
					$("#problem_type_datatable").load("module/ground_water/problem_type_datatable.php");
				}else{
					toastr.error('Failed to Update Problem Type. Please Try Again');
				}
			}
		});	
	}
	
}