function addRow() {
	$("#addRowBtn").button("loading");

	var tableLength = $("#productTable tbody tr").length;

	var tableRow;
	var arrayNumber;
	var count;

	if(tableLength > 0) {		
		tableRow = $("#productTable tbody tr:last").attr('id');
		arrayNumber = $("#productTable tbody tr:last").attr('class');
		count = tableRow.substring(3);	
		count = Number(count) + 1;
		arrayNumber = Number(arrayNumber) + 1;					
	} else {
		// no table row
		count = 1;
		arrayNumber = 0;
	}

	$.ajax({
		url: 'php_action/fetchProductData151.php',
		type: 'post',
		dataType: 'json',
		success:function(response) {
			$("#addRowBtn").button("reset");			

			var tr = '<tr id="row'+count+'" class="'+arrayNumber+'">'+	

               '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					''+count+''+
					'</div>'+
				'</td>'+	
				
				'<td style="padding-left:20px;">'+
					'<div class="form-group">'+

					'<select class="form-control" name="edulevel_id[]" id="edulevel_id'+count+'">'+
						'<option value="">~~SELECT~~</option>';
						 console.log(response);
						$.each(response, function(index, value) {
							tr += '<option value="'+value[0]+'">'+value[1]+'</option>';							
						});
													
					tr += '</select>'+
					'</div>'+
				'</td>'+

                '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="inst_name[]" id="inst_name'+count+'" autocomplete="off" placeholder="Institution Name" class="form-control" />'+
					'</div>'+
				'</td>'+				

               						
			 '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="edu_period[]" id="edu_period'+count+'" autocomplete="off" placeholder="Education Period" class="form-control" />'+
					'</div>'+
				'</td>'+	
				
			
				
				
				'<td>'+
					'<button class="btn btn-default removeProductRowBtn" type="button" onclick="removeProductRow('+count+')"><i class="glyphicon glyphicon-trash"></i></button>'+
				'</td>'+
			'</tr>';
			if(tableLength > 0) {							
				$("#productTable tbody tr:last").after(tr);
			} else {				
				$("#productTable tbody").append(tr);
			}		

		} // /success
	});	// get the product data

} // /add row

function removeProductRow(row = null) {
	if(row) {
		$("#row"+row).remove();


		subAmount();
	} else {
		alert('error! Refresh the page again');
	}
}




function addRow1() {
	$("#addRowBtn1").button("loading");

	var tableLength1 = $("#productTable1 tbody tr").length;

	var tableRow1;
	var arrayNumber1;
	var count1;

	if(tableLength1 > 0) {		
		tableRow1 = $("#productTable1 tbody tr:last").attr('id');
		arrayNumber1 = $("#productTable1 tbody tr:last").attr('class');
		count1 = tableRow1.substring(3);	
		count1 = Number(count1) + 1;
		arrayNumber1 = Number(arrayNumber1) + 1;					
	} else {
		// no table row
		count1 = 1;
		arrayNumber1 = 0;
	}

	$.ajax({
		url: 'php_action/fetchProductData152.php',
		type: 'post',
		dataType: 'json',
		success:function(response1) {
			$("#addRowBtn1").button("reset");			

			var tr = '<tr id="row'+count1+'" class="'+arrayNumber1+'">'+	

               '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					''+count1+''+
					'</div>'+
				'</td>'+	
				
				'<td style="padding-left:20px;">'+
					'<div class="form-group">'+

					'<select class="form-control" name="prel_id[]" id="prel_id'+count1+'">'+
						'<option value="">~~SELECT~~</option>';
						 console1.log(response1);
						$.each(response1, function(index1, value1) {
							tr += '<option value="'+value1[0]+'">'+value1[1]+'</option>';							
						});
													
					tr += '</select>'+
					'</div>'+
				'</td>'+

                '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="pf_name[]" id="pf_name'+count1+'" autocomplete="off" placeholder="First Name" class="form-control" />'+
					'</div>'+
				'</td>'+				

               						
			 '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="pm_name[]" id="pm_name'+count1+'" autocomplete="off" placeholder="Midle Name" class="form-control" />'+
					'</div>'+
				'</td>'+	
				
				'<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="pl_name[]" id="pl_name'+count1+'" autocomplete="off" placeholder="Last Name" class="form-control" />'+
					'</div>'+
				'</td>'+

               '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="p_phone[]" id="p_phone'+count1+'" autocomplete="off" placeholder="Phone Number" class="form-control" />'+
					'</div>'+
				'</td>'+	

                '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="p_email[]" id="p_email'+count1+'" autocomplete="off" placeholder="Email Address" class="form-control" />'+
					'</div>'+
				'</td>'+					
				
			
				
				
				'<td>'+
					'<button class="btn btn-default removeProductRowBtn1" type="button" onclick="removeProductRow1('+count1+')"><i class="glyphicon glyphicon-trash"></i></button>'+
				'</td>'+
			'</tr>';
			if(tableLength1 > 0) {							
				$("#productTable1 tbody tr:last").after(tr);
			} else {				
				$("#productTable1 tbody").append(tr);
			}		

		} // /success
	});	// get the product data

} // /add row

