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

 
function save_buyer_status_folder_bank(){ 
				var monitoring_details		= 	$('#buyer_status_folder_bank_form').serialize(); 
				var mods 					=	$('#main_page').val();
				var types 					=	$('#main_type').val(); 
				var action 					=	$('#main_action').val();
				var mainid					=	$('#main_id').val(); 
				var dd  					=	$('#bsfb_date_delivered').val(); 
				var dataString				=	monitoring_details+"&action="+encodeURIComponent(action)+"&mainid="+encodeURIComponent(mainid)+"&dd="+encodeURIComponent(dd);
				  
						$.post('./ajax/buyer_status_folder_bank.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_folder_bank'; }, 1000);
								}else{
									bootbox.alert("Failed in saving.");
								}
						}); 
}

//LOADING MONITORING OF FOLDERS DETAILS
function load_buyer_status_folder_bank(){ 
				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_folder_bank.php', dataString, function(msg){
								var obj	= $.parseJSON(msg);
								var full_name				=	obj.data[0].full_name;  
								var facility				=	obj.data[0].facility; 
								var date_delivered			=	obj.data[0].date_delivered; 
								var returned_date			=	obj.data[0].returned_date; 
								var bank_account_officer	=	obj.data[0].bank_account_officer; 
								var log						=	obj.data[0].log; 
								var booking					=	obj.data[0].booking; 
								var take_out				=	obj.data[0].take_out; 
								var reservation_date		=	obj.data[0].reservation_date; 
								var reason					=	obj.data[0].reason; 
								
								var phase					=	obj.data[0].phase; 
								var block					=	obj.data[0].block; 
								var lot						=	obj.data[0].lot; 
								var floor_area				=	obj.data[0].floor_area; 
								var lot_size				=	obj.data[0].lot_size; 
 								var loanable_amount			=	obj.data[0].loanable_amount; 
 
							   if(reservation_date=="01/01/1970"){	reservation_date = "";	}
							   if(date_delivered=="01/01/1970"){	date_delivered = "";	}
							   if(returned_date=="01/01/1970"){	returned_date = "";	}
							   if(log=="01/01/1970"){	log = "";	}
							   if(booking=="01/01/1970"){	booking = "";	}
							   if(take_out=="01/01/1970"){	take_out = "";	} 
							   
								$('#bsfb_fullname').val(full_name); 
								$('#bsfb_facility').val(facility); 
								$('#bsfb_date_reserved').val(reservation_date); 
								$('#bsfb_date_delivered').val(date_delivered); 
								$('#bsfb_returned_date').val(returned_date); 
								$('#bsfb_bank_account_officer').val(bank_account_officer); 
								$('#bsfb_log').val(log); 
								$('#bsfb_booking').val(booking); 
								$('#bsfb_takeout').val(take_out); 
								$('#bsfb_reason').val(reason);
								
								$('#bsfb_phase').val(phase);
								$('#bsfb_block').val(block);
								$('#bsfb_lot').val(lot);
								$('#bsfb_lot_size').val(lot_size);
								$('#bsfb_floor_area').val(floor_area);

								$('#bsfb_loanable_amount').val(loanable_amount);

								
						});
}