<?php  
function GroupWiseTrialBalance($UnderGroup,$type,$from,$to)
{
   global $db;
   static $rx=0;
   // echo "<br>--$from-------$to----</br>";
      $GetLedger="select * from accountledger where UnderGroup= '".$UnderGroup."' order by  AccountName ASC  ";
 	 $GetLedger=DB_query($GetLedger,$db);


	 $TDR=array();
	 $TCR=array();
 while($RowGetLedger=DB_fetch_array($GetLedger))
  {
 		   		$TDR[]= Get_AccountByLedger($RowGetLedger['AccountsID'],$type,$from,$to);
	  		 // $TCR[]= Get_AccountByLedger($RowGetLedger['AccountsID'],'CR','','');
   }
    
   return (array_sum($TDR));
}



function APRGroupWise_TrialBalance($maingpid,$type,$from='',$to='')
{   global $db;

//echo $from.$to.'<br>';
$total=array();
$s=new db_query();

	 $sqlCate = "select * from  accountgroupmaster  where    MainGroupId   = '".$maingpid."'";
	$rsCate  = DB_query($sqlCate,$db);
 	if(DB_num_rows($rsCate)>0)
	{
		while($rowCate =DB_fetch_array($rsCate))
		{
			$total[]=GroupWiseTrialBalance($rowCate['GroupId'],$type,$from,$to);
		}
 	}	
	
	
	
	//	echo "<pre>";
//	print_r($total);  
    return (array_sum($total));
}
 
   ?>  


 