<?
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'];
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,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>
<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 "<font size=4 color='black'>Day book from ".datetohtml($df)." to ".datetohtml($dt);
$tbldb="dbookbr".$user.$brcode;
mysqli_query($db,"drop table $tbldb");
mysqli_query($db,"CREATE TABLE $tbldb (select * from journal2 where brcode='$brcode' and  date>='$df' and date<='$dt' )");

$re=mysqli_query($db,"select distinct jvno,date,type,tr_no from $tbldb where brcode='$brcode' and  date>='$df' and date<='$dt' group by jvno order by date")or die(mysqli_error($db));
print "<table  border=0 cellspacing=3 cellpadding=1 width=100% 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>Print";
$ed=0;
while($row=mysqli_fetch_array($re))
{
 $ed=0;
 
  $re2=mysqli_query($db,"select * from $tbldb where jvno='$row[jvno]' and brcode='$brcode'") 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>&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'|| $jvrow[j_type]=='Spare Pur' || $jvrow[j_type]=='JC Spare Invoice' || $jvrow[j_type]=='Warranty Spare Invoice' || $jvrow[j_type]=='Spare Invoice'|| $jvrow[j_type]=='Spare Invoice Other'|| $jvrow[j_type]=='Warranty Invoice GST'|| $jvrow[j_type]=='GST Expense1')
    $ed='1';
    
    if($jvrow[j_type]=='CR NOTE'||$jvrow[j_type]=='DB Note'|| $jvrow[j_type]=='Spare Pur' || $jvrow[j_type]=='JC Spare Invoice'|| $jvrow[j_type]=='Spare Invoice'|| $jvrow[j_type]=='Warranty Invoice GST'|| $jvrow[j_type]=='GST Expense'|| $jvrow[j_type]=='eich'||$jvrow[j_type]=='GST Income'||$jvrow[j_type]=='Spare sale ret')
    $ed='2';
    
/* else
   $ed='0';*/
 }
 
if($level==4)

{
 $dt=$row[date];
 $sq="select to_days(curdate())-to_days('$dt')";
$dtre=mysqli_query($db,$sq)or die(mysqli_error($db));
$dtrow=mysqli_fetch_row($dtre);


if($dtrow[0]<4 )
{

 if($ed==1)
  print "<td colspan=8 align=right><input type=button value='Edit' onClick=ed1('$row[jvno]','$row[date]');></td><td></td></tr>";

     print "<tr><td colspan=9 ></td></tr>";
}


if($ed==2)
 //print "<td colspan=8 align=right></td><td><input type=button value='Del' onClick=ed2('$row[jvno]','$row[date]','$d','$m','$y','$d1','$m1','$y1');></td></tr>";

     print "<tr><td colspan=9 ></td></tr>";
}
if($level==5)

{


 if($ed==1)
  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]','$d','$m','$y','$d1','$m1','$y1');></td></tr>";

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



if($ed==2)
 print "<td colspan=8 align=right></td><td><input type=button value='Del' onClick=ed2('$row[jvno]','$row[date]','$d','$m','$y','$d1','$m1','$y1');></td></tr>";

     print "<tr><td colspan=9 ></td></tr>";
}
}


?>

