<?
session_start();
if(strlen($user)<=0)
{
 print "<script> alert('You are not logged in') </script>";
 include("logout.php");
 return;
}

include("opendb.php");
include("test.php");
?>
<title>PSN Telcon</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="scripts/jquery-latest.js"></script>
<link type="text/css" href="includes/style1.css" rel="stylesheet" />
<link rel="stylesheet" href="css/form.css" type="text/css" />
<script type="text/javascript">
        $(function() {
          if ($.browser.msie && $.browser.version.substr(0,1)<7)
          {
			$('li').has('ul').mouseover(function(){
				$(this).children('ul').show();
				}).mouseout(function(){
				$(this).children('ul').hide();
				})
          }
        });        
    </script>

<body background="back_ground.jpg">
<?php //include('logo2.php'); ?>
<?php include('includes/top.php'); ?>
<br>
<table class="container"><tr><td>
<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px;">  &nbsp;&nbsp;Master >> <a href="mach_menu.php" style="text-decoration:none;">Machine</a> >> Service History</font>
<br>
<center>
<form action='<?print $PHP_SELF?>'>
<table class='form'>
<tr><td>From </td><td>DD <input type=text name=d1 size=2 value='<?print date("d")?>'></td>
		<td>MM <input type=text name=m1 size=2 value='<?print date("m")?>'></td>
		<td>YY <input type=text name=y1 size=4 value='<?print date("Y")?>'></td>
</tr>

<tr><td>To </td><td>DD <input type=text name=d2 size=2 value='<?print date("d")?>'></td>
		<td>MM <input type=text name=m2 size=2 value='<?print date("m")?>'></td>
		<td>YY <input type=text name=y2 size=4 value='<?print date("Y")?>'></td>
</tr>
<tr><td colspan=4 align=center><input type=radio name='chk' value='m' checked>by Month/date
			       <input type=radio name='chk' value='h' >by Hour </td>
</tr>
<tr ><td colspan=4 align=center><input type=submit name='show' value='Show'></td></tr>
</table>
</form>
<?
if($show)
{
 $df=$y1.'-'.$m1.'-'.$d1;
 $dt=$y2.'-'.$m2.'-'.$d2;

?>
<table border=0 cellspacing=1 cellpadding=1 width=100%  class='report'>
<tr BGCOLOR='aliceblue' height=21><td colspan=11 align=center><b>SERVICE HISTORY</TD></TR>
<th>No.<th> MSer NO.<th>Serv. <th>Serv Date <th>Engineer <th>Remark <th>Customer<th>Dist. <th>Phone
<th>Mobile <th>Del
<?
 $re=mysqli_query($db,"select * from servdet where date>='$df' and date<='$dt' order by serviceno,sno");
$i=1;
while($row=mysqli_fetch_array($re))
{
  $en=mysqli_query($db,"select empname from empmaster where empcode='$row[engnr]'");
  $enrow=mysqli_fetch_row($en);

 $mres=mysqli_query($db,"select mcsno from mdet where code='$row[code]'");
 $mrow=mysqli_fetch_array($mres);

 print "<tr bgcolor='aliceblue' onMouseOver=bgColor='ivory' onMouseOut=bgColor='aliceblue'><td align=center>".$i++."</td><td>$mrow[0]</td><td align=center>$row[serviceno]</td><td align=center>".datetohtml($row[date])."<td>$enrow[0]</td>";
 print "<td>$row[rem]</td>";
 $sql="select cname from mdet where code='$row[code]'";

 $rr=mysqli_query($db,$sql)or die(mysqli_error($db));
 $crow=mysqli_fetch_array($rr); 
 $ssq="select * from customer where code='$crow[cname]'";

  $rr2=mysqli_query($db,$ssq)or die(mysqli_error($db));
   $cname=mysqli_fetch_array($rr2);
  print "<td>$cname[cname]</td><td>$cname[dist]</td><td>$cname[phone]</td><td>$cname[mob]</td>";
  print "<td><input type=button value='Del' onClick=delfun('$row[sno]'); </td></tr>";
}
} // end if
?>
  
<script>
function delfun(x)
{
 if(confirm('Do you want to delete the record ?'))
   document.location='delserv.php?sno='+x;
}
</script>
</td></tr></table>
