<?
session_start();
include("../opendb.php");
include("../test.php");
?>
<head>
<TITLE>55000Scheme REPORT</TITLE>
<style>
tr{font-family:arial;font-size:13;background-color:white}
TH{COLOR:WHITE;BACKGROUND-COLOR:STEELBLUE}
</style>

<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<CENTER>

<?
if($Del)
{
 mysqli_query($db,"delete from schooltrans where chno='$chno' and billno='$billno' and partamount='$partamount' ")or die('err'.mysqli_error());
 print "<script>document.location='55report.php'</script>";
}
if($show)
//if($show && $pswd=='ed')
{
$df=$y.'-'.$m.'-'.$d;
$dt=$y1.'-'.$m1.'-'.$d1;
print "<FONT FACE='ARIAL BLACK' color='steelblue'>
55000 Scheme Report ".datetohtml($df).' TO '.datetohtml($dt)."
</FONT>";



if($exec=='All')
$sql="select distinct chno from schooltrans where entrydate>='$df' and entrydate<='$dt' and brcode='$brcode' order by chno";
else
$sql="select distinct chno from schooltrans where entrydate>='$df' and entrydate<='$dt' and chno='$exec' and brcode='$brcode' order by chno";

 print "<table cellspacing=1 cellpadding=2 bgcolor='lightsteelblue' width=100%>";
print "<th>ChasisNo<th>Part<th>Lub<th>Labour<th>Other<th>Total";

$re=mysqli_query($db,$sql);
$i=1;
$gtot1=0;
while($row=mysqli_fetch_array($re))

{
$gtot2=0;
$gpart=0;
$glube=0;
$glabour=0;
$gother=0;
 //print "<fieldset><legend><b>$row[0]</b></legend>";
 $re2=mysqli_query($db,"select * from schooltrans where chno='$row[0]' and entrydate>='$df' and entrydate<='$dt' order by entrydate");
 while($row1=mysqli_fetch_array($re2))

{

//$re22=mysqli_query($db,"select timediff($row1[etime],$row1[stime]) from schooltrans where empname='$row1[5]' and sno='$row1[sno]' and tcno='$row1[tcno]'");
//$row2=mysqli_fetch_array($re22);
  //print "\n<form action='$PHP_SELF'> <input type=hidden name='chno' value='$row1[1]'><input type=hidden name='billno' value='$row1[billno]'><input type=hidden name='partamount' value='$row1[partamount]'><tr><td>";
 // print "\n".$i++."</td>";
 // print "<td align=center>$row1[chno]</td>";
 // print "<td align=center>".datetohtml($row1[entrydate])."</td>";
 // print "<td align=right >$row1[billno]</td>";
 // print "<td align=right >$row1[billdate]</td>";

//  print "<td align=center>$row1[workat]</td>";
 // print "<td align=center>$row1[partamount]</td>";
//print "<td align=center>$row2[0]</td>";

//  print "<td align=center>$row1[lubamount]</td>";
 // print "<td align=center>$row1[labamount]</td>";
//print "<td align=center>$row1[othamount]</td>";
//print "<td align=center>$row1[totamount]</td>";
 // print "<td><input type=submit value='Del' name='Del'></td></tr></form>";


$gpart+=$row1[partamount];
$glube+=$row1[lubamount];
$glabour+=$row1[labamount];
$gother+=$row1[othamount];
$gpart1+=$row1[partamount];
$glube1+=$row1[lubamount];
$glabour1+=$row1[labamount];
$gother1+=$row1[othamount];


$gtot1+=$row1[totamount];
$gtot2+=$row1[totamount];
 }
print "<tr><td><center><b><a href='schooldet.php?ch=$row[0]&f=$df&t=$dt' title='Ref:$row[against] $row[no]'>$row[chno]</td><td align=right>".putComa($gpart)."</td><td align=right>".putComa($glube)."</td><td align=right>".putComa($glabour)."</td><td align=right>".putComa($gother)."</td><td align=right>".putComa($gtot2)."</td></tr>";

}
print "<tr><td><center><b>Total</td><td align=right>".putComa($gpart1)."</td><td align=right>".putComa($glube1)."</td><td align=right>".putComa($glabour1)."</td><td align=right>".putComa($gother1)."</td><td align=right>".putComa($gtot1)."</td></tr>";

print "</table><br>";




return;
}// end if
?>
<p>&nbsp;<p>&nbsp;<p>&nbsp;
<form action='<?print $PHP_SELF?>'>
<table>
<tr><td bgcolor='steelblue'>
<img src='exec.jpg'>
</td><td>
<table border=0 width=250>
<th colspan=2 height=23><FONT FACE='ARIAL' color='white'>
SchoolBus scheme REPORT
</FONT>

<tr><td>From</td><td>
<input type=text name=d value='<?print date("d",time());?>' size=1>
<input type=text name=m value='<?print date("m",time());?>' size=1>
<input type=text name=y value='<?print date("Y",time());?>' size=3>
</td></tr>
<tr><td>To</td><td>
<input type=text name=d1 value='<?print date("d",time());?>' size=1>
<input type=text name=m1 value='<?print date("m",time());?>' size=1>
<input type=text name=y1 value='<?print date("Y",time());?>' size=3>
</td></tr>
<tr><td>Branch</td><td>
<select name='exec'>
<option>All</option>
<?
$sql="select distinct workat from schooltrans where brcode='$brcode' order by workat";
$exres=mysqli_query($db,$sql);
while($exrow=mysqli_fetch_array($exres))
{
 print "<option>$exrow[0]</option>";
}
?>
</select></td></tr>
<tr><td>Password</td><td><input type=password name='pswd'></td></tr>

<tr><td colspan=2 align=center bgcolor='steelblue'><input type=submit value="Show" name='show'></td></tr>
</table>
</td></tr>
</table>
</form>

