<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>
<?
  if($_GET["dt"]!=""){
    $today_date=$_GET["dt"];
  }
?>
<?
  $qtea = "SELECT * FROM xoops_adm_teacher WHERE userID<>'1' AND id<>'admin' ORDER BY repPrint, id";
  $rtea = mysql_query($qtea);
  $ntea = mysql_num_rows($rtea);
  $i=0;
  while($i<$ntea){
    $tname = substr(mysql_result($rtea,$i,"ename"),0,24);
	$tid = mysql_result($rtea,$i,"id");
	
	$arrTea0[$tid] = $tname;
    $i++;
  }
?>
<?
  $qevt = "SELECT * FROM xoops_pc_remarkevent";
  $revt = mysql_query($qevt);
  $nevt = mysql_num_rows($revt);
  $i=0;
  while($i<$nevt){
  
    $tid=mysql_result($revt,$i,"id");
	$tevent=mysql_result($revt,$i,"event");
	$arrEvent[$tid]=$tevent;
  
    $i++;
  }
?>
<?
  $qrmk = "SELECT * FROM xoops_pc_remarkrecord WHERE remarkDate='$today_date' AND status='1'";
  $rrmk = mysql_query($qrmk);
  $nrmk = mysql_num_rows($rrmk);
  $i=0;
  while($i<$nrmk){
  
    $tstaffid=mysql_result($rrmk,$i,"staffid");
	$teventid=mysql_result($rrmk,$i,"eventid");
	$tnotice=mysql_result($rrmk,$i,"notice");
	
	$arrRmkevt[$tstaffid]=$teventid;
	$arrRmkntc[$tstaffid]=$tnotice;
  
    $i++;
  }
?>
<?
  $qrecord = "SELECT * FROM xoops_pc_punchrecord WHERE punchDate='$today_date'";
  $rrecord = mysql_query($qrecord);
  $nrecord = mysql_num_rows($rrecord);
  $i=0;
  while($i<$nrecord){
    
	$tteaid = mysql_result($rrecord,$i,"staffid");
	$arrTea1[$tteaid] = $tteaid;
	
    $i++;
  }
?>

<center>
<table style="font-size:11px " width="450" border="1">
<form action="main.php" method="get">
<input type="hidden" name="pg" value="rmk" />
<input type="hidden" name="ac" value="tska" />
  <tr bgcolor="#999999" style="color:#EEEEEE ">
  <td align="center">
	<input type="text" id="txtDate" name="dt" size="9" value="<?= $today_date ?>" onchange="this.form.submit()">
	<button id="btnDate" name="btnDate">...</button>
	<script type='text/javascript'>
		Calendar.setup({
			inputField : "txtDate",  //ID of the input field
			ifFormat   : "%Y-%m-%d",    //the date format
			button     : "btnDate"   //ID of the button
		});
	</script>
	<input type="submit" value="SUBMIT" />
  </td>
  </tr>
</form>

  <form action="rnktska_up.php" method="post">
  <input type="hidden" name="pdate" value="<?= $today_date ?>">
  <?
    foreach($arrTea0 as $ttid=>$ttval){
	  $txtTid = "arrTeaid0[$ttid]";
	?>
	<input type="hidden" name="<?= $txtTid ?>" value="<?= $ttid ?>" />
	<?
	}
  ?>
  <?
    foreach($arrTea1 as $ttid=>$ttval){
	  $txtTid = "arrTeaid1[$ttid]";
	?>
	<input type="hidden" name="<?= $txtTid ?>" value="<?= $ttid ?>" />
	<?
	}
  ?>

  <tr bgcolor="#999999" style="color:#EEEEEE ">
  <th align="center">
    NOTICE : <input type="text" id="mynotice" name="notice" style="width:300px"/>
  </th>
  </tr>
  <tr bgcolor="#999999" style="color:#EEEEEE ">
  <th align="center">
    ONLY FOR STAFF HAVE ATTENDED : <input type="checkbox" name="attdonly" value="1" checked="checked" />
  </th>
  </tr>
  <tr bgcolor="#999999" style="color:#EEEEEE ">
  <th align="center">
    <input type="submit" value="ADD REMARK" />
  </th>
  </tr>
  </form>
</table>
<br />
<?
//--- display pending request -----------
?>
<div style="width:650px; height:330px; overflow:auto; border-style:inset">
<table style="font-size:11px " width="640" border="1">
  <tr bgcolor="#999999" style="color:#EEEEEE ">
    <th width="120">NAME</th>
	<th width="60">PUNCH IN</th>
	<th width="60">PUNCH OUT</th>
	<th>REMARK</th>
  </tr>
<?
  $arrTeaid[] = "admin";

  $i=0;
  while($i<$nrecord){
    $tid = mysql_result($rrecord,$i,"punch_id");
	$teaid = mysql_result($rrecord,$i,"staffid");
	$punchin = mysql_result($rrecord,$i,"punchin");
	$punchout = mysql_result($rrecord,$i,"punchout");
	$tmsg = mysql_result($rrecord,$i,"message");
	
	$txtid = "myid[$tid]";
	
    if($arrRmkevt[$teaid]!=""){
	  $remark = $arrEvent[$arrRmkevt[$teaid]] . " - " . $arrRmkntc[$teaid];
	}else{
	  $remark = "&nbsp;";
	}
	
	if($remark=="&nbsp;"){
	  $remark = "$tmsg";
	}else{
	  if($tmsg==""){
	    $remark = $remark;
	  }else{
	    $remark = $remark . "; " . $tmsg;
	  }
	}
	
	$arrTeaid[] = $teaid;
?>
  <tr>
    <td><?= $arrTea[$teaid] ?></td>
	<td><?= $punchin ?></td>
	<td><?= $punchout ?></td>
	<td><?= $remark ?>&nbsp;</td>
  </tr>
<?
    $i++;
  }
?>
  
</table>
</div>
</center>
<script>
  function getNotice(pval){
    document.getElementById("mynotice2").value = pval;
  }
</script>