<?php
if ($_POST ['firstvalue'] && $_POST ['secondvalue'] && $_POST ['tablename']) {
	$firstvalue = $_POST ['firstvalue'];
	$secondvalue = $_POST ['secondvalue'];
	$tablename = $_POST ['tablename'];
	
	// $db->insert("first_salaryslip",
	// array("earning"=>$firstvalue.$secondvalue));
	// send the fields according to conditions
	?>

<?php
	
if ($firstvalue == 'value') {
		?>
<script>
$(document).ready(function(){
	//stop another keys only alphabets are allowed...
	$(function () {
		$(".txtboxToFilter1").keydown(function (event) {
			if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) /*|| (event.keyCode == 32)*/ || (event.keyCode == 8)) {
				$(".bhangi").hide(); 
				} else {
					$(this).children().show();	
					event.preventDefault();
	         }
	    });
	 });
});

$(document).ready(function(){
	$(".in").focusout(function(){ 
		//$("#spinner").show();
		//$("#loader-wrapper").show();
		var placeholder= $(this).attr('placeholder');
		////alert(placeholder);
			var fieldname= $(this).attr('name'); 
			////alert(fieldname);
			var tablename= $(this).attr('alt');	
			////alert(tablename);
			var value= $(this).val();
			////alert(value);
			$.ajax({
				type:'POST',
				url:'<?php echo $link->link("slipformat2",Admin);?>',
				data:"field_name="+fieldname+'&table='+tablename+'&val='+value+'&checkvalue='+placeholder,
				success:function(data){
					////alert(data);
					////alert(fieldname);
					////alert(value);
						if(data == 1)
						{
							////alert("bhangi");
							var hidefield= fieldname.split('_')
							////alert("hide="+hidefield[1]+'_'+hidefield[2]);
							/////alert(hidefield[2]);
							var realval=hidefield[2]; 
							if(realval)
							{ 
								////alert("p");
								//$("#spinner").hide();
								//$("#loader-wrapper").hide();
								$(".alpha"+hidefield[1]+'_'+hidefield[2]).hide();
								$(".b___"+hidefield[1]+'_'+hidefield[2]).html(value);
							}else
							{
								////alert("d");
								//$("#spinner").hide();
								//$("#loader-wrapper").hide();
								$(".alpha"+hidefield[1]).hide();
								$(".b___"+hidefield[1]).html(value);
							}
							//$("#spinner").hide();
							//$(".move"+fieldname).html(value);
						}
						if(data ==2)
						{
							
						}
					}
			
				});
			return false;		
	});
});
</script>
<script>
	$(".deletefirst1").click(function(){
		$("#spinner").show();
		$("#loader-wrapper").show();
		var delete_column= $(this).attr('id');
		////alert(delete_column);
		$.ajax({
			type:'POST',
			url:'<?php echo $link->link("slipformat", Admin);?>',
			data:'columnname='+delete_column,
			success:function(data){
				////alert("data="+data);
				var value= delete_column.split("_");
				
				////alert(value[1]);
					if(data==1)
					{
						if(value[2])
						{
							$("#spinner").hide();
							$("#loader-wrapper").hide();
							$(".rowfluid"+value[1]+'_'+value[2]).hide();
						}
						else
						{
							$("#spinner").hide();
							$("#loader-wrapper").hide();
							$(".rowfluid"+value[1]).hide();
						}
					}
				}
			});
		return false;
		});
</script>
<div class="txtboxToFilter1">
	<input type="text" class="in" name="<?php echo "a_".$secondvalue;?>"
		alt="<?php echo $tablename;?>" placeholder="value"> <strong
		class="bhangi" style="display: none; color: #FF0000;">Only Numeric
		Value Are Allowed..</strong>
