
<?
session_start();
include("test.php");
include("opendb.php");
include("includes/function.php");
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}


        
?>
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>PSN Telcon</title>
  

















    </script>

<!-- js code below for active enter with textfield-->






<body >





	<link type="text/css" href="css/jquery-ui-1.8.16.custom.css" rel="stylesheet" />	
		<script type="text/javascript" src="css/jquery-1.6.2.min.js"></script>
		<script type="text/javascript" src="css/jquery-ui-1.8.16.custom.min.js"></script>

<style>

table{border-collapse:collapse;}
</style>
<?

 $res=mysqli_query($db,"select * from estentry where jcno='$jcno' and brcode='$brcode'");
 $jrow=mysqli_fetch_array($res);
?>

<form name=f3  method='post'  >


<table border=1 class='form' width=100% >
<h4>JCNo:<input type=text readonly name='jcno' size=5 value='<?print $jcno?>'></h4>

<tr><td>Date </td><td><input type=text readonly name='date' size='12' value= '<?print datetohtml($jrow[entrydate])?>' size=8></td>
    <td>RegNo </td><td><input type=text readonly name='msno' size='12' value='<?print $jrow[regno]?>' size=12></td>

	<td>Delivery Date</td><td><input type=text readonly name='dcomm' size='12' value='<?print datetohtml($jrow[estdate])?>' size=8></td>
	<td>Model </td><td><input type=text readonly name='model' size='12' value='<?print $jrow[model]?>' size=8></td>
	<td>Owner </td><td><input type=text readonly name='cname' size='12' value='<?print $jrow[owner]?>'></td>
</tr>
<tr>	<td>Make </td><td><input type=text readonly name='stdate' size='12' value='<?print $jrow[vehiclename]?>'></td>
	<td>Insurance </td><td><input type=text readonly name='instype' size='12' value='<?print $jrow[insurance]?>'></td>
	<td>Job Type </td><td><input type=text readonly name='wtstdate' size='12' value='<?print $jrow[instype]?>' size=8></td>
	<td>ReceivedBy </td><td><input type=text readonly name='wtyenddate' size='12' value='<?print $jrow[receivedby]?>' size=8></td>
	<td>KMS </td><td><input type=text name='hmr' size='12' value='<?print $jrow[hmr]?>'></td>

</tr>
<tr>
			<td>User </td><td><input type=text readonly name='user' size='12' value='<?print $user?>' size=8></td>
<td>Entry Date </td><td colspan=3>
dd <input type=text readonly name='entrdate1' size=1 value='<?print date('d')?>'>
mm <input type=text readonly name='entrdate2' size=1 value='<?print date('m')?>'>
yy <input type=text readonly name='entrdate3' size=2 value='<?print date('Y')?>'>
</td>
<td>ChasisNO </td><td><input type=text name='chasisno' size='12' value='<?print $jrow[chasisno]?>'></td>

<td></td>
<td></td>
<td></td>

</tr>
</table> 
<br>
 <hr></hr>
<br>
<h4>Parts Request </h4>

<!--<input type="button" onclick="insRow()" value=" Add Item ">-->
<table border=1 width=100%  >


<th> No <th>Part Code<th> Part Name<th>Part type <th>Qty<th>Rate<th>Discount<th> OtherCharges<th>Total<th>Ref<th colspan=3>OrderDate


