$( ".select2" ).select2();
var currentDate = new Date(); 
$('.datepicker').datepicker({
		inline: true,
		showOtherMonths: true,
		dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], 
		format: 'mm/dd/yyyy' ,
		autoclose: true,
		todayHighlight: true
});
$(".currentdatepicker").datepicker("setDate", currentDate);
$('.subnav').affix({	offset: {	top: $('#navtop').height() }	});	
var customBar = ''; 
var main_type 	= $('#main_type').val();
var main_action = $('#main_action').val(); 
var user_type = $('#usertype').val(); 
 
//right align specific cell
if(main_type=="pricelist"){
	var rightalign	=	new Array(0,1,4);
	var datealign	=	new Array(4);
	var statusrow	=	"";
	var extra		=	"";
	var no_allow_order	=   new Array(0,1);
	var allow_order		=	new Array(4);
	var defaultSort		= 4;
	var defaultOrderSort = "desc";
	 
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar		=	"<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Pricelist Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Pricelist Date From' ></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Pricelist Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	
}else if(main_type=="take_out_accounts"){
	var rightalign	=	new Array(0,1,2,6,7,8,9);
	var datealign	=	new Array(6,8);
	var statusrow	=	"";
	var extra		=	"";
	var no_allow_order	=   new Array(0,1,2,3,4,5,7,9);
	var allow_order		=	new Array(6,8);
	var defaultSort		= 8;
	var defaultOrderSort = "desc";
	 
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar		=	"<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Date of Take-out</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Date of Take-out From' ></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Date of Take-out To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	
}else if(main_type=="buyer_house_renovation_monitoring"){
	var rightalign	=   new Array(0,1,2,3,5,7,8,11,12,13);
	var datealign	=	new Array(5,7,8);
	var statusrow	=   13;
	var extra 	 	=	"";
	var allow_order =	 new Array(2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
	var no_allow_order  =   new Array(0,1);
	var defaultSort		= 	5;
	var defaultOrderSort = "desc";
	
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Take-out Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Take-out Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Take-out Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	
}else if(main_type=="report_buyer_employment_type"){
	 
	var rightalign	=   new Array(0);
	var datealign	=	new Array(0);
	var statusrow	=   ""; 
	var customBar	=	"";
	var extra		=	"";
	var no_allow_order  =   new Array(0);
	var allow_order =	new Array(0);

	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	1;
	var defaultOrderSort = "desc";
}else if(main_type=="report_buyer_house_renovation_monitoring"){
	var rightalign	=   new Array(0);
	var datealign	=	new Array(4,6,7);
	var statusrow	=   12; 
	var customBar	=	"";
	var extra		=	"";
	var no_allow_order  =   new Array(0);
	var allow_order =	new Array(1,2,3,4,5,6,7,8,9,10,11);
	 
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Take-out Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Take-out Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Take-out Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	1;
	var defaultOrderSort = "desc";
}else if(main_type=="report_buyer_payment_monitoring_on_equity"){
	//var rightalign	=	new Array(0,7,8,9,10,11,17,18,19,20,21,22,23,24,25,26,27,30);
	var rightalign	=	new Array(0,1,2,3,5,6,8,9,10,11,12,13,14);
	//var datealign	=	new Array(1,5,6,17,28,29);
	var datealign	=	new Array(1,5,6);
	var statusrow	=	"";
	var customBar	=	"";
	var extra		=	"";
	var no_allow_order	=	new Array(2,3,4,5,6,7,8,9,10,11,12,14,14,15,16);
	//var allow_order	=	new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30);
	var allow_order	=	new Array(0,1);
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}

	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From' ></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	1;
	var defaultOrderSort = "desc";
}else if(main_type=="report_buyer_payment_monitoring_other_payables"){
	var rightalign	=	new Array(0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19);
	var datealign	=	new Array(1,5,17,18); 
	var statusrow	=	new Array(20);
	var customBar	=	"";
	var extra		=	"";
	var no_allow_order	=	new Array(0);
	var allow_order	=	new Array(1,2,3,4,16,17,18); 
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}

	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From' ></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	1;
	var defaultOrderSort = "desc";
}else if(main_type=="report_buyer_payment_monitoring"){
	var rightalign	=	new Array(0,7,8,9,10,11,17,18,19,20,21,22,23,24,25,26,27,30);
	var datealign	=	new Array(1,5,6,17,28,29);
	var statusrow	=	"";
	var customBar	=	"";
	var extra		=	"";
	var no_allow_order	=	new Array(0);
	var allow_order	=	new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30);
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}

	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From' ></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	1;
	var defaultOrderSort = "desc";
}else if(main_type=="releases_to_broker"){
	var rightalign		=	new Array(0,1);
	var datealign		=	new Array(5);
	var statusrow		=	new Array(6);
	var extra			=	"";
	var no_allow_order  =   new Array(0,1);
	var allow_order 	=	new Array(2,3,4,5);
	var defaultSort		= 	5;
	var defaultOrderSort = "desc"; 
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-lg-9 col-md-9 col-sm-9'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
}else if(main_type=="partial_commission_releases_schedule"){
	var rightalign		=	new Array(0,1,2,3,5);
	var datealign		=	new Array(5);
	var statusrow		=	new Array(6);
	var extra			=	"";
	var no_allow_order  =   new Array(0,1,2,3);
	var allow_order 	=	new Array(4,5);
	var defaultSort		= 	5;
	var defaultOrderSort = "desc"; 
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-lg-9 col-md-9 col-sm-9'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
}else if(main_type=="releases_to_broker_for_wht"){
	var rightalign		=	new Array(0,1,2,3,5);
	var datealign		=	new Array(5);
	var statusrow		=	new Array(6);
	var extra			=	"";
	var no_allow_order  =   new Array(0,1);
	var allow_order 	=	new Array(2,3,4,5);
	var defaultSort		= 	5;
	var defaultOrderSort = "desc"; 
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-lg-9 col-md-9 col-sm-9'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
}else if(main_type=="releases_to_contractor"){
	var rightalign		=	new Array(0,1,2,3,5,6);
	var datealign		=	new Array(5,6);
	var statusrow		=	new Array(7);
	var extra			=	"";
	var no_allow_order  =   new Array(0,1);
	var allow_order 	=	new Array(2,3,4,5);
	var defaultSort		= 	5;
	var defaultOrderSort = "desc"; 
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-lg-9 col-md-9 col-sm-9'><div class='col-sm-3'><label>Date P.O. Issued</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Date P.O. Issued From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Date P.O. Issued To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
}else if(main_type=="report_releases_to_contractor"){
	var rightalign	=   new Array(1,2,3,5,6,7,8);
	var datealign	=	new Array(8);
	var statusrow	=   ""; 
	var customBar	=	"";
	var extra		=	"";
	var no_allow_order  =   "";
	var allow_order =	new Array(0,1,2,3,4,5,6,7,8);
	 
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Date Processed</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Date Processed From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Date Processed To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	0;
	var defaultOrderSort = "asc";
}else if(main_type=="report_releases_to_broker"){
	var rightalign		=	new Array(0,2,3,6,7,8);
	var datealign		=	new Array(8);
	//var statusrow		=	new Array(10);
	var statusrow		=	"";
	var extra			=	"";
	var no_allow_order  =   new Array(0,1,2,3,5,6,7,8,9);
	var allow_order 	=	new Array(4);
	var defaultSort		= 	4;
	var defaultOrderSort = "asc"; 
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-lg-9 col-md-9 col-sm-9'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";

}else if(main_type=="report_releases_to_broker_for_wht"){
	var rightalign		=	new Array(0,2,3,7,8,9);
	var datealign		=	new Array(9);
	//var statusrow		=	new Array(10);
	var statusrow		=	"";
	var extra			=	"";
	var no_allow_order  =   new Array(0,1,2,3,5,6,7,8,9);
	var allow_order 	=	new Array(4);
	var defaultSort		= 	4;
	var defaultOrderSort = "asc"; 
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-lg-9 col-md-9 col-sm-9'><div class='col-sm-3'><label>Date Processed</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Date Processed From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Date Processed To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";


}else if(main_type=="payment_status_to_broker"){
	var rightalign		=	new Array(0,1);
	var datealign		=	new Array(5);
	var statusrow		=	new Array(6);
	var extra			=	"";
	var no_allow_order  =   new Array(0,1);
	var allow_order 	=	new Array(2,3,4,5);
	var defaultSort		= 	5;
	var defaultOrderSort = "desc"; 
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-lg-9 col-md-9 col-sm-9'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";

}else if(main_type=="payment_status_to_contractor"){

	var rightalign		=	new Array(0,1);
	var datealign		=	new Array(5);
	var statusrow		=	new Array(6);
	var extra			=	"";
	var no_allow_order  =   new Array(0,1);
	var allow_order 	=	new Array(2,3,4,5);
	var defaultSort		= 	5;
	var defaultOrderSort = "desc"; 
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-lg-9 col-md-9 col-sm-9'><div class='col-sm-3'><label>Date P.O. Issued</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Date P.O. Issued From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Date P.O. Issued To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";

}else if(main_type=="notifications_liaison"){

	var rightalign		=	new Array(0,2,3,4,5);
	var datealign		=	new Array(4,5);
	var statusrow		=	new Array(6);
	var extra			=	"";
	var no_allow_order  =   new Array(0,1,2,3,4);
	var allow_order 	=	new Array(5);
	var defaultSort		= 	5;
	var defaultOrderSort = "desc"; 
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "";


}else if(main_type=="report_summary_po_to_contractor"){
	var rightalign	=   new Array(0,1,2,4,5,6,7);
	var datealign	=	new Array(1,2);
	var statusrow	=   ""; 
	var customBar	=	"";
	var extra		=	"";
	var no_allow_order  =   new Array(0);
	var allow_order =	new Array(1,2,3,4,5,6,7);
	 
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Date P.O. Issued</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Date P.O. Issued From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Date P.O. Issued To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	1;
	var defaultOrderSort = "desc";

}else if(main_type=="adjustment_pricelist"){
	var rightalign	=	new Array(0,3);
	var datealign	=	new Array(3);
	var statusrow	=	"";
	var extra		=	"";
	var no_allow_order	=   new Array(0,1);
	var allow_order		=	new Array(3);
	var defaultSort		= 3;
	var defaultOrderSort = "desc";
	 
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar		=	"<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Pricelist Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Pricelist Date From' ></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Pricelist Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	
}else if(main_type=="conversion"){
	var rightalign			=   new Array(0,2,3,4,5,6,7,8);
	var datealign			=   new Array(4,5,6,7,8);
	var statusrow			=   "";
	var extra				=	"";
	var allow_order 		=	new Array(2);
	var no_allow_order  	=   new Array(0,1,3,4,5,6,7,8);
	var defaultSort			=	 2;
	var defaultOrderSort 	= "asc";
	
	var ischeck = $('.check_tobedelivered').val();
	if(ischeck=='yes'){
	var checked = "checked";
	}else{
	var checked = "";
	}
	
	var ischeck2 = $('.check_tobedelivered_no').val();
	
	if(ischeck2=='yes'){
	var checked2 = "checked";
	}else{
	var checked2 = "";
	}
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	 
	var customBar		=	"<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Released Date by Pag-ibig</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Released Date by Pag-ibig From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Released Date by Pag-ibig To'  ></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div>   <div class='col-sm-1'></div>  </div></div>";




}else if(main_type=="conversion_details"){
	var rightalign			=   new Array(0,1,2,6,7,8,9,10,11,12,13,14,15,16,17);
	var datealign			=   new Array(0,1);
	var statusrow			=   "";
	var extra				=	"";
	var allow_order 		=	new Array(6);
	var no_allow_order  	=   new Array(0,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17);
	var defaultSort			=	 6;
	var defaultOrderSort 	= "asc";
	
	var ischeck = $('.check_tobedelivered').val();
	if(ischeck=='yes'){
	var checked = "checked";
	}else{
	var checked = "";
	}
	
	var ischeck2 = $('.check_tobedelivered_no').val();
	
	if(ischeck2=='yes'){
	var checked2 = "checked";
	}else{
	var checked2 = "";
	}
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	 
	var customBar		=	"<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Date Released by Pag-ibig</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Date Released by Pag-ibig From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Date Released by Pag-ibig To'  ></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div>   <div class='col-sm-1'></div>  </div></div>";




}else if(main_type=="status_of_accounts_for_conversion"){
	var rightalign			=   new Array(0,2,3,4,5,6,7,8);
	var datealign			=   new Array(4,5,6,7,8);
	var statusrow			=   new Array(9);
	var extra				=	"";
	var allow_order 		=	new Array(2);
	var no_allow_order  	=   new Array(0,1,3,4,5,6,7,8);
	var defaultSort			=	 2;
	var defaultOrderSort 	= "asc";
	
	var ischeck = $('.check_tobedelivered').val();
	if(ischeck=='yes'){
	var checked = "checked";
	}else{
	var checked = "";
	}
	
	var ischeck2 = $('.check_tobedelivered_no').val();
	
	if(ischeck2=='yes'){
	var checked2 = "checked";
	}else{
	var checked2 = "";
	}
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	 
	var customBar		=	"<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Released Date by Pag-ibig</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Released Date by Pag-ibig From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Released Date by Pag-ibig To'  ></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div>   <div class='col-sm-1'></div>  </div></div>";




}else if(main_type=="report_summary_status_of_permits"){ 
	var rightalign	=   new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19);
	var datealign	=	new Array(2,3,5,6,8,9,10,11,12,13,14,15,16,17,18,19);
	var statusrow	=   "";
	var extra		=	"";
	var allow_order =	new Array(0);
	var no_allow_order   =	new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19);
	var defaultSort		 = 	0;
	var defaultOrderSort = "asc";
}else if(main_type=="units"){ 
	var rightalign	=   new Array(1,2);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	var allow_order =   new Array(1);
	var no_allow_order  =   new Array(0,2);
	var defaultSort		= 	1;
	var defaultOrderSort = "asc";
}else if(main_type=="permits_and_licenses"){ 
	var rightalign	=   new Array(1,2);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	var allow_order  =   new Array(1);
	var no_allow_order  =   new Array(0,2);
	var defaultSort		= 	1;
	var defaultOrderSort = "asc";

	var customBar = '<div class="row">';
  	customBar += '<div class="col-xs-1 text-right right">';
    	customBar += '<label class="text-right right">Block</label>';
  	customBar += '</div>';
  	customBar += '<div class="col-xs-1">';
		customBar += '<input type="text" class="form-control block_from" name="block_from" id="block_from" placeholder="From">';
	customBar += '</div>';
  	customBar += '<div class="col-xs-1 text-center center" style="padding:0px; margin:0px; width:1%">';
    	customBar += '<label class="text-center center" style="padding:0px; margin:0px">To</label>';
  	customBar += '</div>';
  	customBar += '<div class="col-xs-1">';
		customBar += '<input type="text" class="form-control block_to" name="block_to" id="block_to" placeholder="To">';
	customBar += '</div>'; 
//customBar += '</div>';

//customBar += '<div class="row">';
  	customBar += '<div class="col-xs-1  text-right right">';
    	customBar += '<label class="text-right right">Lot</label>';
  	customBar += '</div>';
  	customBar += '<div class="col-xs-1">';
		customBar += '<input type="text" class="form-control lot_from" name="lot_from" id="lot_from" placeholder="From">';
	customBar += '</div>';
  	customBar += '<div class="col-xs-1 text-center center" style="padding:0px; margin:0px; width:1%">';
    	customBar += '<label class="text-center center" style="padding:0px; margin:0px">To</label>';
  	customBar += '</div>';
  	customBar += '<div class="col-xs-1">';
		customBar += '<input type="text" class="form-control lot_to" name="lot_to" id="lot_to" placeholder="To">';
	customBar += '</div>';
customBar += '</div>';

}else if(main_type=="construction_and_utilities"){ 
	var rightalign	=   new Array(1,2);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	var allow_order  =   new Array(1);
	var no_allow_order  =   new Array(0,2);
	var defaultSort		= 	1;
	var defaultOrderSort = "asc";

	var customBar = '<div class="row">';
  	customBar += '<div class="col-xs-1 text-right right">';
    	customBar += '<label class="text-right right">Block</label>';
  	customBar += '</div>';
  	customBar += '<div class="col-xs-1">';
		customBar += '<input type="text" class="form-control block_from" name="block_from" id="block_from" placeholder="From">';
	customBar += '</div>';
  	customBar += '<div class="col-xs-1 text-center center" style="padding:0px; margin:0px; width:1%">';
    	customBar += '<label class="text-center center" style="padding:0px; margin:0px">To</label>';
  	customBar += '</div>';
  	customBar += '<div class="col-xs-1">';
		customBar += '<input type="text" class="form-control block_to" name="block_to" id="block_to" placeholder="To">';
	customBar += '</div>'; 
//customBar += '</div>';

//customBar += '<div class="row">';
  	customBar += '<div class="col-xs-1  text-right right">';
    	customBar += '<label class="text-right right">Lot</label>';
  	customBar += '</div>';
  	customBar += '<div class="col-xs-1">';
		customBar += '<input type="text" class="form-control lot_from" name="lot_from" id="lot_from" placeholder="From">';
	customBar += '</div>';
  	customBar += '<div class="col-xs-1 text-center center" style="padding:0px; margin:0px; width:1%">';
    	customBar += '<label class="text-center center" style="padding:0px; margin:0px">To</label>';
  	customBar += '</div>';
  	customBar += '<div class="col-xs-1">';
		customBar += '<input type="text" class="form-control lot_to" name="lot_to" id="lot_to" placeholder="To">';
	customBar += '</div>';
customBar += '</div>';

}else if(main_type=="buyer_payment_monitoring"){
	var rightalign		=	new Array(0,1);
	var datealign		=	"";
	var statusrow		=   6;
	var extra			=	"";
	var no_allow_order  =   new Array(0,4);
	var allow_order 	=	new Array(1,2,3,5);
	var defaultSort		= 	5;
	var defaultOrderSort = "desc";
	
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-lg-9 col-md-9 col-sm-9'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
}else if(main_type=="postdated_pagibig_loan_amortization"){
	var rightalign		=	new Array(1,2,3);
	var datealign		=	"";
	var statusrow		=   6;
	var extra			=	"";
	var no_allow_order  =   new Array(0,1);
	var allow_order 	=	new Array(2,3,4,5);
	var defaultSort		= 	5;
	var defaultOrderSort = "desc";
	
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-lg-9 col-md-9 col-sm-9'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
}else if(main_type=="report_buyer_status_monitoring"){
	var rightalign	=   new Array(0,1,2,3,5,8,9,10,11,12,13,14);
	var datealign	=	new Array(1,5,8,9,10,11,12,13);
	var statusrow	=   ""; 
	var customBar	=	"";
	var extra		=	"";
	var no_allow_order  =   new Array(0);
	var allow_order =	new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14);
	 
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	1;
	var defaultOrderSort = "desc";



}else if(main_type=="report_partial_commission_releases_schedule"){
	var rightalign	=   new Array(1,2,3,5,6,8,9,10);
	var datealign	=   new Array(10);
	var statusrow	=   "";
	var extra		=	"";
	//var allow_order  	=   new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
	var allow_order  =   new Array(0,1,2,3,4,5,6,7,8,9,10);
	var no_allow_order  =   "";
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}

	var customBar = "<div class='row'><div class='col-sm-9'><div class='col-sm-2'><label>Date Released</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Date Released From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Date Released To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	4;
	var defaultOrderSort = "asc";

}else if(main_type=="sales_report_per_broker"){
	var rightalign	=   new Array(2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	//var allow_order  	=   new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
	var allow_order = "";
	var no_allow_order  =   "";
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}

	var customBar = "<div class='row'><div class='col-sm-9'><div class='col-sm-2'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	0;
	var defaultOrderSort = "asc";
}else if(main_type=="sales_report_per_agent"){
	var rightalign	=   new Array(3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	//var allow_order =   new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);
	//var no_allow_order  =   new Array(0);

	var allow_order		= 	"";
	var no_allow_order  =   "";
	
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-9'><div class='col-sm-2'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		 = 0;
	var defaultOrderSort = "asc";
}else if(main_type=="notifications_accounting1"){
	var rightalign	=   new Array(1,2,4,5,6);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	//var allow_order =   new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);
	//var no_allow_order  =   new Array(0);

	var allow_order  	 = new Array(0,4,5,6);
	var no_allow_order   = new Array(1,2,3);
	
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-9'><div class='col-sm-2'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		 = 0;
	var defaultOrderSort = "asc";
}else if(main_type=="notifications_accounting2"){
	var rightalign	=   new Array(1,2,4);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	//var allow_order =   new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);
	//var no_allow_order  =   new Array(0);

	var allow_order  	 = new Array(4);
	var no_allow_order   = new Array(0,1,2,3);
	
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-9'><div class='col-sm-2'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		 = 0;
	var defaultOrderSort = "asc";
}else if(main_type=="notifications_documentation1"){
	var rightalign	=   new Array(0,1,3,4);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	//var allow_order =   new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);
	//var no_allow_order  =   new Array(0);

	var allow_order  	 = new Array(0,1);
	var no_allow_order   = new Array(2,3,4,5);
	
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-9'><div class='col-sm-2'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		 = 0;
	var defaultOrderSort = "asc";
}else if(main_type=="notifications_with_balance"){
	var rightalign	=   new Array(1,2,3,4,5,6,7);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	//var allow_order =   new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);
	//var no_allow_order  =   new Array(0);

	var allow_order  	 = new Array(0,3,4,5,6,7);
	var no_allow_order   = new Array(1,2);
	
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-9'><div class='col-sm-2'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		 = 0;
	var defaultOrderSort = "asc";
}else if(main_type=="notifications_admin"){
	var rightalign	=   new Array(1,2,3,4,5);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	//var allow_order =   new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);
	//var no_allow_order  =   new Array(0);

	var allow_order  	 = new Array(0,3,4,5);
	var no_allow_order   = new Array(1,2);
	
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-9'><div class='col-sm-2'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		 = 0;
	var defaultOrderSort = "asc";
}else if(main_type=="notifications_documentation2"){
	var rightalign	=   new Array(0,1,3,4);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	//var allow_order =   new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);
	//var no_allow_order  =   new Array(0);

	var allow_order  	 = new Array(0,1);
	var no_allow_order   = new Array(2,3,4);
	
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-9'><div class='col-sm-2'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		 = 0;
	var defaultOrderSort = "asc";
}else if(main_type=="report_summary_report_of_buyers"){
	var rightalign		 = new Array(0);
	var datealign        = new Array(1);
	var statusrow		 = '';
	var extra			 = "";
	var allow_order  	 = new Array(0,1);
	var no_allow_order   = new Array(2,3,4,5,6);
	var defaultSort		 = 1;
	var defaultOrderSort = "desc";
	var dtype = $('#dtype').val();
	if(dtype=="cancellation"){
		var sel1 = "selected";
		var rightalign		 = new Array(0,1,2,3,4);

	}else if(dtype=="past_due"){
		var sel2 = "selected";
		var rightalign		 = new Array(0,1,2,3,7,9);
		var no_allow_order   = new Array(2,3,4,5,6,7,8,9,10);

	}else if(dtype=="lacking"){
		var sel3 = "selected";
		var rightalign		 = new Array(0,1,2,3);

	}else if(dtype=="transferred"){
		var sel4 = "selected";
		var rightalign		 = new Array(0,1,2,3,7,8,9);
	}
	
	

var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";

	}else{
	var checked3 = "";
	}
 
 if(dtype=="lacking_notice"){
	var customBar = "<div class='row'><div class='col-sm-9'><div class='col-sm-2'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div><div class='col-sm-1'></div><div class='col-sm-3'></div></div></div>";
 }else{
	var customBar = "<div class='row'><div class='col-sm-9'><div class='col-sm-2'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div><div class='col-sm-1'></div><div class='col-sm-3'><select class='form-control' onchange='javascript:location.href = this.value;'><option "+sel3+" value='index.php?pg=reservation&type=report_summary_report_of_buyers&dtype=lacking'>Lacking Requirement/s</option><option "+sel2+" value='index.php?pg=reservation&type=report_summary_report_of_buyers&dtype=past_due'>Past Due/s</option>	</select></div></div></div>";
 }	
}else if(main_type=="monthly_sales_reservation"){
	
	var datealign	=	new Array(1);
	var statusrow	=   new Array(10);
	var extra		=	"";
	 
	var dtype = $('#dtype').val(); 
	if(dtype=="monthly"){
		var rightalign	=   new Array(1,2,3);
		var sel3 = "selected";
		var allow_order =	new Array(0,1);
		var no_allow_order  =   new Array(2,3,4,5,6,7,8,9);
	}else if(dtype=="cancellation"){
		var sel1 = "selected";
		var allow_order =	new Array(0,1);
		var no_allow_order  =   new Array(2,3,4,5,6,7);
		var rightalign	=   new Array(0,1,2,3,4);
	}else if(dtype=="transferred"){
		var sel4 = "selected";
		var rightalign	=   new Array(1,2,3,7,8,9);
		//var allow_order =	new Array(1,2,3,4,5,7,8,9);
		var allow_order =	new Array(0,1);
		var no_allow_order  =   new Array(2,3,4,5,6,7,8,9,10,11);
	}  
	
	var defaultSort		= 	1;
	var defaultOrderSort = "desc";

	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
		var checked3 = "checked";
	}else{
		var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div><div class='col-sm-1'></div><div class='col-sm-3'><select class='form-control' onchange='javascript:location.href = this.value;' style='font-size:10pt; width:300px'><option "+sel3+" value='index.php?pg=reservation&type=monthly_sales_reservation&dtype=monthly'>Monthly Sales Reservation</option><option "+sel4+" value='index.php?pg=reservation&type=monthly_sales_reservation&dtype=transferred'>Transferred Account/s</option><option "+sel1+" value='index.php?pg=reservation&type=monthly_sales_reservation&dtype=cancellation'>Cancelled Account/s</option></select></div></div></div>";
}else if(main_type=="buyer_status_monitoring"){
	var rightalign	=   new Array(1,2,3,5,6,9,10,11,13,14);
	var datealign	=	new Array(5,6,8,9,10,11,13,14);
	var statusrow	=   17;
	var extra 	 	=	"";
	var allow_order =	 new Array(2,3,4,5,6,7,8,9,10,11,12,13,14,15);
	var no_allow_order  =   new Array(0,1);
	var defaultSort		= 	5;
	var defaultOrderSort = "desc";
	
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	
}else if(main_type=="buyer_status_folder_pagibig"){
	var rightalign	=   new Array(0,1,2,3,5,6,7,8,10,11,12);
	var datealign	=	new Array(5,7,8,10,11,12);
	var statusrow	=   14;
	var extra 	 	=	"";
	var allow_order =	 new Array(2,3,6,7,8,10,11,12);
	var no_allow_order  =   new Array(0,1,4,5,9,13);
	var defaultSort		= 	7;
	var defaultOrderSort = "desc";
	var ischeck = $('.check_tobedelivered').val();
	if(ischeck=='yes'){
	var checked = "checked";
	}else{
	var checked = "";
	}
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar		=	"<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Date Delivered to Pag-ibig</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Date Delivered From' ></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Date Delivered To'></div> <div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div><div class='col-sm-3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='checkbox' id='check_tobedelivered' name='check_tobedelivered' value='' "+checked+"> <label style='cursor:pointer' for='check_tobedelivered'>To Be Delivered</label></div></div></div>";
}else if(main_type=="buyer_status_folder_bank"){
	var rightalign	=   new Array(0,1,5,7);
	var datealign	=	new Array(5,7,8,10,11,12);
	var statusrow	=   14;
	var extra 	 	=	"";
	//var allow_order =	 new Array(2,3,4,5,6,7,8,9,10,11,12,13);
	var allow_order =	 new Array(2,3,7);
	var no_allow_order  =   new Array(0,1,4,5,6,8,9,10,11,12,13);
	var defaultSort		= 	7;
	var defaultOrderSort = "desc";
	var ischeck = $('.check_tobedelivered').val();
	if(ischeck=='yes'){
	var checked = "checked";
	}else{
	var checked = "";
	}
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar		=	"<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Date Delivered</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Date Delivered From' ></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Date Delivered To'></div> <div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div> </div></div>";
}else if(main_type=="schedule_of_loan_folders"){
	var rightalign	=   new Array(0,7);
	var datealign	=   new Array(1,9);
	var statusrow	=   '';
	var extra		=	"";
	var allow_order  	= new Array(1,2,3);
	var no_allow_order  =   new Array(0,4,5,6,7,8,9);
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	1;
	var defaultOrderSort = "desc";

}else if(main_type=="report_schedule_of_loan_folders"){
	var rightalign	=   new Array(0,1,2,3,4,6);
	var datealign	=   new Array(0);
	var statusrow	=   new Array(8);
	var extra		=	"";
	var allow_order  	= new Array(0,1,2,6);
	var no_allow_order  =   new Array(3,4,5,7);
	
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
 
	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Date to be Delivered </label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Date to be Delivered From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Date to be Delivered To'></div><div class='col-sm-2'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	0;
	var defaultOrderSort = "asc";
}else if(main_type=="report_monitoring_folders"){
	var rightalign	=   new Array(0,7);
	var datealign	=	new Array(1);
	var statusrow	=   "";
	var extra		=	"";
	var allow_order  	= new Array(0,1);
	var no_allow_order  =   new Array(2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22);
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	1;
	var defaultOrderSort = "desc";

}else if(main_type=="report_buyer_status_folder_pagibig"){
	var rightalign		=   new Array(0,1,2,3,5,6,7,8,10,11,12);
	var datealign		=	new Array(1,7,8,10,11,12);
	var statusrow		=   '';
	var extra			=	"";
	//var allow_order  	=	new Array(1,2,3,4,5,6,7,8,9,10,11);
	var allow_order  	=	new Array(1,7,8,10,11,12);
	var no_allow_order  =   new Array(0,2,3);
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	var customBar		=	"<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Date Delivered to Pag-ibig</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Date Delivered From' ></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Date Delivered To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	1;
	var defaultOrderSort = "desc";
}else if(main_type=="report_buyer_status_folder_bank"){
	var rightalign		=   new Array(0,5);
	var datealign		=	new Array(1,7,9,10,12);
	var statusrow		=   '';
	var extra			=	"";
	var allow_order  	=	new Array(1,2,3,4,5,6,7,8,9,10,11);
	var no_allow_order  =   new Array(0);
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	var customBar		=	"<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Date Delivered</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Date Delivered From' ></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Date Delivered To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
	var defaultSort		= 	1;
	var defaultOrderSort = "desc";
}else if(main_type=="reservation"){
	var rightalign	=   new Array(1,2,3,5,18);
	var datealign	=	new Array(5);
	var statusrow	=   21;
	var extra		=	"";
	var allow_order =	new Array(1,2,3,5);
	var no_allow_order  =   new Array(0,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
	var defaultSort		= 	5;
	var defaultOrderSort = "desc";
	
	var ischeck = $('.check_tobedelivered').val();
	if(ischeck=='yes'){
	var checked = "checked";
	}else{
	var checked = "";
	}
	
	var ischeck2 = $('.check_tobedelivered_no').val();
	
	if(ischeck2=='yes'){
	var checked2 = "checked";
	}else{
	var checked2 = "";
	}
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	 
	var customBar		=	"<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'  ></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div> <div class='col-sm-1'></div> <div class='col-sm-1'><input type='checkbox' id='check_tobedelivered' name='check_tobedelivered' value='yes' "+checked+" title='Filter with Take-Out Date'> <label style='cursor:pointer' for='check_tobedelivered'>&nbsp;&nbsp;<span style='color:#ff0000' class='glyphicon glyphicon-home' title='Filter with Take-Out Date'></span></label></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_no' name='check_tobedelivered_no' value='yes' "+checked2+" title='Filter with No Take-Out Date'> <label style='cursor:pointer' for='check_tobedelivered_no' >&nbsp;&nbsp;<span style='color:#f8f8f8' class='glyphicon glyphicon-home' title='Filter with No Take-Out Date'></span></label></div></div></div>";
}else if(main_type=="report_reservation"){
	var rightalign	=   new Array(1,2,3,5,12,13,14,17,18);
	var datealign	=	new Array(5);
	var statusrow	=   20;
	var extra		=	"";
	var allow_order =	new Array(2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
	var no_allow_order  =   new Array(0,1);
	var defaultSort		= 	5;
	var defaultOrderSort = "desc";
	
	var ischeck = $('.check_tobedelivered').val();
	if(ischeck=='yes'){
	var checked = "checked";
	}else{
	var checked = "";
	}
	
	var ischeck2 = $('.check_tobedelivered_no').val();
	
	if(ischeck2=='yes'){
	var checked2 = "checked";
	}else{
	var checked2 = "";
	}
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	 
	var customBar		=	"<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'  ></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div> <div class='col-sm-1'></div> <div class='col-sm-1'><input type='checkbox' id='check_tobedelivered' name='check_tobedelivered' value='yes' "+checked+" title='Filter with Take-Out Date'> <label style='cursor:pointer' for='check_tobedelivered'>&nbsp;&nbsp;<span style='color:#ff0000' class='glyphicon glyphicon-home' title='Filter with Take-Out Date'></span></label></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_no' name='check_tobedelivered_no' value='yes' "+checked2+" title='Filter with No Take-Out Date'> <label style='cursor:pointer' for='check_tobedelivered_no' >&nbsp;&nbsp;<span style='color:#f8f8f8' class='glyphicon glyphicon-home' title='Filter with No Take-Out Date'></span></label></div></div></div>";
}else if(main_type=="reserved_lots"){ 
	var cancelStatus = "";
	var rightalign	=	new Array(0,3,4,5,6);
	var datealign	=	new Array(3);
	var statusrow	=   "";
	var extra		=	"";
	var allow_order =	new Array(2,3,4,5,6,7);
	var no_allow_order  =   new Array(0,1);
	var defaultSort		= 	2;
	var defaultOrderSort = "asc";
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar		=	"<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Reservation Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From' ></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";
}else if(main_type=="broker"){ 
	var cancelStatus = "";
	var rightalign	=   new Array(0);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	var allow_order =	"";
	var no_allow_order  =   new Array(0);
	var defaultSort		= 	1;
	var defaultOrderSort = "asc";
}else if(main_type=="brokeragent"){ 
	var cancelStatus = "";
	var rightalign	=   new Array(1);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	var allow_order =	"";
	var no_allow_order  =   new Array(0,1);
	var defaultSort		= 	2;
	var defaultOrderSort = "asc";
}else if(main_type=="tin"){  
	var cancelStatus = "";
	var rightalign	=   new Array(0);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	var allow_order =	"";
	var no_allow_order  =   new Array(0);
	var defaultSort		= 	1;
	var defaultOrderSort = "asc";
}else if(main_type=="agent"){ 
	var rightalign	=   new Array(0);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	var allow_order =	"";
	var no_allow_order  =   new Array(0);
	var defaultSort		= 	1;
	var defaultOrderSort = "asc";
}else if(main_type=="employee_type"){ 
	var rightalign	=   new Array(0);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	var allow_order =	"";
	var no_allow_order  =   "";
	var defaultSort		= 	0;
	var defaultOrderSort = "asc";
}else if(main_type=="position"){ 
	var rightalign	=   new Array(0);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	var allow_order =	"";
	var no_allow_order  =   "";
	var defaultSort		= 	1;
	var defaultOrderSort = "asc";
}else if(main_type=="buyer_profile"){ 
	var rightalign 	=   new Array(0);
	var datealign	=	"";
	var statusrow	=   "";
	var extra		=	"";
	var allow_order =	"";
	var no_allow_order  =   "";
	var defaultSort		= 	0;
	var defaultOrderSort = "asc";
}else if(main_type=="notifications"){
	var rightalign 		=   new Array(0,1);
	var datealign		=	"";
	var statusrow  		=   "";
	var extra		  	=   "";
	var allow_order		=   new Array(0,1,2,3);
	var no_allow_order  =   new Array(0);
	//var customBar 		= "";
	var defaultSort		= 	1;
	var defaultOrderSort = "desc";
	
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
	var checked3 = "checked";
	}else{
	var checked3 = "";
	}
	
	var customBar = "<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Reservation Date From'></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' title='Reservation Date To'></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div></div></div>";


}else if(main_type=="postdated_checks_received"){
	var rightalign 		=   new Array(1,5);
	var datealign		=   new Array(2,10);
	var statusrow  		=   11;
	var extra		  	=   11;
	var allow_order		=   new Array(2,3,4,5,6,7,8,9,10,11);
	var no_allow_order  =   new Array(0,1); 
	
 
	var	customBar = '<div class="row">';
		      	customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		          customBar += '<div class="form-group">';
		          customBar += '<label class="col-lg-3 col-md-3 col-sm-3 control-label text-left" style="font-size:10pt"><small>Borrower</small></label>';
		          customBar += '<div class="col-lg-9 col-md-9 col-sm-9"><input type="text" id="cheque_borrower" style="font-size:8pt" class="form-control" readonly></div>';
		          customBar += '</div>';
		        customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  			customBar += '<div class="form-group">';
		  			 	customBar += '<label class="col-xs-12 col-sm-4 col-md-4 col-lg-4 control-label text-left" style="font-size:10pt"><small>Downpayment</small></label>';
		  			 	customBar += '<div class="col-md-8 col-sm-8 col-lg-8"><input type="text" id="cheque_downpayment" class="text-right form-control" readonly></div>';
		  			customBar += '</div>';
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  			customBar += '<div class="form-group">';
		  				customBar += '<label class="col-md-5 col-lg-5 col-sm-5 control-label text-left" style="font-size:10pt"><small>Monthly Equity</small></label>';
		  				customBar += '<div class="col-md-7 col-lg-7 col-sm-7"><input type="text" id="cheque_monthly_equity" class="text-right form-control" readonly></div>';
		  			customBar += '</div>';
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  			customBar += '<div class="form-group">';
		  				customBar += '<label class="col-lg-5 col-md-5 col-sm-5 control-label text-left" style="font-size:10pt"><small>PDC Submitted</small></label>';
		  				customBar += '<div class="col-md-7 col-lg-7 col-sm-7">';
		  				//customBar += '<input type="text" id="cheque_pdc_submitted" class="text-right form-control" >';
						customBar += '<select id="cheque_pdc_submitted_status" name="cheque_pdc_submitted_status" class="form-control">';
						customBar += '<option value=""></option>';
						customBar += '<option value="Complete">Complete</option>';
						customBar += '<option value="Incomplete">Incomplete</option>';
						customBar += '</select>';
		  				customBar += '</div>';
		  			customBar += '</div>';
		  		customBar += '</div>';
		  	customBar += '</div>';
		  	
		  	customBar += '<div class="row" style="padding:1px"></div>';
		  	
		  	customBar += '<div class="row">';
		  		customBar += '<div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">';
		  			customBar += '<div class="form-group">';
		  				customBar += '<label class="col-md-3 col-lg-3 col-sm-3 control-label text-left" style="font-size:10pt"><small>Block</small></label>';
		  				customBar += '<div class="col-lg-9 col-md-9 col-sm-9"><input type="text" id="cheque_block" class="form-control" readonly></div>';
		  			customBar += '</div>';
		  		customBar += '</div>';

		  		
		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  			customBar += '<div class="form-group">';
		  			 	customBar += '<label class="col-xs-12 col-sm-4 col-md-4 col-lg-4 control-label text-left" style="font-size:10pt"><small>Net Equity</small></label>';
		  			 	customBar += '<div class="col-md-8 col-sm-8 col-lg-8"><input type="text" id="cheque_equity" class="text-right form-control" readonly></div>';
		  			customBar += '</div>';
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  			customBar += '<div class="form-group">';
		  				customBar += '<label class="col-md-5 col-lg-5 col-sm-5 control-label text-left" style="font-size:10pt"><small>Terms</small></label>';
		  				customBar += '<div class="col-md-7 col-sm-7 col-lg-7"><input type="text" id="cheque_terms" class="form-control text-right" readonly></div>';
		  			customBar += '</div>';
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  			customBar += '<div class="form-group">';
		  				customBar += '<label class="col-md-5 col-lg-5 col-sm-5 control-label text-left" style="font-size:10pt"><small>Lacking PDC</small></label>';
		  				customBar += '<div class="col-md-7 col-sm-7 col-lg-7"><input type="text" id="cheque_lacking_pdc" class="form-control text-right">';
		  				customBar += '</div>';
		  			customBar += '</div>';
		  		customBar += '</div>';
		  	customBar += '</div>';

		  	customBar += '<div class="row" style="padding:1px"></div>';

		  	customBar += '<div class="row">';
		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  			customBar += '<div class="form-group">';
		  				customBar += '<label class="col-md-3 col-lg-3 col-sm-3 control-label text-left" style="font-size:10pt"><small>Lot</small></label>';
		  				customBar += '<div class="col-md-9 col-sm-9 col-lg-9"><input type="text" id="cheque_lot" class="form-control" readonly></div>';

		  				customBar += '<div class="col-md-12 col-sm-12 col-lg-12 col-xs-12"></div>';
		  				//CONSTRUCTION STATUS UPON RESERVATION
		  				customBar += '<label class="col-md-3 col-lg-3 col-sm-3 control-label text-left" style="font-size:10pt"><small>Construction Status upon Reservation</small></label>';
		  				customBar += '<div class="col-md-9 col-sm-9 col-lg-9"> ';
		  				customBar += '<input type="text" id="cheque_construction_status_upon_reservation" class="form-control text-left" readonly >';
		  				customBar += '</div>';



		  			customBar += '</div>';
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  			customBar += '<div class="form-group">'; 

		  				//DISCOUNT IF ANY ADMIN ONLY
		  		    if(user_type=='admin'){
		  		    	isreadonly = '';
		  		    }else{
		  		    	isreadonly = 'readonly';
		  		    }	
		  		    
		  				customBar += '<label class="col-md-4 col-lg-4 col-sm-4 control-label text-left" style="font-size:10pt; padding-right:0px; margin-right:0px;"><small>Discount</small> <small><i style="font-size:8pt; padding:0px; margin:0px;">(if any)</i></small></label>';
		  				customBar += '<div class="col-md-8 col-sm-8 col-lg-8"><input type="text" id="cheque_discount" name="cheque_discount" class="form-control text-right" onblur = "javascript:this.value=Comma(this.value);  updatePDCDiscount();" '+isreadonly+' onchange="updatePDCDiscount()" onkeypress="return isNumberKey(event);"> </div>';
		  			

		  				customBar += '<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"></div>';

		  				//TOTAL COLLECTIBLE
		  				customBar += '<label class="col-md-4 col-lg-4 col-sm-4 col-xs-4 control-label text-left" style="font-size:10pt"><small>Total Collectible</small></label>';
		  				customBar += '<div class="col-md-8 col-lg-8 col-sm-8 col-xs-8"><input type="text" id="cheque_total_collectible" class="form-control text-right" readonly ></div>';
		  				
		  				customBar += '<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="padding:0px; margin:0px"></div>';

		  				//TOTAL RECEIVED
		  				customBar += '<label class="col-md-4 col-lg-4 col-sm-4 control-label text-left" style="font-size:10pt"><small>Total Received</small></label>';
		  				customBar += '<div class="col-md-8 col-sm-8 col-lg-8"><input type="text" id="cheque_total" class="form-control text-right" readonly></div>';

		  				

		  			customBar += '</div>';

		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  			customBar += '<div class="form-group">';
		  				//START EQUITY
		  				customBar += '<label class="col-lg-5 col-md-5 col-sm-5 control-label text-left" style="font-size:10pt"><small>Start Equity</small></label>';
		  				customBar += '<div class="col-lg-7 col-md-7 col-sm-7 "><input type="text" id="cheque_start_equity" class="form-control text-right" readonly></div>';

		  				customBar += '<div class="col-md-12 col-sm-12 col-lg-12 col-xs-12"></div>';

		  				//FINANCING
		  				customBar += '<label class="col-md-5 col-lg-5 col-sm-5 control-label text-left" style="font-size:10pt"><small>Financing</small></label>';
		  				customBar += '<div class="col-md-7 col-sm-7 col-lg-7"><input type="text" id="cheque_financing" class="form-control text-left" readonly></div>';


		  			customBar += '</div>';
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  			customBar += '<div class="form-group">';

		  				//STATUS
		  				customBar += '<label class="col-md-5 col-lg-5 col-sm-5 control-label text-left" style="font-size:10pt"><small>Status</small></label>';
		  				customBar += '<div class="col-md-7 col-sm-7 col-lg-7"><select class="form-control" id="cheque_status" name="cheque_status"><option value=""></option><option value="fully_paid">Fully Paid</option><option value="final_notice_to_pay">Final Notice to Pay</option><option value="notice_of_cancellation">Notice of Cancellation</option><option value="cancelled">Cancelled</option><option value="voluntary_cancellation">Voluntary Cancellation</option></select><small style="color:#ff0000"><b><div class="pdc_date_caption">&nbsp;</div></b></small></div>';

		  				customBar += '<div class="col-md-12 col-sm-12 col-lg-12 col-xs-12"></div>';

		  				//PERMIT TO OCCUPY
		  				customBar += '<label class="col-md-5 col-lg-5 col-sm-5 control-label text-left" style="font-size:10pt"><small>Permit to Occupy</small></label>';
		  				customBar += '<div class="col-md-7 col-sm-7 col-lg-7"> ';
		  				customBar += '<input type="text" id="cheque_permit_to_occupy" class="form-control text-right" readonly>';
		  				customBar += '</div>';


		  			customBar += '</div>';
		  		customBar += '</div>';
		  	customBar += '</div>';
 
		  	customBar += '<div class="row" style="padding:1px"></div>';

	 
		
		var defaultSort		= 	2;
		var defaultOrderSort = "asc";
}else if(main_type=="postdated_checks_received_past_due"){
	var rightalign 		=   new Array(1,5);
	var datealign		=   new Array(2,10);
	var statusrow  		=   11;
	var extra		  	=   11;
	var allow_order		=   new Array(2,3,4,5,6,7,8,9,10,11);
	var no_allow_order  =   new Array(0,1); 
	
 
	var	customBar = ''; 
	 
		
		var defaultSort		= 	2;
		var defaultOrderSort = "asc";
}else if(main_type=="postdated_pagibig_loan_amortization_details"){
	var rightalign 		=   new Array(1,2,4);
	var datealign		=   new Array(2);
	var statusrow  		=   6;
	var extra		  	=   7;
	var allow_order		=   new Array(2,3,4,5);
	var no_allow_order  =   new Array(0,1); 
		var customBar = '<div>';
		customBar += '<div class="row">';
		      	customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		          customBar += '<div class="form-group">';
		          customBar += '<label class="col-lg-3 col-md-3 col-sm-3 control-label text-left" style="font-size:10pt"><small>Borrower</small></label>';
		          customBar += '<div class="col-lg-9 col-md-9 col-sm-9"><input type="text" id="cheque_borrower" style="font-size:8pt" class="form-control" readonly></div>';
		          customBar += '</div>';
		        customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3"></div>'; 

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3"></div>'; 

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  			customBar += '<div class="form-group">';
		  				customBar += '<label class="col-lg-5 col-md-5 col-sm-5 control-label text-left" style="font-size:10pt"><small>PDC Submitted</small></label>';
		  				customBar += '<div class="col-md-7 col-lg-7 col-sm-7">'; 

		  				customBar += '<select id="cheque_pdc_submitted_status_pagibig" name="cheque_pdc_submitted_status" class="form-control">';
						customBar += '<option value=""></option>';
						customBar += '<option value="Complete">Complete</option>';
						customBar += '<option value="Incomplete">Incomplete</option>';
						customBar += '</select>';

		  				customBar += '</div>';
		  			customBar += '</div>';
		  		customBar += '</div>';
		  	customBar += '</div>';
		  	
		  	customBar += '<div class="row" style="padding:1px"></div>';
		  	

		  	customBar += '<div class="row">';
		  		customBar += '<div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">';
		  			customBar += '<div class="form-group">';
		  				customBar += '<label class="col-md-3 col-lg-3 col-sm-3 control-label text-left" style="font-size:10pt"><small>Project</small></label>';
		  				customBar += '<div class="col-lg-9 col-md-9 col-sm-9">';
		  				customBar += '<input type="text" id="cheque_project" class="form-control" readonly style="margin-bottom:2px"> '; 
		  				customBar += '</div>';
		  			customBar += '</div>';
		  		customBar += '</div>';

		  		
		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">'; 
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">'; 
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  			customBar += '<div class="form-group">';
		  				customBar += '<label class="col-md-5 col-lg-5 col-sm-5 control-label text-left" style="font-size:10pt"><small>Lacking PDC</small></label>';
		  				customBar += '<div class="col-md-7 col-sm-7 col-lg-7"><input type="text" id="cheque_lacking_pdc" class="form-control text-right">';
		  				customBar += '</div>';
		  			customBar += '</div>';
		  		customBar += '</div>';
		  	customBar += '</div>';


		  	customBar += '<div class="row">';
		  		customBar += '<div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">';
		  			customBar += '<div class="form-group">';
		  				customBar += '<label class="col-md-3 col-lg-3 col-sm-3 control-label text-left" style="font-size:10pt"><small>Block</small></label>';
		  				customBar += '<div class="col-lg-9 col-md-9 col-sm-9"><input type="text" id="cheque_block" class="form-control" readonly></div>';
		  			customBar += '</div>';
		  		customBar += '</div>';

		  		
		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">'; 
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">'; 
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">'; 
		  		customBar += '</div>';
		  	customBar += '</div>';

		  	customBar += '<div class="row" style="padding:1px"></div>';

		  	customBar += '<div class="row">';
		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  			customBar += '<div class="form-group">';
		  				customBar += '<label class="col-md-3 col-lg-3 col-sm-3 control-label text-left" style="font-size:10pt"><small>Lot</small></label>';
		  				customBar += '<div class="col-md-9 col-sm-9 col-lg-9"><input type="text" id="cheque_lot" class="form-control" readonly></div>';
		  			customBar += '</div>';
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">'; 
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">'; 
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">'; 
		  		customBar += '</div>';
		  	customBar += '</div>';
 
		  	customBar += '<div class="row" style="padding:1px"></div>';

		  	customBar += '<div class="row">';
		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  				customBar += '<div class="form-group"></div>';
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  				customBar += '<div class="form-group"></div>';
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';
		  				customBar += '<div class="form-group"></div>';
		  		customBar += '</div>';

		  		customBar += '<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">';		  			
		  		customBar += '</div>';
		  	customBar += '</div>';
		  	customBar += '<div class="row"><br></div>';
		  	customBar += '</div>';
		
		var defaultSort		= 	2;
		var defaultOrderSort = "asc";
}else if(main_type=="postdated_checks_status"){
	var rightalign 		=   new Array(1,5);
	var datealign		=   new Array(2,8);
	var statusrow  		=   9;
	var extra		  	=   10;
	var allow_order		=   new Array(2,3,4,5,6,7,8,9,10,11);
	var no_allow_order  =   new Array(0,1); 
		var customBar = '<div><div class="row"><div class="col-xs-12 col-sm-3 col-md-3 col-lg-3"><div class="form-group"><label class="col-lg-3 col-md-3 col-sm-3 control-label text-left" style="font-size:10pt"><small>Borrower</small></label><div class="col-lg-9 col-md-9 col-sm-9"><input type="text" id="cheque_borrower" style="font-size:8pt" class="form-control" readonly></div></div></div><div class="col-lg-3 col-md-3 col-sm-3 col-xs-12"><div class="form-group"><label class="col-md-3 col-lg-3 col-sm-3 control-label text-left" style="font-size:10pt"><small>Block</small></label><div class="col-lg-9 col-md-9 col-sm-9"><input type="text" id="cheque_block" class="form-control" readonly></div></div></div><div class="col-xs-12 col-sm-3 col-md-3 col-lg-3"><div class="form-group"><label class="col-md-3 col-lg-3 col-sm-3 control-label text-left" style="font-size:10pt"><small>Lot</small></label><div class="col-md-9 col-sm-9 col-lg-9"><input type="text" id="cheque_lot" class="form-control" readonly></div></div></div></div><div class="row"><br></div></div>';
		
		var defaultSort		= 	2;
		var defaultOrderSort = "asc";
}else if(main_type=="cheque_for_clearing" || main_type=="cleared" || main_type=="hold" || main_type=="no_check" || main_type=="check_for_replacement" || main_type=="past_due"  || main_type=="due_date" || main_type=="no_payment" || main_type=="returned"){
 	 
	var dtype = main_type;
	if(dtype=="cheque_for_clearing"){
		var sel1 = "selected";
		var rightalign 		=   new Array(1,4);
		var datealign		=   new Array(1,8);
		var statusrow  		=   6;
		var extra		  	=   7;
		var allow_order		=   new Array(1,2,3,4,5,6,7,8,9,10,11,12,13);
		var no_allow_order  =   new Array(0); 
		var defaultSort		= 	2;
		var defaultOrderSort = "asc";
	}else if(dtype=="cleared"){
		var sel2 = "selected";
		var rightalign 		=   new Array(0,3,7,9,10,11);
		var datealign		=   new Array(0,7);
		var statusrow  		=   5;
		var extra		  	=   6;
		var allow_order		=   new Array(1,2,3,4,5,6,7,12);
		var no_allow_order  =   new Array(8,9,10,11); 
		var defaultSort		= 	0;
		var defaultOrderSort = "asc";
	}else if(dtype=="hold"){
		var sel3 = "selected";
		var rightalign 		=   new Array(0,3,7,9,10,11);
		var datealign		=   new Array(0,7);
		var statusrow  		=   6;
		var extra		  	=   7;
		var allow_order		=   new Array(1,2,3,4,5,6,7,8,9,10,11);
		var no_allow_order  =   new Array(0,1);
		var defaultSort		= 	0;
		var defaultOrderSort = "asc";
	}else if(dtype=="no_check"){
		var sel4 = "selected";
		var rightalign 		=   new Array(1,5);
		var datealign		=   new Array(2,9);
		var statusrow  		=   7;
		var extra		  	=   8;
		var allow_order		=   new Array(2,3,4,5,6,7,8,9,10,11,12,13,14);
		var no_allow_order  =   new Array(0,1);
		var defaultSort		= 	2;
		var defaultOrderSort = "asc";
	}else if(dtype=="check_for_replacement"){
		var sel5 = "selected";
		var rightalign 		=   new Array(1,5);
		var datealign		=   new Array(2,9);
		var statusrow  		=   7;
		var extra		  	=   8;
		var allow_order		=   new Array(2,3,4,5,6,7,8,9,10,11,12,13,14);
		var no_allow_order  =   new Array(0,1);
		var defaultSort		= 	2;
		var defaultOrderSort = "asc";
	}else if(dtype=="due_date"){
		var sel6 = "selected";
		var rightalign 		=   new Array(1,5);
		var datealign		=   new Array(2,9);
		var statusrow  		=   7;
		var extra		  	=   8;
		var allow_order		=   new Array(2,3,4,5,6,7,8,9,10,11,12,13,14);
		var no_allow_order  =   new Array(0,1);
		var defaultSort		= 	2;
		var defaultOrderSort = "asc";
	}else if(dtype=="no_payment"){
		var sel7 = "selected";
		var rightalign 		=   new Array(1,5);
		var datealign		=   new Array(2,9);
		var statusrow  		=   7;
		var extra		  	=   8;
		var allow_order		=   new Array(2,3,4,5,6,7,8,9,10,11,12,13,14);
		var no_allow_order  =   new Array(0,1);
		var defaultSort		= 	2;
		var defaultOrderSort = "asc";
	}else if(dtype=="returned"){
		var sel8 = "selected";
		var rightalign 		=   new Array(1,5);
		var datealign		=   new Array(2,9);
		var statusrow  		=   7;
		var extra		  	=   8;
		var allow_order		=   new Array(2,3,4,5,6,7,8,9,10,11,12,13,14);
		var no_allow_order  =   new Array(0,1);
		var defaultSort		= 	2;
		var defaultOrderSort = "asc";
	}else if(dtype=="past_due"){
		var sel9 = "selected";
		var rightalign 		=   new Array(1,5);
		var datealign		=   new Array(2,9);
		var statusrow  		=   7;
		var extra		  	=   8;
		var allow_order		=   new Array(2,3,4,5,6,7,8,9,10,11,12,13,14);
		var no_allow_order  =   new Array(0,1);
		var defaultSort		= 	2;
		var defaultOrderSort = "asc";
	}  
	
	 
		
	var ischeck3 = $('.check_tobedelivered_date').val();
	if(ischeck3=='yes'){
		var checked3 = "checked";
	}else{
		var checked3 = "";
	}

	var customBar =	"<div class='row'><div class='col-sm-8'><div class='col-sm-3'><label>Cheque Date</label></div><div class='col-sm-2'><input name='monthly_reservation_from' onchange='resetunselect()' placeholder='From' type='text' id='0' class='daterange-search-input daterange-from datepicker form-control monthly_reservation_from' title='Cheque Date From' '></div><div class='col-xs-1 text-center'><label>To</label></div><div class='col-sm-2'><input placeholder='To' type='text' id='1' class='daterange-search-input daterange-to datepicker form-control monthly_reservation_to' onchange='resetunselect()' title='Cheque Date To' name='monthly_reservation_to' ></div><div class='col-sm-1'><input type='checkbox' id='check_tobedelivered_date' name='check_tobedelivered_date' value='yes' "+checked3+" title='Filter with Date Range'> <label style='cursor:pointer' for='check_tobedelivered_date'>&nbsp;&nbsp;<span  class='glyphicon glyphicon-calendar' title='Filter with Date Range'></span></label></div><div class='col-sm-3'><select class='form-control' onchange='javascript:location.href = this.value;' style='font-size:10pt; width:300px;'><option "+sel1+" value='index.php?pg=cheque_for_clearing&type=cheque_for_clearing'>Cheque for Clearing</option><option "+sel2+" value='index.php?pg=cheque_for_clearing&type=cleared'>Cleared</option><option "+sel3+" value='index.php?pg=cheque_for_clearing&type=hold'>Hold</option><option "+sel4+" value='index.php?pg=cheque_for_clearing&type=no_check'>No Check</option><option "+sel5+" value='index.php?pg=cheque_for_clearing&type=check_for_replacement'>Check for Replacement</option><option "+sel6+" value='index.php?pg=cheque_for_clearing&type=due_date'>Due Date</option><option "+sel7+" value='index.php?pg=cheque_for_clearing&type=no_payment'>No Payment</option><option "+sel8+" value='index.php?pg=cheque_for_clearing&type=returned'>Returned</option><option "+sel9+" value='index.php?pg=cheque_for_clearing&type=past_due'>Past Due</option></select></div></div></div>";
  	
	var sdate	= $.datepicker.formatDate('mm/dd/yy', new Date()); 
	$('.monthly_reservation_from').val(sdate); 
	
	

}else if(main_type=="notifications_accounting1"){
	var rightalign			=   new Array(1,2,4,5,6);
	var datealign			=	new Array(5);
	var statusrow			=   "";
	var extra 	 			=	"";
	var allow_order			=   "";
	var no_allow_order  	=   new Array(0,1,2,3,4,5);
	var defaultSort			= 	6;
	var defaultOrderSort 	= "asc";
	 
}else if(main_type=="notifications_accounting2"){
	var rightalign			=   new Array(1,2,4);
	var datealign			=	new Array(4);
	var statusrow			=   "";
	var extra 	 			=	"";
	var allow_order			=   "";
	var no_allow_order  	=   new Array(0,1,2,3);
	var defaultSort			= 	4;
	var defaultOrderSort 	= "asc";
	  
	 
}else if(main_type=="notifications_admin"){
	var rightalign			=   new Array(1,2,4,5);
	var datealign			=	new Array(5);
	var statusrow			=   "";
	var extra 	 			=	"";
	var allow_order			=   "";
	var no_allow_order  	=   new Array(0,1,2,3,4,5);
	var defaultSort			= 	3;
	var defaultOrderSort 	= "desc";
	  
	 
}else if(main_type=="notifications_with_balance"){
	var rightalign			=   new Array(1,2,4,5,6,7);
	var datealign			=	new Array(3);
	var statusrow			=	"";
	var extra 	 			=	"";
	var allow_order			=   "";
	var no_allow_order  	=   new Array(0,1,2,3,4,5,6,7);
	var defaultSort			= 	3;
	var defaultOrderSort 	= "desc";
	  
	 
}else{
	var rightalign 	=   new Array(1);
	var statusrow 	=	"";
	var extra  		=	"";
	var allow_order	=	"";
	var datealign	=	"";
	var defaultSort		= 1;
	var defaultOrderSort = "asc";
	var no_allow_order  =   new Array(0,1);
}	

 

if(main_type=="postdated_checks_received"){
	var rid = $('#main_rid').val(); 
	loadReserveDetails(rid); 
	loadScrollList('#'+main_type+'_table','./list/'+main_type+'.php?rid='+rid,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}else if(main_type=="postdated_checks_received_past_due"){
	var rid = $('#main_rid').val(); 
	var cmid = $('#cmid').val(); 
 
	
	loadReserveDetails(rid); 
	loadScrollList('#'+main_type+'_table','./list/'+main_type+'.php?rid='+rid+'&cmid='+cmid,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}else if(main_type=="postdated_pagibig_loan_amortization_details"){
	var rid = $('#main_rid').val(); 
	loadReserveDetails(rid); 
	loadScrollList('#'+main_type+'_table','./list/'+main_type+'.php?rid='+rid,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
 
}else if(main_type=="postdated_checks_status"){
	var rid = $('#main_rid').val(); 
	loadReserveDetails(rid); 
	loadScrollList('#'+main_type+'_table','./list/'+main_type+'.php?rid='+rid,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}else if(main_type=="report_summary_report_of_buyers"){
	var dtype = $('#dtype').val();
	loadScrollList('#'+dtype+'_table','./list/report_'+dtype+'.php?rid='+rid,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}else if(main_type=="monthly_sales_reservation"){
	var dtype = $('#dtype').val();
	loadScrollList('#'+dtype+'_table','./list/report_'+dtype+'.php?rid='+rid,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort); 
}else{ 
	loadScrollList('#'+main_type+'_table','./list/'+main_type+'.php',customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}

var mstart	= $.datepicker.formatDate('mm/dd/yy', new Date());
 
var currentTime = new Date(); 
var startDateFrom = $.datepicker.formatDate('mm/dd/yy',new Date(currentTime.getFullYear(),currentTime.getMonth(),1));
var startDateTo = $.datepicker.formatDate('mm/dd/yy', new Date(currentTime.getFullYear(),currentTime.getMonth() +1,0));

$('.monthly_reservation_from').val(startDateFrom);
$('.monthly_reservation_to').val(startDateTo);
 /*
$('#check_tobedelivered_date').on('change',function(e){
	e.preventDefault();

	if($(this).is(':checked')){
		var s = "yes";
	}else{
		var s = "no";
	}

	 //$('#'+main_type+'_table').dataTable().columns.adjust().draw(); 
 	//	$('#'+main_type+'_table').DataTable().columns.adjust().draw(); 
 	 //$('#'+main_type+'_table').DataTable().adjust().draw(false); 
var mf = $('.monthly_reservation_from').val();
var mt = $('.monthly_reservation_to').val();
 
	

 if(main_type=="report_summary_report_of_buyers"){
	var dtype = $('#dtype').val();
	loadScrollList('#'+dtype+'_table','./list/report_'+dtype+'.php?rid='+rid,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}else if(main_type=="monthly_sales_reservation"){
	var dtype = $('#dtype').val();
	loadScrollList('#'+dtype+'_table','./list/report_'+dtype+'.php?rid='+rid,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}else{
	 loadScrollList('#'+main_type+'_table','./list/'+main_type+'.php',customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}
 

	 $('.check_tobedelivered_date').val(s);
	 $('.monthly_reservation_from').val(mf);
	 $('.monthly_reservation_to').val(mt);  
});

*/



$('#check_tobedelivered').on('change',function(){   

	if($(this).is(':checked')){
		var s = "yes";
	}else{
		var s = "no";
	}
 	 
	var mf = $('.monthly_reservation_from').val();
	var mt = $('.monthly_reservation_to').val();
  
	loadScrollList('#'+main_type+'_table','./list/'+main_type+'.php',customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
	$('.check_tobedelivered').val(s); 
 	$('.monthly_reservation_from').val(mf);
 	$('.monthly_reservation_to').val(mt); 
 
});

 

$('#check_tobedelivered_date').on('click',function(e){
	//e.preventDefault();
    /*
	if($(this).is(':checked')){
		var s = "yes";
	}else{
		var s = "no";
	}*/

	 //$('#'+main_type+'_table').dataTable().columns.adjust().draw(); 
 	//	$('#'+main_type+'_table').DataTable().columns.adjust().draw(); 
 	 //$('#'+main_type+'_table').DataTable().adjust().draw(false); 
var mf = $('.monthly_reservation_from').val();
var mt = $('.monthly_reservation_to').val();
 
	

 if(main_type=="report_summary_report_of_buyers"){
	var dtype = $('#dtype').val();
	loadScrollList('#'+dtype+'_table','./list/report_'+dtype+'.php?rid='+rid,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}else if(main_type=="monthly_sales_reservation"){
	var dtype = $('#dtype').val();
	loadScrollList('#'+dtype+'_table','./list/report_'+dtype+'.php?rid='+rid,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}else{
	 loadScrollList('#'+main_type+'_table','./list/'+main_type+'.php',customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}
 


		var cdev = $('#check_tobedelivered_date').is(":checked");
		if(cdev==true){
			$('#check_tobedelivered_date').val('yes');
				
				if(main_type=="report_buyer_employment_type"){
					 getAnalysisReport();
				}
				
		}else{
			$('#check_tobedelivered_date').val('no');
		}
	 
		var check_tobedelivered_date = $('#check_tobedelivered_date').val();
 		
	 //$('#check_tobedelivered_date').val(s);
	 $('.monthly_reservation_from').val(mf);
	 $('.monthly_reservation_to').val(mt);  
});



$('#check_tobedelivered').on('click',function(){   

	if($(this).is(':checked')){
		var s = "yes";
	}else{
		var s = "no";
	}
 	 
	var mf = $('.monthly_reservation_from').val();
	var mt = $('.monthly_reservation_to').val();
  
	loadScrollList('#'+main_type+'_table','./list/'+main_type+'.php',customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
	$('.check_tobedelivered').val(s); 
 	$('.monthly_reservation_from').val(mf);
 	$('.monthly_reservation_to').val(mt); 
 
});



if(main_type=='reservation'){
	$('#check_tobedelivered_no').change(function(){   
		if($(this).is(':checked')){
			var so = "yes";
		}else{
			var so = "no";
		}


var mf = $('.monthly_reservation_from').val();
var mt = $('.monthly_reservation_to').val(); 
		//$('#reservation_table').DataTable().destroy();
		 loadScrollList('#'+main_type+'_table','./list/'+main_type+'.php',customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);

		$('.check_tobedelivered_no').val(so); 
		$('.monthly_reservation_from').val(mf);
		$('.monthly_reservation_to').val(mt);
 
	});
}


if(main_type=='report_reservation'){
	$('#check_tobedelivered_no').change(function(){   
		if($(this).is(':checked')){
			var so = "yes";
		}else{
			var so = "no";
		}


var mf = $('.monthly_reservation_from').val();
var mt = $('.monthly_reservation_to').val(); 
		//$('#reservation_table').DataTable().destroy();
		 loadScrollList('#'+main_type+'_table','./list/'+main_type+'.php',customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);

		$('.check_tobedelivered_no').val(so); 
		$('.monthly_reservation_from').val(mf);
		$('.monthly_reservation_to').val(mt);
 
	});
}

$('.monthly_reservation_from').change(function(e){
	e.preventDefault();  
var mf = $('.monthly_reservation_from').val();
var mt = $('.monthly_reservation_to').val(); 




 if(main_type=="report_summary_report_of_buyers"){
	var dtype = $('#dtype').val();
	loadScrollList('#'+dtype+'_table','./list/report_'+dtype+'.php?rid='+rid,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}else if(main_type=="monthly_sales_reservation"){
	var dtype = $('#dtype').val();
	loadScrollList('#'+dtype+'_table','./list/report_'+dtype+'.php?rid='+rid,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}else if(main_type=="report_buyer_employment_type"){
	getAnalysisReport(); 
}else{
		 loadScrollList('#'+main_type+'_table','./list/'+main_type+'.php',customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort); 
}

 	
 $('.monthly_reservation_from').val(mf);
 $('.monthly_reservation_to').val(mt);
 
});


$('.monthly_reservation_to').change(function(e){
	e.preventDefault();  
var mf = $('.monthly_reservation_from').val();
var mt = $('.monthly_reservation_to').val(); 


 if(main_type=="report_summary_report_of_buyers"){
	var dtype = $('#dtype').val();
	loadScrollList('#'+dtype+'_table','./list/report_'+dtype+'.php?rid='+rid,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}else if(main_type=="monthly_sales_reservation"){
	var dtype = $('#dtype').val();
	loadScrollList('#'+dtype+'_table','./list/report_'+dtype+'.php?rid='+rid,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
}else if(main_type=="report_buyer_employment_type"){
	getAnalysisReport(); 
}else{
		 loadScrollList('#'+main_type+'_table','./list/'+main_type+'.php',customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort);
 
}
 	
 $('.monthly_reservation_from').val(mf);
 $('.monthly_reservation_to').val(mt);
 
});

//LOAD DATATABLE LISTING	 


if(main_type=="postdated_pagibig_loan_amortization_details"){
	$('#postdated_pagibig_loan_amortization_details_table_filter').css("display","none");
	$('button.ColVis_Button').css("display","none"); 
}else if(main_type=="postdated_checks_received"){
	$('#postdated_checks_received_table_filter').css("display","none");
	$('button.ColVis_Button').css("display","none"); 
}else if(main_type=="postdated_checks_received_past_due"){
	$('#postdated_checks_received_past_due_table_filter').css("display","none");
	$('button.ColVis_Button').css("display","none"); 
}

function loadScrollList(tableId,loadFileName,customBar,rightalign,allow_order,no_allow_order,defaultSort,defaultOrderSort){ 
  
if(main_type=="postdated_checks_received"){
	//var customBarIcons = "<\"toolbar\"><\"clear\">RrtiS";
	var customBarIcons = "fC<\"toolbar\"><\"clear\">RrtiS"; 
	var tableHeight = 200;
}else if(main_type=="postdated_checks_received_past_due"){ 
	var customBarIcons = "fC<\"toolbar\"><\"clear\">RrtiS"; 
	var tableHeight = 300;
}else if(main_type=="postdated_pagibig_loan_amortization_details"){
	//var customBarIcons = "<\"toolbar\"><\"clear\">RrtiS"; 
	var customBarIcons = "fC<\"toolbar\"><\"clear\">RrtiS"; 
	var tableHeight = 240;

}else if(main_type=="position" || main_type=="employee_type" || main_type=="buyer_profile" || main_type=="agent" || main_type=="broker"){
	var customBarIcons = "fC<\"toolbar\"><\"clear\">RrtiS";
	var tableHeight = 400;
}else if(main_type=="reservation"){
	var customBarIcons = "fC<\"toolbar\"><\"clear\">RrtiS";
	var tableHeight = 400;
}else if(main_type=="sales_report_per_agent"){
	var customBarIcons = "fC<\"toolbar\"><\"clear\">RrtiS";
	var tableHeight = 355;

}else if(main_type=="report_schedule_of_loan_folders"){
	var customBarIcons = "fC<\"toolbar\"><\"clear\">RrtiS";
	var tableHeight = 385;	

}else if(main_type=="monthly_sales_reservation"){
	var customBarIcons = "fC<\"toolbar\"><\"clear\">RrtiS";
	var tableHeight = 355;	

}else if(main_type=="buyer_status_folder_pagibig"){
	var customBarIcons = "fC<\"toolbar\"><\"clear\">RrtiS";
	var tableHeight = 390; 

}else if(main_type=="conversion"){
	var customBarIcons = "fC<\"toolbar\"><\"clear\">RrtiS";
	var tableHeight = 400; 

}else if(main_type=="conversion_details"){
	var customBarIcons = "fC<\"toolbar\"><\"clear\">RrtiS";
	var tableHeight = 350; 

}else if(main_type=="pricelist"){
	var customBarIcons = "fC<\"toolbar\"><\"clear\">RrtiS";
	var tableHeight = 350; 

}else{
	var customBarIcons = "fC<\"toolbar\"><\"clear\">RrtiS";
	var tableHeight = 365;
}
 


	 var table =  $(tableId).DataTable({
        //"ajax"				:	loadFileName,  
		     "ajax": {
                        "url": loadFileName, 
                        "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();
							d.block_from		= $('.block_from').val();
							d.block_to			= $('.block_to').val();
							d.lot_from			= $('.lot_from').val();
							d.lot_to			= $('.lot_to').val(); 
                        }
                    } ,
		"processing"		:	true,  
		   "destroy"		: 	true,
 		"serverSide"		:	true,   
		"deferRender"		:	true,
		"retrieve"			:	true,
		//"sDom"				:	'fC<"toolbar"><"clear">RrtiS', 
		"sDom"				:	customBarIcons, 
		 
        "colVis"			:	{
            "buttonText"	:	"<i class='glyphicon glyphicon-eye-open'></i>", 
			"exclude"		:	[0,1]
        },
        //"scrollY"			:	tableHeight, 
        scrollY: tableHeight,
    //    scrollX: true, 
		//"scrollX"			:	"100%", 


	    "scrollX": true, 
        "scrollCollapse"	:	true, 
		"autoWidth"			:	false,   
		"scroller"			:	{
            //"loadingIndicator": true
        },  

		"order": [[ defaultSort, defaultOrderSort ]],
		"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull){  
		if(main_type=="reservation"){
			var statusrow = 21;
			var extra = "";		
		}else if(main_type=="releases_to_broker"){
			var statusrow = 6;
			var extra = "";	  
		}else if(main_type=="partial_commission_releases_schedule"){
			var statusrow = 7;
			var extra = "";	  
		}else if(main_type=="releases_to_broker_for_wht"){
			var statusrow = 7;
			var extra = "";	  
		}else if(main_type=="payment_status_to_broker"){
			var statusrow = 6;
			var extra = "";	   
		}else if(main_type=="report_releases_to_broker"){
			var statusrow = 10;
			var extra = "";	  
		}else if(main_type=="report_reservation"){
			var statusrow = 21;
			var extra = "";		
		}else if(main_type=="report_monitoring_folders"){
			var statusrow = 23;
			//var statusrow = "";
			var extra = "";		
		}else if(main_type=="report_buyer_payment_monitoring"){
			var statusrow = 31;
			var extra = "";		
		}else if(main_type=="report_buyer_payment_monitoring_on_equity"){
			var statusrow = 17;
			var extra = "";		
 		}else if(main_type=="report_buyer_payment_monitoring_other_payables"){
			var statusrow = 20;
			var extra = "";	
		}else if(main_type=="status_of_accounts_for_conversion"){
			var statusrow = 9;
			var extra = "";	 
		}else if(main_type=="postdated_checks_received"){
			var statusrow = 11; 
			var extra = 12;
			var extra2 = 14;
		}else if(main_type=="postdated_checks_received_past_due"){
			var statusrow = 11; 
			var extra = 7;
			var extra2 = 14;
		}else if(main_type=="postdated_pagibig_loan_amortization_details"){
			var statusrow = 6; 
			var extra = 7; 
		}else if(main_type=="postdated_checks_status"){
			var statusrow = 9; 
			var extra = 10;
		}else if(main_type=="cheque_for_clearing"){
			var statusrow = 6; 
			var extra = 7;
		}else if((main_type=="buyer_payment_monitoring")){
			var statusrow = 6;  
			var extra = "";
		}else if((main_type=="postdated_pagibig_loan_amortization")){
			var statusrow = 6;  
			var extra = "";
		}else if((main_type=="buyer_house_renovation_monitoring")){
			var statusrow = 13;  
			var extra = "";	
		}else if((main_type=="buyer_status_monitoring")){
			var statusrow = 17;  
			var extra = "";
		}else if((main_type=="buyer_status_folder_pagibig")){
			var statusrow = 14;  
			var extra = "";
		}else if((main_type=="buyer_status_folder_bank")){
			var statusrow = 14;  
			var extra = "";
		}else if((main_type=="report_buyer_status_monitoring")){
			var statusrow = 16;  
			var extra = "";
		}else if((main_type=="report_buyer_status_folder_pagibig")){
			var statusrow = 14;  
			var extra = "";
		}else if((main_type=="report_buyer_status_folder_bank")){
			var statusrow = 14;  
			var extra = "";
		}else if((main_type=="report_schedule_of_loan_folders")){
			var statusrow = 9;  
			var extra = "";
		}else if((main_type=="schedule_of_loan_folders")){
			var statusrow = 10;  
			var extra = "";
		}else if((main_type=="report_summary_report_of_buyers")){ 
			var dtype = $('#dtype').val();  		
			if(dtype=='lacking'){
				//var statusrow = 8;  
				var statusrow = 7;  
				var extra = "";
			}
		}else if((main_type=="monthly_sales_reservation")){ 
			var dtype = $('#dtype').val(); 

			if(dtype=='cancellation'){
				var statusrow = 8;  
				var extra = "";
			}else if(dtype=='monthly'){
				var statusrow = 10;
				var extra = "";
			}else if(dtype=='transferred'){
				var statusrow = 12;
				var extra = "";
			}
		}else{
			var statusrow = "";
			var extra = "";
		} 
 
					if ( aData[statusrow]=="FULLY PAID"){
					   $(nRow).children().each(function (index, td) {
						   $(this).addClass('commission_status');
					   });
					}else if ( aData[statusrow]=="CANCELLED" || aData[statusrow]=="RETURNED"){
					   $(nRow).children().each(function (index, td) {
						   $(this).addClass('cancel_status');
					   });
					}else if ( aData[statusrow]=="TRANSFERRED" || aData[statusrow]=="HOLD"){
					   $(nRow).children().each(function (index, td) {
						   $(this).addClass('transfer_status');
					   });
					}else if ( aData[statusrow]=="PAST DUE CLEARED" && aData[extra2]=="UNPAID"){
					   $(nRow).children().each(function (index, td) {
						   $(this).addClass('pastduecleared_unpaid_status');
					   });
					}else if ( aData[statusrow]=="PAST DUE CLEARED" && aData[extra2]=="PAID"){
					   $(nRow).children().each(function (index, td) {
						   $(this).addClass('pastduecleared_paid_status');
					   });
					}else if ( aData[statusrow]=="CLEARED" && aData[extra]=="RE-DEPOSIT" && aData[extra2]=="Unpaid"){
					   $(nRow).children().each(function (index, td) {
						   $(this).addClass('clear_redeposit_unpaid_status');
					   });
					}else if ( aData[statusrow]=="CLEARED" && aData[extra]!=""){
					   $(nRow).children().each(function (index, td) {
						   $(this).addClass('clear_return_status');
					   });
					}else if ( aData[statusrow]=="CLEARED"){
					   $(nRow).children().each(function (index, td) {
						   $(this).addClass('clear_status');
					   });
					}else if ( aData[statusrow]=="REPLACED"){
					   $(nRow).children().each(function (index, td) {
						   $(this).addClass('replace_status');
					   });
					}else if (aData[statusrow]=="REPLACEMENT"){
					   $(nRow).children().each(function (index, td) {
						   $(this).addClass('replacement_status');
					   });
					} 
			},"columnDefs"		:	[
				{ "targets": no_allow_order, "orderable": false},
				{ "targets": allow_order, "type":"formatted-num", "orderable": true },
				{ "targets": allow_order, "type":"formatted-num", "orderable": true }, //26AUG23
				{ "orderable": true, "className": "textright", "type":"formatted-num", "targets": rightalign },
				{ "type":"formatted-num", "orderable": true}]

					/*, "columnDefs" : [
					  { 
					    "type": 'html',
					    "targets": 0 
					  },{ 
					    "type": 'num',
					    "targets": 1 
					  },{ 
					    "type": 'string',
					    "targets": 2 
					  },{ 
					    "type": 'string',
					    "targets": 3 
					  }
					] */
			
    }); 
		 table.columns.adjust().draw();


 
		
/*		$('.search-input-text').on( 'keyup click', function () {   // for text boxes 
			var i =$(this).attr('data-column');  // getting column index
			var v =$(this).val();  // getting search input value
			table.columns(i).search(v).draw();
		});*/
	
	 $("div.toolbar").html(customBar); 
	/**********************/   
 

 
$('#myInputTextField').keyup(function(){ 
		var value = $('.dataTables_filter input').val();
      table.search($(this).val()).draw();
});
 
 
	
$(tableId).on('search.dt', function() {
    var value = $('.dataTables_filter input').val().replace("'","CHAR(39)");
  //table.search($(this).val()).draw();
}); 
	

 	$('.block_from').on('keyup change load', function () {  
					var i =$(this).attr('id');  // getting column index
					var v =$(this).val();  // getting search input value						
					table.columns(i).search(v).draw();
	}); 

 	$('.block_to').on('keyup change load', function () {  
					var i =$(this).attr('id');  // getting column index
					var v =$(this).val();  // getting search input value						
					table.columns(i).search(v).draw();
	}); 

  	$('.lot_from').on('keyup change load', function () {  
					var i =$(this).attr('id');  // getting column index
					var v =$(this).val();  // getting search input value						
					table.columns(i).search(v).draw();
	}); 

    $('.lot_to').on('keyup change load', function () {  
					var i =$(this).attr('id');  // getting column index
					var v =$(this).val();  // getting search input value						
					table.columns(i).search(v).draw();
	}); 


	 if(main_type=="monthly_sales_reservation" || main_type=="report_monitoring_folders" || main_type=="report_buyer_payment_monitoring" || "report_buyer_status_monitoring" || "report_summary_report_of_buyers" || "schedule_of_loan_folders" || "report_schedule_of_loan_folders" || main_type=='sales_report_per_broker' || main_type=='sales_report_per_agent' || main_type=='cheque_for_clearing' || main_type=='report_partial_commission_releases_schedule'){
  
				 $('.daterange-search-input').on('keyup change load', function () {  
					var i =$(this).attr('id');  // getting column index
					var v =$(this).val();  // getting search input value						
					table.columns(i).search(v).draw();
				 }); 
 
		 
		 $( ".datepicker" ).datepicker({
			dateFormat: "yy-mm-dd",
			showOn: "button",
			showAnim: 'slideDown',
			showButtonPanel: true ,
			autoSize: true,
			buttonImage: "//jqueryui.com/resources/demos/datepicker/images/calendar.gif",
			buttonImageOnly: true,
			buttonText: "Select date",
			language: "en-GB",
		    todayHighlight: true,
			orientation: "bottom left",
			closeText: "Clear"
		});


 
		 
		 $(document).on("click", ".ui-datepicker-close", function(){
			$('.datepicker').val("");  
			table.columns(1).search("").draw(); 
		}); 
		
		
		
		$('#check_tobedelivered').change(function(){
			if($(this).is(':checked')){
				var s = "yes";
			}else{
				var s = "no";
			} 
			$('.check_tobedelivered').val(s); 
			table.columns.adjust().draw(); 
		});
		
		$('#check_tobedelivered_no').change(function(){
			if($(this).is(':checked')){
				var s = "yes";
			}else{
				var s = "no";
			} 
			$('.check_tobedelivered_no').val(s); 
			table.columns.adjust().draw(); 
		});
		
		$('#check_tobedelivered_date').change(function(){
			if($(this).is(':checked')){
				var s = "yes";
			}else{
				var s = "no";
			} 
			$('.check_tobedelivered_date').val(s); 
			table.columns.adjust().draw(); 
		});
	}
}
		 
//ADD COMMA SEPARATED	
function Comma(Num)
{
       Num += '';
       Num = Num.replace(',' , '');Num = Num.replace(',' , '');Num = Num.replace(',' , '');
       Num = Num.replace(',' , '');Num = Num.replace(',' , '');Num = Num.replace(',' , '');
       x = Num.split('.');
       x1 = x[0];
       x2 = x.length > 1 ? '.' + x[1] : '';
       var rgx = /(\d+)(\d{3})/;
       while (rgx.test(x1))
       x1 = x1.replace(rgx, '$1' + ',' + '$2');
        return x1 + x2; 
}

//INPUT NUMBER's ONLY
function isNumberKey(evt) {
          var theEvent = evt || window.event;
          var key = theEvent.keyCode || theEvent.which;
          key = String.fromCharCode(key);
          if (key.length == 0) return;
          var regex = /^[0-9.,\-\b]+$/;
          if (!regex.test(key)) {
              theEvent.returnValue = false;
              if (theEvent.preventDefault) theEvent.preventDefault();
          }
} 

//CALL POP-UP MODAL
function callModal(modalId){ 
	$(modalId).modal({
		keyboard: false,
		backdrop: "static",
		show : true
	});
}

//CANCEL TRANSACTION
$('#button_cancel').click(function(e){
	e.preventDefault(); 
	bootbox.dialog({
	  message: "Are you sure you want to cancel this record?", 
	  buttons: {
		success: {
		  label: "Yes",
		  className: "btn-success",
		  callback: function() {
			var mods 	= $('#main_page').val();
			var types 	= $('#main_type').val(); 
				if(types=="checklist_of_requirements" || types=="reservation" || types=="monitoring_folders"){
					types = "reservation";
					window.setTimeout(function() { window.location.href = 'index.php?pg='+mods+'&type='+types; }, 1000);
				}else{
					window.setTimeout(function() { window.location.href = 'index.php?pg='+mods+'&type='+types; }, 1000);
				} 
		  }
		},
		main: {
		  label: "No",
		  className: "btn-default"
		}
	  }
	});	
});

//EDIT TRANSACTION
$('#button_edit').click(function(e){
	e.preventDefault();
	var id	 	= $('#main_id').val();
	var mods 	= $('#main_page').val();
	var types 	= $('#main_type').val(); 
	var action 	= $('#main_action').val(); 
	window.location.replace("index.php?pg="+mods+"&type="+types+"&action=edit&id="+id);
});

//BACK TO LISTINGS
$('#button_back').click(function(e){
	e.preventDefault();
	var mods 	= $('#main_page').val();
	var types 	= $('#main_type').val(); 
	var action 	= $('#main_action').val();
	var id	 	= $('#main_id').val();
	window.location.replace("index.php?pg="+mods+"&type="+types);
});

//SAVE TRANSACTION
$('#button_save').click(function(e){
	e.preventDefault(); 
	var mods 	= $('#main_page').val();
	var types 	= $('#main_type').val(); 
	var action 	= $('#main_action').val(); 
	if(types=="promo"){
		var save_message 	= "Do you want to save the changes you made to promo?";
	}else if(types=="pricelist"){ 
		var save_message 	= "Do you want to save the changes you made to pricelist?";
	}else if(types=="reservation"){ 
		var save_message 	= "Do you want to save the changes you made to reservation?";
	}else if(types=="buyer_profile"){ 
		var save_message 	= "Do you want to save the changes you made to buyer profile?";
	}else if(types=="position"){ 
		var save_message 	= "Do you want to save the changes you made to position?";
	}else if(types=="employee_type"){ 
		var save_message 	= "Do you want to save the changes you made to employee type?";
	}else if(types=="broker"){ 
		var save_message 	= "Do you want to save the changes you made to broker?";
	}else if(types=="brokeragent"){ 
		var save_message 	= "Do you want to save the changes you made to the account details of broker & agent?";
	}else if(types=="tin"){ 
		var save_message 	= "Do you want to save the changes you made to the Tin of Supplier?";
	}else if(types=="agent"){ 
		var save_message 	= "Do you want to save the changes you made to agent?";
	}else if(types=="checklist_of_requirements"){ 
		var save_message 	= "Do you want to save the changes you made to checklist of requirements?";
	}else if(types=="monitoring_folders" && action=="batch_update"){ 
		var save_message 	= "Do you want to save the changes you made to monitoring folders batch update?";
	}else if(types=="monitoring_folders"){ 
		var save_message 	= "Do you want to save the changes you made to monitoring folders?";
	}else if(types=="buyer_payment_monitoring"){ 
		var save_message 	= "Do you want to save the changes you made to buyer's payment monitoring?";
	}else if(types=="buyer_status_monitoring"){ 
		var save_message 	= "Do you want to save the changes you made to buyer's status monitoring?";
	}else if(types=="buyer_status_folder_pagibig"){ 
		var save_message 	= "Do you want to save the changes you made to status of buyer's folders with Pag-Ibig?"; 		
	}else if(types=="buyer_status_folder_bank"){ 
		var save_message 	= "Do you want to save the changes you made to status of buyer's folders with Bank?"; 		
	}else if(types=="users"){ 
		var save_message 	= "Do you want to save the changes you made to users?"; 		
	}else if(types=="releases_to_broker"){ 
	 		var save_message 	= "Do you want to save the changes you made to releases to broker?"; 		
	}else if(types=="partial_commission_releases_schedule"){ 
	 		var save_message 	= "Do you want to save the changes you made to partial commission releases schedule?"; 		
	}else if(types=="releases_to_broker_for_wht"){ 
	 		var save_message 	= "Do you want to save the changes you made to releases to broker for wht?"; 		
	}else if(types=="releases_to_contractor"){ 
 		var save_message 	= "Do you want to save the changes you made to releases to contractor?";
	}else if(types=="payment_status_to_broker"){ 
 		var save_message 	= "Do you want to save the changes you made to payment status to broker?";
	}else if(types=="payment_status_to_contractor"){ 
 		var save_message 	= "Do you want to save the changes you made to payment status to contractor?"; 		 
	}else if(types=="buyer_house_renovation_monitoring"){ 
 		var save_message 	= "Do you want to save the changes you made to buyer house renovation monitoring?";
	}else if(types=="contractor"){ 
 		var save_message 	= "Do you want to save the changes you made to contractor?"; 
	}else if(types=="units"){ 
 		var save_message 	= "Do you want to save the changes you made to units?"; 
	}else if(types=="permits_and_licenses"){ 
 		var save_message 	= "Do you want to save the changes you made to permits and licenses?"; 
	}else if(types=="construction_and_utilities"){ 
 		var save_message 	= "Do you want to save the changes you made to construction and utilities?"; 
	}else{  
		var save_message 	= "Do you want to save the changes you made?";
	}
	bootbox.dialog({
	  message: save_message, 
	  buttons: {
		success: {
			  label: "Yes",
			  className: "btn-success",
			  callback: function() { 
					if(types=="promo" && mods=="promo"){
						save_promo();
					}else if(types=="pricelist" && mods=="pricelist"){ 
						save_pricelist();
					}else if(types=="reservation" && mods=="reservation"){ 
						save_reservation();
					}else if(types=="broker" && mods=="settings"){ 
						save_broker();
					}else if(types=="brokeragent" && mods=="settings"){ 
						save_brokeragent();
					}else if(types=="tin" && mods=="settings"){ 
						save_tin();
					}else if(types=="agent" && mods=="settings"){ 
						save_agent(); 
					}else if(types=="position" && mods=="settings"){ 
						save_position(); 
					}else if(types=="buyer_profile" && mods=="settings"){ 
						save_buyer_profile(); 
					}else if(types=="employee_type" && mods=="settings"){ 
						save_employee_type(); 
					}else if(types=="checklist_of_requirements" && mods=="reservation"){ 
						save_checklist();
					}else if(action=="batch_update" && types=="monitoring_folders" && mods=="reservation"){  
						save_monitoring_folders_batch_update(); 
					}else if(types=="monitoring_folders" && mods=="reservation"){ 
						save_monitoring_folders();
					}else if(types=="buyer_payment_monitoring" && mods=="payment"){ 
						save_buyer_payment_monitoring();
					}else if(types=="buyer_status_monitoring" && mods=="payment"){ 
						save_buyer_status_monitoring();
					}else if(types=="buyer_status_folder_pagibig" && mods=="payment"){ 
						save_buyer_status_folder_pagibig();
					}else if(types=="buyer_status_folder_bank" && mods=="payment"){ 
						save_buyer_status_folder_bank();
					}else if(types=="users" && mods=="users"){ 
						save_users();
					}else if(types=="releases_to_broker"){ 
						save_releases_to_broker();
					}else if(types=="releases_to_broker_for_wht"){ 
						save_releases_to_broker_for_wht();
					}else if(types=="partial_commission_releases_schedule"){ 
						save_partial_commission_releases_schedule();
					}else if(types=="releases_to_contractor"){ 
						 save_releases_to_contractor();
					}else if(types=="payment_status_to_broker"){ 
						save_payment_status_to_broker();
					}else if(types=="payment_status_to_contractor"){ 
						 save_payment_status_to_contractor();
					}else if(types=="buyer_house_renovation_monitoring"){ 
						 save_buyer_house_renovation_monitoring();
					}else if(types=="units"){ 
 						 save_units();
					}else if(types=="contractor"){ 
 						 save_contractor();
					}else if(types=="permits_and_licenses"){ 
 						 save_permits_and_licenses();
					}else if(types=="construction_and_utilities"){
						save_construction_and_utilities();
					} 

			  }
		},
		danger: {
		  label: "No",
		  className: "btn-danger",
		  callback: function() {
				if(types=="checklist_of_requirements" || types=="reservation" || types=="monitoring_folders"){
					types = "reservation";
					window.setTimeout(function() { window.location.href = 'index.php?pg='+mods+'&type='+types; }, 1000);
				}else if(types=="buyer_payment_monitoring" || types=="payment"){
					types = "buyer_payment_monitoring";
					window.setTimeout(function() { window.location.href = 'index.php?pg='+mods+'&type='+types; }, 1000);
				}else if(types=="buyer_status_monitoring"){
					types = "buyer_status_monitoring";
					window.setTimeout(function() { window.location.href = 'index.php?pg='+mods+'&type='+types; }, 1000);
				}else if(types=="buyer_status_folder_pagibig"){
					types = "buyer_status_folder_pagibig";
					window.setTimeout(function() { window.location.href = 'index.php?pg='+mods+'&type='+types; }, 1000);
				}else if(types=="buyer_status_folder_bank"){
					types = "buyer_status_folder_bank";
					window.setTimeout(function() { window.location.href = 'index.php?pg='+mods+'&type='+types; }, 1000);
				}else{
					window.setTimeout(function() { window.location.href = 'index.php?pg='+mods+'&type='+types; }, 1000);
				}
		  }
		},
		main: {
		  label: "Cancel",
		  className: "btn-default"
		}
	  }
	});	
});

//DELETE CURRENT TABLE ROW
function removeCurrentRow(currentRow){
	$(currentRow).closest('tr').remove();
}

//SHOW VALUE IN A HIDDEN BOX
function showValueInHidden(currentValue,hiddenBox){
	$(hiddenBox).val(currentValue);
}

//DELETE a Transaction
function deleteTransaction(id){ 
				var mods 	= $('#main_page').val();
				var types 	= $('#main_type').val(); 
				var action 	= $('#main_action').val(); 
				if(types=="promo"){
					var save_message 	= "Do you want to delete this promo?";
				}else if(types=="pricelist"){ 
					var save_message 	= "Do you want to delete this pricelist?";
				}else if(types=="reservation"){ 
					var save_message 	= "Do you want to delete this reservation?";
				}else if(types=="broker"){ 
					var save_message 	= "Do you want to delete this broker?";
				}else if(types=="brokeragent"){ 
					var save_message 	= "Do you want to delete this account details of broker & agent?";
				}else if(types=="tin"){ 
					var save_message 	= "Do you want to delete this Tin of Supplier?";
				}else if(types=="agent"){ 
					var save_message 	= "Do you want to delete this agent?";
				}else if(types=="employee_type"){ 
					var save_message 	= "Do you want to delete this employee type?";
				}else if(types=="buyer_profile"){ 
					var save_message 	= "Do you want to delete this buyer profile?";
				}else if(types=="position"){ 
					var save_message 	= "Do you want to delete this position?";
				}else if(types=="users"){ 
					var save_message 	= "Do you want to delete this user?";
				}else if(types=="units"){ 
					var save_message 	= "Do you want to delete this unit?";
				}else if(types=="contractor"){ 
					var save_message 	= "Do you want to delete this contractor?";
				}else{
					var save_message 	= "";
				}
				bootbox.dialog({
				  message: save_message, 
				  buttons: {
					success: {
						  label: "Yes",
						  className: "btn-success",
						  callback: function() {
								bootbox.alert("Deleting...");
								if(types=="promo" && mods=="promo"){
									delete_promo(id);
								}

								if(types=="pricelist" && mods=="pricelist"){
									delete_pricelist(id);
								}

								if(types=="reservation" && mods=="reservation"){ 
									delete_reservation(id);
								}
								
								if(types=="broker" && mods=="settings"){ 
									delete_broker(id);
								}
								
								if(types=="brokeragent" && mods=="settings"){ 
									delete_brokeragent(id);
								}

								if(types=="tin" && mods=="settings"){ 
									delete_tin(id);
								}
								
								if(types=="agent" && mods=="settings"){ 
									delete_agent(id);
								}
								
								if(types=="employee_type" && mods=="settings"){ 
									delete_employee_type(id);
								}
								
								if(types=="buyer_profile" && mods=="settings"){ 
									delete_buyer_profile(id);
								}
								
								if(types=="position" && mods=="settings"){ 
									delete_position(id);
								}
								
								if(types=="users" && mods=="users"){ 
									delete_users(id);
								}


								if(types=="contractor"){ 
									delete_contractor(id);
								}

								if(types=="units"){ 
									delete_units(id);
								}
						  }
					},
					danger: {
					  label: "No",
					  className: "btn-danger"
					}
				  }
				});	 
}

function loadReserveDetails(rid){ 
						var mods 			=	$('#main_page').val();
						var types 			=	$('#main_type').val(); 
						var action 			=	$('#main_action').val();
						var mainid			=	rid;
						var dataString		=	"mainid="+encodeURIComponent(mainid);

								$.post('./ajax/load_reservation.php', dataString, function(msg){
								
								 var obj	= $.parseJSON(msg);
 

										var project					=	obj.data[0].project;
										var model					=	obj.data[0].model;
										var reservationDate			=	obj.data[0].reservation_date;
										var startOfEquityDate		=	obj.data[0].start_of_equity;
										var approvedEquityDate		=	obj.data[0].approved_equity_date;
										var phase					=	obj.data[0].phase;
										var block					=	obj.data[0].block;
										var lot						=	obj.data[0].lot;
										var last_name				=	obj.data[0].last_name;
										var first_name				=	obj.data[0].first_name;
										var middle_name				=	obj.data[0].middle_name;
										var net_equity				=	obj.data[0].net_equity;
										var pdc_submitted			=	obj.data[0].pdc_submitted;
										var pdc_submitted_status	=	obj.data[0].pdc_submitted_status;
										var pdc_submitted_status_pagibig	=	obj.data[0].pdc_submitted_status_pagibig;
										
										var lacking_pdc			=	obj.data[0].lacking_pdc;
										var monthly_equity		=	obj.data[0].monthly_equity;
										var terms_of_payment	=	obj.data[0].terms_of_payment;
										var pop_pdc_status		=	obj.data[0].pop_pdc_status;
										var pop_pdc_status_date	=	obj.data[0].pop_pdc_status_date;
										var pto_status			=	obj.data[0].pto_status; //text
										var financing			=	obj.data[0].financing;
										var permit_to_occupy	=	obj.data[0].permit_to_occupy; //date
										 

										var construction_status	=	obj.data[0].construction_status;  

										var pdc_downpayment		=	obj.data[0].pdc_downpayment;  
										var pdc_discount		=	obj.data[0].pdc_discount;   
 
										var fullname 			= 	last_name+", "+first_name+" "+middle_name; 
 
										
										
										$('#cheque_financing').val(financing);
										$('#cheque_permit_to_occupy').val(pto_status); //text with PTO or Temporary PTO

										if(pto_status=='Temporary PTO'){
										  $('#cheque_permit_to_occupy').css("color", "red");
										}


										$('#cheque_project').val(project);
										$('#cheque_block').val(block);
										$('#cheque_lot').val(lot);
										$('#cheque_borrower').val(fullname);
										
										$('#cheque_construction_status_upon_reservation').val(construction_status); //16APR23

										$('#cheque_pdc_submitted_status').val(pdc_submitted_status);
										$('#cheque_pdc_submitted_status_pagibig').val(pdc_submitted_status_pagibig);

										$('#cheque_lacking_pdc').val(lacking_pdc);
										$('#cheque_terms').val(terms_of_payment);
										if(approvedEquityDate!=''){
										$('#cheque_start_equity').val(approvedEquityDate);
										}else{
										$('#cheque_start_equity').val(startOfEquityDate);
										}
										
										$('#cheque_equity').val(Comma(parseFloat(net_equity).toFixed(2)));
										$('#cheque_monthly_equity').val(Comma(parseFloat(monthly_equity).toFixed(2)));
										$('.pdc_date_caption').text(pop_pdc_status_date);
										$('#cheque_status').val(pop_pdc_status); 

										$('#cheque_downpayment').val(Comma(parseFloat(pdc_downpayment).toFixed(2)));
										$('#cheque_discount').val(Comma(parseFloat(pdc_discount).toFixed(2))); 
										
 										let total_collectible = (parseFloat(pdc_downpayment) + parseFloat(net_equity)) - parseFloat(pdc_discount);
 										$('#cheque_total_collectible').val(Comma(parseFloat(total_collectible).toFixed(2))); 
 

										 
								});
	 
}



$('#reservation_fee_save').click(function(e){
	e.preventDefault(); 
	var dataString = $('#reservation_fee_form').serialize();
	 
		$.post('./ajax/save_default_reservation_fee.php', dataString, function(msg){ 
										var obj	= $.parseJSON(msg);
										 
										if(obj.output==true){
											bootbox.alert("Successfully Saved ..."); 
										}else{
											bootbox.alert("Failed in saving.");
										}
								});
});

//DEFAULT RESERVE FEE
$('#call_reservation_fee').click(function(e){
	e.preventDefault();
	$('#reservation_fee_amount').val('');
	loadDefaultModel('reservation_fee'); 
	callModal('.reservation_fee_modal'); 
});

function loadDefaultReserveFee(){  
	var dataString = "";
		$.post('./ajax/load_default_reserve_fee.php', dataString, function(msg){ 
										var obj	= $.parseJSON(msg); 
										 $('#rf_amber').val(Comma(obj.data.amber));
										 $('#rf_selena_mae').val(Comma(obj.data.selena_mae));
										 $('#rf_annalisa').val(Comma(obj.data.annalisa));
										  
								});
}


//DEFAULT MOVEIN FEE
$('#call_move_in').click(function(e){
	e.preventDefault();
	//loadDefaultMoveInFee();
	$('#move_in_amount').val('');
	loadDefaultModel('move_in'); 
	callModal('.move_in_modal'); 
});

function loadDefaultMoveInFee(){  
	var dataString = "";
		$.post('./ajax/load_default_movein_fee.php', dataString, function(msg){ 
										var obj	= $.parseJSON(msg); 
										 $('#mi_amber').val(Comma(obj.data.amber));
										 $('#mi_selena_mae').val(Comma(obj.data.selena_mae));
										 $('#mi_annalisa').val(Comma(obj.data.annalisa));
								});
}
$('#move_in_save').click(function(e){
	e.preventDefault(); 
	var dataString = $('#move_in_form').serialize();
		$.post('./ajax/save_default_movein_fee.php', dataString, function(msg){ 
										var obj	= $.parseJSON(msg);
										if(obj.output==true){
											bootbox.alert("Successfully Saved ..."); 
										}else{
											bootbox.alert("Failed in saving.");
										}
								});
});

//DEFAULT TRANSFER FEE
$('#call_transfer_fee').click(function(e){
	e.preventDefault();
	$('#transfer_fee_amount').val('');
	//loadDefaultTransferFee();
	loadDefaultModel('transfer_fee');
	callModal('.transfer_fee_modal'); 
});


//DEFAULT MODEL
$('#call_model').click(function(e){
	e.preventDefault();
	//$('#transfer_fee_amount').val('');
	//loadDefaultModel('transfer_fee'); 
	callModal('.model_modal'); 
});

function callModelDefaultValues(type,returnvalue){ 
	  
	if(type=='move_in'){
		var mv = $('#move_in_model').val();	
		var url = './ajax/load_default_movein_fee.php';
	}else if(type=='reservation_fee'){
		var mv = $('#reservation_fee_model').val();	
		var url = './ajax/load_default_reserve_fee.php';
	}else if(type=='transfer_fee'){
		var mv = $('#transfer_fee_model').val();	
		var url = './ajax/load_default_transfer_fee.php';
	}
	$('#'+returnvalue).val('');
	var dataString = "model="+mv;
	if(mv!='' && mv!=null){	
		$.post(url, dataString, function(msg){ 
			var obj	= $.parseJSON(msg);   
			if(obj.data.amount==null){
				$('#'+returnvalue).val('');
			}else{
				$('#'+returnvalue).val(Comma(obj.data.amount));
			}
		});
	}else{
			$('#'+returnvalue).val('');
	}
}

function loadDefaultModel(type){  
	var dataString = "";
		$.post('./ajax/load_model.php', dataString, function(msg){ 
										var obj	= $.parseJSON(msg); 
										var ctr	=	obj.data.length;
										var modelHTML = "";
										
										modelHTML += '<select onchange="callModelDefaultValues(\''+type+'\',\''+type+'_amount\')" name="'+type+'_model" id="'+type+'_model" class="select2 form-control">';
											modelHTML += '<option value="">- Select Model - </option>';
										for(var a=0; a<ctr; a++){
											modelHTML += '<option value="'+obj.data[a].model+'">'+obj.data[a].model+'</option>';
										}
										modelHTML += '</select>';
										$('.show_'+type+'_model').html(modelHTML);
								});
								
}
 
$('#move_in_save').click(function(e){
	e.preventDefault(); 
	var model = $('#move_in_model').val();
	if(model!='' && model!=null){
			
			var dataString = $('#move_in_form').serialize();
			$.post('./ajax/save_default_movein_fee.php', dataString, function(msg){ 
										var obj	= $.parseJSON(msg);
										if(obj.output==true){
											bootbox.alert("Successfully Saved ..."); 
											$('#move_in_amount').val('');
										}else{
											bootbox.alert("Failed in saving.");
										}
								});
	}else{
		bootbox.alert("Select a Model to update");
	}
});

$('#model_save').click(function(e){
	e.preventDefault(); 
	 
			
			var dataString = $('#model_form').serialize();
			$.post('./ajax/save_model.php', dataString, function(msg){ 
										var obj	= $.parseJSON(msg);
										if(obj.output==true){
											bootbox.alert("Successfully Saved ..."); 
											$('#model_name').val('');
										}else{
											bootbox.alert("Failed in saving.");
										}
								});
	 
});

function loadDefaultTransferFee(){  
	var dataString = "";
		$.post('./ajax/load_default_transfer_fee.php', dataString, function(msg){ 
										var obj	= $.parseJSON(msg); 
										 $('#tf_amber').val(Comma(obj.data.amber));
										 $('#tf_selena_mae').val(Comma(obj.data.selena_mae));
										 $('#tf_annalisa').val(Comma(obj.data.annalisa));
								});
}

$('#transfer_fee_save').click(function(e){
	e.preventDefault(); 
	var dataString = $('#transfer_fee_form').serialize();
		$.post('./ajax/save_default_transfer_fee.php', dataString, function(msg){ 
										var obj	= $.parseJSON(msg);
										if(obj.output==true){
											bootbox.alert("Successfully Saved ..."); 
										}else{
											bootbox.alert("Failed in saving.");
										}
								});
});
 
//SAVE USERS
function save_users(){
			var mods 	= $('#main_page').val();
			var types 	= $('#main_type').val(); 
			var action 	= $('#main_action').val();
			var id	 	= $('#main_id').val();
			var uform  =  $('#user_form').serialize();
			var dataString = uform+"&action="+action+"&id="+id;
		$.post('./ajax/save_users.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='+types; }, 1000);
										}else{
											bootbox.alert("Failed in saving.");
										}
								});
}

var mods 	= $('#main_page').val();
var types 	= $('#main_type').val(); 
var action 	= $('#main_action').val();
if(mods=="users" && action=="edit"){
	loadUsers(); 
}
function loadUsers(){
	var mods 	= $('#main_page').val();
	var types 	= $('#main_type').val(); 
	var action 	= $('#main_action').val();
	var id	 	= $('#main_id').val(); 
 	var dataString = "id="+id;
		$.post('./ajax/load_user_details.php', dataString, function(msg){ 
										var obj	= $.parseJSON(msg); 
										 $('#ufirstname').val(obj.data.first_name); 
										 $('#ulastname').val(obj.data.last_name);
										 $('#uusername').val(obj.data.username);
										 $('#uusertype').val(obj.data.user_type);
								});
}


//DELETE Users
function delete_users(id){
		var transaction		=	"user";
		var mods 			=	$('#main_page').val();
		var types 			=	$('#main_type').val(); 
		var dataString		=	"mainid="+encodeURIComponent(id)+"&transaction="+encodeURIComponent(transaction);
						$.post('./ajax/delete_transaction.php', dataString, function(msg){
								var obj	= $.parseJSON(msg);
								if(obj.output==true){
									bootbox.alert("Successfully Deleted ..."); 
									window.setTimeout(function() { window.location.href = 'index.php?pg='+mods+'&type='+types; }, 1000);
								}	
						});
}


$('#print_report').click(function(e){
	e.preventDefault();
	var types 			=	$('#main_type').val(); 
	var rid 			=	$('#main_rid').val(); 
	var rid 			=	$('#main_rid').val(); 
	var cmid 			=	$('#cmid').val(); 
	
	var additional 		=	"";
	 
		var dtype = $('#dtype').val();
		var filter_date = $('.check_tobedelivered_date').val(); 
		var month_from = $('.monthly_reservation_from').val();
		var month_to = $('.monthly_reservation_to').val(); 
		var filter = $('.dataTables_filter input').val(); 
		if(types=="postdated_checks_received"){
		additional = "?id="+encodeURIComponent(rid)+"&filter="+encodeURIComponent(filter);
		}else if(types=="postdated_checks_received_past_due"){
		additional = "?id="+encodeURIComponent(rid)+"&cmid="+encodeURIComponent(cmid)+"&filter="+encodeURIComponent(filter);
		}else if(types=="postdated_pagibig_loan_amortization_details"){
		additional = "?id="+encodeURIComponent(rid)+"&filter="+encodeURIComponent(filter);
  		}else if(types=="postdated_checks_status"){
		additional = "?id="+encodeURIComponent(rid)+"&filter="+encodeURIComponent(filter);
		}else if(types=="report_buyer_employment_type"){
  
		additional = "?month_from="+encodeURIComponent(month_from)+"&month_to="+encodeURIComponent(month_to)+"&isfilterdate="+encodeURIComponent(filter_date);

		}else if(types=="cheque_for_clearing"){
			var check_tobedelivered_date =  $('#check_tobedelivered_date').is(":checked"); 
 			var notselectedchecks = $('#notselected').val();
 			  
 			var search = $('#cheque_for_clearing_table_filter > label > input[type=search]').val();
			additional = "?month_from="+encodeURIComponent(month_from)+"&month_to="+encodeURIComponent(month_to)+"&check_tobedelivered_date="+encodeURIComponent(check_tobedelivered_date)+"&notselectedchecks="+encodeURIComponent(notselectedchecks)+"&filter="+encodeURIComponent(search)+"&isfilterdate="+encodeURIComponent(filter_date);

		}else if(types=="report_reservation"){	 
			 
			var check_tobedelivered		= $('.check_tobedelivered').val(); 
			var check_tobedelivered_no	= $('.check_tobedelivered_no').val();
			var check_tobedelivered_date	= $('.check_tobedelivered_date').val(); 
			 
		additional = "?month_from="+encodeURIComponent(month_from)+"&month_to="+encodeURIComponent(month_to)+"&filter="+encodeURIComponent(filter)+"&isfilterdate="+encodeURIComponent(filter_date)+"&check_tobedelivered="+encodeURIComponent(check_tobedelivered)+"&check_tobedelivered_no="+encodeURIComponent(check_tobedelivered_no)+"&check_tobedelivered_date="+encodeURIComponent(check_tobedelivered_date);
		}else{
		additional = "?month_from="+encodeURIComponent(month_from)+"&month_to="+encodeURIComponent(month_to)+"&filter="+encodeURIComponent(filter)+"&isfilterdate="+encodeURIComponent(filter_date);
		}

		if(types=='monthly_sales_reservation' && (dtype!='' || dtype!='undefined' || dtype!=null)){
			var reportType = "report_"+dtype;
		}else{
			var reportType = types;
		}

				
		window.setTimeout(function() { window.location.href = 'report/'+reportType+'_print.php'+additional+''; }, 1000);  
});

$('#print_report_contractor').click(function(e){
	e.preventDefault();
	var types 			=	$('#main_type').val(); 
	var rid 			=	$('#main_id').val(); 
	var additional 		=	"";
	
	additional = "?id="+encodeURIComponent(rid);
	var reportType = types;
	
	window.setTimeout(function() { window.location.href = 'report/report_releases_to_contractor_individual_print.php'+additional+''; }, 1000);  
});

//PDC change status, updating of pdc submitted, lacking of pdc and status
//update pdc submitted
$('#cheque_pdc_submitted').change(function(e){
	e.preventDefault();
	var cur_val				=	$('#cheque_pdc_submitted').val();
	var pdc_type			=	'pdc_submitted';
	var pdc_type_caption	=	'PDC Submitted';
	var rid					=	$('#main_rid').val();
	var dataString			=	"mainid="+encodeURIComponent(rid)+"&transtype="+pdc_type+"&uvalue="+cur_val;
	$.post('./ajax/update_pdc_lacking_submitted_status.php', dataString, function(msg){
			var obj	= $.parseJSON(msg);
			if(obj.output==true){
				bootbox.alert("Successfully Updated " + pdc_type_caption);
			}
	});
});

//update pdc submitted status
$('#cheque_pdc_submitted_status').change(function(e){
	e.preventDefault();
	var cur_val				=	$('#cheque_pdc_submitted_status').val();

	var types 			=	$('#main_type').val();

	var pdc_type			=	'pdc_submitted_status';	
	 
	var pdc_type_caption	=	'PDC Submitted';
	var rid					=	$('#main_rid').val();
	var dataString			=	"mainid="+encodeURIComponent(rid)+"&transtype="+pdc_type+"&uvalue="+cur_val;
	$.post('./ajax/update_pdc_lacking_submitted_status.php', dataString, function(msg){
			var obj	= $.parseJSON(msg);
			if(obj.output==true && cur_val!=""){
				
				bootbox.alert("Successfully Updated " + pdc_type_caption);
			}
	});
});


//update pdc submitted status pagibig
$('#cheque_pdc_submitted_status_pagibig').change(function(e){
	e.preventDefault();
	var cur_val				=	$('#cheque_pdc_submitted_status_pagibig').val();

	var types 				=	$('#main_type').val();
 	var pdc_type			=	'pdc_submitted_status_pagibig';	
	  
	var pdc_type_caption	=	'PDC Submitted';
	var rid					=	$('#main_rid').val();
	var dataString			=	"mainid="+encodeURIComponent(rid)+"&transtype="+pdc_type+"&uvalue="+cur_val;
	$.post('./ajax/update_pdc_lacking_submitted_status.php', dataString, function(msg){
			var obj	= $.parseJSON(msg);
			if(obj.output==true && cur_val!=""){
				bootbox.alert("Successfully Updated " + pdc_type_caption);
			}
	});
});

//update lacking pdc
$('#cheque_lacking_pdc').change(function(e){
	e.preventDefault();
	var cur_val				=	$('#cheque_lacking_pdc').val();
	var pdc_type			=	'lacking_pdc';
	var pdc_type_caption	=	'Lacking PDC';
	var rid					=	$('#main_rid').val();
	var dataString			=	"mainid="+encodeURIComponent(rid)+"&transtype="+pdc_type+"&uvalue="+cur_val;
	$.post('./ajax/update_pdc_lacking_submitted_status.php', dataString, function(msg){
			var obj	= $.parseJSON(msg);
			if(obj.output==true){
				bootbox.alert("Successfully Updated " + pdc_type_caption);
			}
	});
});
 
$('#cheque_status').change(function(e){
	e.preventDefault();
	var cur_val				=	$('#cheque_status').val();
	var pdc_type			=	'pdc_status';
	var pdc_type_caption	=	'Status';
	var rid					=	$('#main_rid').val();
	var dataString			=	"mainid="+encodeURIComponent(rid)+"&transtype="+pdc_type+"&uvalue="+cur_val;
	
	if(cur_val=="final_notice_to_pay" || cur_val=="notice_of_cancellation" || cur_val=="cancelled" || cur_val=="voluntary_cancellation"){ 
		callModal('#pop_pdc_status_modal');
		$('#pop_pdc_status_date').val("");
		$('.pdc_date_caption').text("");
		if(cur_val=="final_notice_to_pay"){
			$('#pdc_pop_title').text("Final Notice to Pay");
		}else if(cur_val=="notice_of_cancellation"){
			$('#pdc_pop_title').text("Notice of Cancellation");
		}
	}else if(cur_val=='fully_paid'){
		 
		 
		 //CHECK IF TOTAL COLLECTIBLE AND TOTAL RECEIVED SAME OR NOT
		 let total_collect = $('#cheque_total_collectible').val().replace(/,/g, "");
		 let total_receive = $('#cheque_total').val().replace(/,/g, ""); 
		 if(total_collect!=total_receive){ 
		 	//INSERT TO DISCREPANCIES 
				var rid			 =	$('#main_rid').val();
				var dataString2	 =	"mainid="+encodeURIComponent(rid)+"&total_collect="+total_collect+"&total_receive="+total_receive;
				$.post('./ajax/pdc_discrepancies.php', dataString2, function(msg2){
					var obj2 = $.parseJSON(msg2);
					if(obj2.output==true){
						$.post('./ajax/update_pdc_lacking_submitted_status.php', dataString, function(msg){
							var obj	= $.parseJSON(msg);
							if(obj.output==true){
								bootbox.alert("Successfully Updated " + pdc_type_caption);
							}
						});
					}
				}); 
		 }else{
		 	//update status
		 	$.post('./ajax/update_pdc_lacking_submitted_status.php', dataString, function(msg){
				var obj	= $.parseJSON(msg);
				if(obj.output==true){
					bootbox.alert("Successfully Updated " + pdc_type_caption);
				}
			});
		 }

	}else{

		if(cur_val!='fully_paid' && cur_val!=''){
			$('.pdc_date_caption').text("");	
		}
		
		
		$.post('./ajax/update_pdc_lacking_submitted_status.php', dataString, function(msg){
			var obj	= $.parseJSON(msg);
			if(obj.output==true){
				bootbox.alert("Successfully Updated " + pdc_type_caption);
			}
		});
	}	 
}); 

$('#pdc_status_date_save').click(function(e){
	e.preventDefault();
	var cur_val				=	$('#cheque_status').val();
	var cur_val_date		=	$('#pop_pdc_status_date').val(); 
	var pdc_type			=	'pdc_status_date';
	var pdc_type_caption	=	'Status';
	var rid					=	$('#main_rid').val();
	var dataString			=	"mainid="+encodeURIComponent(rid)+"&transtype="+pdc_type+"&uvalue="+cur_val+"&uvaluedate="+cur_val_date; 
		$.post('./ajax/update_pdc_lacking_submitted_status.php', dataString, function(msg){
			var obj	= $.parseJSON(msg);
			if(obj.output==true){
				bootbox.alert("Successfully Updated " + pdc_type_caption);
				$('#pop_pdc_status_modal').modal('hide');
				$('.pdc_date_caption').text(cur_val_date);
			}
		});		 
});




		$( ".datepicker2" ).datepicker();





if(main_type=='report_buyer_employment_type'){
	var mods 	= $('#main_page').val();
	var types 	= $('#main_type').val(); 
	var action 	= $('#main_action').val();
	getAnalysisReport();

}

function getAnalysisReport(){

	var range_start = $('.monthly_reservation_from').val();
	var range_end 	= $('.monthly_reservation_to').val();
	var check_tobedelivered_date = $('#check_tobedelivered_date').val();
	 
	var dataStringEmployee = "range_start="+range_start+"&range_end="+range_end+"&check_tobedelivered_date="+check_tobedelivered_date;
		$.post('./ajax/load_analysis_report_overseas.php', dataStringEmployee, function(msg){ 
			var obj		= $.parseJSON(msg);  
			var ecount  	=  obj.data.overseas_employeecount;	 
			var etotal  	=  obj.data.overseas_employeetotal;
			$('#overseas_count').html(ecount);	
			$('#overseas_total').html(etotal);	
		});

	var dataStringPrivate = "range_start="+range_start+"&range_end="+range_end+"&check_tobedelivered_date="+check_tobedelivered_date;
		$.post('./ajax/load_analysis_report_private.php', dataStringPrivate, function(msg){ 
			var obj		= $.parseJSON(msg);  
			var ecount  	=  obj.data.private_employeecount;	 
			var etotal  	=  obj.data.private_employeetotal;
			 
			$('#private_count').html(ecount);	
			$('#private_total').html(etotal);	
		});	

	var dataStringSelf = "range_start="+range_start+"&range_end="+range_end+"&check_tobedelivered_date="+check_tobedelivered_date;
		$.post('./ajax/load_analysis_report_self.php', dataStringSelf, function(msg){ 
			var obj		= $.parseJSON(msg);  
			var ecount  	=  obj.data.self_employeecount;	 
			var etotal  	=  obj.data.self_employeetotal;
			$('#selfemployed_count').html(ecount);	
			$('#selfemployed_total').html(etotal);	
		});	

	var dataStringOnline = "range_start="+range_start+"&range_end="+range_end+"&check_tobedelivered_date="+check_tobedelivered_date;
		$.post('./ajax/load_analysis_report_online.php', dataStringOnline, function(msg){ 
			var obj		= $.parseJSON(msg);  
			var ecount  	=  obj.data.online_employeecount;	 
			var etotal  	=  obj.data.online_employeetotal;
			$('#online_count').html(ecount);	
			$('#online_total').html(etotal);	
		});	

	var dataStringImmigrant = "range_start="+range_start+"&range_end="+range_end+"&check_tobedelivered_date="+check_tobedelivered_date;
		$.post('./ajax/load_analysis_report_immigrant.php', dataStringImmigrant, function(msg){ 
			var obj		= $.parseJSON(msg);  
			var ecount  	=  obj.data.immigrant_employeecount;	 
			var etotal  	=  obj.data.immigrant_employeetotal;
			$('#immigrant_count').html(ecount);	
			$('#immigrant_total').html(etotal);	
		});			
 
 	/*******************FINANCING***********************************************/
	var dataStringCash = "range_start="+range_start+"&range_end="+range_end+"&check_tobedelivered_date="+check_tobedelivered_date;
		$.post('./ajax/load_analysis_report_cash.php', dataStringCash, function(msg){ 
			var obj		= $.parseJSON(msg);  
			var ecount  	=  obj.data.cash_employeecount;	 
			var etotal  	=  obj.data.cash_employeetotal;
			$('#cash_count').html(ecount);	
			$('#cash_total').html(etotal);	
		});	

 	var dataStringBank = "range_start="+range_start+"&range_end="+range_end+"&check_tobedelivered_date="+check_tobedelivered_date;
		$.post('./ajax/load_analysis_report_bank.php', dataStringBank, function(msg){ 
			var obj		= $.parseJSON(msg);  
			var ecount  	=  obj.data.bank_employeecount;	 
			var etotal  	=  obj.data.bank_employeetotal;
			$('#bank_count').html(ecount);	
			$('#bank_total').html(etotal);	
		});	

 	var dataStringPagibig = "range_start="+range_start+"&range_end="+range_end+"&check_tobedelivered_date="+check_tobedelivered_date;
		$.post('./ajax/load_analysis_report_pagibig.php', dataStringPagibig, function(msg){ 
			var obj		= $.parseJSON(msg);  
			var ecount  	=  obj.data.pagibig_employeecount;	 
			var etotal  	=  obj.data.pagibig_employeetotal;
			$('#pagibig_count').html(ecount);	
			$('#pagibig_total').html(etotal);	
		});	 

}


function updatePDCDiscount(){
		var cur_val				=	$('#cheque_discount').val().replace(/,/g, ""); 
		var pdc_type			=	'pdc_discount';
		 
		var rid					=	$('#main_rid').val();
		var dataString			=	"mainid="+encodeURIComponent(rid)+"&transtype="+pdc_type+"&uvalue="+cur_val; 
		$.post('./ajax/update_pdc_lacking_submitted_status.php', dataString, function(msg){
			var obj	= $.parseJSON(msg);
			if(obj.output==true){
				
				//UPDATE TOTAL COLLECTIBLE VALUE 
				let cheque_downpayment 	=	$('#cheque_downpayment').val().replace(/,/g, ""); 
				let cheque_equity 		=	$('#cheque_equity').val().replace(/,/g, ""); 
				let cheque_discount 	=	$('#cheque_discount').val().replace(/,/g, ""); 
				
				if(isNaN(cheque_discount)) {
					cheque_discount = 0.00;
				}

				if(isNaN(cheque_downpayment)) {
					cheque_downpayment = 0.00;
				}

				let total_collectible = (parseFloat(cheque_downpayment) + parseFloat(cheque_equity)) - parseFloat(cheque_discount);
				$('#cheque_total_collectible').val(Comma(total_collectible.toFixed(2)));  

			}
		});		 
}


function updatePDCDownpayment(){
		var cur_val				=	$('#cheque_downpayment').val().replace(/,/g, ""); 
		var pdc_type			=	'pdc_downpayment';
		 
		var rid					=	$('#main_rid').val();
		var dataString			=	"mainid="+encodeURIComponent(rid)+"&transtype="+pdc_type+"&uvalue="+cur_val; 
		$.post('./ajax/update_pdc_lacking_submitted_status.php', dataString, function(msg){
			var obj	= $.parseJSON(msg);
			if(obj.output==true){
				 
				 //UPDATE TOTAL COLLECTIBLE VALUE
				let cheque_downpayment 	=	$('#cheque_downpayment').val().replace(/,/g, ""); 
				let cheque_equity 		=	$('#cheque_equity').val().replace(/,/g, ""); 
				let cheque_discount 	=	$('#cheque_discount').val().replace(/,/g, ""); 
				
				let total_collectible = (parseFloat(cheque_downpayment) + parseFloat(cheque_equity)) - parseFloat(cheque_discount);
				$('#cheque_total_collectible').val(Comma(total_collectible.toFixed(2)));  

			}
		});		 
}

