
<?php  
require_once("config/configDB.php"); 
if(isset($_POST["query"]))  
 {  
	if($_POST["query"]!=""){
      
	  $empcode = $_POST["query"];
	  
	
	  
      $query1 = "SELECT sum(advance_amount) as advamt FROM employee_advance WHERE employee_id='$empcode' and status=''";  
      $exec1 = mysqli_query($conn,$query1) or die ("Error in Query1".mysql_error());
      $row1 = mysqli_fetch_array($exec1);
	  
	  $query_col = "SELECT sum(advance_collection_amount) as col_advamt FROM employee_advance_collection WHERE employee_id='$empcode' and status=''";  
      $exec_col = mysqli_query($conn,$query_col) or die ("Error in Query1".mysql_error());
      $row_col = mysqli_fetch_array($exec_col);
	  
		$advamt = $row1['advamt'];
		$advamt_col = $row_col['col_advamt'];
		
		$totamt=$advamt-$advamt_col;
		
      $output = $totamt.'||';
	}  
 }
echo $output;  
 ?>  
