<?php //error_reporting(0);
$PageSecurity = 3;
 include ('includes/session.inc');
  include ('includes/function_lib.php');
 global $db;
 include('includes/Class_Branch.php');
	include('includes/AccountGroupMaster_Class.php');
 
	$modid=$_REQUEST['modid'];
	$frmid=$_REQUEST['frmid'];
	$rurl="&modid=".$modid."&frmid=".$frmid;
?>	 
<p align="right"><a href="javascript:history.go(-1);"><input type="button" value="Go Back" /></a></p>
<?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 *  from account_book  where id='".$_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']);
			
			
			
			 $transation_type=$myrow['transation_type'];
			$Branch=$myrow['Branch'];
 		 	$banks_checkno=$myrow['banks_checkno'];
			// $myrow['banks_checkdate'];
			$banks_checkdate=ConvertSQLDate($myrow['banks_checkdate']);
			$banks_receivedfrom=$myrow['banks_receivedfrom'];
			$favouring_name=$myrow['favouring_name'];
			$cross_inst=$myrow['cross_inst'];			
 			$deposit_vouchertype=$myrow['deposit_vouchertype'];
			$dcrno=$myrow['dcrno'];
			$deposit_voucherdate=ConvertSQLDate($myrow['deposit_voucherdate']);
			$depositedby=$myrow['depositedby'];

	 ?>
			   <h2><center ><?php echo $_SESSION['CompanyRecord']['CompanyName']?>
			   
			   <?php echo $fromtitle=  $s->getField('voucher_master','VoucherType',$_REQUEST['VPrefix'],'GroupName');?></center></h2>
 <table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#ccc" style="border:1px sol #CCC;">
  
   
   
   
  <tr bgcolor="#FFFFFF">
    <td width="23%">Branch</td>
    <td width="29%">
<?php 	echo $s->getField('locations','loccode',$myrow['Branch'],'locationname');?>
	 </td>
    <td width="21%">Voucher No. </td>
    <td width="27%"><?php echo $voucher_no;?> </td>
    </tr>
  <tr  bgcolor="#FFFFFF">
    <td>Date</td>
    <td> 
	<?php echo $Dates;?>
	</td>
    <td> Ref. No.</td>
    <td><?php echo $Ref_no;?>
    </td>
	</tr>
	
<?php  if($BillBookType=='JV'){?>
	 <tr  bgcolor="#FFFFFF">
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>Document </td>
    <td><input name="document_type" type="text"   value="<?php echo $document_type;?>"   style="width:98%"/></td>
	</tr>
	<?php }?>
  
   <tr  bgcolor="#FFFFFF">
    <td colspan="4">
	<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#CCCCCC">
  <tr>
  	<td><table width="100%" border="0" cellspacing="1" cellpadding="2">
  	  <tr>
  	    <td scope="col"><strong> Ledger Name</strong></td>
  	    <td scope="col"><strong>Amount</strong></td>
  	     <td scope="col"><strong>Debit</strong></td>
  	    <td scope="col"><strong>Credit</strong></td> 	   
   	    <td scope="col"><strong>Currency</strong></td>
   	    </tr>
		<?php 
		 
		$total_cr=array();$total_dr=array();
	   $query1="select *  from account_book_details where account_bookid ='".$myrow['id']."'  ";
   		$result1=DB_query($query1,$db);
			while($myrow1=DB_fetch_array($result1))
			{
 
//foreach ($_SESSION['ACGLedgerId'] as $i => $LED)
 
		//  for($i=0;$i<count($_SESSION['ACGLedgerId']);$i++)
		 
		?>
  	  <tr bgcolor="#ffffff" >
  	    <td><?php  //echo $i;?> <?php  echo $s->getField('accountledger','AccountsID',$myrow1['ledgerid'],'AccountName');;?></td>
  	    <td> <?php  echo  $myrow1['amount'];?></td>
  	    </td>
  	     <td> <?php  echo  ( $myrow1['amount_type']=='DR'? $myrow1['amount']:"0");
		 $total_dr[]=($myrow1['amount_type']=='DR'? $myrow1['amount']:"0");
		 ?></td>
  	    
  	    <td> <?php
		echo ($myrow1['amount_type']=='CR'? $myrow1['amount']:"0");
		$total_cr[]=($myrow1['amount_type']=='CR'? $myrow1['amount']:"0");
		
		?>
		  <td> <?php  echo $myrow1['currency'];?></td>
	    
  	    </tr>
		<?php 
}		
		?>
  	   
	  </table></td>
  </tr> 
  <tr><td>
  <fieldset>
	<legend> Bank CheckDetails</legend>
 	<table width="100%" cellpadding="0" cellspacing="0" border="0">	 
 	<tr>
	   <td>Transation Type</td>
    <td><?php echo $transation_type; ?></td>
    <td>Instrument NO</td>
    <td><?php echo $banks_checkno; ?></td>
    <td>Instrument Date</td>
    <td><?php echo ($banks_checkdate!=''?$banks_checkdate:''); ?></td>   

   
  </tr>
 	<tr>
	 <td>Received From</td>
    <td><?php echo ($banks_receivedfrom!=''?$banks_receivedfrom:'') ; ?></td>   
 	  <td>Favouring name</td>
 	  <td><?php echo $favouring_name; ?></td>
 	  <td>CSross inst</td>
 	  <td><?php echo $cross_inst; ?></td>
 	  <td>&nbsp;</td>
 	  <td>&nbsp;</td>
 	  </tr>
  </table>
  </fieldset>
  
  <?php if($deposit_vouchertype!==''){?>
<fieldset>
	
	<legend> Deposit Voucher Type</legend>
 	<table width="100%"  border="0" cellspacing="2" >	 
 	<tr>
    <td>Voucher Type</td>
    <td><?php echo $deposit_vouchertype?></td>
    <td>DCR No.</td>
    <td><?php echo $dcrno; ?></td>   
    </tr>
 	<tr>
 	  <td>Date</td>
 	  <td><?php echo $deposit_voucherdate; ?></td>
 	  <td>Deposited By</td>
 	  <td><?php echo $depositedby; ?></td>
 	  </tr>
  </table>
  </fieldset>  
  <?php } ?>
  </td></tr>
  
  <tr>
  	<td>
    	<table width="100%" cellpadding="5" cellspacing="0" border="0">
        	<tr bgcolor="#fff">
    <td nowrap="nowrap">Total Credit Amt.</td>
    <td><?php echo $totalCR =array_sum($total_cr); ?></td>
    <td align="right" nowrap="nowrap">Total Debit Amt.</td>
    <td><?php echo $totalDR=array_sum($total_dr); ?></td>
    <td align="right" nowrap="nowrap">Difference Amt.</td>
    <td><?php echo $totalCR-$totalDR; ?></td>
  </tr>
  <tr bgcolor="#fff">
    <td> Narration</td>
    <td colspan="5"> 
	<?php echo $narration;?> </td>
    </tr>
  <tr bgcolor="#fff">
  
	
	   <td>Signature&nbsp;</td> <td> </td>
    <td colspan="3"><div align="right" >Authorised Signature</div>&nbsp;</td>
	  <td > </td>
  </tr>
        </table>    </td>
  </tr>
    </table></td>
    </tr>
</table>
			   
			   
			   <?php 
			}
			}
?>
<p align="center"><a href="javascript:window.close();"><input type="button" value="Close" /></a></p>