<?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;
	 
	

   //echo '<link href="'.$rootpath. '/css/'. $_SESSION['Theme'] .'/default.css" rel="stylesheet" type="text/css" />';
   ?>
   <link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
   <?php $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'];
			  $Pay_against=$myrow['payment_against'];
			$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'];
			$banks_checkdate=ConvertSQLDate($myrow['banks_checkdate']);
			$banks_receivedfrom=ConvertSQLDate($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'];

	 ?>

			   <h1><?php echo $_SESSION['CompanyRecord']['CompanyName']?>
			   
			   <?php echo $fromtitle=  $s->getField('voucher_master','VoucherType',$_REQUEST['VPrefix'],'GroupName');?></h1>
 <table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr class="row1">
    <td width="23%" align="right">Branch -</td>
    <td width="29%"><?php echo $s->getField('locations','loccode',$myrow['Branch'],'locationname'); ?></td>
    <td width="21%" align="right">Voucher No. -</td>
    <td><?php echo $voucher_no;?> </td>
  </tr>
  <tr class="row1">
    <td align="right">Date -</td>
    <td><?php echo $Dates; ?></td>
    <td align="right">Payment Against -</td>
    <td><?php echo $Pay_against;?></td>
	</tr>
	
<?php  if($BillBookType=='JV'){?>
	 <tr class="row1">
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td align="right">Document</td>
    <td><input name="document_type" type="text"   value="<?php echo $document_type;?>" /></td>
	</tr>
	<?php }?>
</table>
<br>
	<table width="100%" border="0" cellspacing="0" cellpadding="3" class="thborder">
  <tr>
	    <th>Ledger Name</th>
	    <th width="15%">Amount</th>
	    <th width="15%">Credit</th>
	    <th width="15%">Debit</th>
 	    <th width="15%">Currency</th>
  </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>
  	    <td><?php  //echo $i;?> <?php  echo $s->getField('accountledger','AccountsID',$myrow1['ledgerid'],'AccountName');;?></td>
  	    <td><?php  echo  $myrow1['amount'];?></td>
  	    <td><?php
		echo ($myrow1['amount_type']=='CR'? $myrow1['amount']:"0");
		$total_cr[]=($myrow1['amount_type']=='CR'? $myrow1['amount']:"0");		
		?></td>
  	   <td><?php  echo  ( $myrow1['amount_type']=='DR'? $myrow1['amount']:"0");
		 $total_dr[]=($myrow1['amount_type']=='DR'? $myrow1['amount']:"0");
		 ?></td>
  	   <td><?php  echo $s->getField('currency_master','id',$myrow1['currency'],'abbreviation');?></td>	    
  	    </tr>
		<?php 
}		
		?>  	   
	  </table>

   <?php if($_REQUEST['VPrefix']==4)
  { ?>
  <br>
  <fieldset>
	<legend> Bank CheckDetails</legend>
 	<table width="100%" cellpadding="3" cellspacing="0" border="0">	 	
 	<tr class="row1">
	   <td width="13%" align="right">Transation Type -</td>
    <td width="20%"><?php echo $transation_type; ?></td>
    <td width="13%" align="right">Instrument No. -</td>
    <td width="20%"><?php echo $banks_checkno; ?></td>
    <td width="13%" align="right">Instrument Date -</td>
    <td><?php echo ($banks_checkdate!=''?$banks_checkdate:''); ?></td>   
  </tr> 
  </table>
  </fieldset>
  <?php } ?>
  
  <?php if($deposit_vouchertype!==''){?>
  <br>
<fieldset>
	
	<legend> Deposit Voucher Type</legend>
 	<table width="100%"  border="0" cellspacing="0" cellpadding="3">	 
 	<tr class="row1">
    <td width="13%" align="right">Voucher Type</td>
    <td width="35%"><?php echo $deposit_vouchertype?></td>
    <td width="13%" align="right">DCR No.</td>
    <td><?php echo $dcrno; ?></td>   
  </tr>
 	<tr class="row1">
 	  <td align="right">Date</td>
 	  <td><?php echo $deposit_voucherdate; ?></td>
 	  <td align="right">Deposited By</td>
 	  <td><?php echo $depositedby; ?></td>
 	</tr>
  </table>
  </fieldset>  
  <?php } ?>
  
  <br>
  <table width="100%" cellpadding="5" cellspacing="0" border="0">
    <tr class="row1">
      <td width="13%" align="right">Total Credit Amt. -</td>
      <td width="20%"><?php echo $totalCR =array_sum($total_cr); ?></td>
      <td width="13%" align="right">Total Debit Amt. -</td>
      <td width="20%"><?php echo $totalDR=array_sum($total_dr); ?></td>
      <td width="13%" align="right">Difference Amt. -</td>
      <td><?php echo $totalCR-$totalDR; ?></td>
    </tr>
    <tr class="row1">
      <td align="right">Narration -</td>
      <td colspan="5"><?php echo $narration;?></td>
      </tr>
    <tr class="row1">
  	   <td align="center" valign="bottom" height="60">Signature</td>
       <td colspan="4"></td>
      <td align="center" valign="bottom">Authorised Signature</td>
    </tr>
  </table>
			   
			   
			   <?php 
			}
			}
?>

</div>
</div>


