var mods 			=	$('#main_page').val();
var types 			=	$('#main_type').val(); 
var action 			=	$('#main_action').val();
if(mods=="payment" && types=="buyer_status_monitoring" && (action=="edit" || action=="view")){
	load_buyer_status_monitoring(); 
}

function save_buyer_status_monitoring(){
				var monitoring_details		= 	$('#buyer_status_monitoring_form').serialize(); 
				var mods 					=	$('#main_page').val();
				var types 					=	$('#main_type').val(); 
				var action 					=	$('#main_action').val();
				var mainid					=	$('#main_id').val(); 
				var dataString				=	monitoring_details+"&action="+encodeURIComponent(action)+"&mainid="+encodeURIComponent(mainid);
				 
						$.post('./ajax/buyer_status_monitoring.php', dataString, function(msg){
								var obj	= $.parseJSON(msg);
								if(obj.output==true){
									bootbox.alert("Successfully Saved ...");
									window.setTimeout(function() { window.location.href = 'index.php?pg='+mods+'&type=buyer_status_monitoring'; }, 1000);
								}else{
									bootbox.alert("Failed in saving.");
								}
						});
}

//LOADING MONITORING OF FOLDERS DETAILS
function load_buyer_status_monitoring(){ 
				var mods 			=	$('#main_page').val();
				var types 			=	$('#main_type').val(); 
				var action 			=	$('#main_action').val();
				var mainid			=	$('#main_id').val();
				var dataString		=	"action="+encodeURIComponent(action)+"&mainid="+encodeURIComponent(mainid);
						$.post('./ajax/load_buyer_status_monitoring.php', dataString, function(msg){
								var obj	= $.parseJSON(msg);
								var full_name				=	obj.data[0].full_name; 
								var reservation_date		=	obj.data[0].reservation_date; 
								var orientation_date		=	obj.data[0].orientation_date; 
								var conducted				=	obj.data[0].conducted; 
								var pagibig_takeout_date	=	obj.data[0].pagibig_takeout_date; 
								var homeowner_orientation	=	obj.data[0].homeowner_orientation; 
								var inspection				=	obj.data[0].inspection; 
								var reinspection			=	obj.data[0].reinspection; 
								var letter_sent				=	obj.data[0].letter_sent; 
								var house_acceptance		=	obj.data[0].house_acceptance; 
								var permit_to_occupy		=	obj.data[0].permit_to_occupy; 
								var permit_to_occupy_num	=	obj.data[0].permit_to_occupy_number; 
								var block					=	obj.data[0].block; 
								var lot						=	obj.data[0].lot; 
								var phase					=	obj.data[0].phase; 
								var lot_size				=	obj.data[0].lot_size; 
								var floor_area				=	obj.data[0].floor_area; 
							    var pto  					=	obj.data[0].pto_status;

							   if(orientation_date=="01/01/1970"){	orientation_date = "";	}
							   if(homeowner_orientation=="01/01/1970"){	homeowner_orientation = "";	}
							   if(inspection=="01/01/1970"){	inspection = "";	}
							   if(reinspection=="01/01/1970"){	reinspection = "";	}
							   if(letter_sent=="01/01/1970"){	letter_sent = "";	}
							   if(house_acceptance=="01/01/1970"){	house_acceptance = "";	}
							   if(permit_to_occupy=="01/01/1970"){	permit_to_occupy = "";	}
							   if(pagibig_takeout_date=="01/01/1970"){	pagibig_takeout_date = "";	}
								$('#bsm_fullname').val(full_name); 
								$('#bsm_reservation_date').val(reservation_date); 
								$('#bsm_orientation_date').val(orientation_date); 
								$('#bsm_conducted').select2('val',conducted); 
								$('#bsm_pagibig_takeout_date').val(pagibig_takeout_date); 
								$('#bsm_homeowner_orientation').val(homeowner_orientation); 
								$('#bsm_inspection').val(inspection); 
								$('#bsm_reinspection').val(reinspection); 
								$('#bsm_letter_sent').val(letter_sent); 
								$('#bsm_house_acceptance').val(house_acceptance); 
								$('#bsm_permit_to_occupy').val(permit_to_occupy); 
								$('#bsm_permit_to_occupy_number').val(permit_to_occupy_num); 
								
								$('#bsm_phase').val(phase); 
								$('#bsm_block').val(block); 
								$('#bsm_lot').val(lot); 
								$('#bsm_lot_size').val(lot_size); 
								$('#bsm_floor_area').val(floor_area); 
								$('#bsm_pto').val(pto); 
						});
}