<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$level=$_SESSION['level'];
if(strlen($brcode)<=0)
{
  print "<script> alert('Invalid User'); parent.document.location='../index.html' </script>";
  return;
}
include_once('top.php'); 
?>
<style>
 td{font-family:arial;font-size:14;color:black;}
 th{font-family:arial;font-size:14;color:black;}
 
 input
  {border-style:ridge;
   border-color:#22437f;
   
   height:25px;
   border-size=1;
   font-family:sans-serif;
   color:BLACK;
  }
</style>
<title>AMPL</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">

<?
header("Cache-Control: max-age=300, must-revalidate"); 
include("../opendb.php");
include("../test.php");

$y=$_REQUEST['y'];
$m=$_REQUEST['m'];
$d=$_REQUEST['d'];
$y1=$_REQUEST['y1'];
$m1=$_REQUEST['m1'];
$d1=$_REQUEST['d1'];

?>
<script>
function ed1(jv,d)
{
 if (confirm('Do you want to edit this entry?'))
  document.location='editjour_new.php?jvno='+jv+'&dt='+d;
}
 
function ed23(jv,d)
{
 if (confirm('Do you want to Delete this entry ?'))
  document.location='deljour_new.php?jvno='+jv+'&dt='+d;
}

function ed2(jv,d,dd1,mm1,yy1,dd2,mm2,yy2)
{
 if (confirm('Do you want to Delete this entry ?'))
  document.location='../accounts/deljour.php?jvno='+jv+'&dt='+d+'&dfd1='+dd1+'&dfm1='+mm1+'&dfy1='+yy1+'&dtd1='+dd2+'&dtm1='+mm2+'&dty1='+yy2;
}




</script>



<?
$df=$y.'-'.$m.'-'.$d;
$dt=$y1.'-'.$m1.'-'.$d1;
print "<font size=4>Day book from ".datetohtml($df)." to ".datetohtml($dt);
print "<hr style={background-color:green;color:green}>";

$re=mysqli_query($db,"select distinct jvno,date,type from journal2 where brcode='$brcode' and  date>='$df' and date<='$dt' group by jvno order by date")or die(mysqli_error($db));
print "<table bgcolor='ivory' border=0 cellspacing=3 cellpadding=1 width=100%> \n<th>Tr. No <th>Date <th>Particulars <th>Debit <th>Credit <th>Narration <th width=50>Type<th>Ref <th>No<th>Print";
$ed=0;
while($row=mysqli_fetch_array($re))
{
 $ed=0;
  $re2=mysqli_query($db,"select * from journal2 where jvno='$row[jvno]' and brcode='$brcode'") or die(mysqli_error($db));
  print "\n<tr bgcolor='silver'><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>&nbsp;</td><td>&nbsp;</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></tr>";
 if($jvrow[j_type]=='DB Note'||$jvrow[j_type]=='CR' || $jvrow[j_type]=='CP' ||$jvrow[j_type]=='BP' || $jvrow[j_type]=='BR' || $jvrow[j_type]=='JV')
    $ed='1';
/* else
   $ed='0';*/
 }

 if($ed==1 &&$level==5 && (strtoupper($user) =='JOY' || strtoupper($user) =='VALI' || strtoupper($user) =='RAMJITH') )
 print "<td colspan=8 align=right><input type=button value='Edit' onClick=ed1('$row[jvno]','$row[date]');></td><td><input type=button value='Del' onClick=ed2('$row[jvno]','$row[date]');></td></tr>";

     print "<tr><td colspan=9 bgcolor=silver></td></tr>";

}
echo "<a href=\"javascript:window.history.go(-1)\">GO BACK</a>";



