<?
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'];
$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;
$tbljv='gstrrev'.$brcode.$user;
mysql_query("drop table $tbljv");
mysql_query("create table $tbljv( select * from journal2 where brcode='$branch1' and date>='$df' and date<='$dt')");
print "<font size=4 color='white'>Day book from ".datetohtml($df)." to ".datetohtml($dt);

$rebr=mysql_query("select brcode from branch where brcode='$branch1' order by brcode");

while($rowbr=mysql_fetch_array($rebr))
{
/*$re=mysql_query("select distinct jvno,date,type,tr_no from $tbljv where brcode='$rowbr[0]' and  date>='$df' and date<='$dt' and partic in('BUSINESS PROMOTION ADVERTISEMENT','BUSINESS PROMOTION EXPENSE','CLEANING 
CHARGES',
'COUPON SCHEME','GENERATOR RUNNING EXPENSES','POOJA EXPENSES','PRINTING AND STATIONARY','PROFESSIONAL CHARGES','RENT, SERVICE TAX ON RENT A/C','REPAIRS AND MAINTAINENCE - BUILDING',
'REPAIRS AND MAINTENENCE - OTHERS',
'SALES COMMISSION',
'SALES PROMOTION EXPENSE',
'SECURITY CHARGES',
'SERVICE CHARGE EXPENSE',
'SERVICE CHARGE EXPENSE - ACCIDENT',
'SERVICE CHARGE EXPENSE - FC',
'SERVICE CHARGE EXPENSE - HD',
'SERVICE CHARGE EXPENSE - WTY',
'SERVICE PROMOTION CLAIM INCOME',
'SERVICE PROMOTION EXPENSE',
'STAFF SELECTION AND TRAINING',
'STAFF WELFARE',
'VAN CAMPAIGN EXPENSE',
'Vehicle Running Expense') group by jvno order by date")or die(mysql_error());*/

/*$re=mysql_query("select distinct jvno,date,type,tr_no from $tbljv where brcode='$rowbr[0]' and  date>='$df' and date<='$dt' and partic in('Handling Charges',
'OTHER CHARGES PAID',
'Other Charges',
'othr charges paid','PACKING MATERIAL A/C','RENT','SERVICE TAX ON RENT A/C') group by jvno order by date")or die(mysql_error());
*/
$re=mysql_query("select distinct jvno,date,type,tr_no from $tbljv where brcode='$rowbr[0]' and  date>='$df' and date<='$dt' and partic in('Input CGST Expense14.00%',
'Input CGST Expense2.50%',
'Input CGST Expense6.00%',
'Input CGST Expense9.00%',
'INPUT CGST OTHERS 14.00',
'INPUT CGST OTHERS 6.00',
'INPUT CGST OTHERS 9.00',
'INPUT CGST PURCHASE 14.00',
'Input CGST Purchase 2.50',
'INPUT CGST PURCHASE 6.00',
'INPUT CGST PURCHASE 9.00',
'INPUT GST CESS',
'Input IGST 18.00%',
'Input IGST 28.00%',
'INPUT IGST EXPENSE 5.00%',
'Input IGST Expense18.00%',
'Input IGST Expense28.00%',
'INPUT IGST OTHERS 18.00',
'INPUT IGST OTHERS 28.00',
'INPUT IGST PURCHASE 18.00',
'INPUT IGST PURCHASE 18.00',
'INPUT IGST PURCHASE 28.00',
'INPUT IGST PURCHASE 28.00',
'INPUT IGST STOCK TRANSFER IN 18.00',
'INPUT IGST STOCK TRANSFER IN 28.00',
'Input SGST Expense14.00%',
'Input SGST Expense2.50%',
'Input SGST Expense6.00%',
'Input SGST Expense9.00%',
'INPUT SGST OTHERS 14.00',
'INPUT SGST OTHERS 6.00',
'INPUT SGST OTHERS 9.00',
'INPUT SGST PURCHASE 14.00',
'Input SGST Purchase 2.50',
'INPUT SGST PURCHASE 6.00',
'INPUT SGST PURCHASE 9.00',
'INPUT TAX','IGST COLLECTED 18.00%','IGST COLLECTED 28.00%') group by jvno order by date")or die(mysql_error());

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>Branch";
$ed=0;
while($row=mysql_fetch_array($re))
{
 $ed=0;
  $re2=mysql_query("select * from $tbljv where jvno='$row[jvno]' and brcode='$rowbr[0]'") or die(mysql_error());
  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=mysql_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><td>$rowbr[0]</td></tr>"; 
       
 if($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]=='eich' || $jvrow[j_type]=='Warranty Spare Invoice' || $jvrow[j_type]=='JC Spare Invoice')
    $ed='1';
    
    if($jvrow[j_type]=='DA' || $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]=='GST Income')
    $ed='2';
    
/* else
   $ed='0';*/
 }

if($level>2)
{
 if($ed==3)
 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 ></td></tr>";
     
if($ed==4)
 print "<td colspan=8 align=right></td><td><input type=button value='Del' onClick=ed2('$row[jvno]','$row[date]');></td></tr>";

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

