<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$level=$_SESSION['level'];
//$jvno=$_REQUEST['jvno'];
$d=$_REQUEST['d'];
$m=$_REQUEST['m'];
$y=$_REQUEST['y'];
$d1=$_REQUEST['d1'];
$m1=$_REQUEST['m1'];
$y1=$_REQUEST['y1'];
$type=$_REQUEST['type'];
//$branch1=$_REQUEST['branch1'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Invalid Login'); parent.document.location='../inde.php' </script>";
 return;
}
include("../opendb.php");
include("../test.php");

?>
<script>
function ed1(jv,d)
{
 if (confirm('Do you want to edit this entry?'))
  document.location='multientry/editjour.php?jvno='+jv+'&dt='+d;
}
 
function ed2(jv,d)
{
 if (confirm('Do you want to Delete this entry ?'))
  document.location='../accounts/deljour.php?jvno='+jv+'&dt='+d;
}

</script>
<title>AMPL EICHER</title>
    <script type="text/javascript" src="../scripts/jquery-latest.js"></script>
	<link type="text/css" href="../includes/style1.css" rel="stylesheet" />
	<link type="text/css" href="../css/form.css" rel="stylesheet" />
    <script type="text/javascript">
        $(function() {
          if ($.browser.msie && $.browser.version.substr(0,1)<7)
          {
			$('li').has('ul').mouseover(function(){
				$(this).children('ul').show();
				}).mouseout(function(){
				$(this).children('ul').hide();
				})
          }
        });        
    </script>

<body background="../back_ground.jpg">

<?php include('top.php'); ?>
<table class="container"><tr><td>


<center>
<?
$df=$y.'-'.$m.'-'.$d;
$dt=$y1.'-'.$m1.'-'.$d1;
//print $df;

//print $dt;
$tbljv='gstrrevstk'.$brcode.$user;
//print $tbljv;
mysqli_query($db,"drop table if exists $tbljv") ;
//print "select * from journal2 where j_type in('Spare trans out','Spare trans in','Acs trans out','acs trans in') and date>='$df' and date<='$dt')";
mysqli_query($db,"create table if not exists  $tbljv( select * from journal2 where j_type in('Spare trans out','Spare trans in','Acs trans out','acs trans in','jv','Spare trans out agt','Spare trans in agt') and date>='$df' and date<='$dt')")or die(mysqli_error($db));
print "<font size=4 color='white'>Transaction Details from ".datetohtml($df)." to ".datetohtml($dt);

$rebr=mysqli_query($db,"select brcode,brname from branch   order by brcode")or die(mysqli_error($db));
print "<table  border=0 cellspacing=3 cellpadding=1 width=60% class='report'> \n<th>Tr. No <th>Date <th>Particulars <th>Debit <th>Credit <th>Narration <th width=50>Type<th>Ref <th>No<th>Branch";

while($rowbr=mysqli_fetch_array($rebr))
{

if($type=='OUT')
{
$re=mysqli_query($db,"select distinct jvno,date,type,tr_no from $tbljv where brcode='$rowbr[0]' and  date>='$df' and date<='$dt' and partic in('STOCK TRANSFER OUT ACCESSORIES',
'STOCK TRANSFER OUT',
'STOCK TRANSFER OUT IGST 28.00',
'STOCK TRANSFER OUT IGST 18.00') group by jvno order by date")or die(mysqli_error($db));
}
else
{
 $re=mysqli_query($db,"select distinct jvno,date,type,tr_no from $tbljv where brcode='$rowbr[0]' and  date>='$df' and date<='$dt' and partic in('STOCK TRANSFER IN IGST 28.00',
'STOCK TRANSFER IN IGST 18.00',
'STOCK TRANSFER IN ACCESSORIES','STOCK TRANSFER IN') group by jvno order by date")or die(mysqli_error($db));   
}
/*,

'STOCK TRANSFER OUT ACCESSORIES',
'STOCK TRANSFER OUT',
'STOCK TRANSFER OUT IGST 28.00',
'STOCK TRANSFER OUT IGST 18.00'

'STOCK TRANSFER IN IGST 28.00',
'STOCK TRANSFER IN IGST 18.00',
'STOCK TRANSFER IN ACCESSORIES','STOCK TRANSFER IN'
*/

while($row=mysqli_fetch_array($re))
{
 $ed=0;
  $re2=mysqli_query($db,"select * from $tbljv where jvno='$row[jvno]' and brcode='$rowbr[0]'") or die(mysqli_error($db));
  //print "\n<tr ><td>$row[jvno]</td><td>".datetohtml($row['date'])."</td><td></td>";
 // print "\n<td></td><td></td><td></td><td></td>";
// print "<td> <td></td></td><td><input type=button value='Print' onclick=window.open('prnvoucher.php?jvno=".$row[jvno]."')></td>";
    while($jvrow=mysqli_fetch_array($re2))
    {
        print "\n<tr><td>$row[jvno]</td><td>".datetohtml($row['date'])."</td><td>$jvrow[partic]</td>";
        print "<td align=right>".nozero($jvrow['dramt'])."</td>";
        print "<td align=right>".nozero($jvrow['cramt'])."</td><td>$jvrow[narr]</td><td>$jvrow[j_type]</td><td>$jvrow[against]</td><td>$jvrow[no]</td><td>$rowbr[1]</td></tr>"; 
       
 
 }


}
}
print"</table>";

?>

