<?
  include "include/CEVENT.php";
?>
<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["pdte"]!=""){
    $pdate = $_GET["pdte"];
  }else{
    $pdate = date("Y-m-d");
  }
?>
<center>
<form action="main.php" method="get">
<input type="hidden" name="pg" value="pch" />
<table border="0" cellpadding="0" cellspacing="1" class="mytable">
    <tr><td>
DATE : <input type="text" name="pdte" id="pdte" value="<?= $pdate ?>" onchange="this.form.submit()" />
    </td></tr>
    </table>
  <button id="btnPdate" >...</button>
  <script type='text/javascript'>
	Calendar.setup({
	inputField : "pdte",  //ID of the input field
	ifFormat   : "%Y-%m-%d",   //the date format
	button     : "btnPdate"   //ID of the button
	});
  </script>
</form>
</center>
<?
  function myRemoveArr($arr1, $arr2){
    foreach($arr2 as $tid){
	  if(isset($arr1[$tid])){
	    unset($arr1[$tid]);
	  }
	}
	return $arr1;
  }
?>
<?
  $arrTea1 = getTeaList();
  $arrTea2 = getTeaListOfDate($pdate);
if(count($arrTea2)>0){
  $arrTea0 = myRemoveArr($arrTea1, $arrTea2);
}else{
    $arrTea0 = $arrTea1;
}
?>
<style>
.menu1{
  background-color:#999999;
  color:#EEEEEE;
  font-family:Arial;
  font-weight:bold;
  cursor:pointer;
}
.menu2{
  background-color:#DDDDDD;
  color:#999999;
  font-family:Arial;
  font-weight:bold;
  cursor:pointer;
}
</style>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td>

<table cellpadding="0" cellspacing="0">
<tr><td id="mymenu1" class="menu1">
<span onclick="jsmymenu1()" onclick="jsmymenu1()">&nbsp;&nbsp;PUNCH RECORD&nbsp;&nbsp;</span>
</td>
<!--td>&nbsp;&nbsp;</td>
<td id="mymenu2" class="menu2">
<span onclick="jsmymenu2()" onclick="jsmymenu2()">&nbsp;&nbsp;PUNCH RECORD & REMARK&nbsp;&nbsp;</span>
</td--></tr>
</table>

</td></tr>
<tr><td>

<table id="tblmenu1" width="100%">
<form action="record_sav.php" method="post">
<input type="hidden" name="pdate" value="<?= $pdate ?>" />
<tr style="background-color:#999999">
  <th>TEACHER</th>
  <th>PUNCH IN</th>
  <th>PUNCH OUT</th>
  <th>&nbsp;</th>
</tr>
<tr align="center">
  <td bgcolor="#CCCCCC">
  <select name="teaid">
  <?
  foreach($arrTea0 as $tid=>$arrTea){
    if($arrTea["status"]!="1"){
    ?>
    <option value="<?= $tid ?>"><?= $arrTea["ename"] ?></option>
    <?
	}
  }
  ?>
  </select>
  </td>
  <?
    for($i=0;$i<24;$i++){
	  if($i<10){
	    $thr="0".$i;
	  }else{
	    $thr=$i;
	  }
	  $arrHr[]=$thr;
	}
    for($i=0;$i<60;$i++){
	  if($i<10){
	    $tmin="0".$i;
	  }else{
	    $tmin=$i;
	  }
	  $arrMin[]=$tmin;
	}
  ?>
  <td bgcolor="#CCCCCC">
  <select name="inhr">
    <?
	foreach($arrHr as $thr){
	  ?>
	  <option value="<?= $thr ?>"><?= $thr ?></option>
	  <?
	}
	?>
  </select>:
  <select name="inmin">
    <?
	foreach($arrMin as $tmin){
	  ?>
	  <option value="<?= $tmin ?>"><?= $tmin ?></option>
	  <?
	}
	?>
  </select>
  </td>
  <td bgcolor="#CCCCCC">
  <select name="outhr">
    <?
	foreach($arrHr as $thr){
	  ?>
	  <option value="<?= $thr ?>"><?= $thr ?></option>
	  <?
	}
	?>
  </select>:
  <select name="outmin">
    <?
	foreach($arrMin as $tmin){
	  ?>
	  <option value="<?= $tmin ?>"><?= $tmin ?></option>
	  <?
	}
	?>
  </select>
  </td>
  <td bgcolor="#CCCCCC">
    <input type="submit" value="ADD" />
  </td>
