<?
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");
if(isset($_POST['show']))
{
?>
<style>
td,th,body{font-size:14;font-family:'arial narrow';letter-spacing:1}
</style>
<center>
<?
$d1=$_REQUEST['d1'];
$m1=$_REQUEST['m1'];
$y1=$_REQUEST['y1'];

$d2=$_REQUEST['d2'];
$m2=$_REQUEST['m2'];
$y2=$_REQUEST['y2'];
 $dfrom=$y1.'-'.$m1.'-'.$d1;
 $dto=$y2.'-'.$m2.'-'.$d2;

$ordby=$_REQUEST['ordby'];

$brres=mysqli_query($db,"select brcode from branch where brcode='$brcode'");
while($brrow=mysqli_fetch_array($brres))
{

   /* if($ordby=='Invoice')
$re=mysqli_query($db,"select invno,invdate,customer,sum(aprice) aprice,sum(taxamt)txamt,sum(cessamt)cess ,sum(tot)tot, vatorcst,invtype,msno from spareinvoice  where brcode='$brcode' and invtype='$invrow[0]' and invdate>='$dfrom' and invdate<='$dto'  group by invno")or die('err'.mysqli_error($db));
    else*/
$re=mysqli_query($db,"select distinct(msno) from warspareinvoice  where brcode='$brrow[0]' and partcode='service_reference' ")or die('err'.mysqli_error($db));    

while($row=mysqli_fetch_array($re))
{
    $sql2="select * from warspareinvoice  where brcode='$brrow[0]' and msno='$row[0]' and partcode='service_reference' ";
   // print "$sql2<br>";
    $re2=mysqli_query($db,$sql2)or die('err'.mysqli_error($db));    
while($row2=mysqli_fetch_array($re2))
{
 $sql3="select * from warspareinvoicepass  where brcode='$brrow[0]' and claimno='$row[0]' and partcode='$row2[8]' and partname='$row2[9]' ";
 print "$sql3<br>";
 $re3=mysqli_query($db,$sql3)or die('err'.mysqli_error($db));
 if(mysqli_num_rows($re3)>0)
 {
$row3=mysqli_fetch_row($re3);

$sqlupd="update warspareinvoice set claimpamt='$row3[aprice]',claimptax='$row3[gstamt]',claimptot='$row3[tot]' where brcode='$brrow[0]' and partcode='$row3[8]' and partname='$row3[9]' and msno='$row[0]'";
print "$sqlupd<br>";

mysqli_query($db,$sqlupd);
}
}
}
}

print "<script> alert('Posting Done Successfully...!!!'); </script>";

}// 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>WARRANTY PASS REPORT -repost</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>


