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

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

//LOADING MONITORING OF FOLDERS DETAILS
function load_buyer_status_folder_pagibig(){ 
				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_pagibig.php', dataString, function(msg){
								var obj	= $.parseJSON(msg);
								var full_name				=	obj.data[0].full_name;  
								var window					=	obj.data[0].window; 
								var date_delivered			=	obj.data[0].date_delivered; 
								var date_inspection			=	obj.data[0].date_inspection; 
								var appraiser				=	obj.data[0].appraiser; 
								var noa						=	obj.data[0].noa; 
								var post_approval			=	obj.data[0].post_approval; 
								var take_out				=	obj.data[0].take_out; 
								var reservation_date		=	obj.data[0].reservation_date; 
								var reason					=	obj.data[0].reason; 
								var hlid					=	obj.data[0].hlid; 
								
								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; 
								  
							   if(reservation_date=="01/01/1970"){	reservation_date = "";	}
							   if(date_delivered=="01/01/1970"){	date_delivered = "";	}
							   if(date_inspection=="01/01/1970"){	date_inspection = "";	}
							   if(noa=="01/01/1970"){	noa = "";	}
							   if(post_approval=="01/01/1970"){	post_approval = "";	}
							   if(take_out=="01/01/1970"){	take_out = "";	} 
							   
								$('#bsfp_fullname').val(full_name); 
								$('#bsfp_window').val(window); 
								$('#bsfp_date_reserved').val(reservation_date); 
								$('#bsfp_date_delivered').val(date_delivered); 
								$('#bsfp_date_inspection').val(date_inspection); 
								$('#bsfp_appraiser').val(appraiser); 
								$('#bsfp_noa').val(noa); 
								$('#bsfp_post_approval').val(post_approval); 
								$('#bsfp_takeout').val(take_out); 
								$('#bsfp_reason').val(reason);
								$('#bsfp_hlid').val(hlid);
								
								$('#bsfp_phase').val(phase);
								$('#bsfp_block').val(block);
								$('#bsfp_lot').val(lot);
								$('#bsfp_lot_size').val(lot_size);
								$('#bsfp_floor_area').val(floor_area);
						});
}


/*

 $(document).ready( function () {
             var table =  $('#buyer_status_folder_pagibig_table').DataTable({   
		     "ajax": {
                        "url": './list/buyer_status_folder_pagibig.php', 
                        "type": "GET",
                        "data": function ( d ) { 
							d.range_start	= $('.monthly_reservation_from').val();
							d.range_end		= $('.monthly_reservation_to').val(); 
							d.tobe_stat		= $('.check_tobedelivered').val(); 
							d.tobe_stat_no	= $('.check_tobedelivered_no').val();
							d.tobe_stat_date	= $('.check_tobedelivered_date').val();
                        }
                    } ,
		"processing"		:	true,  
		"serverSide"		:	true,   
		"deferRender"		:	true,
		"sDom"				:	'fC<"toolbar"><"clear">RrtiS', 
		  
        "colVis"			:	{
            "buttonText"	:	"<i class='glyphicon glyphicon-eye-open'></i>", 
			"exclude"		:	[0,1]
        },
        "scrollY"			:	"500", 
		"scrollX"			:	"100%", 
        "scrollCollapse"	:	true, 
		"autoWidth"			:	true,  
		"scroller"			:	{
            "loadingIndicator": true
        },
		"order": [[ defaultSort, defaultOrderSort ]],
		"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull){  
		 
			var statusrow = "";
			var extra = "";
		 
					 
			} 
    });
} );
*/

