
<table width="100%" border="0" cellspacing="0" cellpadding="3" class="thborder">
   <tr>
   <th width="5%">Group Id</th>
   <th>Group Name</th>
   <th width="18%">Under</th>
   <th width="18%">Nature</th>
   <th width="5%" style="text-align:center;">Edit</th>
   <th width="5%" style="text-align:center;">Delete</th>
   </tr>
   <?php 
      // LIMIT $startpoint,$perpage
   $GetRecord = "Select * from $table where Type!='N'  order by MainGroupId asc, NatureOfGroup asc, GroupName asc";
   $ResultData = DB_query($GetRecord,$db);
   $i=1;
   if(DB_num_rows($ResultData)==0)
   echo "<td>--No Record--</td>";
   
   while($RowData = DB_fetch_array($ResultData))
   {
  
   		$check_ledger=DB_query("select * from accountledger where UnderGroup='".$RowData['GroupId']."'",$db);
		$data1=DB_num_rows($check_ledger);
		$check_under_group=DB_query("select * from accountgroupmaster where MainGroupId='".$RowData['GroupId']."'",$db);
		$data2=DB_num_rows($check_under_group);
		
   ?>
 <tr>
    <td><?php echo $i; ?></td>
    <td><?php echo $RowData['GroupName'];?></td>
    <td><?php 	   
	    $parent= $s->getField($table,'GroupId',$RowData['MainGroupId'],'GroupName');	 
	  if($parent!='')
	  echo $parent;
	  else{
	  echo "Primary";
	  }
 	   ?></td>   
   <td><?PHP          
	 if($RowData['MainGroupId']=='0' && $RowData['Type']=='G')
	 {
	 	echo $s->getField($table,'GroupId',$RowData['NatureOfGroup'],'GroupName');
	 }	 
   ?>
  </td>   
  <td style="text-align:center;"><a href="index.php?route=Account/AccountGroups_Master&action=Edit&GroupId=<?php echo $RowData['GroupId'].$url; ?>"><img src="images/icon-edit.png"  width="15" height="15" title="Edit Document" /></a></td>
	<td style="text-align:center;"><?php if($data1=='0' && $data2=='0'){?><a href="index.php?route=Account/AccountGroups_Master&action=del&GroupId=<?php echo $RowData['GroupId'].$url;; ?>" onclick="return confirm('Do You Want To Delete This Record')"><img src="images/Icon_Delete.png" width="15" height="15" title="Delete Document" /></a><?php }else{ ?><img src="images/Icon_Delete.png" width="15" height="15" title="No Permission to Delete Document" style="opacity:0.5;" /><?php } ?></td>	
  </tr>
 
	<?php $i++;}   
   ?> 
   
    
    <!-- <td colspan="4">
	<?php  
	//$cond="1=1";
	//Pages($table,20,"index.php?route=AccountGroups_Master&action=Edit".$url,$cond,'GroupId');
	 //echo Pages("jos_users",$perpage,"index.php?option=com_empdictory&dept=$dept&",$condition);?>
	</td> -->
 
  </table>
 