<?
session_start();
include_once('includes/top.php');
include_once('opendb.php');
include_once("test.php");
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
    print "<script> alert('Invalid Login'); parent.document.location='ind.php' </script>";
    return;
}


?>
<link rel="stylesheet" href="../style.css" type="text/css" />
<style>
body,td{font-family:arial narrow;font-size:14}
</style>
<center>

<form action='<?print $PHP_SELF?>' name='f1'>
<table border=1 width=450>
<tr><td>Enter Narration or chq no: or amount</td><td><input type=text name=sea size=20>
</td> <td>Branch</td><td><select name=br><option><? print $brcode;?></option><option>All</option></select>
</td><td colspan=2 align=center><input type=submit value="Show" name='show'></td></tr>
</table>
</form>

<?

$show=$_REQUEST['show'];
$sea=$_REQUEST['sea'];
$br=$_REQUEST['br'];

if($show)
{
print "<hr style={background-color:green;color:green}>";

if($br=='All')
{
 $re=mysqli_query($db,"select distinct jvno,date,type,brcode from journal2 where narr like'%$sea%'  group by jvno order by date")or die(mysqli_error($db));
   
}
else
{
$re=mysqli_query($db,"select distinct jvno,date,type,brcode from journal2 where narr like'%$sea%' and brcode='$br'  group by jvno order by date")or die(mysqli_error($db));
}
//print $r=("select distinct jvno,date,type,brcode from journal2 where narr like'%$sea%'  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";
$ed=0;
while($row=mysqli_fetch_array($re))
{
 $ed=0;
  
  $re2=mysqli_query($db,"select * from journal2 where jvno='$row[jvno]' and brcode='$row[brcode]'") or die(mysqli_error($db));
  //print $reee=("select * from journal2 where jvno='$row[jvno]' and brcode='$row[brcode]'") or die(mysqli_error($db));
  
  print "\n<tr bgcolor='silver'><td>$row[jvno]</td><td>".implode('-', array_reverse(explode('-', $row['date'])))."</td><td></td>";
  print "\n<td></td><td></td><td></td><td>$row[brcode]</td>";
 print "<td> </td><td></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><td>$row[brcode]</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']=='TDSJV')
    $ed='1';
/* else
   $ed='0';*/
 }
     print "<tr><td colspan=9 bgcolor=silver></td></tr>";

}
}
?>

