<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
  print "<script> alert('Invalid User'); parent.document.location='ind.php' </script>";
  return;
}
include("../opendb.php");
include("../test.php");
?>
<link type="text/css" href="../css/form.css" rel="stylesheet" />	

<style>
body,td 
{
    margin: 0 auto;
	font-family: Arial, Verdana, Sans-Serif;
	font-size: 0.8em;
}

 th{font-family:verdana;font-size:11;color:white;background-color:#5b5858}
 body{background-color:ivory}
</style>
<?
$print=$_REQUEST['print'];
if($print)
{
 $y=$_REQUEST['y'];
$m=$_REQUEST['m'];
$d=$_REQUEST['d'];
$y1=$_REQUEST['y1'];
$m1=$_REQUEST['m1'];
$d1=$_REQUEST['d1'];
$df=$y.'-'.$m.'-'.$d;
$dto=$y1.'-'.$m1.'-'.$d1;
print "<script> window.open('prnbreco.php?df=$df&dto=$dto&bnk=$bnk'); </script>";
return;
}
$show=$_REQUEST['show'];
$df=$_REQUEST['df'];
if($show||$df)
{
if(!$df)
{
     $y=$_REQUEST['y'];
$m=$_REQUEST['m'];
$d=$_REQUEST['d'];
$y1=$_REQUEST['y1'];
$m1=$_REQUEST['m1'];
$d1=$_REQUEST['d1'];
$df=$y.'-'.$m.'-'.$d;
$dto=$y1.'-'.$m1.'-'.$d1;

}
$bnk=$_REQUEST['bnk'];
 $res=mysqli_query($db,"select * from journal2 where partic='$bnk' and brcode='$brcode' and date>='$df' and date<='$dto' order by date")or die(mysqli_error());

print "<center><table cellspacing=1 cellpadding=3><th colspan=7>BANK RECONCILITATION OF <br>$bnk <br>From ".implode('-', array_reverse(explode('-', $df))).' to '.implode('-', array_reverse(explode('-', $dto)))."<tr>";
print "<th>No. <th>Date <th>Narration<th>Amount<th>Rec. Date<th>Rec";
$i=1;
while($drow=mysqli_fetch_array($res))
{
 print "\n<tr bgColor='#E7E7E7' onMouseOver=bgColor='aliceblue' onMouseOut=bgColor='#e7e7e7'>";
 print "\n<form action='updbreco.php' method='post'>";
 print "\n<input type=hidden name='jvno' value='$drow[jvno]'>";
 print "\n<input type=hidden name='bdate' value='$drow[date]'>";
 print "\n<input type=hidden name='bank' value='$bnk'>";
 print "\n<input type=hidden name='df' value='$df'>";
 print "\n<input type=hidden name='dto' value='$dto'>";
 print "\n<td>".$i++."</td><td>".implode('-', array_reverse(explode('-', $drow['date'])))."</td><td>$drow[narr]<br>Against: $drow[against]: $drow[no]</td>";
 print "<td align=right>".putComa($drow['dramt']+$drow['cramt'])."</td>";
 print "<td width=125>";
 $sq="select recdate from breco where jvno='$drow[jvno]' and bank='$bnk' and brcode='$brcode'";
$recres=mysqli_query($db,$sq);
 $recdt=mysqli_fetch_array($recres);
  $spdate=explode('-',$recdt[0]);

?>
d <input type=text name=rd size=1 value='<?print $spdate[2]?>'>
m <input type=text name=rm size=1 value='<?print $spdate[1]?>'>
y <input type=text name=ry  value='<?print $spdate[0]?>' size=3></td>
<td><input type=submit value='Upd' name='upd'></td>
</form>
</tr>
<?
}

return;
}// end if show

?>
<form action='<?print $PHP_SELF?>'>
<br><br><br><br>
<?
print "<center><table> <th colspan=5>BANK RECONCILIATION</th>";
print "<tr><td>Bank </td><td><select name='bnk'>";
$bre=mysqli_query($db,"select * from ledger where grp like '%bank%' and brcode='$brcode' order by led")or die('err'.mysqli_error());
while($row=mysqli_fetch_array($bre))
{
 print "<option>$row[led]</option>";
}
?>
</select></td></tr>
<tr><td>From</td><td>
<input type=text name=d value='<?print date('d')?>' size=1>
<input type=text name=m value='<?print date('m')?>' size=1>
<input type=text name=y value='<?print date('Y')?>' size=3>
</td></tr>
<tr><td>To</td><td>

<input type=text name=d1 value='<?print date('d')?>' size=1>
<input type=text name=m1 value='<?print date('m')?>' size=1>
<input type=text name=y1 value='<?print date('Y')?>' size=3>
</td></tr>
<tr><th colspan=2 align=center><input type=submit value="Show" name='show'>
<input type=submit value="Print" name='print'>
</td></tr>
</form>