</tr>
</form>
</table>

<table id="tblmenu2" width="100%" style="display:none">
<form action="record_sav.php" method="post">
<input type="hidden" name="pdate" value="<?= $pdate ?>" />
<tr style="background-color:#999999">
  <th>TEACHER</th>
  <th>PUNCH IN</th>
  <th>PUNCH OUT</th>
</tr>
<tr align="center">
  <td bgcolor="#CCCCCC">
  <select name="teaid">
  <?
  foreach($arrTea0 as $tid=>$arrTea){
    if($arrTea["status"]!="1"){
    ?>
    <option value="<?= $tid ?>"><?= $arrTea["ename"] ?></option>
    <?
	}
  }
  ?>
  </select>
  </td>
  <?
    for($i=0;$i<24;$i++){
	  if($i<10){
	    $thr="0".$i;
	  }else{
	    $thr=$i;
	  }
	  $arrHr[]=$thr;
	}
    for($i=0;$i<60;$i++){
	  if($i<10){
	    $tmin="0".$i;
	  }else{
	    $tmin=$i;
	  }
	  $arrMin[]=$tmin;
	}
  ?>
  <td bgcolor="#CCCCCC">
  <select name="inhr">
    <?
	foreach($arrHr as $thr){
	  ?>
	  <option value="<?= $thr ?>"><?= $thr ?></option>
	  <?
	}
	?>
  </select>:
  <select name="inmin">
    <?
	foreach($arrMin as $tmin){
	  ?>
	  <option value="<?= $tmin ?>"><?= $tmin ?></option>
	  <?
	}
	?>
  </select>
  </td>
  <td bgcolor="#CCCCCC">
  <select name="outhr">
    <?
	foreach($arrHr as $thr){
	  ?>
	  <option value="<?= $thr ?>"><?= $thr ?></option>
	  <?
	}
	?>
  </select>:
  <select name="outmin">
    <?
	foreach($arrMin as $tmin){
	  ?>
	  <option value="<?= $tmin ?>"><?= $tmin ?></option>
	  <?
	}
	?>
  </select>
  </td>
</tr>

<?
  $arrEvent = getEventList();
?>
<tr bgcolor="#CCCCCC">
  <td colspan="3" align="center">
  
  <table>
  <tr><td>
    EVENT : 
  </td>
  <td>
  <select name="eventid">
<?
  foreach($arrEvent as $id=>$event){
    echo "<option value='$id'>".$event["event"]."</option>";
  }
?>
    </select>
  </td>
  </tr>
  <tr>
  <td>
	DESCRIPTION :
  </td>
  <td>
	<textarea name="notice" rows="3" cols="30"></textarea>
  </td>
  </tr>
  </table>
  
</tr>
<tr>
  <td colspan="3" align="center" style="background-color:#999999">
  <input type="submit" value="SUBMIT" />
  </td>
</tr>
</form>
</table>

</td>
</tr>
</table>
<script>
  function jsmymenu2(){
    document.getElementById("mymenu1").className = "menu2";
    document.getElementById("mymenu2").className = "menu1";
	document.getElementById("tblmenu1").style.display = "none";
	document.getElementById("tblmenu2").style.display = "";
  }
  function jsmymenu1(){
    document.getElementById("mymenu1").className = "menu1";
    document.getElementById("mymenu2").className = "menu2";
	document.getElementById("tblmenu1").style.display = "";
	document.getElementById("tblmenu2").style.display = "none";
  }
</script>