function removeProductRow1(row = null) {
	if(row) {
		$("#row"+row).remove();


		subAmount();
	} else {
		alert('error! Refresh the page again');
	}
}



function addRow2() {
	$("#addRowBtn2").button("loading");

	var tableLength2 = $("#productTable2 tbody tr").length;

	var tableRow2;
	var arrayNumber2;
	var count2;

	if(tableLength2 > 0) {		
		tableRow2 = $("#productTable2 tbody tr:last").attr('id');
		arrayNumber2 = $("#productTable2 tbody tr:last").attr('class');
		count2 = tableRow2.substring(3);	
		count2 = Number(count2) + 1;
		arrayNumber2 = Number(arrayNumber2) + 1;					
	} else {
		// no table row
		count2 = 1;
		arrayNumber2 = 0;
	}

	$.ajax({
		url: 'php_action/fetchProductData152.php',
		type: 'post',
		dataType: 'json',
		success:function(response2) {
			$("#addRowBtn2").button("reset");			

			var tr = '<tr id="row'+count2+'" class="'+arrayNumber2+'">'+	

               '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					''+count2+''+
					'</div>'+
				'</td>'+	
				
				'<td style="padding-left:20px;">'+
					'<div class="form-group">'+

					'<select class="form-control" name="prel_id[]" id="prel_id'+count2+'">'+
						'<option value="">~~SELECT~~</option>';
						 console2.log(response2);
						$.each(response2, function(index2, value2) {
							tr += '<option value="'+value2[0]+'">'+value2[1]+'</option>';							
						});
													
					tr += '</select>'+
					'</div>'+
				'</td>'+

                '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="kf_name[]" id="kf_name'+count2+'" autocomplete="off" placeholder="First Name" class="form-control" />'+
					'</div>'+
				'</td>'+				

               						
			 '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="km_name[]" id="km_name'+count2+'" autocomplete="off" placeholder="Middle Name" class="form-control" />'+
					'</div>'+
				'</td>'+	
				
				 '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="kl_name[]" id="kl_name'+count2+'" autocomplete="off" placeholder="Last Name" class="form-control" />'+
					'</div>'+
				'</td>'+	
				
			'<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="k_phone[]" id="k_phone'+count2+'" autocomplete="off" placeholder="Phone Number" class="form-control" />'+
					'</div>'+
				'</td>'+	
				
				'<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="k_email[]" id="k_email'+count2+'" autocomplete="off" placeholder="Email Address" class="form-control" />'+
					'</div>'+
				'</td>'+
				
				'<td>'+
					'<button class="btn btn-default removeProductRowBtn2" type="button" onclick="removeProductRow2('+count2+')"><i class="glyphicon glyphicon-trash"></i></button>'+
				'</td>'+
			'</tr>';
			if(tableLength > 0) {							
				$("#productTable2 tbody tr:last").after(tr);
			} else {				
				$("#productTable2 tbody").append(tr);
			}		

		} // /success
	});	// get the product data

} // /add row

