<style>
  .mytable{
    font-size:16px;
	width:700px;
	margin-top:10px;
	color:#000000;
  }
  
  .mytableth{
    background-color:#000000;
	color:#FFCC00;
	padding:5px 5px 5px 5px;
  }
  
  .mybtn{
    width:100px;
	font-size:14px;
	font-weight: bold;
	font-family: Arial;
  }
    
  .mytext{
    text-align: center;
    padding: 3px;
  }
</style>

<?
  $pid = $_GET["pid"];
    
//  $teaid = $_GET["teaid"];
//  $pdate = $_GET["pdate"];
?>
<?
  $qrecord = "SELECT * FROM punchsys_punchrecord WHERE punch_Id='$pid'";
  $rrecord = mysqli_query($conn,$qrecord);
  while($myrow = mysqli_fetch_array($rrecord)){
	  $pstaffId = $myrow["staffId"];
	  $pdate = $myrow["punchDate"];
  }
?>
<?
  $qtea = "SELECT * FROM punchsys_staff WHERE id='$pstaffId'";
  $rtea = mysqli_query($conn,$qtea);
  $ntea = mysqli_num_rows($rtea);
  $i=0;
  while($myrow = mysqli_fetch_array($rtea)){
  
    $id = $myrow["id"];
    $ename = $myrow["eName"];
	if( strlen($ename)>20 ){
	  $ename = substr($ename,0,19) . "...";
	}
    $cname = $myrow["cname"];
  
    $teaName = $cname . " " . $ename;
  
    $i++;
  }
?>
<?
  $qevent = "SELECT * FROM punchsys_remarkevent";
  $revent = mysqli_query($conn,$qevent);
  $nevent = mysqli_num_rows($revent);
  $i=0;
  while($myrow = mysqli_fetch_array($revent)){
  
    $id = $myrow["id"];
	$event = $myrow["event"];
	$arrEvent[$id] = $event;
  
    $i++;
  }
?>
<?
  $qrmkrcd = "SELECT * FROM punchsys_remarkrecord WHERE staffId='$pstaffId' AND remarkDate='$pdate'";
  $rrmkrcd = mysqli_query($conn,$qrmkrcd);
  $nrmkrcd = mysqli_num_rows($rrmkrcd);
  while($myrow = mysqli_fetch_array($rrmkrcd)){
    $eventid = $myrow["eventId"];
    $notice = $myrow["notice"];
  }
?>

<center>
<form action="rmktsksav.php" method="post">
<table border="0" cellpadding="0" cellspacing="1" class="mytable">
<tr>
  <th colspan="2" class="mytableth">EDIT REMARK</th>
</tr>
<tr>
<?
  //------ teacher id part -----------------
?>
  <th class="mytableth">STAFF</th>
  <td style="padding-left: 10px; background-color: #CCCCCC;"><?= $teaName ?></td>
</tr>
<input type="hidden" name="teaid" value="<?= $pstaffId ?>" />
<?
  //------ date part -------------------------
  if( $nrmkrcd>0 ){
    $disabled = "disabled";
	$readonly = "readonly";
    $txtcolor = "style='background-color:#CCCCCC'";
  }else{
    $disabled = "";
	$readonly = "";
	$txtcolor = "";
  }
?>
<tr>
  <th class="mytableth">DATE</th>
  <td style="padding-left: 10px; background-color: #CCCCCC;">
	<input type="date" id="txtDatefrom" name="txtDatefrom" value="<?= $pdate ?>" <?= $readonly ?> <?= $txtcolor ?> style="font-family: Arial; font-weight: bold">
  </td>
</tr>
<?
  //------ event part -------------------------
?>
<tr>
  <th class="mytableth">EVENT</th>
  <td style="padding-left: 10px; background-color: #CCCCCC;">
    <select name="eventid">
<?
  foreach($arrEvent as $id=>$event){
    if($id==$eventid){
	  $selected = "SELECTED";
	}else{
	  $selected = "";
	}
    echo "<option value='$id' $selected>$event</option>";
  }
?>
    </select>
  </td>
</tr>
<?
  //------ desc part -------------------------
?>
<script language="javascript" type="text/javascript">
function imposeMaxLength(Object, MaxLen){
  return (Object.value.length <= MaxLen);
}
</script>
<tr>
  <th class="mytableth">DESCRIPTION</th>
  <td style="padding-left: 10px; background-color: #CCCCCC;">
    <textarea name="notice" rows="3" cols="30" onkeypress="return imposeMaxLength(this, 80);"><?= $notice ?></textarea>
  </td>
</tr>
<?
  //------ submit part -------------------------
?>
<input type="hidden" name="apvdate" value="<?= $today_date ?>" />
<tr>
  <td align="center" colspan="2"  class="mytableth">
    <input type="submit" name="submit" value="SUBMIT" class="mybtn" style="color: #0000FF">
	<input type="submit" name="submit" value="DELETE" class="mybtn" style="color: #FF0000">
  </td>
</tr>
</table>
</form>
</center>