<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$br=$_SESSION['branch'];
include("opendb.php");

if(strlen($brcode)<=0)
{
    print "<script> alert('Invalid User'); document.location='inde.php' </script>";
    return;
}?>
<link rel="stylesheet" href="css/form.css" type="text/css" />
<html>
<body>
<form action='<?print $PHP_SELF?>' method='POST'><?
$sql="SELECT * FROM psnindia_gen4psnauto_psn_psneicherdb.journal2 where (left(against,3) = 'SBI' or left(against,3) = 'FBL'  or left(against,3) = 'FBL' or left(against,3) = 'FED') and against NOT LIKE '%|%'  and isnull(prftcntr) and dramt > 0 and partic ='PSN COCHIN HO' ";
//print $sql;
$result = mysqli_query($db,$sql);
print "<table border='1'><tr><th>Eicher Branches</th><th>Date</th><th>Bank</th><th>Narration</th><th>Cheq Dtls</th><th>Amount<th>Customer<th colspan='2'>Action</th>";
while($row=mysqli_fetch_array($result))
{
    $sqlbr="SELECT brname FROM psnindia_gen4psnauto_psn_psneicherdb.branch where brcode = '$row[brcode]' ";
    $resultbr = mysqli_query($db,$sqlbr);
    $rowbr=mysqli_fetch_array($resultbr);
    print "<tr><td>".$rowbr['brname']."</td><td>$row[date]</td><td>$row[against]</td><td>$row[narr]</td><td>$row[no]</td><td>$row[dramt]</td><td>$row[partic]</td>";
    print "<td><input type=button value='Update in Bank Receipt' onClick=ed1('$row[jvno]','$row[brcode]','PSNEICHER')>";
    print "<input type=button value='Reject & Cancel from Branch' onClick=ed2('$row[jvno]','$row[brcode]','PSNEICHER')></td>";    
}

$sql="SELECT * FROM psnindia_gen4psnauto_psn_zfdb.journal2 where (left(against,3) = 'SBI' or left(against,3) = 'FBL' or left(against,3) = 'FED') and against NOT LIKE '%|%' and  dramt > 0 and partic ='PSN COCHIN HO' ";
//echo $sql;
$result = mysqli_query($db,$sql);

print "<tr><th>ZF Branches</th><th>Date</th><th>Bank</th><th>Narration</th><th>Cheq Dtls</th><th>Amount<th>Customer<th colspan='2'>Action</th>";
while($row=mysqli_fetch_array($result))
{
    $sqlbr="SELECT brname FROM psnindia_gen4psnauto_psn_zfdb.branch where brcode = '$row[brcode]' ";
    $resultbr = mysqli_query($db,$sqlbr);
    $rowbr=mysqli_fetch_array($resultbr);
    print "<tr><td>".$rowbr['brname']."</td><td>$row[date]</td><td>$row[against]</td><td>$row[narr]</td><td>$row[no]</td><td>$row[dramt]</td><td>$row[partic]</td>";
    print "<td><input type=button value='Update in Bank Receipt' onClick=ed1('$row[jvno]','$row[brcode]','ZF')>";
    print "<input type=button value='Reject & Cancel from Branch' onClick=ed2('$row[jvno]','$row[brcode]','ZF')></td>";    
}

$sql="SELECT * FROM psnindia_gen4psnauto_psn_accessoriesdb2526.journal2 where (left(against,3) = 'SBI' or left(against,3) = 'FBL' or left(against,3) = 'FED')and against NOT LIKE '%|%'  and dramt > 0 and partic ='PSN COCHIN HO' ";
$result = mysqli_query($db,$sql);
print "<tr><th>BOSCH Branches</th><th>Date</th><th>Bank</th><th>Narration</th><th>Cheq Dtls</th><th>Amount<th>Customer<th colspan='2'>Action</th>";
while($row=mysqli_fetch_array($result))
{
    $sqlbr="SELECT brname FROM psnindia_gen4psnauto_psn_accessoriesdb2526.branch where brcode = '$row[brcode]' ";
    $resultbr = mysqli_query($db,$sqlbr);
    $rowbr=mysqli_fetch_array($resultbr);
    print "<tr><td>".$rowbr['brname']."</td><td>$row[date]</td><td>$row[against]</td><td>$row[narr]</td><td>$row[no]</td><td>$row[dramt]</td><td>$row[partic]</td>";
    print "<td><input type=button value='Update in Bank Receipt' onClick=ed1('$row[jvno]','$row[brcode]','BOSCH')>";
    print "<input type=button value='Reject & Cancel from Branch' onClick=ed2('$row[jvno]','$row[brcode]','BOSCH')></td>";    
}

?>
</body></html>

<script>
function ed1(jv,br,div)
{
   
    if (confirm('Do you want to update this entry ?'))
        document.location='multientry/brupdentry.php?jvno='+jv+'&br='+br+'&div='+div;
}
 
function ed2(jv,br,div)
{
    if (confirm('Do you want to Reject this entry ?'))
        document.location='multientry/brrejentry.php?jvno='+jv+'&br='+br+'&div='+div;
}
</script>