function removeProductRow2(row = null) {
	if(row) {
		$("#row"+row).remove();


		subAmount();
	} else {
		alert('error! Refresh the page again');
	}
}


function addRow3() {
	$("#addRowBtn3").button("loading");

	var tableLength3 = $("#productTable3 tbody tr").length;

	var tableRow3;
	var arrayNumber3;
	var count3;

	if(tableLength3 > 0) {		
		tableRow3 = $("#productTable3 tbody tr:last").attr('id');
		arrayNumber3 = $("#productTable3 tbody tr:last").attr('class');
		count3 = tableRow3.substring(3);	
		count3 = Number(count3) + 1;
		arrayNumber3 = Number(arrayNumber3) + 1;					
	} else {
		// no table row
		count3 = 1;
		arrayNumber3 = 0;
	}

	$.ajax({
		url: 'php_action/fetchProductData153.php',
		type: 'post',
		dataType: 'json',
		success:function(response3) {
			$("#addRowBtn3").button("reset");			

			var tr = '<tr id="row'+count3+'" class="'+arrayNumber3+'">'+	

               '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					''+count3+''+
					'</div>'+
				'</td>'+	
				
				'<td style="padding-left:20px;">'+
					'<div class="form-group">'+

					'<select class="form-control" name="drel_id[]" id="drel_id'+count3+'">'+
						'<option value="">~~SELECT~~</option>';
						 console3.log(response3);
						$.each(response3, function(index3, value3) {
							tr += '<option value="'+value3[0]+'">'+value3[1]+'</option>';							
						});
													
					tr += '</select>'+
					'</div>'+
				'</td>'+

                '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="df_name[]" id="df_name'+count3+'" autocomplete="off" placeholder="First Name" class="form-control" />'+
					'</div>'+
				'</td>'+				

               						
			 '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="dm_name[]" id="dm_name'+count3+'" autocomplete="off" placeholder="Middle Name" class="form-control" />'+
					'</div>'+
				'</td>'+	
				
			'<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="dl_name[]" id="dl_name'+count3+'" autocomplete="off" placeholder="Last Name" class="form-control" />'+
					'</div>'+
				'</td>'+

            '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					
					'<select class="form-control" name="gender_id1[]" id="gender_id1'+count3+'">'+
						'<option value="">~~SELECT~~</option>';
						// console.log(response);
						//$.each(response, function(index, value) {
							tr += '<option value="1">MALE</option>';	
                            tr += '<option value="2">FEMALE</option>';								
						//});
													
					tr +='</select>'+
					
					
					//'<input type="text" name="debitNote[]" id="debitNote'+count+'" autocomplete="off" placeholder="Debit Note"  class="form-control"/>'+
					'</div>'+
				'</td>'+
								
				
			'<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="date" name="db_date[]" id="db_date'+count3+'" autocomplete="off" placeholder="Birth Date" class="form-control" />'+
					'</div>'+
				'</td>'+
				
				'<td>'+
					'<button class="btn btn-default removeProductRowBtn3" type="button" onclick="removeProductRow3('+count3+')"><i class="glyphicon glyphicon-trash"></i></button>'+
				'</td>'+
			'</tr>';
			if(tableLength3 > 0) {							
				$("#productTable3 tbody tr:last").after(tr);
			} else {				
				$("#productTable3 tbody").append(tr);
			}		

		} // /success
	});	// get the product data

} // /add row

function removeProductRow3(row = null) {
	if(row) {
		$("#row"+row).remove();


		subAmount();
	} else {
		alert('error! Refresh the page again');
	}
}






