<? session_start();
$brcode = $_SESSION['brcode'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}

include("../opendb.php");
include("../test.php");
?>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;font-size:13}
th{background-color:c1d7bb;font-size:13}
.mnu{margin-left:5}
</style>
<center>
<form action='<?print $PHP_SELF?>'>
<table>
<th colspan=2>Search by text in Journal</th>
<tr><td> Enter Text </td><td><input type=text name='ch' size='40' value='<?print $ch?>'></td></tr>
<th colspan=2><input type=submit value='Search' name='sea'></th>
</table>
</form>
<?
$sea = $_REQUEST['sea'];
$ch = $_REQUEST['ch'];
if($sea)
{
    if(strlen($ch)>0)
    {
        print "<table bgcolor='lightsteelblue' cellpadding='1' cellspacing='1'><tr><td bgcolor='#ffffff'>";
        print "<table>";
        print "<tr><td colspan='10' bgcolor='lightsteelblue' align='center'>Journal Details</td></tr><tr>";
        print "<th>Division & Branch<th>Date<th>JVNO<th>Dramt<th>Cramt<th>Ledger<th>Narration<th>Against<th>No<th>TR No.</tr>";
        $sql=mysqli_query($db,"select * from psnindia_gen4psnauto_psn_psndb.journal2 where narr LIKE '%$ch%' or against LIKE '%$ch%' or no LIKE '%$ch%' or tr_no LIKE '%$ch%'");
        while($row=mysqli_fetch_array($sql))
        {
            print "<tr><td>PSN HO</td><td>".datetohtml($row['date'])."</td><td>$row[jvno]</td><td align='right'>$row[dramt]</td><td align='right'>$row[cramt]</td><td>$row[partic]</td><td>$row[narr]</td><td align='center'>$row[against]</td><td align='center'>$row[no]</td><td align='center'>$row[tr_no]</td>";
        
        }
        $sql=mysqli_query($db,"select * from psnindia_gen4psnauto_psn_zfdb.journal2 where narr LIKE '%$ch%' or against LIKE '%$ch%' or no LIKE '%$ch%' or tr_no LIKE '%$ch%'");
        while($row=mysqli_fetch_array($sql))
        {
            $sql1=mysqli_query($db,"select brname from psnindia_gen4psnauto_psn_zfdb.branch where brcode = '$row[brcode]'");
            $brrow=mysqli_fetch_array($sql1);
            
            print "<tr><td>ZF-".$brrow[0]."</td><td>".datetohtml($row['date'])."</td><td>$row[jvno]</td><td align='right'>$row[dramt]</td><td align='right'>$row[cramt]</td><td>$row[partic]</td><td>$row[narr]</td><td align='center'>$row[against]</td><td align='center'>$row[no]</td><td align='center'>$row[tr_no]</td>";
        }
        $sql=mysqli_query($db,"select * from psnindia_gen4psnauto_psn_accessoriesdb2526.journal2 where narr LIKE '%$ch%' or against LIKE '%$ch%' or no LIKE '%$ch%' or tr_no LIKE '%$ch%'");
        while($row=mysqli_fetch_array($sql))
        {
            $sql1=mysqli_query($db,"select brname from psnindia_gen4psnauto_psn_accessoriesdb2526.branch where brcode = '$row[brcode]'");
            $brrow=mysqli_fetch_array($sql1);
            
            print "<tr><td>BOSCH-".$brrow[0]."</td><td>".datetohtml($row['date'])."</td><td>$row[jvno]</td><td align='right'>$row[dramt]</td><td align='right'>$row[cramt]</td><td>$row[partic]</td><td>$row[narr]</td><td align='center'>$row[against]</td><td align='center'>$row[no]</td><td align='center'>$row[tr_no]</td>";
        }
        $sql=mysqli_query($db,"select * from psnindia_gen4psnauto_psn_psneicherdb.journal2 where narr LIKE '%$ch%' or against LIKE '%$ch%' or no LIKE '%$ch%' or tr_no LIKE '%$ch%'");
        while($row=mysqli_fetch_array($sql))
        {
            $sql1=mysqli_query($db,"select brname from psnindia_gen4psnauto_psn_psneicherdb.branch where brcode = '$row[brcode]'");
            $brrow=mysqli_fetch_array($sql1);
            
            print "<tr><td>PSNEICHER-".$brrow[0]."</td><td>".datetohtml($row['date'])."</td><td>$row[jvno]</td><td align='right'>$row[dramt]</td><td align='right'>$row[cramt]</td><td>$row[partic]</td><td>$row[narr]</td><td align='center'>$row[against]</td><td align='center'>$row[no]</td><td align='center'>$row[tr_no]</td>";
        }
        print "</tr></table>";
        print "</td></tr></table><br>";
    }
}
?>
