<?
session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../index.html'; </script>";
 return;
}
include("../opendb.php");
include("../test.php");
if($show)
{
?>

<script>
 function delfun(x)
 {
  if(confirm('Do you want to delete tds no '+x))
   document.location='deltdstrans.php?tdsno='+x;
 }
function edfun(x)
{
 document.location='edittdsjour.php?tdsno='+x;
}
</script>
<style>

	td,th,body{font-size:14;font-family:'arial narrow';letter-spacing:1}
</style>
<center>
<?
 $dfrom=$y1.'-'.$m1.'-'.$d1;
 $dto=$y2.'-'.$m2.'-'.$d2;

$brres=mysqli_query($db,"select * from branch where brcode='$brcode'");
$brrow=mysqli_fetch_array($brres);
?>
<table>
<TR><TD COLSPAN=2 ALIGN=CENTER><b> PSN  </b><BR>
	 <?print $brrow[braddr].",".$brrow[brcity].",<br><u> PH - ".$brrow[brphone]?></u>
TIN: <?print $brrow[tin]?>, CST: <?print $brrow[cstno]?>&nbsp;
</td></tr>
<tr><td COLSPAN=2 ALIGN=CENTER>
<?print "<h4><br>TDS REPORT - SECTION WISE</H4>";

print " From ".datetohtml($dfrom).' to '.datetohtml($dto);
?>
</td></tr>
</table>

<?

$invre=mysqli_query($db,"select distinct section from tdstrans where brcode='$brcode'");
while($invrow=mysqli_fetch_array($invre))
{
$engre=mysqli_query($db,"select distinct dcode from tdstrans where brcode='$brcode' and tdscoldt>='$dfrom' and tdscoldt<='$dto' order by dcode");
while($engrow=mysqli_fetch_array($engre))
{
$gtot1=0;
$ttx=0;
$tcess=0;
$ttot=0;
$ttrnd=0;
$sql="select tdsno,tdscoldt,cname,panno,dcode,section,amtpaid,taxrate,tdsamt,chequeno,bsrcode,taxdepodt,challanno,branch from tdstrans  where brcode='$brcode' and section='$invrow[0]' and tdscoldt>='$dfrom' and tdscoldt<='$dto' and dcode='$engrow[0]'";
$re=mysqli_query($db,$sql)or die(mysqli_error());
 if(mysqli_num_rows($re)>0)
{
print "\n<table border=0 cellspacing=1 cellpadding=4 bgcolor='lightsteelblue' width=100%>";
print "<th colspan=10><h3>Section $invrow[0] - : $engrow[0]</th></tr>";
print " <th>No <th>TDS Date ";
print "<th>Customer<th>PAN No.<th>Deductee Code <th>Section<th>Principal Amt<th>TaxRate<th>TDS Amt<th>ChqNo<th>BSRCode<th>Deposit Date<th>ChallanNo<th>Branch";
while($row=mysqli_fetch_array($re))
{
 print "\n<tr bgcolor=white><td>$row[tdsno]</td><td>".datetohtml($row[tdscoldt]);
 print "<td>".strtoupper($row[cname])."</td>";
  
 print "<td align=right>$row[panno]</td><td align=right>$row[dcode]</td>";
 print "<td align=right>$row[section]</td>";
 print "<td align=right>$row[amtpaid]</td>";
 print "<td align=right>$row[taxrate]</td>";
 print "<td align=right>$row[tdsamt]</td>";
 print "<td align=right>$row[chequeno]</td>";
 print "<td align=right>$row[bsrcode]</td>";
 print "<td align=right>".datetohtml($row[taxdepodt])."</td>";
 print "<td align=right>$row[challanno]</td>";
 print "<td align=right>$row[branch]</td>";
 print "\n<td><input type=button value='Edit' onClick=javascript:edfun('$row[tdsno]')></td>";
 print "\n<td><input type=button value='Del' onClick=javascript:delfun('$row[tdsno]')></td></tr>";

}
print "\n<tr><td colspan=3><center><b>Total</td><td align=right>".putComa($gtot1)."</td>";
print "<td align=right>".putComa($ttx)."</td>";
print "<td align=right>".putComa($tcess)."</td>";
print "<td align=right>".putComa($ttot)."</td>";
print "<td align=right>".putComa($ttrnd)."</td>";
print "</tr></table><br>";
}

}
 print "</center><p align=right> Printed by $user</p>";
}
return;


}// end if


?>




<link rel="stylesheet" href="../style.css" type="text/css" />
<style>
//	tr{background-color:white}
	th{background-color:steelblue;color:white}
	td{font-size:13}
.right{text-align:right};
</style>

<center>
<h3>TDS REPORT -2</H3>
<form action='<?Print $PHP_SELF?>' method='post'>
<table cellspacing=1 cellpadding=1 bgcolor='steelblue'>
<tr><td bgcolor='white' align=center>
<table class=noprint>
<tr><td>Date from </td><td>dd <input type=text name='d1' size=2 value='<?print date("d")?>'>
mm <input type=text name='m1' size=2 value='<?print date("m")?>'>
yy <input type=text name='y1' size=4 value='<?print date("Y")?>'></td></tr>

<tr><td align=right>to </td><td>dd <input type=text name='d2' size=2 value='<?print date("d")?>'>
mm <input type=text name='m2' size=2 value='<?print date("m")?>'>
yy <input type=text name='y2' size=4 value='<?print date("Y")?>'>
</td></tr>
<tr><td colspan=2 align=center bgcolor='lightsteelblue'><input type=submit value='Show' name='show'></td></tr>
</table>
</td></tr>
</table>
</form>

