<?
session_start();
if(strlen($user)<=0)
{
 print "<script> alert('You are not logged in') </script>";
 include("logout.php");
 return;
}
if(!checkdate($m,$d,$y))
{
 print "<script>alert('Invalid Commission Date'); history.back(1);</script>";
 return;
}
if(!checkdate($m1,$d1,$y1))
{
 print "<script>alert('Invalid Commission Date'); history.back(1);</script>";
 return;
}

$dcomm=$y.'-'.$m.'-'.$d;
$entrydate=$y1.'-'.$m1.'-'.$d1;

include("opendb.php");
$re=mysqli_query($db,"select * from minput where msno='$msno'");
 if(mysqli_num_rows($re)>0)
 {
  print "<script> alert('Machine Code Serial No already exists'); history.back(1); </script>";
  return;
 }

$sql1="insert into minput (user, entrydate, optype, war, engineer, msno, esno, emodel, cust, dcomm, hmr,model,mtype,brcode) values('$user', '$entrydate', '$optype', '$war', '$engineer','$msno', '$esno', '$emodel', '$cust', '$dcomm', '$hmr','$model','$mtype','$brcode1')";
mysqli_query($db,$sql1)or die('sq1 err1'.mysqli_error());

$rr=mysqli_query($db,"select max(code) from minput")or die(mysqli_error());
$crow=mysqli_fetch_row($rr);
$code=$crow[0];

$sql="insert into mach_location (mcode,brcode,engineer,date,cust) values('$code','$brcode1','$engineer', '$entrydate','$cust')";
mysqli_query($db,$sql) or die('sq2 err2'.mysqli_error());

//******************************888888888888*******************88888888
$comdate=$dcomm;


/* $code=substr($msno,0,4).date("dms");
 str_replace(' ','-',$code);
*/

/*
 $re=mysqli_query($db,"select date_add('$comdate', INTERVAL $s0d DAY)")or die(mysqli_error());
 $dr=mysqli_fetch_row($re);
  $s0d=$dr[0];

 $re=mysqli_query($db,"select date_add('$comdate', INTERVAL $s0h HOUR)")or die(mysqli_error());
 $dr=mysqli_fetch_row($re);
//  $s0h=$dr[0];

 $re=mysqli_query($db,"select date_add('$comdate', INTERVAL $s1m MONTH)")or die(mysqli_error());
 $dr=mysqli_fetch_row($re);
  $s1m=$dr[0];

 $re=mysqli_query($db,"select date_add('$comdate', INTERVAL $s1h HOUR)")or die(mysqli_error());
 $dr=mysqli_fetch_row($re);
//  $s1h=$dr[0];

 $re=mysqli_query($db,"select date_add('$comdate', INTERVAL $s2m MONTH)")or die(mysqli_error());
 $dr=mysqli_fetch_row($re);
  $s2m=$dr[0];


 $re=mysqli_query($db,"select date_add('$comdate', INTERVAL $s2h HOUR)")or die(mysqli_error());
 $dr=mysqli_fetch_row($re);
//  $s2h=$dr[0];


 $re=mysqli_query($db,"select date_add('$comdate', INTERVAL $s3m MONTH)")or die(mysqli_error());
 $dr=mysqli_fetch_row($re);
  $s3m=$dr[0];


 $re=mysqli_query($db,"select date_add('$comdate', INTERVAL $s3h HOUR)")or die(mysqli_error());
 $dr=mysqli_fetch_row($re);
//  $s3h=$dr[0];


 $re=mysqli_query($db,"select date_add('$comdate', INTERVAL $s4m MONTH)")or die(mysqli_error());
 $dr=mysqli_fetch_row($re);
  $s4m=$dr[0];

 $re=mysqli_query($db,"select date_add('$comdate', INTERVAL $s5m MONTH)")or die(mysqli_error());
 $dr=mysqli_fetch_row($re);
  $s5m=$dr[0];

 $re=mysqli_query($db,"select date_add('$comdate', INTERVAL $s4h HOUR)")or die(mysqli_error());
 $dr=mysqli_fetch_row($re);
//  $s4h=$dr[0];

*/
$sql="insert into mdet values('$msno','$model','$esno', '$emodel','$hmr','$cust','$dcomm','$s0d','$s0h','$s1m','$s1h','$s2m', '$s2h','$s3m','$s3h','$s4m','$s4h','$code','$s5m','$s5h')";
mysqli_query($db,$sql)or die('sq1 err4'.mysqli_error());

if($mtype=='WH')
{
 $sql="insert into wheeled values('$hpump','$hmake','$trsno','$raxilsno','$rmake','$faxilno', '$fmake','$fpump', '$fumake', '$lvalve', '$lvmake','$esvalve', '$esmake', '$stavalve', '$stamake' , '$batno', '$batmake','$boocyl', '$boocylmk','$acylin' ,  '$acylmk', '$bucylin' , '$bucylmk' , '$lcylinlh', '$lcylinlhmk' , '$lcylinrh'  ,'$lcylinrhmk' , '$ticylin', '$ticylinmk'  , '$ticylinrh', '$ticylinrhmk','$steecylin' , '$steecylinmk', '$slewcylin' , '$slewcylinmk', '$slewcylinrh','$slewcylinrhmk' , '$stablh' , '$stablhmk' ,'$stabrh' ,'$stabrhmk' , '$bukexc' ,'$bukexcmk', '$buklodcapa', '$bukloadmk' ,
 '$frrh', '$frrhmake', '$frrhsize' ,'$rrlh' ,'$rrlhmake' , '$rrlhsize' , '$rrrh', '$rrrhmake', '$rrrhsize','$code')";
 //mysqli_query($db,$sql) or die('sq1 err5'.mysqli_error());
}
else if($mtype=='TR')
{
 $sql="insert into hyd values('$hypub', '$hypubmake'  ,'$hypubrr','$hypubrrmk' ,'$smotor','$smotormake' ,'$swgrb', '$swgrbmake', '$tmotorlh' ,'$tmotormklh','$tmotorrh','$tmotormkrh','$trgearl','$trgearml','$trgearr', '$trgearrmk','$fpumpno', '$fpumpmk' ,'$boocylin' ,'$boomake', '$boocyclinr','$boocylmk', '$armcylin' ,'$armcylinmk', '$bktcylin' ,'$bktcylinmk','$slcylinlh', '$slcylinlhmk','$slcylinrh','$slcylinrhmk' ,'$blcylin','$blmake', '$escvalve', '$escvalvem', '$batno','$batmake', '$besc','$attch','$attchmk','$attser','$code')";
 //mysqli_query($db,$sql) or die('sq1 err6'.mysqli_error());

}
echo "<meta http-equiv='refresh' content='.1;url=minput.html'>";
?>
<link rel="stylesheet" href="style.css" type="text/css" />

