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

$dt=explode(' ',$updt);
$dt1=explode('-',$dt[0]);
$update=$dt1[2].'-'.$dt1[1].'-'.$dt1[0].' '.$dt[1];

if ($stat=='NJD')
{

$qry=mysqli_query($db,"select * from jcardparts  where jcno='$jcno' and brcode='$brcode'  ");
//$qry1=mysqli_fetch_row($qry);

if(mysqli_num_rows($qry)>0)
{
print "<script> alert ('Remove parts from jobcard');</script>";

}
else
{
mysqli_query($db,"insert into jcworking_status values('','$jcno','$regno','$stat','$entdt','$update','$remark','$brcode')");
mysqli_query($db,"update gateentry set work_status='$stat',work_status_date='$update' where jcno='$jcno' and brcode='$brcode'");
print "<script> alert ('Updated1');</script>";
}

}
else
{

mysqli_query($db,"insert into jcworking_status values('','$jcno','$regno','$stat','$entdt','$update','$remark','$brcode')");

mysqli_query($db,"update gateentry set work_status='$stat',work_status_date='$update' where jcno='$jcno' and brcode='$brcode'");

print "<script> alert ('Updated2');</script>";
print $mysql=("insert into jcworking_status values('','$jcno','$regno','$stat','$entdt','$update','$remark','$brcode')");

}
?>
<script>
 document.location='jcworking_status.php';
</script>