<?
  include "include/CEVENT.php";
//  $mypcsys = new CSETTING();
?>
<style>
	.mytable{
		font-family: Arial;
		width: 500px;
		border-style: none;
		font-size: 13px;
	}
	
	.mytable_th{
		background-color: #999999;
		color: #EEEEEE;
	}
	
	.mytable_td1{
		background-color: #EEEEEE;
	}
	
	.mytable_td2{
		background-color: #DDDDDD;
	}
	
</style>
<?
  $qadmin = "SELECT * FROM xoops_adm_teacher WHERE id='admin'";
  $radmin = mysql_query($qadmin);
  $tadminpass = mysql_result($radmin,0,"password");
?>
<center>
<form action="syssttgup.php" method="post">
<table class="mytable">
  <tr class="mytable_th">
    <th colspan="2">PUNCH CARD SETTING</th>
  </tr>
  <tr>
<?
  if( $mypcsys->passverify==1 ){
    $chkPassverifyy = "CHECKED";
    $chkPassverifyn = "";
  }else{
    $chkPassverifyy = "";
    $chkPassverifyn = "CHECKED";
  }
?>
    <th width="150px" class="mytable_th" >PASSWORD VERIFY</th>
    <th  class="mytable_td1">
      <input type="radio" name="radPassverify" value="1" <?= $chkPassverifyy ?>>YES &nbsp;&nbsp;&nbsp;
      <input type="radio" name="radPassverify" value="0" <?= $chkPassverifyn ?>>NO
    </th>
  </tr>
  
  <tr>
    <th class="mytable_th">MAX PUNCH PER DAY</th>
    <th class="mytable_td2">
      <input type="text" name="txtMaxpunchtime" value="<?= $mypcsys->maxpunchtime ?>" size="5" style="text-align:center ">
    </th>
  </tr>
  
  <tr>
    <th class="mytable_th" >ADMIN PASSWORD</th>
    <th class="mytable_td1">
      <input type="password" name="txtAdminPass" value="<?= $tadminpass ?>" style="text-align:center ">
    </th>
  </tr>
  
  <?
    $arrStype = getStype();
  ?>
  <tr>
    <th class="mytable_th" >TYPE</th>
    <th class="mytable_td2">
      <select name="stype">
	  <?
	  foreach($arrStype as $tid=>$tstype){
	    if($mypcsys->stype == $tid){
		  $selected = "SELECTED";
		}else{
		  $selected = "";
		}
	  ?>
	    <option value="<?= $tid ?>" <?= $selected ?>><?= $tstype ?></option>
	  <?
	  }
	  ?>
	  </select>
    </th>
  </tr>
  
  <tr>
    <th class="mytable_th">AUTO REMARK FOR LATE</th>
    <th class="mytable_td1">
      <select name="autolate">
	    <?
		if($mypcsys->autolate=="1"){
		  $selected0 = "";
		  $selected1 = "SELECTED";
		  $disevent = "compact";
		}else{
		  $selected0 = "SELECTED";
		  $selected1 = "";
		  $disevent = "none";
		}
		?>
	    <option value="1" <?= $selected1 ?>>YES</option>
	    <option value="0" <?= $selected0 ?>>NO</option>
	  </select>
	  <select name="lateId" style="display:<?= $disevent ?>">
      <?
	    $arrEvent = getEventList();
		foreach($arrEvent as $tid=>$tevent){
		  if($mypcsys->lateId==$tid){
		    $selected = "SELECTED";
		  }else{
		    $selected = "";
		  }
		?>
		<option value="<?= $tid ?>" <?= $selected ?>><?= $tevent["event"] ?></option>
		<?
		}
	  ?>
	  </select>
    </th>
  </tr>
  
  <tr>
    <th class="mytable_th" >GB NAME</th>
    <th class="mytable_td2">
      <input type="text" name="gbname" value="<?= $mypcsys->gbname ?>"  style="text-align:center ">
    </th>
  </tr>
  
  <tr>
    <th class="mytable_th">G.TUGAS NAME</th>
    <th class="mytable_td1">
      <input type="text" name="gtname" value="<?= $mypcsys->gtname ?>"  style="text-align:center ">
    </th>
  </tr>
  
  <tr>
    <th colspan="2" class="mytable_th" >
	<input type="submit" value="UPDATE" style=" font-size:12px ">
	</th>
  </tr>
</table>
</form>
	
	<hr>
	
<?
  $qexsttg = "SELECT * FROM xoops_pc_exsttg ORDER BY tb_order";
  $rexsttg = $xoopsDB->query($qexsttg);
  $i=0;
  while($myrow = $xoopsDB->fetchArray($rexsttg)){
	  $arrExsttg[$myrow["name"]] = $myrow["val"];
	  $arrExsttgDesc[$myrow["name"]] = $myrow["descr"];
	  if($i==0){
		  $pExsttg0 = $myrow["name"];
	  }
	  $i++;
  }
?>


<table class="mytable">
  <tr class="mytable_th">
    <th colspan="2">EXTRA SETTING</th>
  </tr>
	
<?
	if( isset($_GET["pexsttg"]) ){
		$pexsttg = $_GET["pexsttg"];
	}else{
		$pexsttg = $pExsttg0;
	}
?>
	
  <tr class="mytable_td1">
	  
    <form action="main.php" method="get">
	<input type="hidden" name="pg" value="<?= $_GET["pg"] ?>">
	<input type="hidden" name="ac" value="<?= $_GET["ac"] ?>">
	<td align="right" valign="top">
	<select name="pexsttg" onChange="this.form.submit()">
	<?
	foreach($arrExsttg as $tname=>$tval){
		if($tname==$pexsttg){
			$selected = "SELECTED";
		}else{
			$selected = "";
		}
		?>
		<option value="<?= $tname ?>" <?= $selected ?>><?= $tname ?></option>
		<?
	}
	?>
	</select>
	</td>
	</form>


<?
	if($_GET["pexsttg"]!=""){
		$pval = $arrExsttg[$pexsttg];
	}else{
		$pval = $arrExsttg["face_mc"];
	}
?>
	<form action="syssttgex_up.php" method="post">
	<input type="hidden" name="pg" value="<?= $_GET["pg"] ?>">
	<input type="hidden" name="ac" value="<?= $_GET["ac"] ?>">
	<input type="hidden" name="pexsttg" value="<?= $pexsttg ?>">
	<td width="250px">
		<input type="text" name="pval" value="<?= $pval ?>">
    </td>

  </tr>
	
  <tr class="mytable_td2">
	  <td colspan="2" align="center">
		  <fieldset style="color: #0000FF">
			  <legend>Setting description</legend>
			  <?= $arrExsttgDesc[$pexsttg] ?>
		  </fieldset>
	  </td>
  </tr>
	
  <tr>
	  <th class="mytable_th" colspan="2">
		  <input type="submit" value="UPDATE">
	  </th>
  </tr>
  </form>
	
</table>
	  
	  
</center>