<style>
  .mytable{
    font-size:16px;
	width:550px;
	margin-top:10px;
	color:#FFFFFF;
  }
  
  .mytableth{
    background-color:#000000;
	color:#FFCC00;
	padding:5px 5px 5px 5px;
  }
    
    .mytabletd{
        background-color: #EEEEEE;
        text-align: center;
        color: #000000;
    }
  
  .mybtn{
    width:100px;
	font-size:14px;
	font-weight: bold;
	font-family: Arial;
  }
</style>

<?
  //---------------- section -------------------------
  $qsecid = "SELECT * FROM punchsys_staff WHERE id NOT IN ('admin','pejabat') ORDER BY section, repPrint";
  $rsecid = mysqli_query($conn,$qsecid);
  $nsec = mysqli_num_rows($rsecid);
  while($myrow = mysqli_fetch_array($rsecid)){
      $tsecid = $myrow["section"];
      $arrSecid[$tsecid] = $tsecid;
      $tstaffid = $myrow["id"];
      $arrStaffid[$tstaffid] = $tstaffid;
      $arrStaff[$tstaffid] = $myrow["eName"];
  }
  $strSecid = "'".implode("','",$arrSecid)."'";
  $strStaffid = "'".implode("','",$arrStaffid)."'";
?>
<?
  $qevetid = "SELECT DISTINCT eventId FROM punchsys_remarkrecord";
  $revetid = mysqli_query($conn,$qevetid);
  $nevetid = mysqli_num_rows($revetid);
  if($nevetid>0){
	  
  while($myrow = mysqli_fetch_array($revetid)){
      $tid = $myrow["eventId"];
      $arrEventid[$tid] = $tid;
  }
  $strEventid = "'".implode("','",$arrEventid)."'";

  $qevet = "SELECT * FROM punchsys_remarkevent WHERE id IN ($strEventid) ORDER BY tb_ord";
  $revet = mysqli_query($conn,$qevet);
  $nevet = mysqli_num_rows($revet);
  while($myrow = mysqli_fetch_array($revet)){
  
    $tid = $myrow["id"];
    $tevent = $myrow["event"];
	$arrEvent[$tid] = $tevent;

  }
	  
  }

//  $qrmk2 = "SELECT DISTINCT eventid FROM xoops_pc_remarkrecord r, xoops_pc_remarkevent e 
//              WHERE r.eventid=e.id ORDER BY e.tb_ord, e.id";
//  $rrmk2 = mysql_query($qrpunchsys_remarkrecordmk2);
//  $nrmk2 = $xoopsDB->queryows($rrmk2);
 // while($myrow = $xoopsDB->fetchArray($rrmk)){
//$d[$i] = mysql_result($rrmk2,$i,"eventid");
  
//    $i++;
//  }
?>


<center>
<table border="0" cellpadding="0" cellspacing="1" class="mytable">
  <tr bgColor="#999999" style="color: #EEEEEE">
    <th colspan="2" class="mytableth">REMARK REPORT</th>
  </tr>
    
<form action="main.php" method="get">
<input type="hidden" name="pg" value="<?= $_GET["pg"] ?>" />
<input type="hidden" name="ac" value="<?= $_GET["ac"] ?>" />
<tr>
  <th class="mytableth">
    REMARK TYPE
  </th>
  <td class="mytabletd" style="text-align: left; padding-left: 10px">
  <select name="rmk" onchange="this.form.submit()">
    <?
	  if($_GET["rmk"]==""){
	?>
    <option></option>
	<?
	  }
	?>
    <option value="a"><?= "ALL" ?></option>
<?
    foreach($arrEvent as $tid=>$tevent){
	  if($_GET["rmk"]==$tid){
	    $selected = "SELECTED";
	  }else{
	    $selected = "";
	  }
	?>
	<option value="<?= $tid ?>" <?= $selected ?>><?= $tevent ?></option>
	<?
	}
?>
  </select>
  </td>
</tr>
</form>

<form action="rptltely2_prv.php" method="post">
<input type="hidden" name="rmk" value="<?= $_GET["rmk"] ?>" />
<?
/*
  $sec = $_GET["sec"];
  if($sec=="a"){
    $exquery="id<>''";
  }else{
    $exquery=" section='$sec'";
  }
  //--------- teacher id ---------------
  $qtea = "SELECT * FROM xoops_adm_teacher WHERE $exquery AND id<>'admin' ORDER BY id";
  $rtea = mysql_query($qtea);
  $ntea = mysql_num_rows($rtea);
?>
  <th bgColor="#999999" style="color: #EEEEEE">
    TEACHER
  </th>
  <th bgcolor="#EEEEEE">
  <select name="tea1">
    <option value="_all">ALL</option>
<?
  $i=0;
  while($i<$ntea){
    $id = mysql_result($rtea,$i,"id");
	$name = mysql_result($rtea,$i,"ename");
	if(strlen($name)>18){
	  $dot = "...";
	}else{
	  $dot = "";
	}
	$name = substr($name,0,15) . $dot;
	
	echo "<option value='$id'>($id) $name</option>";
    $arrTeaid[]=$id;
	
    $i++;
  }
?>
  </select>
  </th>
</tr>
<?
  $strTeaid = implode(",",$arrTeaid);
  */
?>
<form action="rptltelyprv.php" method="post">
<?
  //------- staff ---------------------------
?>
<tr>
    <th class="mytableth">STAFF</th>
    <td class="mytabletd" style="text-align: left; padding-left: 10px">
        <select name="tea1">
            <option value="a">ALL</option>
            <?
            foreach($arrStaff as $tid=>$tstaff){
                echo "<option value='$tid'>$tstaff</option>";
            }
            ?>
        </select>
    </td>
</tr>
<?
  //------- date ---------------------------
?>
<tr>
  <th class="mytableth">DATE</th>
  <td class="mytabletd" style="text-align: left; padding-left: 10px">
	<input type="date" id="txtDatefrom" name="txtDatefrom" size="9" value="<?= $today_date ?>">

    &nbsp; UNTIL &nbsp;

	<input type="date" id="txtDatetil" name="txtDatetil" size="9" value="<?= $today_date ?>">

  </td>
</tr>




<input type="hidden" name="pbrk" value="y" />
<!--tr>
  <th bgColor="#999999" style="color: #EEEEEE">
    PAGE BREAK
  </th>
  <th bgcolor="#EEEEEE">
    <input type="radio" name="pbrk" value="y" checked> YES &nbsp;&nbsp;&nbsp; 
	<input type="radio" name="pbrk" value="n">NO
  </th>
</tr-->

<tr bgColor="#999999" style="color: #EEEEEE">
  <th class="mytableth" colspan="2"><input type="submit" value="REPORT" class="mybtn" style="color: #0000FF"></th>
</tr>
<input type="hidden" name="teaids" value="<?= $strStaffid ?>" />
</form>

</table>
</center>