 <?php class AccountGroupMaster
{
  var $GroupName;
  var $Predefined;
  var $MainGroupId;
  var $GroupLevel;
  var $p1;
  var $p2;
	public function AccountGroupMaster()  
	{
	 $this->GroupName =''; 
	 $this->Predefined ='';
	 $this->MainGroupId =0;
	  $this->p1 =0;
	   $this->GroupLevel =0; 
	   $this->p2 =0;
	 
	}
   function  AccountGroup($id,$idname)
   { 
    		global $db;
		
  		$sql=DB_query("select * from overheadmaster",$db);		
		if(!$sql)
		{
		   die('Error.'.DB_error_msg($db));
		}
		echo "<select name='".$idname."' onchange='select_account(this.value)'>";
		echo "<option value='0'>----</option>";
		while($row=DB_fetch_array($sql))
		{
		   $p='';
		   if($row['GroupId']==$id)
		   $p='selected';
		  echo "<option value='".$row['GroupId']."' $p >".$row['GroupName']."</option>";
		}
		echo "</select>";
    }
   
   
  
   

//**********************************************************	
 function  AccountLeger($ledger_id,$tname,$LId='',$undergroup ='',$ledgertype='')
   { 
   		global $db;		
		//echo $ledger_id;
		 $query="SELECT AccountsID,AccountName  FROM accountledger  WHERE ";
		 
		if($undergroup!=''  )
		{
	 	$testAS="onchange='GetBankDetals(this.value)'";
  		$query .= " UnderGroup in($undergroup) ORDER BY AccountName ASC" ;   			
		}
	
	
	
		if( $ledgertype!='' ){
		$query .= " UnderGroup not  in($ledgertype)  ORDER BY AccountName ASC" ;   	
		//$result_ledger = DB_query("SELECT AccountsID,AccountName  FROM accountledger  WHERE ledgertype in($ledgertype)",$db);   			
		}
		
	   if($undergroup=='' && $ledgertype=='' ){

		$query .= " 1=1 ORDER BY AccountName ASC";
		}
	 	
		$result_ledger = DB_query($query,$db); 
		
		?>
		
			<?php 			
 			while($myrow_ledger = DB_fetch_row($result_ledger))
			{
			  $p='';
			  if($myrow_ledger[0]==$ledger_id)
			  $p="selected";
			?>
			<option value="<?php echo $myrow_ledger[0]; ?>"<?php echo $p; ?>><?php echo $myrow_ledger[1]; ?></option>
			<?php }?>
			
 <?php 
    }
function  AccountLeger1($ledger_id,$tname,$LId='',$undergroup ='',$ledgertype='')
   { 
   		global $db;		
		//echo $undergroup;
		 $query="SELECT AccountsID,AccountName  FROM accountledger  WHERE";
		 
		if($undergroup!=''  )
		{
	 
  		$query .= " UnderGroup in($undergroup)" ;   			
		}
	
	
	
		if( $ledgertype!='' ){
		$query .= " UnderGroup not  in($ledgertype)  " ;   	
		//$result_ledger = DB_query("SELECT AccountsID,AccountName  FROM accountledger  WHERE ledgertype in($ledgertype)",$db);   			
		}
		
	   if($undergroup=='' && $ledgertype=='' ){

		$query .= " 1=1";
		}
	 	//echo $query ;
		$result_ledger = DB_query($query,$db); 
		
		?>
		
			
			<option value="000">Please select Ledger</option>
			<?php 			
 			while($myrow_ledger = DB_fetch_row($result_ledger))
			{
			  $p='';
			  if($myrow_ledger[0]==$ledger_id)
			  $p="selected";
			?>
			<option value="<?php echo $myrow_ledger[0]; ?>"<?php echo $p; ?>><?php echo $myrow_ledger[1]; ?></option>
			<?php }?>
			
 <?php 
    }

  
}
$AccountMaster=new AccountGroupMaster();

 ?>
