<?php
  $qadmin = "SELECT * FROM punchsys_staff WHERE id='admin'";
  $radmin = mysqli_query($conn,$qadmin);
  while($myrow = mysqli_fetch_array($radmin)){
	 $tadminpass = $myrow["password"]; 
  }
?>
<?php
  $qpej = "SELECT * FROM punchsys_staff WHERE id='pejabat'";
  $rpej = mysqli_query($conn,$qpej);
  $npej = mysqli_num_rows($rpej);
  if( $npej>0 ){
	  while($myrow = mysqli_fetch_array($rpej)){
		 $tpejpass = $myrow["password"]; 
	  }
  }else{
    $tpejpass = "";
  }
?>
<?php
  $qsys = "SELECT * FROM xoops_sps_system";
  $rsys = mysqli_query($conn,$qsys);
  while($myrow = mysqli_fetch_array($rsys)){
  	$tschname = $myrow["schName"];
	$tschlogo = $myrow["imgPath"];
  }
?>

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

<center>
<form action="syssttgup.php" method="post" enctype="multipart/form-data">
    
<input type="hidden" name="himgpath" value="<?= $tschlogo ?>">
<table border="0" cellpadding="0" cellspacing="1" class="mytable">

  <tr>
    <th colspan="2" class="mytableth">SYSTEM SETTING</th>
  </tr>

  <tr>
    <th class="mytableth">ORGANIZATION</th>
    <th bgcolor="#DDDDDD">
      <input type="text" name="txtSchName" value="<?= $tschname ?>" class="mytext" style="width:350px">
    </th>
  </tr>

  <tr>
    <th class="mytableth"><img src="img/<?= $tschlogo ?>" height="60px"></th>
    <th style="background-color: #DDDDDD; color: #838383">
      <input type="file" name="myfile">
    </th>
  </tr>
	
  <tr>
    <th class="mytableth">ADMIN PASSWORD</th>
    <th bgcolor="#DDDDDD">
      <input type="password" name="txtAdminPass" value="<?= $tadminpass ?>" class="mytext" >
    </th>
  </tr>
  
  <tr>
    <th class="mytableth">PEJABAT PASSWORD</th>
    <th bgcolor="#DDDDDD">
      <input type="password" name="txtPajPass" value="<?= $tpejpass ?>" class="mytext" >
    </th>
  </tr>
  
  <tr>
    <th class="mytableth">RIGHT SIGNATURE</th>
    <th bgcolor="#DDDDDD">
      <input type="text" name="gbname" value="<?= $mypcsys->gbname ?>"  class="mytext" >
    </th>
  </tr>
  
  <tr>
    <th class="mytableth">LEFT SIGNATURE</th>
    <th bgcolor="#DDDDDD">
      <input type="text" name="gtname" value="<?= $mypcsys->gtname ?>"  class="mytext" >
    </th>
  </tr>
  
<input type="hidden" name="stype" value="0" />
    
  <tr>
    <th colspan="2" class="mytableth">
	<input type="submit" value="UPDATE" class="mybtn" style="color: #0000FF">
	</th>
  </tr>
</table>
</form>

<hr />

<?
  $qexsttg = "SELECT * FROM punchsys_exsttg ORDER BY tb_order";
  $rexsttg = mysqli_query($conn,$qexsttg);
  $i=0;
  while($myrow = mysqli_fetch_array($rexsttg)){
	  $arrExsttg[$myrow["name"]] = $myrow["val"];
	  $arrExsttgDesc[$myrow["name"]] = $myrow["descr"];
	  if($i==0){
		  $pExsttg0 = $myrow["name"];
	  }
	  $i++;
  }
?>
<table border="1" cellpadding="0" cellspacing="1" class="mytable">
  <tr>
    <th colspan="2" class="mytableth">EXTRA SETTING</th>
  </tr>
<?
	if( isset($_GET["pexsttg"]) ){
		$pexsttg = $_GET["pexsttg"];
	}else{
		$pexsttg = $pExsttg0;
	}
?>
  <tr>
    <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" bgcolor="#DDDDDD" 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  bgcolor="#DDDDDD" width="50%">
		<input type="text" name="pval" value="<?= $pval ?>">
    </td>
	
  </tr>
  
  <tr>
	  <td colspan="2"  bgcolor="#DDDDDD" align="center">
		  <fieldset style="color: #0000FF">
			  <legend>Setting description</legend>
			  <?= $arrExsttgDesc[$pexsttg] ?>
		  </fieldset>
	  </td>
  </tr>
  
  <tr>
	  <th colspan="2" class="mytableth">
		  <input type="submit" value="UPDATE" class="mybtn" style="color: #0000FF">
	  </th>
  </tr>
  
	</form>
  
</table>

</center>