
<?php //error_reporting(0);
session_name('CAKEPHP'); @session_start();
$PageSecurity = 3;
 include('includes/Class_Branch.php');
	include('includes/AccountGroupMaster_Class.php');
 
 	$modid=$_REQUEST['modid'];
	 $frmid=$_REQUEST['frmid'];
	 $rurl="&modid=".$modid."&frmid=".$frmid;
	 
	
 include ('includes/session.inc');
  include ('includes/function_lib.php');
 global $db;
 ?>
 <link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
	<div class="tab_div">
   <h1>Ledger Summary <?php echo $fromtitle=  $s->getField('voucher_master','VoucherType',$_REQUEST['VPrefix'],'GroupName');?></h1>			   
			   
	 <table width="100%" border="1" cellspacing="0" cellpadding="3" style="border:#808080 1px solid;">
  	  <tr>
	  	<th>Branch</th>
	  	<th width="10%">Voucher No.</th>
 		<th width="10%">Voucher Type</th>
  	    <th width="20%">Ledger Name</th>
  	    <th width="10%" style="text-align:center;">Amount</th>
  	    <th width="10%" style="text-align:center;">Credit</th>
  	    <th width="10%" style="text-align:center;">Debit</th>
   	    <th width="10%" style="text-align:center;">Currency</th>
		<th width="5%" style="text-align:center;">View</th>
      </tr>
 <?php 
   echo '<link href="'.$rootpath. '/css/'. $_SESSION['Theme'] .'/default.css" rel="stylesheet" type="text/css" />';
   $BillBookType=  $s->getField('voucher_master','VoucherType',$_REQUEST['VPrefix'],'VPrefix');

      $query="select A.id as Pid,A.Voucher_NO,A.Branch,A.VPrefix ,B.amount, B.amount_type ,B.ledgerid ,B.currency from account_book A,account_book_details B  where A.id=B.account_bookid  and B.ledgerid    ='".$_REQUEST['id']."' ";
   	$result=DB_query($query,$db);
		$i=1;
		if(DB_num_rows($result)>0)
		{
			while($myrow=DB_fetch_array($result))
			{
				$voucher_no=$myrow['Voucher_NO'];
				$Dates=$myrow['Dates'];
				$Ref_no=$myrow['Ref_no'];
				$voucher_no=$myrow['Voucher_NO'];			
				$narration=trim($myrow['narration']);
				$document_type=trim($myrow['document_type']);				
	 			 
				$Branch=$myrow['Branch'];
				$banks_checkno=$myrow['banks_checkno'];
				$banks_checkdate=ConvertSQLDate($myrow['banks_checkdate']);
				$banks_receivedfrom=ConvertSQLDate($myrow['banks_receivedfrom']);
				$favouring_name=$myrow['favouring_name'];
				$cross_inst=$myrow['cross_inst'];
	 ?>
 
  	  <tr bgcolor="#ffffff" >
	    <td><?php echo $myrow['Branch'];?></td>
	    <td><?php echo $myrow['Voucher_NO'];?></td>
		<td><?php echo $BillBookType=  $s->getField('voucher_master','VoucherType',$myrow['VPrefix'],'VPrefix');?>	</td>
  	    <td><?php //echo $i;?><?php  echo $s->getField('accountledger','AccountsID',$myrow['ledgerid'],'AccountName');;?></td>
  	    <td style="text-align:right;"><?php echo  $myrow['amount'];?></td>
  	    <td style="text-align:right;"><?php echo ($myrow['amount_type']=='CR'? $myrow['amount']:"0");
		$total_cr[]=($myrow['amount_type']=='CR'? $myrow['amount']:"0"); ?></td>
  	    <td style="text-align:right;"><?php echo  ( $myrow['amount_type']=='DR'? $myrow['amount']:"0");
		 $total_dr[]=($myrow['amount_type']=='DR'? $myrow['amount']:"0");
		 ?></td>
  	    <td><?php echo $myrow['currency'];?></td>
	    <td style="text-align:center;"><a href="address_book.php?id=<?php  echo $myrow['Pid'].$rurl?>&VPrefix=<?php echo $myrow['VPrefix'];?>">View</a></td>
       </tr>
  	 
		<?php 
}		
		?>
  	   
	 <tr bgcolor="#999999">
  	    <td>&nbsp;</td>
  	    <td>&nbsp;</td>
  	    <td>&nbsp;</td> 
  	    <td>&nbsp;</td>
  	    <td style="text-align:right;"><strong>Total</strong></td>
  	    <td style="text-align:right;"><strong><?php echo array_sum($total_cr); ?></strong></td>
  	    <td style="text-align:right;"><strong><?php echo array_sum($total_dr); ?></strong></td>
  	    <td>&nbsp;</td>
  	    <td>&nbsp;</td>
       </tr>
			   
			   
			   <?php 
		 
			}
?>
  </table> 