</div>
<?php
	
	} else {
		?>
<script
	src="<?php echo SITE_URL.'/assets/backend/js/jquery.maskedinput.min.js'?>"></script>
<script>
//only numeric value are allowed
$(".txtboxToFilter").mask("9?9%");
</script>
<script>
$(document).ready(function(){
	$(".in").focusout(function(){
		$("#spinner").show();
		$("#loader-wrapper").show();
		var placeholder= $(this).attr('placeholder');
		////alert(placeholder);
			var fieldname= $(this).attr('name'); 
			////alert(fieldname);
			var tablename= $(this).attr('alt');	
			////alert(tablename);
			var value= $(this).val();
			////alert(value);
			$.ajax({
				type:'POST',
				url:'<?php echo $link->link("slipformat2",Admin);?>',
				data:"field_name="+fieldname+'&table='+tablename+'&val='+value+'&checkvalue='+placeholder,
				success:function(data){
					//alert(data);
					////alert(fieldname);
					////alert(value);
						if(data == 1)
						{
							////alert("bhangi");
							var hidefield= fieldname.split('_')
							////alert("hide="+hidefield[1]+'_'+hidefield[2]);
							/////alert(hidefield[2]);
							var realval=hidefield[2]; 
							if(realval)
							{ 
								$("#spinner").hide();
								$("#loader-wrapper").hide();
								////alert("p");
								$(".alpha"+hidefield[1]+'_'+hidefield[2]).hide();
								$(".b___"+hidefield[1]+'_'+hidefield[2]).html(value);
							}else
							{
								$("#spinner").hide();
								$("#loader-wrapper").hide();
								////alert("d");
								$(".alpha"+hidefield[1]).hide();
								$(".b___"+hidefield[1]).html(value);
							}
							
						}
						if(data ==2)
						{
							
							var r = confirm("Your Percent is more than 100!, Please Choose Another One");
						    if (r == true || r == false) {
						        window.location= '';
						    } 
						}
					}
				});
			return false;	
	});
});
</script>
<input type="text" class="txtboxToFilter in"
	alt="<?php echo $tablename;?>" name="<?php echo "a_".$secondvalue;?>"
	placeholder="percentage">

<?php
	
	}
} elseif (isset ( $_POST ['firstvalue_deduction'] ) && isset ( $_POST ['secondvalue_deduction'] ) && isset ( $_POST ['tablename_deduction'] )) {
	$firstvalue = $_POST ['firstvalue_deduction'];
	$secondvalue = $_POST ['secondvalue_deduction'];
	$tablename = $_POST ['tablename_deduction'];
	
	// $db->insert("first_salaryslip",
	// array("earning"=>$firstvalue.$secondvalue));
	?>
<script
	src="<?php echo SITE_URL.'/assets/backend/js/jquery.maskedinput.min.js'?>"></script>
<script>
//only numeric value are allowed
$(".txtboxToFilter").mask("9?9%");

$(document).ready(function(){
	//stop another keys only alphabets are allowed...
	$(function () {
		$(".txtboxToFilter1").keydown(function (event) {
			if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) /*|| (event.keyCode == 32)*/ || (event.keyCode == 8)) {
				$(".bhangi").hide(); 
				} else {
					$(this).children().show();	
					event.preventDefault();
	         }
	    });
	 });
});
</script>
<?php
	
