<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"];
  }
?>
<center>
<form action="main.php" method="get">
<input type="hidden" name="pg" value="rmk" />
<input type="hidden" name="ac" value="tsk" />
<table style="font-size:11px " width="400" border="1">
  <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>
</table>
</form>
<?
  $qtea = "SELECT * FROM punchsys_staff WHERE userID<>'1'";
  $rtea = mysqli_query($conn,$qtea);
  $ntea = mysqli_num_rows($rtea);
  $i=0;
  while($myrow = mysqli_fetch_array($rtea)){
    $tname = substr($myrow["eName"],0,24);
	$tid = $myrow["id"];
	
	$arrTea[$tid] = $tname;
    $i++;
  }

?>
<?
  $qevt = "SELECT * FROM punchsys_remarkevent";
  $revt = mysqli_query($conn,$qevt);
  $nevt = mysqli_num_rows($revt);
  $i=0;
  while($myrow = mysqli_fetch_array($revt)){
  
    $tid = $myrow["id"];
	$tevent = $myrow["event"];
	$arrEvent[$tid]=$tevent;
  
    $i++;
  }
?>
<?
  $qrmk = "SELECT * FROM punchsys_remarkrecord WHERE remarkDate='$today_date' AND status='1'";
  $rrmk = mysqli_query($conn,$qrmk);
  $nrmk = mysqli_num_rows($rrmk);
  $i=0;
  while($myrow = mysqli_fetch_array($rrmk)){
  
    $tstaffid = $myrow["staffId"];
	$teventid = $myrow["eventId"];
	$tnotice = $myrow["notice"];
	
	$arrRmkevt[$tstaffid]=$teventid;
	$arrRmkntc[$tstaffid]=$tnotice;
  
    $i++;
  }
?>
<?
  $qrecord = "SELECT * FROM xoops_pc_punchrecord WHERE punchDate='$today_date'";
  $rrecord = mysqli_query($conn,$qrecord);
  $nrecord = mysqli_num_rows($rrecord);
?>
<?
//--- display pending request -----------
?>
<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>
	<th width="100"></th>
  </tr>
<?
  $arrTeaid[] = "admin";

  $i=0;
  while($myrow = mysqli_fetch_array($rrecord)){
    $tid = $myrow["punch_id"];
	$teaid = $myrow["staffId"];
	$punchin = $myrow["punchIn"];
	$punchout = $myrow["punchOut"];
	
    if($arrRmkevt[$teaid]!=""){
	  $remark = $arrEvent[$arrRmkevt[$teaid]] . " - " . $arrRmkntc[$teaid];
	}else{
	  $remark = "&nbsp;";
	}
	
	$arrTeaid[] = $teaid;
?>
  <form action="main.php" method="get">
  <input type="hidden" name="pg" value="<?= $_GET["pg"] ?>">
  <input type="hidden" name="ac" value="tsk2">
  <input type="hidden" name="pdate" value="<?= $today_date ?>">
  <input type="hidden" name="teaid" value="<?= $teaid ?>">
  <tr>
    <td><?= $arrTea[$teaid] ?></td>
	<td><?= $punchin ?></td>
	<td><?= $punchout ?></td>
	<td><?= $remark ?>&nbsp;</td>
	<td align="center"><input style="font-size:10px" type="submit" name="submit" value="ADD TASK"></td>
  </tr>
  </form>
<?
    $i++;
  }
?>


<?
  $strTeaid = "'".implode("','",$arrTeaid)."'";
  $qtea2 = "SELECT * FROM xoops_adm_teacher WHERE id NOT IN ($strTeaid) AND userID<>'1' ORDER BY ename";
  $rtea2 = mysqli_query($conn,$qtea2);
  $ntea2 = mysqli_num_rows($rtea2);
?>
  <form action="main.php" method="get">
  <input type="hidden" name="pg" value="<?= $_GET["pg"] ?>">
  <input type="hidden" name="ac" value="tsk22">
  <input type="hidden" name="pdate" value="<?= $today_date ?>">
  <tr bgcolor="#DFDFDF">
    <td>
	<select name="teaid" style="font-family:Arial; font-size:11px">
	<?
    $i=0;
	while($myrow = mysqli_fetch_array($rtea2)){
	
	  $tid = $myrow["id"];
	  $tename = $myrow["eName"];
	  
	  echo "<option value='$tid'>$tename</option>";
	
	  $i++;
	}
	?>
	</select>
	</td>
	<td>00:00:00</td>
	<td>00:00:00</td>
	<td>&nbsp;</td>
	<td align="center"><input style="font-size:10px" type="submit" name="submit" value="ADD TASK"></td>
  </tr>
  </form>
  
</table>
</center>