<?php 
ob_start();
$PageSecurity = 11;
include('includes/session.inc');
include('includes/header.inc');
include('includes/function_lib.php');
include('includes/SQL_CommonFunctions.inc');

if(isset($_REQUEST['delcrdrid'])){
	$i=$_REQUEST['delcrdrid'];
	unset($_SESSION['ACGLedgerId'][$i]);
	unset($_SESSION['Amount'][$i]);
	unset($_SESSION['Currency'][$i]);
	unset($_SESSION['Amount_type'][$i]);
}

	$j=0;
  	
    if(count($_SESSION['ACGLedgerId'])>0)
  	$j=count($_SESSION['ACGLedgerId']);

	if(isset($_REQUEST['debit_amount'])){
	  $_SESSION['ACGLedgerId'][]=$_REQUEST['ledger_dr'];
	  $_SESSION['Amount'][]=$_REQUEST['debit_amount'];
	  $_SESSION['Amount_type'][]='DR';
	  $_SESSION['Currency'][]=$_REQUEST['dr_currency'];
	}
	
	if(isset($_REQUEST['credit_amount'])){
		$_SESSION['ACGLedgerId'][]=$_REQUEST['ledger_cr'];
	  	$_SESSION['Amount'][]=$_REQUEST['credit_amount'];
	  	$_SESSION['Amount_type'][]='CR';
	  	$_SESSION['Currency'][]=$_REQUEST['cr_currency'];
	}
	
?>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<?php 
if(count($_SESSION['ACGLedgerId'])>0)		 
{
foreach ($_SESSION['ACGLedgerId'] as $i => $LED)
{ 
		//  for($i=0;$i<count($_SESSION['ACGLedgerId']);$i++)?>
<tr class="row1">
  	    <td style="width:280px;"><?php  echo $s->getField('accountledger','AccountsID',$LED,'AccountName');;?></td>
  	    <td style="width:180px;"> <?php  echo $_SESSION['Amount'][$i].$_SESSION['Amount_type'][$i];?></td>
  	    <td> <?php
		echo ($_SESSION['Amount_type'][$i]=='CR'? $_SESSION['Amount'][$i]:"0");
		$total_cr[]=($_SESSION['Amount_type'][$i]=='CR'? $_SESSION['Amount'][$i]:"0");
		
		?></td>
  	     <td> <?php  echo  ( $_SESSION['Amount_type'][$i]=='DR'? $_SESSION['Amount'][$i]:"0");
		 $total_dr[]=($_SESSION['Amount_type'][$i]=='DR'? $_SESSION['Amount'][$i]:"0");
		 ?></td>
  	   <td> <?php  echo $_SESSION['Currency'][$i];?></td>
	   <td> <a href="#" onclick="deletedrcr(<?php echo $i;?>,'<?php echo $_SESSION['Amount_type'][$i]; ?>',<?php echo $_SESSION['Amount'][$i]; ?>)"><img src="images/Icon_Delete3.gif" /></a></td>
</tr>
		<?php } 
}else{

echo "<tr><td colspan=5>No record</td></tr>";
}		
		?>
  	   
	  </table>