<?php include "dbconfig.php"; 
$party_id=$_GET['party_id'];
					$date1=$_GET['date1'];
					$date2=$_GET['date2'];		
?>
<!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>
<style type="text/css">
<!--
.style2 {color: #FFFFFF; font-weight: bold; }
-->
</style><style>
body{
font-family:"Courier New", Courier, monospace;
}
</style>
</head>

<body>
<form name="rtop" action="repor_datet.php" enctype="multipart/form-data" method="get">
<table width="100%" border="2" cellspacing="2" cellpadding="2">
  <tr>
    <td><div align="center">
      Select Date Range 
      <input type="text" name="date1" value="<?php echo $date1; ?>" required placeholder='YYYY-MM-DD'   />
      -
      <input type="text" name="date2" value="<?php echo $date2; ?>" required  placeholder='YYYY-MM-DD'/>
    </div></td>
  </tr>
  <tr>
    <td><div align="center">
      <input type="submit" name="Submit" value="Search" />
    </div></td>
  </tr>
</table>
</form>
<?php
	 //$rf=date('Y-m-d');
$query = "SELECT * FROM voucher where paydate>='$date1' AND paydate<='$date2' 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="right"><a href="print_report_date.php?date1=<?php echo $date1; ?>&date2=<?php echo $date2; ?>&Submit=Search" target="_blank">Print</a></div>
<div align="center"></div>
<table width="100%" border="1" cellspacing="0" cellpadding="4">
  <tr>
    <td  bgcolor="#000000"><div align="center" class="style2">S.No.</div></td>
    <td  bgcolor="#000000"><div align="center" class="style2">Date</div></td>
    <td  bgcolor="#000000"><div align="center" class="style2">V.No</div></td>
    <td  bgcolor="#000000"><div align="center" class="style2">Party Name</div></td>
    <td  bgcolor="#000000"><div align="center" class="style2">Narration</div></td>
    <td  bgcolor="#000000"><div align="center" class="style2">Debit Amt</div></td>
    <td  bgcolor="#000000"><div align="center" class="style2">Credit Amt</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'];
	if($vpppayment_type=='Cheque'){
	echo $a_row['bank_name']; ?>/
    <?php echo $a_row['chequeno']; ?>/
    <?php echo $a_row['chequedate']; ?>/
    <?php echo $a_row['branch_name']; ?>/
    <?php }echo $a_row['payment_type']; ?>/
    
    <?php  echo $a_row['vtype']; ?>/
    <?php echo $a_row['remarks']; ?>/
    <?php echo $a_row['create_by']; ?>    </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;}
	if($debit_cheque!=''){ echo $debit_cheque;}
	 ?></div></td>
    <?php
	// $rf=date('Y-m-d');
$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;}
	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 bgcolor="#FF0000">&nbsp;</td>
    <td bgcolor="#FF0000">&nbsp;</td>
    <td bgcolor="#FF0000">&nbsp;</td>
    <td bgcolor="#FF0000" class="style2">&nbsp;</td>
    <td bgcolor="#FF0000" class="style2">&nbsp;</td>
    <td bgcolor="#FF0000" class="style2"><div align="right"><?php $dcct=$dca+$dch; echo $dcct;
?></div></td>
    <td bgcolor="#FF0000" class="style2"><div align="right"><?php $ccct=$cch+$cca; echo $ccct;  ?>
     </div></td>
  </tr>
</table>
<table width="400" border="2" cellspacing="0" cellpadding="4" align="center">
  <tr>
    <td width="207"><div align="left"><strong>G.Total [Credit]</strong></div></td>
    <td width="169"><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>