<?
$tbl="stockrepdet10".$brcode.$user;
mysqli_query($db,"delete from $tbl where supqty<=0 ");

 $res=mysqli_query($db,"select * from pjcardparts where jcno='$jcno' and brcode='$brcode'");
 $i=1;
 $j=100;
 while($jrow=mysqli_fetch_array($res))
  {
$edate1=explode('-',$jrow[edate]);

   print "<tr><td>".$i."</td><td><input type= text readonly name='partcode[]' value='$jrow[2]' size=12></td>";
 print "<td><input type=text size=20 name='partname[]' value='$jrow[3]'></td>";
 print "<td><input type=text  readonly name='spareengineer[]' id='spareengineer$j' value='$jrow[engineer]' size=20></td>";
  
 print "<td><input type=text size=4 name='qty[]' id='qty$j' value='$jrow[qty]' onChange=calcamt2($j)></td>";

  print "<td><input type=text size=8  name='rate[]' id='rate$j' value='$jrow[rate]' onChange=calcamt2($j)> </td>";
   print "<td><input type=text size=4 name='disc[]' id='disc$j' value='$jrow[disc]' onChange=calcamt2($j)></td>";


   print "<td><input type=text size=3 name='hnd[]' id='hnd$j' value='$jrow[hnd]' onChange=calcamt2($j)></td>";

   print "<td><input type=text readonly size=8 name='gtot[]' id='gtot$j' value='$jrow[gtot]'></td>";


 $qtres=mysqli_query($db,"select supqty from $tbl where partcode='$jrow[2]'");
 $qtrow=mysqli_fetch_row($qtres);
   $qqty=($qtrow[0]+$jrow[qty]);


   print "<td><input type=text  readonly name='exqty[]' id='exqty$j' value='$qqty' size=4></td>";

    print "<td><input type=text   name='day[]' id='day$j' value='$edate1[2]' size=2></td>";
    print "<td><input type=text   name='month[]' id='month$j' value='$edate1[1]' size=2></td>";
    print "<td><input type=text   name='year[]' id='year$j' value='$edate1[0]' size=4></td>";

  




	print "<script>cur++</script>";
	
   $i++;
   $j++;
  }
?>
</table>
<br>
 <hr></hr>
<br> 
<h4>Service Details </h4>
<!-- <input type="button" onclick="insRow2()" value="   Add Service   ">-->
<table border=1 id="myTable2" width=100%>
<th>No.<th>Service  <th>Repair/Replace<th>Amt <th>Assigned to<th colspan=3>EnteredOn

<?
 $res=mysqli_query($db,"select * from jcardserv where jcno='$jcno' and brcode='$brcode'");
 $i=1;
 $totservamt=0;
 while($jrow=mysqli_fetch_array($res))


  {
$edate2=explode('-',$jrow[edate]);

   print "\n<tr><td>".$i."</td>";
   print "<td><input type=text size=20 name='service[]' value='$jrow[2]'></td>";
   print "<td><input type=text size=20 name='jobs[]' value='$jrow[4]'></td>";
  
  print "\n<td><input type=text size=8 name='servamt[]' value='$jrow[3]' id='servamt$i' onChange='calctotal2($i)'></td>";
   




 print "<td> <select name='engineer1[]' id='engineer1$i'><option>$jrow[engineer]</option>\n";


 $empre1=mysqli_query($db,"select ename from empprofile where status!='releived' order by ename");
 while($emprow1=mysqli_fetch_row($empre1))
{
print "<option>$emprow1[0]</option>' \n";
}

   print "</select></td>";



    print "<td><input type=text   name='day1[]' id='day1$j' value='$edate2[2]' size=2></td>";
    print "<td><input type=text   name='month1[]' id='month1$j' value='$edate2[1]' size=2></td>";
    print "<td><input type=text   name='year1[]' id='year1$j' value='$edate2[0]' size=4></td>";



//print "<td><input type=button value='Del' ></td>";

 
 print "</tr>";
   $i++;
print "<script>cur2++</script>";
 $totservamt+=$jrow[3];
  }

?>
</table>
<br>
 <hr></hr>
<br>

<br>
<hr></hr>
<br>

<?

 $res1=mysqli_query($db,"select * from  workshoplabour where jcno='$jcno' and brcode='$brcode'");
$jrow1=mysqli_fetch_array($res1)
?>



<h4>Workshop Labour (Total Amount-<INPUT TYPE='TEXT' NAME='servtotal' id='servtotal' value='<? echo $jrow1[7];?>' size='5' onkeyup='workshopamt(this.value,this)'/>)</h4>
<table border=1 id="myTable1" width=100%><th>No.<th>Workshop</br>category<th>Work in %<th>Amt<th>Esti.Time<th>Compt.Time<th>Assigned to<th colspan=3>EnteredOn<del>

