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

include("../opendb.php");
include("../test.php");
?>

<link rel="stylesheet" href="../style.css" type="text/css" />
<style>
th{background-color:lightsteelblue;color:black}
//tr{background-color:white}
</style>
<center>

<?
if(isset($_POST['show']))
{
$brres=mysqli_query($db,"select * from branch where brcode='$brcode'");
$brrow=mysqli_fetch_array($brres);
?>
<table>
<TR><TD COLSPAN=2 ALIGN=CENTER><b> PSN AUTOMOTIVE P LTD </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>
</td></tr>
</table>
<?

$d1=$_REQUEST['d1'];
$m1=$_REQUEST['m1'];
$y1=$_REQUEST['y1'];

$d=$_REQUEST['d'];
$m=$_REQUEST['m'];
$y=$_REQUEST['y'];
 $dfrom=$y.'-'.$m.'-'.$d;
 $dto=$y1.'-'.$m1.'-'.$d1;
 $pstvl=$_REQUEST['pstvl'];
 
$sql1="select * from zwty_list where claimdte>='$dfrom' and claimdte<='$dto'";
 $re1=mysqli_query($db,$sql1)or die(mysqli_error($db));
print "<b>ZWTY_LIST from ".datetohtml($dfrom).' to '.datetohtml($dto). "- INTRASTATE";

print "<table border=0 cellspacing=1 cellpadding=4 bgcolor='lightsteelblue'>";
print "<th>ClaimDte<th>InternalClaimNo <th>ClaimNo <th>ClaimTyp<th>ClaimStatus<th>JobCardNumber   <th>Cus.Nme <th>ClaimAmt <th>ApprovedAmtWarranty <th>TDSAmt <th>ClaimStatus<th>AutoDeduction<th>StatusDate <th>PendingDays <th>SHQRemarks<th>DeductionRemarks<th>AccountingDocument";



   
 print "<tr bgcolor='white' onMouseOver=bgColor='silver'; onMouseOut=bgColor='white'>";

 while($row1=mysqli_fetch_array($re1))
 {
     
  
  $t1=0;
 $t2=0;
 $t3=0;
 $gtot=0;
 $gstp=$row1[0]*2;

 print  "<td>$row1[0]</td><td>$row1[1]</td><td>$row1[2]</td>";
 print  "<td>$row1[3]</td><td>$row1[4]</td>";
 print "<td>$row1[5]</td>";
 print "<td>$row1[6]</td>";
 print "<td>$row1[7]</td>";
 print "<td>$row1[8]</td>";
 print "<td>$row1[9]</td>";
  print  "<td>$row1[10]</td><td>$row1[11]</td><td>$row1[12]</td>";
 print  "<td>$row1[13]</td><td>$row1[14]</td>";
 print "<td>$row1[15]</td>";
 print "<td>$row1[16]</td>";
 print "<td>$row1[17]</td>";

 
 
 
print "</tr>";
 $t1+=$row[aprice];
 $t2+=$gstp1;
 $t3+=$row[sgstamt];
 $gtot+=$row[tot];


}

print "<tr bgcolor='white'><td colspan=6 align=right><b>Total</td>";
print "<td align=right><b>".putComa($t1)."</td>";
print "<td align=right><b>".putComa($t2)."</td>";
print "<td align=right><b>".putComa($t3)."</td>";
print "<td align=right><b>".putComa($gtot)."</td>";
print "<td align=right><b></td>";

print "</table><br>";
//*********************************
/*$sql1="select distinct pbillno, purno,suplier,entrydate,porderno,taxtype from sparepurchase where entrydate>='$dfrom' and entrydate<='$dto' and brcode='$brcode' and taxtype='cst' order by purno";
 $re1=mysqli_query($db,$sql1)or die(mysqli_error($db));
print "<b>Purchase Report from ".datetohtml($dfrom).' to '.datetohtml($dto). "- CST";
print "<table border=0 bgcolor='steelblue' cellspacing=1 cellpadding=3>";
print "<th>PNo <th>PBill No <th>Date <th>Supplier <th>Before Tax <th>Tax <th>Cess <th>Total ";

 while($row1=mysqli_fetch_array($re1))
 {
 $sql="select sum(supqty),sum(aprice) aprice, sum(hand) hand,sum(taxamt) tax, sum(cessamt) cessamt,sum(tot) tot from sparepurchase where entrydate between '$dfrom' and '$dto' and pbillno='$row1[pbillno]' and brcode='$brcode' and taxtype='cst' ";
 $re=mysqli_query($db,$sql) or die(mysqli_error($db));

while($row=mysqli_fetch_array($re))
{
 print "<tr bgcolor='white' onMouseOver=bgColor='silver'; onMouseOut=bgColor='white'>";
 print  "<td>$row1[purno]</td><td>$row1[pbillno]</td>";
 print "<td>".datetohtml($row1[entrydate])."</td> ";
 print "<td>$row[suplier]</td>";
 print "<td align=right bgcolor='ivory'>$row[aprice]</td><td align=right>$row[tax]</td>";
 print "<td align=right>$row[cessamt]</td><td align=right>$row[tot]</td>";
print "</tr>";
 $gtot+=$row[tot];
}
}
print "<tr><td colspan=7 align=right><b>Total</td><td align=right>".putComa($gtot)."</td>";

print "</table>";*/
return;
}
?>

<form action='<?print $PHP_SELF?>' name='f1' method='post'>
<table>
<tr><td bgcolor='steelblue' colspan=2><center><b><font color=white>ZWTY_LIST REPORT</td></tr>
<tr><td>Date From </td><td>dd<input type=text name='d' size=2 value='<?print date("d");?>'>
			mm<input type=text name='m' size=2 value='<?print date("m");?>'>
			yy<input type=text name='y' size=4 value='<?print date("Y");?>'>
</td></tr>
<tr><td>Date To </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>Sort BY</td><td><select name='pstvl'>
   <option value='All'>All</option> 
   <option value='All'>Plant</option> 


</select></td></tr>
<th colspan=2><INPUT TYPE=SUBMIT VALUE='SHOW' name='show'></td></tr>
</table>
</form>
<script>
function edfun(x,y)
{
 if(confirm('Do you want to edit P.O. No.'+x+' ?'))
  document.location='edpur.php?purno='+x+'&ttype='+y;
}
</script>


