<SCRIPT LANGUAGE=JAVASCRIPT>
function verify(){
    msg = "Are you sure want to delete this REMARK?";
    return confirm(msg);
    }
</SCRIPT>
<?
  $status = $_GET["selStatus"];
  if( $status=="" ){
    $status=0;
	$event=0;
  }else{
    $event=$_GET["selEvent"];
  }
?>
<?
  $qtea = "SELECT * FROM xoops_adm_teacher";
  $rtea = mysql_query($qtea);
  $ntea = mysql_num_rows($rtea);
  $i=0;
  while($i<$ntea){
  
    $id = mysql_result($rtea,$i,"id");
    $ename = mysql_result($rtea,$i,"ename");
	if( strlen($ename)>25 ){
	  $ename = substr($ename,0,23) . "...";
	}
  
    $arrTea[$id] = $ename;
  
    $i++;
  }
?>
<?
  $arrStatus = array("PENDING","APPROVED","REJECT","ALL");
?>
<?
  $qevent = "SELECT * FROM xoops_pc_remarkevent";
  $revent = mysql_query($qevent);
  $nevent = mysql_num_rows($revent);
  $i=0;
  while($i<$nevent){
  
    $id = mysql_result($revent,$i,"id");
	$tevent = mysql_result($revent,$i,"event");
	$arrEvent[$id] = $tevent;
  
    $i++;
  }
?>
<?
  $qchk = "SELECT * FROM xoops_pc_remarkrecord WHERE staffid='".$_SESSION["teacherSessionId"]."' ORDER BY remarkDate DESC";
  $rchk = mysql_query($qchk);
  $nchk = mysql_num_rows($rchk);

  if($_GET["s"]!=""){
    $s = $_GET["s"];
  }else{
    $s = "0";
  }

  $query = "SELECT * FROM xoops_pc_remarkrecord WHERE staffid='".$_SESSION["teacherSessionId"]."' ORDER BY remarkDate DESC LIMIT ".($s*10).", 10";
  $result = mysql_query($query);
  $num = mysql_num_rows($result);
?>
<?
  if($nchk>10){
    $br = ceil($nchk/10);
    for($i=0;$i<$br;$i++){
	  echo "<a href='main.php?pg=rmk&ac=chk&s=$i'>";
	  echo "[".($i*10+1)."~".($i*10+10)."]";
	  echo "</a>";
	  echo "&nbsp;&nbsp;";
	}
  }
?>
<?
//--- display pending request -----------
?>
<table style="font-size:11px " width="640" border="1">
  <tr bgcolor="#999999" style="color:#EEEEEE ">
    <th width="80">NAME</th>
	<th width="70">DATE</th>
	<th>EVENT</th>
	<th>NOTICE</th>
	<th width="100">STATUS</th>
	<th width="70"></th>
  </tr>
<?
  $i=0;
  while($i<$num){
    $tid = mysql_result($result,$i,"id");
    $tteaid = mysql_result($result,$i,"staffId");
	$rDate = mysql_result($result,$i,"remarkDate");
	$rDatetil = mysql_result($result,$i,"remarkDatetil");
    $tevent = mysql_result($result,$i,"eventId");
	$tapvby = mysql_result($result,$i,"apvby");
    $tnotice = mysql_result($result,$i,"notice");
	if($tnotice==""){
	  $tnotice="-";
	}
	$tstatus = mysql_result($result,$i,"status");
	if($tstatus!='0'){
	  $disstatus = $arrStatus[$tstatus] . " by <br>" . $arrTea[$tapvby];
	}else{
	  $disstatus = $arrStatus[$tstatus];
	}
?>
  <form action="rmkdel.php" method="post">
  <input type="hidden" name="hid" value="<?= $tid ?>">
  <tr>
    <td><?= $arrTea[$tteaid] ?></td>
	<td align="center"><?= $rDate ?></td>
	<td><?= $arrEvent[$tevent] ?></td>
	<td><?= $tnotice ?></td>
	<td align="center"><?= $disstatus ?></td>
	<td align="center"><input type="submit" name="submit" value="DELETE" onClick="return verify()"></td>
  </tr>
  </form>
<?
    $i++;
  }
?>
</table>
</center>