<?
 $res=mysqli_query($db,"select * from  workshoplabour where jcno='$jcno' and brcode='$brcode'");

 $k=1;
 while($jrow=mysqli_fetch_array($res))


  {


$edate2=explode('-',$jrow[5]);

   print "\n<tr><td>".$k."</td>";
  
  
 
   
  print"<td> <select name='cate[]' onKeyPress='return handleEnter(this, event,this.value)' id='cate$k'  >";
print "<option>$jrow[1]</option>' \n";
 $res2=mysqli_query($db,"select * from workshop_category  where brcode='$brcode' and status='yes' order by category");
while($row2=mysqli_fetch_array($res2))
{

print "<option>$row2[1]</option>' \n";
} 

   print "</select></td>";

  print"<td><input type=text name='wrkavg[]' id='wrkavg$k' size=8 value='$jrow[2]' onKeyPress='return handleEnter(this, event,this.value)' onkeyup='workshopamt(this.value,this)'></td>";
    

     

  print "\n<td><input type=text size=8 readonly name='workamt[]' onKeyPress='return handleEnter(this, event,this.value)' value='$jrow[3]' id='workamt$k' ></td>";


 	 $hr_est = floor($jrow[8] / 60);

 	 $hr_est1 = $hr_est*60;

  	 $mn_est = $jrow[8]% 60;

  	 $hr_cmp = floor($jrow[9] / 60);

  	  $hr_cmp1=$hr_cmp*60;
  	 $mn_cmp = $jrow[9]% 60;


  	print "<td> <b>Hr</b><select name='e_hr[]' onKeyPress='return handleEnter(this, event,this.value)' id='e_hr$k' style='width:40px'>\n";
   		$j=0;
   		$kk=0;
               print "<option value='".$hr_est1."'>$hr_est</option>' \n"; 

  	 for($j=0;$j<50;$j++)
     		 {
        		 $m=$j*60;
         		print "<option value='".$m."'>$j</option>' \n"; 
      		}

  		 print "</select>";
		 print "<b>:</b> <b>mm</b><select name='e_mt[]' onKeyPress='return handleEnter(this, event,this.value)' id='e_mt$k' style='width:40px'>\n";
                 print "<option>$mn_est</option>' \n"; 
 	   for($kk=0;$kk<60;$kk++)
     		 {
         		$m=$kk*60;
          		print "<option>$kk</option>' \n"; 
     		 }
   		 print "</select></td>";



               	print "<td> <b>Hr</b><select name='c_hr[]' onKeyPress='return handleEnter(this, event,this.value)' id='c_hr$k' style='width:40px'>\n";
   		$j=0;
   		$kk=0;
         print "<option value='".$hr_cmp1."'>$hr_cmp</option>' \n"; 
  	 for($j=0;$j<50;$j++)
     		 {
        		 $m=$j*60;
         		print "<option value='".$m."'>$j</option>' \n"; 
      		 }

  		 print "</select>";
		 print "<b>:</b> <b>mm</b><select name='c_mt[]' onKeyPress='return handleEnter(this, event,this.value)' id='c_mt$k' style='width:40px'>\n";

                  print "<option>$mn_cmp</option> \n"; 
 	    for($kk=0;$kk<60;$kk++)
     		 {
         		$m=$kk*60;
          		print "<option>$kk</option>' \n"; 
     		 }
   		 print "</select></td>";




 print "<td> <select name='staff[]' onKeyPress='return handleEnter(this, event,this.value)' id='emp$k' style='width:150px'>\n";
print "<option>$jrow[4]</option>' \n";

  $res3=mysqli_query($db,"select ename from empprofile where status!='releived' order by ename");
 while($row3=mysqli_fetch_row($res3))
{
print "<option>$row3[0]</option>' \n";
}

   print "</select></td>";



    print "<td><input type=text   name='day2[]' id='days$k' value='$edate2[2]' onKeyPress='return handleEnter(this, event,this.value)' size=2></td>";
    print "<td><input type=text   name='month2[]' id='months$k' value='$edate2[1]' onKeyPress='return handleEnter(this, event,this.value)' size=2></td>";
    print "<td><input type=text   name='year2[]' id='years$k' value='$edate2[0]' onKeyPress='insRow3(event,this,this.id)' size=4></td>";




 
 print "</tr>";
   $k++;
print "<script>cur3++</script>";
print "<script>cnt3++</script>";
  }

?>
</table><br>


 
</span>



</form>
 




