<?
session_start();
include("opendmsdb.php");
include("../test.php");
?>
<head>
<TITLE>MECHANIC WISE 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 timecard where jcno='$jcno' and sno='$sno' and tcno='$tcno' ")or die('err'.mysqli_error());
 print "<script>document.location='labreport.php'</script>";
}

//if($show && $pswd=='cltlabour')
if($show)

{
$df=$y.'-'.$m.'-'.$d;
$dt=$y1.'-'.$m1.'-'.$d1;
print "<FONT FACE='ARIAL BLACK' color='steelblue'>
MECHANIC WISE REPORT FROM ".datetohtml($df).' TO '.datetohtml($dt)."
</FONT>";



if($exec=='All')
$sql="select distinct brcode from branch where divis='AMPL'";

else
$sql="select distinct empname from timecard where dat>='$df' and dat<='$dt' and empname='$exec' and brcode='$brcode' order by empname";


$re=mysqli_query($db,$sql);

$s1="select sum(labamt) from timecard where brcode in (select brcode from branch where divis='ampl') and dat>='$df' and dat<='$dt'";
$r=mysqli_query($db,$s1);
$row5=mysqli_fetch_array($r);


$i=1;
$gtot2=0;
 print "<table cellspacing=1 cellpadding=2 bgcolor='lightsteelblue' width=80%>";
 print "<th>Mechanic <th align=right>Amount<th align=right>Percent";
while($row=mysqli_fetch_array($re))

{
$gtot1=0;


 $re2=mysqli_query($db,"select * from timecard where brcode='$row[0]' and dat>='$df' and dat<='$dt' order by dat");
 while($row1=mysqli_fetch_array($re2))

{
//$re22=mysqli_query($db,"select timediff($row1[etime],$row1[stime]) from timecard 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='jcno' value='$row1[0]'><input type=hidden name='sno' value='$row1[sno]'><input type=hidden name='tcno' value='$row1[tcno]'><tr><td>";
 // print "\n".$i++."</td>";
//  print "<td align=center>".datetohtml($row1[dat])."</td>";
//  print "<td align=center>$row1[0]</td>";
 // print "<td align=right >$row1[1]</td>";
//  print "<td align=center>$row1[2]</td>";
//  print "<td align=center>$row1[3]</td>";
//print "<td align=center>$row2[0]</td>";

//  print "<td align=center>$row1[6]</td>";
 // print "<td align=center>$row1[sno]</td>";

 

$gtot1+=$row1[labamt];
$gtot2+=$row1[labamt];
 }
$per=0;
$per=($gtot1/$row5[0])*100;
$per=round($per,2);
$gper+=$per;
$sql2="select  brname from branch where brcode='$row[0]' ";
$exres1=mysqli_query($db,$sql2);
$exrow1=mysqli_fetch_array($exres1);
print "<tr><td ><center><b><a href='labrptsumbr.php?brcod=$row[0]&f=$df&t=$dt' title='Ref:$row[against] $row[no]'>$exrow1[0]</a></td><td align=right>".putComa($gtot1)."</td><td align=right>$per</td></tr>";


}
print "</table><br>&nbsp;";
print "<table cellspacing=1 cellpadding=2 bgcolor='lightsteelblue' width=80%>";
print "<tr><td><center><b>Grand Total</td><td align=right>".putComa($gtot2)."</td><td align=right>".round($gper,0)."</td></tr>";
print "</table><br>&nbsp;";
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'>
MECHANIC WISE 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>Mechanic</td><td>
<select name='exec'>
<option>All</option>
<?
$sql="select distinct brname from branch where divis='AMPL' order by ";
$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>

