<?php
 session_start();
 include("db.php");
  
 $customerId=$_POST['customerNumber'];
 $currencyId=$_POST['currencyId'];
    
	    
		//avordegi Pool
		$avordegi_sql="select sum(amount) as amount from customer_statement where customerId='$customerId' and transaction_type=1 and currency_id='$currencyId'";
		$avordegi_query= $db ->query($avordegi_sql);
		$avordegi_row=$avordegi_query ->fetch_array();
		$avordegi=$avordegi_row['amount'];
		 
		//$avordegi_sql 
		//bordegi Pool
		$bordegi_sql="select sum(amount) as amount from customer_statement where customerId='$customerId' and transaction_type=2 and currency_id='$currencyId'";
		$bordegi_query= $db ->query($bordegi_sql);
	    $bordegi_row=$bordegi_query ->fetch_array();
		$bordegi=$bordegi_row['amount'];
		 				 
						   //$bordegi 
	 
    /*   $customerBalanceSql="select amount,dollarAmount from customerbalance where customerId='$customerId' and currencyId='$currencyId'";
	  $customerBalanceQuery=$db ->query($customerBalanceSql);
      $customerBalanceRow=$customerBalanceQuery->fetch_array();
	  $customerBalanceAmount=$customerBalanceRow['amount']; */
	 
	  $customerBalanceAmount=(($avordegi)-$bordegi);
	   
	  if($customerBalanceAmount==''){
	     $customerBalanceAmount=0;
	     $customerBalanceAmount=0;
		 echo '<input type="text"    disabled  class="filed" value='.number_format($customerBalanceAmount,2).'>';
		 echo '<input type="hidden"  id="customerAmount"       name="customerAmount"        value='.$customerBalanceAmount.'>';
		 echo '<input type="hidden"  id="customerdollarAmount" name="customerdollarAmount"  value='.$customerBalanceDollarAmount.'>';
	  
	  }
      else{
	  echo '<input type="text"  disabled     class="filed" value='.number_format($customerBalanceAmount,2).'>';
	  echo '<input type="hidden"  id="customerAmount"       name="customerAmount"         value='.$customerBalanceAmount.'>';
	  echo '<input type="hidden"  id="customerdollarAmount" name="customerdollarAmount"   value='.$customerBalanceDollarAmount.'>';
	  }

?>