<?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');
include('Fun_num_to_words.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'];
			$fromtitle=$s->getField('voucher_master','VoucherType',$_REQUEST['VPrefix'],'GroupName');
	 ?>
<script type="text/javascript" language="javascript">
function toggle_visibility(id) {
	
       var e = document.getElementById("print");
	       e.style.display = 'none';
		       //alert(e.style.display);
			   window.print();
    }
</script>
<link rel="stylesheet" href="../jjrs_projects/css/purchase_requision_print.css">
<title><?php echo $fromtitle;?></title>
<div class="body_contain">
<div class="tab_div">
<h1><center><?php echo $_SESSION['CompanyRecord']['CompanyName'].'('.$s->getField('locations','loccode',$myrow['Branch'],'locationname').')';?></center></h1>  
<p align="center" style="font-size:14px"><strong>
<?php echo $fromtitle;?></strong></p>
<table width="100%" cellpadding="3" cellspacing="0" border="0">
 <tr>
    <td  width="51%">No.:<?php echo $voucher_no;?></td>
	<td  colspan="2" width="49%"><div align="right">Date:<?php echo ConvertSQLDate($Dates);?></div></td>
</tr>
</table>
 <table width="100%" border="0" cellspacing="0" cellpadding="3" style="border-collapse:collapse;border:#000000 solid 1px">

<tr style="background-color:#B7B7B7 ">
    <td style="border-right:#000000 solid 1px;"><strong>Particulars</strong></td>
	<td style="border-right:#000000 solid 1px;"><strong>Debit</strong></td>
	<td style="border-right:#000000 solid 1px;"><strong>Credit</strong></td>
</tr>
<?php 
$total_cr='';
$total_cr1='';
//$total_dr=array();
$query1="select *  from account_book_details where account_bookid ='".$myrow['id']."'";
$result1=DB_query($query1,$db);
$i=0;
while($myrow1=DB_fetch_array($result1))
{?>
  	  <tr bgcolor="#ffffff" >
  	    <td style="border-right:#000000 solid 1px;"><?php  //echo $i;?> <?php  
		if($myrow1['amount_type']=='DR')
		{
		echo 'To:'.$s->getField('accountledger','AccountsID',$myrow1['ledgerid'],'AccountName');
		}
		echo $s->getField('accountledger','AccountsID',$myrow1['ledgerid'],'AccountName');
		?></td>
  	    <td style="border-right:#000000 solid 1px;"> <?php  
		if($myrow1['amount_type']=='CR')
		{
		echo  $myrow1['amount'];$total_cr[]=$myrow1['amount'];
		}?></td>
		<td style="border-right:#000000 solid 1px;"> <?php  
		if($myrow1['amount_type']=='DR')
		{
		echo  $myrow1['amount'];$total_cr1[]=$myrow1['amount'];
		}?></td>
  	    </tr>
		<?php $i++;}
		  if($i=='0'){
			$i=0;
		}
		else
		$i=$i;
		for($i;$i<15;$i++)
		{	
		 ?>
  
  <tr>
    <td style="border-right:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px;">&nbsp;</td>
  </tr>
<?php }
$ArrSum1=array_sum($total_cr1);
$ArrSum=array_sum($total_cr)
?>
<tr>
    <td bgcolor="#B7B7B7" style="border-right:#000000 solid 1px;"><strong>Ammount (in Words) :<?php echo convert_number_to_words($ArrSum); ?></strong></td>
    <td bgcolor="#B7B7B7" style="border-right:#000000 solid 1px;"> <strong>&#x20B9; <?php echo $ArrSum1; ?></strong></td>
	<td bgcolor="#B7B7B7"> <strong>&#x20B9; <?php echo $ArrSum; ?></strong></td>
</tr>
  
  <tr>
    <td height="40"><strong>Receiver's Signature : </strong></td>
    <td colspan="2"><strong>Authorised Signatory :</strong> </td>
  </tr>
</table>
<?php 
	}
}
?>
</div>
</div>
<p align="center"><a href="#" onClick="toggle_visibility();"><input id="print" type="button" value="Print" /></a></p>