<?php
include("include/config.inc.php");
   $partyId = isset($_REQUEST['partyId']) ? $_REQUEST['partyId'] : 0;
   
   $selectClientAavk = "SELECT SUM(vkg) AS aKg,SUM(vTotalAmt) AS aTotalAmt
	                      FROM vepari
					   WHERE veTransType = 'A'
				    AND partyId = ".$partyId;
	$selectClientAavkRes = mysql_query($selectClientAavk);
	if($cavakRow = mysql_fetch_assoc($selectClientAavkRes))
	{
      $aKg          = $cavakRow['aKg'];
	  $aTotalAmt    = $cavakRow['aTotalAmt'];  
	}
    
	$selectClientJavak = "SELECT SUM(vkg) AS javakKg,SUM(vTotalAmt) AS javaktotalAmt
	                   FROM vepari
					  WHERE veTransType = 'J'
				AND partyId = ".$partyId;
	$selectClientJavakRes = mysql_query($selectClientJavak);
	if($cjavakRow = mysql_fetch_assoc($selectClientJavakRes))
	{
      $javakKg          = $cjavakRow['javakKg'];
	  $javaktotalAmt    = $cjavakRow['javaktotalAmt'];  
	}
	
	
	$finalKg     = $javakKg       - $aKg;
	$finalAmount = $javaktotalAmt - $aTotalAmt;
    
	include("bottom.php");
	$smarty->assign('finalKg',$finalKg);
	$smarty->assign('finalAmount',$finalAmount);
	$smarty->display("getAmount.tpl");
 
?>