<?php include "dbconfig.php"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Report</title>
</head>
<style>
body{
font-family:"Courier New", Courier, monospace;
}
td{border:1px #000000 solid; border-top:#000000 1px solid;
}
</style>
<body>

<?php
$party_id=$_GET['party_id'];
					$date1=$_GET['date1'];
					$date2=$_GET['date2'];		
	 //$rf=date('Y-m-d');
$query = "SELECT * FROM voucher where  paydate>='$date1' AND paydate<='$date2' and session='$session' and code='$code' order by id";
$numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);
$result = mysql_query($query) or die("Couldn't execute query");


?>
    
<div align="center"><br /> 
<strong>Statement of the account from</strong> <?php echo $date1; ?> <strong>till</strong> <?php echo $date2; ?><br />
<?php echo $a_rowup['address'];  ?><br/><?php echo $a_rowup['mobileno'];  ?><br />
</div>
<table width="100%" border="1" cellspacing="0" cellpadding="4">
  <tr>
    <td width="7%" >&nbsp;</td>
    <td width="6%" >&nbsp;</td>
    <td width="14%" >&nbsp;</td>
    <td width="15%" >&nbsp;</td>
    <td width="32%" >&nbsp;</td>
    <td colspan="2" ><div align="center" >Debit Amt</div></td>
    <td colspan="2" ><div align="center" >Credit Amt</div></td>
  </tr>
  <tr>
    <td ><div align="center" >S.No.</div></td>
    <td ><div align="center" >Date</div></td>
    <td ><div align="center" >Voucher No</div></td>
    <td ><div align="center" >Party Name</div></td>
    <td ><div align="center" >Narration</div></td>
    <td width="6%" ><div align="right">Cash</div></td>
    <td width="6%" ><div align="right">Cheque</div></td>
    <td width="4%" ><div align="right">Cash</div></td>
    <td width="10%" ><div align="right">Cheque</div></td>
  </tr>
  
   <?php 
$counter = 1;?>
  <?php
while ( $a_row = mysql_fetch_array( $result ) )
 {?>
  <tr>
    <td><?php echo $counter; ?></td>
    <td><?php echo $mdate=$a_row['paydate']; ?></td>
    <td><?php echo $a_row['vno']; ?></td>
    <td  ><?php 
	$party_id=$a_row['partyname'];
	$query66 = "SELECT * FROM party where id='$party_id' and session='$session' and code='$code'";
$numresults66=mysql_query($query66);
 $numrows66=mysql_num_rows($numresults66);
$result66 = mysql_query($query66) or die("Couldn't execute query");

$a_rowup = mysql_fetch_array( $result66 );
	
	?>
    
<div align="center">
<?php echo $a_rowup['name'];  ?> / <?php echo $a_rowup['id'];  ?></td>
    <td  ><?php 
	$vpppayment_type=$a_row['payment_type'];
	echo $a_row['payment_type'];
	if($vpppayment_type=='Cheque'){
	echo $a_row['bank_name']; ?>/
    <?php echo $a_row['branch_name']; ?>/
    <?php echo $a_row['chequeno']; ?>/
    <?php echo $a_row['chequedate']; ?>/
    
    <?php } ?>/
     <?php echo $a_row['create_by']; ?>
   
    <?php echo $a_row['remarks']; ?>/
       </td>
   
    <?php
	// $rf=date('Y-m-d');
	$idg=$a_row['id'];
$queryo = "SELECT * FROM voucher where partyname='$party_id'  and paydate='$mdate'and vtype='Debit' and id='$idg' and session='$session' and code='$code' ORDER BY vtype";
$numresultso=mysql_query($queryo);
 $numrowso=mysql_num_rows($numresultso);
$resulto = mysql_query($queryo) or die("Couldn't execute query");
$a_rowu = mysql_fetch_array( $resulto );
$debit_cash=$a_rowu['camount'];
$debit_cheque=$a_rowu['chequeamount'];
?>
    <td  ><div align="right">
      <?php if($debit_cash!=''){ echo $debit_cash;} ?>
    </div></td> <td  >      <div align="right">
	<?php 
	
	if($debit_cheque!=''){ echo $debit_cheque;}
	 ?></div></td>
    
    <?php
	// $rf=date('Y-m-d');
	$party_id=$a_row['partyname']; 
$queryop = "SELECT * FROM voucher where partyname='$party_id'  and paydate='$mdate' and vtype='Credit'and id='$idg' and session='$session' and code='$code' ORDER BY vtype";
$numresultsop=mysql_query($queryop);
 $numrowsop=mysql_num_rows($numresultsop);
$resultop = mysql_query($queryop) or die("Couldn't execute query");
$a_rowup = mysql_fetch_array( $resultop );
$credit_cash=$a_rowup['camount']; 
$credit_cheque=$a_rowup['chequeamount'];
?>
    <td ><div align="right">
      <?php if($credit_cash!=''){ echo $credit_cash;} ?>
    </div></td>
    <td ><div align="right"><?php 
	
	if($credit_cheque!=''){ echo $credit_cheque;}
	 ?></div></td>
  </tr>
  <?php $counter++;
  $dca+=$a_rowu['camount'];
  $dch+=$a_rowu['chequeamount'];
  $cca+=$a_rowup['camount'];
  $cch+=$a_rowup['chequeamount'];
  
  }?>
  
  <tr>
    <td >&nbsp;</td>
    <td >&nbsp;</td>
    <td >&nbsp;</td>
    <td  >&nbsp;</td>
    <td  >&nbsp;</td>
    <td  ><div align="right"><?php echo $dca; ?></div></td>
    <td  ><div align="right"><?php echo $dch;
?></div></td>
    <td  ><div align="right"><?php echo $cca;  ?></div></td>
    <td  ><div align="right"><?php echo $cch; ?>
     </div></td>
  </tr>
</table>
<table width="400" border="2" cellspacing="0" cellpadding="4" align="center">
  <tr>
    <td width="189"><div align="left"><strong>G.Total [Credit]</strong></div></td>
    <td width="187"><div align="right">
    <?php  $Ctt=$cca+$cch; echo $Ctt; ?>
    </div></td>
  </tr>
  <tr>
    <td><div align="left"><strong>G.Total [Debit]</strong></div></td>
    <td><div align="right">
      <?php 
	
 $Gtt=$dca+$dch;
 echo $Gtt;
	?>
    </div></td>
  </tr>
  <tr>
    <td><div align="left"><strong>Balance</strong></div></td>
    <td><div align="right"><?php $fgtotal=$Ctt-$Gtt; echo $fgtotal; ?></div></td>
  </tr>
</table>

</body>
</html>