if ($firstvalue == 'value') {
		?>
<script>
	$(document).ready(function(){
		$(".in_deduction").focusout(function(){
			$("#spinner").show();
			$("#loader-wrapper").show();
			var placeholder= $(this).attr('placeholder');
			////alert(placeholder);
				var fieldname= $(this).attr('name'); 
				////alert(fieldname);
				var tablename= $(this).attr('alt');	
				////alert(tablename);
				var value= $(this).val();
				////alert(value);
				$.ajax({
					type:'POST',
					url:'<?php echo $link->link("slipformat2",Admin);?>',
					data:"field_name_deduction="+fieldname+'&table_deduction='+tablename+'&val_deduction='+value+'&checkvalue_deduction='+placeholder,
					success:function(data){
						////alert(data);
						////alert(fieldname);
						////alert(value);
							if(data == 1)
							{
								////alert("bhangi");
								var hidefield= fieldname.split('_')
								////alert("hide="+hidefield[1]+'_'+hidefield[2]);
								/////alert(hidefield[2]);
								var realval=hidefield[2]; 
								if(realval)
								{ 
									////alert("p");
									$("#spinner").hide();
									$("#loader-wrapper").hide();
									$(".alpha_deduction"+hidefield[1]+'_'+hidefield[2]).hide();
									$(".bdeduction___"+hidefield[1]+'_'+hidefield[2]).html(value);
								}else
								{
									////alert("d");
									$("#spinner").hide();
									$("#loader-wrapper").hide();
									$(".alpha_deduction"+hidefield[1]).hide();
									$(".bdeduction___"+hidefield[1]).html(value);
								}
								//$("#spinner").hide();
								//$(".move"+fieldname).html(value);
							}
							if(data ==2)
							{
								 
							}
						}
				
					});
				return false;
		});
	});
	</script>
<script>
	$(".deletefirst2").click(function(){
		$("#spinner").show();
		$("#loader-wrapper").show();
		var delete_column= $(this).attr('id');
		////alert(delete_column);
		$.ajax({
			type:'POST',
			url:'<?php echo $link->link("slipformat", Admin);?>',
			data:'columnname_deduction='+delete_column,
			success:function(data){
				////alert("data="+data);
				var value= delete_column.split("_");
				
				////alert(value[1]);
					if(data==1)
					{
						if(value[2])
						{
							$(".rowfluid"+value[1]+'_'+value[2]).hide();
						}
						else
						{
							$(".rowfluid"+value[1]).hide();
						}
					}
				}
		$("#spinner").hide();
		$("#loader-wrapper").hide();
			});
		return false;
		});
	</script>
<div class="txtboxToFilter1">
	<input type="text" class="in_deduction"
		name="<?php echo "a_".$secondvalue;?>" alt="<?php echo $tablename;?>"
		placeholder="value"> <strong class="bhangi"
		style="display: none; color: #FF0000;">Only Numeric Value Are
		Allowed..</strong>
</div>
<?php
	
	} else {
		?>
<script>
	$(document).ready(function(){
		$(".in_deduction").focusout(function(){
			$("#spinner").show();
			$("#loader-wrapper").show();
			var placeholder= $(this).attr('placeholder');
			////alert(placeholder);
				var fieldname= $(this).attr('name'); 
				////alert(fieldname);
				var tablename= $(this).attr('alt');	
				////alert(tablename);
				var value= $(this).val();
				////alert(value);
				$.ajax({
					type:'POST',
					url:'<?php echo $link->link("slipformat2",Admin);?>',
					data:"field_name_deduction="+fieldname+'&table_deduction='+tablename+'&val_deduction='+value+'&checkvalue_deduction='+placeholder,
					success:function(data){
						//alert(data);
						////alert(fieldname);
						////alert(value);
							if(data == 1)
							{
								////alert("bhangi");
								var hidefield= fieldname.split('_');
								////alert("hide="+hidefield[1]+'_'+hidefield[2]);
								/////alert(hidefield[2]);
								var realval=hidefield[2]; 
								if(realval)
								{ 
									////alert("p");
									$(".alpha_deduction"+hidefield[1]+'_'+hidefield[2]).hide();
									$(".bdeduction___"+hidefield[1]+'_'+hidefield[2]).html(value);
								}else
								{
									////alert("d");
									$(".alpha_deduction"+hidefield[1]).hide();
									$(".bdeduction___"+hidefield[1]).html(value);
								}
								$("#spinner").hide();
								$("#loader-wrapper").hide();
							}
							if(data ==2)
							{
								var r = confirm("Your Percent is more than 100!, Please Choose Another One");
							    if (r == true || r == false) {
							        window.location= '';
							    }
							}
						}
					});
				return false;	
		});
	});
	</script>
<script>
	$(".deletefirst2").click(function(){
		$("#spinner").show();
		$("#loader-wrapper").show();
		var delete_column= $(this).attr('id');
		////alert(delete_column);
		$.ajax({
			type:'POST',
			url:'<?php echo $link->link("slipformat", Admin);?>',
			data:'columnname_deduction='+delete_column,
			success:function(data){
				////alert("data="+data);
				var value= delete_column.split("_");
				
				////alert(value[1]);
					if(data==1)
					{
						if(value[2])
						{
							$(".rowfluid"+value[1]+'_'+value[2]).hide();
						}
						else
						{
							$(".rowfluid"+value[1]).hide();
						}
					}
				}
		$("#spinner").hide();
		$("#loader-wrapper").hide();
			});
		return false;
		});
	</script>
<input type="text" class="txtboxToFilter in_deduction"
	alt="<?php echo $tablename;?>" name="<?php echo "a_".$secondvalue;?>"
	placeholder="percentage">

<?php
	
	}
}
?>