<head>
  
  
  
<?php include("../../include/dbconnect.php");

  foreach($_POST as $p=>$t)
  {
     $_POST[$p] = trim($t);
  }

  $myCompany = $_POST['Company'];

  foreach($_POST as $p=>$t)
  {
     $_POST[$p] = trim($t);
  }

  $myBranch = $_POST['Branch'];
  


foreach($_POST as $q=>$r)
{
	$_POST[$q] = $r;
}
$myDate = $_POST['Date'];


?>
<SCRIPT LANGUAGE="JavaScript" src="../../include/CalendarPopup.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
var cal = new CalendarPopup();
</SCRIPT>
<title>Receipt</title>

<body topmargin="0" style=" background:url(../../images/body_bg.jpg) repeat-x; font-family:Arial, Helvetica, sans-serif; font-size:12px;">
<center> 
<table border=0 cellpadding=3 cellspacing=4 width="640" bgcolor="#E6E6FF">
  <tr> 
    <td  colspan="100%" style="background:#BDE09E"><b><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">Journal Printing</font></b></td></tr>


<form name='myForm01' method='POST' action='<?=$_SERVER['PHP_SELF']?>'>







    <tr>    
      <td height="31" align="right" ><b><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif">Select Date</font></b></td>
    <td  >
	
	<?
	$result = mysqli_query($conn,"select account_year,start_date,end_date,compcode,code from branches ") or die(mysqli_error());
	$row = mysqli_fetch_row($result);
	$account_year = $row[0];
	$compcode = $row[3];
	$branch = $row[4];
	

$sBuyQuery = mysqli_query($conn,"SELECT distinct date from ledger where account_year = '$account_year' and compcode = '$compcode' and branch_code = '$branch' and amttype ='J'   order by date desc ") or die(mysqli_error());



?>
          <select name='Date' onChange="javascript:submit();">
            <?
				echo "<option selected value=\0\">Date";
				while($row = mysqli_fetch_row($sBuyQuery))
				{
					$dt = british($row[0]);
					if(isset($myDate) && preg_match("/" . preg_quote($myDate, '/') . "/", $row[0]))
					{
						echo "<option selected value=\"$row[0]\">$dt";
					}
					else{
						echo "<option value=\"$row[0]\">$dt";
					}
				}
?>
        </select></td>
		
    </tr>




</form>
<form name='myform2' method='POST' action='jvprint.php?compcode=<?=$myCompany?>&branch=<?=$myBranch?>&date=<?=$myDate?>'  target="_blank">


    <tr>
      <td height="31" align="right"  ><b><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif">Select Transactions</font></b></td>
    <td colspan="2"  ><?

	$result = mysqli_query($conn,"select account_year,start_date,end_date,compcode,code from branches  ") or die(mysqli_error());
	$row = mysqli_fetch_row($result);
	$account_year = $row[0];
	$compcode = $row[3];
	$branch = $row[4];
	?>
<input type="hidden" name="compcode" value="<?=$compcode?>">
<input type="hidden" name="branch" value="<?=$branch?>">
<input type="hidden" name="date" value="<?=$myDate?>">	
<?
$myresult = mysqli_query($conn,"SELECT distinct trans_id from ledger where account_year = '$account_year' and compcode = '$compcode' and branch_code = '$branch' and amttype ='J' and date = '$myDate'  order by date desc ") or die(mysqli_error());



?>
          <select name='trans_id[]' multiple size="5">
            <?
				while($row = mysqli_fetch_row($myresult))
				{
				
					$tresult = mysqli_query($conn,"SELECT sum(dbamt) from ledger where account_year = '$account_year' and compcode = '$compcode' and branch_code = '$branch' and amttype ='J' and trans_id = '$row[0]' and date = '$myDate' order by date desc ") or die(mysqli_error());				
					$trow = mysqli_fetch_row($tresult);
						$dt = 'Trans_id:&nbsp;'.$row[0].'::&nbsp;Amount:&nbsp;Rs.&nbsp;'.$trow[0];					
						echo "<option  value=\"$row[0]\">$dt";
				}
?>
        </select></td>
		
    </tr>







  <table cellpading=0 cellspacing=10 width= 50>
    <tr> 
      <td> <blockquote> <input type =submit name="submit" value = "Submit" ></blockquote></td>
  </table>

    </table>

</form>
<font size=1> 
<br><br><font size=1><center><a href= "javascript:window.close();">Close Window</a></center></font>
</font> 

