<? session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}

include("../opendb.php");
include("../test.php");
if($save)
{
 $date=parseDate($dt);
  $sql="insert into blockda values('$da','$usr','$rep','$date','$rem','$brcode')";
  mysqli_query($db,$sql) or die(mysqli_error());
  print "<font color=green><blink> Data has been saved</blink></font>";
 print "<script> document.location='stockrepo_veh.php'</script>";
 return;
}

if($del)
{
    mysqli_query($db,"delete from blockda where da='$da' and brcode='$brcode'") or die(mysqli_error());
    print "<font color=green><blink> Data has been cleared</blink></font>";
    print "<script> document.location='stockrepo_veh.php'</script>";
    return;
}

?>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;font-size:14}
tr{background-color:white} 
th{background-color:c1d799;font-size:14}
.mnu{margin-left:5}
body{BACKGROUND-COLOR:fcfff1}
</style>

<center>
<?
 if($type=='clr')
  {
 $res=mysqli_query($db,"select * from blockda where da='$da'")or die(mysqli_error());
 $brow=mysqli_fetch_array($res);
?>
<form action='<?print $PHP_SELF?>'>
<table cellspacing=1 cellpadding=1 bgcolor=c1d799>
<tr><td align=center>
<table cellspacing=1 cellpadding=3>
<th colspan=2><h3>CLEAR DA</H3></th>
<tr><td>DA to Block <td><input type=text name='da' readonly size=25 value='<?print $brow[da]?>' style={border:none;background-color:silver}></td></tr>

<tr><td>User Name <td><input type=text name='usr' readonly size=25 value='<?print strtoupper($brow[user])?>'></td></tr>
<tr><td>Rep <td><input type=text name=rep readonly value='<?print $brow[rep]?>'>
</select></td></tr>
<tr><td>Date </td><td><input type=text readonly name=dt value='<?print $brow[date]?>'></td></tr>
<tr><td>Remark </td><td><textarea READONLY name=rem cols=40><?print $brow[rem]?></textarea></td></tr>
<th colspan=2><input type=submit name='del' value='Clear'> <input type=button value='Cancel' onClick=history.back(1)></th>
</td></tr>
</table>
</form>

<?
}
else
{
?>
<form action='<?print $PHP_SELF?>'>
<table cellspacing=1 cellpadding=1 bgcolor=c1d799>
<tr><td align=center>
<table cellspacing=1 cellpadding=3>
<th colspan=2><h3>BLOCK DA</H3></th>
<tr><td>DA to Block <td><input type=text name='da' readonly size=25 value='<?print $da?>' style={border:none;background-color:silver}></td></tr>

<tr><td>User Name <td><input type=text name='usr' readonly size=25 value='<?print strtoupper($user)?>'></td></tr>
<tr><td>Rep <td><select name='rep'>
<?
 $re=mysqli_query($db,"select * from rep_master where branch='$brcode' order by repname");
 while($row=mysqli_fetch_array($re))
 {
  print "<option>$row[repname]</option>";
 }
?>
</select></td></tr>
<tr><td>Date </td><td><input type=text readonly name=dt value='<?print date('d-m-Y');?>'></td></tr>
<tr><td>Remark </td><td><textarea name=rem cols=40></textarea></td></tr>
<th colspan=2><input type=submit name='save' value='Save'> <input type=button value='Cancel' onClick=history.back(1)></th>
</td></tr>
</table>
</form>

<?
}
?>
