<?php  
session_name('CAKEPHP'); session_start();
ob_start();
$PageSecurity = 1;
include('config.php');
include('includes/ConnectDB.inc');
include('includes/function_lib.php');
include('includes/LanguageSetup.php');
include('includes/DateFunctions.inc');
$pcode= $rolepid;

function CategoryShow(  $PcateID, $dashVal)
{
	global $db;
	$dashVal = $dashVal . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	$s=new db_query();
	$rurl="&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid'];
	
	$sqlCate = "select * from accountgroupmaster  where  MainGroupId  = '".$PcateID."' ";
	
	$rsCate  = DB_query($sqlCate,$db);	
	if(DB_num_rows($rsCate)>0)
	{
	while($rowCate = DB_fetch_array($rsCate))
	{
	echo '<tr bgcolor="#CCCCCC"><td><b>'.$dashVal.'&nbsp;';
	echo  '</b>'.$dashVal.'';
	$k=1;
	echo $dashVal.'&nbsp; 
	';
	echo "<b>".$rowCate['GroupName']."</b>";
	echo ' </td></tr>';
	$ledgersSql=DB_query("Select * from accountledger where UnderGroup=".$rowCate['GroupId']."",$db);
	while($ledgersRow=DB_fetch_array($ledgersSql)){
	echo '<tr bgcolor="#FFFFFF"><td>';
	echo $dashVal .$dashVal.$dashVal.$dashVal."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$ledgersRow['AccountName'];
	echo '</td></tr>'; }
	CategoryShow( $rowCate['GroupId'], $dashVal);
	}
	} 
}
$dashVal = "&nbsp;&nbsp;&nbsp;";		
?>
<script type="text/javascript" language="javascript">
  function toggle_visibility(id) {
       var e = document.getElementById(id);
	      e.style.display = 'none';
		       //alert(e.style.display);
			   window.print();
    }
  
</script>
<title>Account List Report</title>
<link rel="stylesheet" href="css/purchase_requision_print.css">
<div class="body_contain">
<div class="tab_div">
<?php 
$logo="<div>";
$logo.="<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
$logo.="<tr>";
$logo.="<td align='left'><img src='images/cloud_logo.jpg' /></td>";
$logo.="<td align='right'><img src='images/right_img.jpg' /></td>";
$logo.="</tr>";
$logo.="<tr>";
$logo.="<td colspan='2'><h1>".'Account List Report'."</h1></td>";
$logo.="</tr>";
$logo.="</table>";
$logo.="</div>";
echo $logo;
?>
<div id="foo">
  <p align="center"><input type="button" onclick="javascript:toggle_visibility('foo');" value="Print" /></p>
</div>

 		<?php 
			$dashVal = "&nbsp;&nbsp;&nbsp;";
			?>
<table width="100%" border="1" cellspacing="0" cellpadding="5" bordercolor="#000000">
 			<?php 
			
			 $k=1;
			  //echo "select * from accountgroupmaster where MainGroupId=0";
			  //echo "select * from accountgroupmaster where MainGroupId=0 and Type='G'";
			 $query_comprole=DB_query("select * from accountgroupmaster where MainGroupId=0 and Type='G' ",$db);
 			  while($row_comprole=DB_fetch_array($query_comprole))
			  {
			  	 echo '<tr style="background:#999999"><td style="border-bottom:#333333 solid 1px"><b><font face="Arial, Helvetica, sans-serif"></font>';
					  		echo $k++.'-'.$row_comprole['GroupName'].'<br>';
				 echo '  </b></td></tr>';
  			     $getDirectLedgers=DB_query("Select * from accountledger where UnderGroup=".$row_comprole['GroupId']."",$db);
				
				 while($directLedgersRow=DB_fetch_array($getDirectLedgers))
				 {
				 	echo '<tr style="background:#FFFFFF"><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$directLedgersRow['AccountName'].'</td></tr>';
				 }
				 CategoryShow(   $row_comprole['GroupId'], $dashVal);
 			  }	
 		 ?>
</table>
