<?
  $teaid = $_GET["teaid"];
  $pdate = $_GET["pdate"];
?>
<?
  $qtea = "SELECT * FROM punchsys_staff WHERE id='$teaid'";
  $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='$teaid' 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"];
  }
?>

<style type="text/css">@import url(calendar-win2k-1.css);</style>
<script type="text/javascript" src="calendar.js"></script>
<script type="text/javascript" src="calendar-en.js"></script>
<script type="text/javascript" src="calendar-setup.js"></script>

<center>
<form action="rmktsksav.php" method="post">
<table cellspacing="1" style=" font-family:Arial; font-size:14px " width="500">
<tr>
  <th bgcolor="#999999" style="color:#EEEEEE " colspan="2">sfsdREQUEST REMARK</th>
</tr>
<tr bgcolor="#CCCCCC">
<?
  //------ teacher id part -----------------
?>
  <td bgcolor="#999999" style="color:#EEEEEE ">TEACHER</td>
  <td>&nbsp;<?= $teaName ?></td>
</tr>
<input type="hidden" name="teaid" value="<?= $teaid ?>" />
<?
  //------ date part -------------------------
  if( $nrmkrcd>0 ){
    $disabled = "disabled";
	$readonly = "readonly";
    $txtcolor = "style='background-color:#CCCCCC'";
  }else{
    $disabled = "";
	$readonly = "";
	$txtcolor = "";
  }
?>
<tr>
  <td bgcolor="#999999" style="color:#EEEEEE ">DATE</td>
  <td bgcolor="#CCCCCC">&nbsp;
	<input type="text" id="txtDatefrom" name="txtDatefrom" size="9" value="<?= $pdate ?>" <?= $readonly ?> <?= $txtcolor ?>>
	<button id="btnDatefrom" name="btnDatefrom" <?= $disabled ?>>...</button>
	<script type='text/javascript'>
      Calendar.setup({
		inputField : "txtDatefrom",  //ID of the input field
		ifFormat   : "%Y-%m-%d",    //the date format
		button     : "btnDatefrom"   //ID of the button
		});
	</script>
  </td>
</tr>
<?
  //------ event part -------------------------
?>
<tr>
  <td bgcolor="#999999" style="color:#EEEEEE ">EVENT</td>
  <td bgcolor="#CCCCCC">&nbsp;
    <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>
  <td bgcolor="#999999" style="color:#EEEEEE ">DESCRIPTION</td>
  <td bgcolor="#CCCCCC">&nbsp;
    <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 bgcolor="#999999">
  <td align="center" colspan="2">
    <input type="submit" name="submit" value="SUBMIT">
	<input type="submit" name="submit" value="DELETE">
  </td>
</tr>
</table>
</form>
</center>