<link href="css/form.css" type="text/css" rel="stylesheet" />


<?php
    if(isset($_SESSION["ses_id_tpk"])){
      $id=$_SESSION["ses_id_tpk"];
    }else{
      $id=mysqli_real_escape_string($mysqli, $_GET["id"]);
    }
    $qry=mysqli_query($mysqli,"SELECT * FROM m_user WHERE id='$id'");
    if(mysqli_num_rows($qry)>0){

        $data=mysqli_fetch_array($qry);

    }

    echo "<h3>UBAH DATA PENGGUNA</h3>";
    echo "<h3 align=\"right\"><a href=\"?page=ls_user&page_desc=Daftar Pengguna\" style=\"color:#FF0066\">Kembali</a></h3>";

?>

<form name="form1" method="post" action="_edit_pengguna.php">
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="20%">&nbsp;</td>
      <td width="80%">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top">ID Pengguna</td>
      <td valign="top"><input type="hidden" name="txtId0" id="txtId0" class="kotak" size="40" value="<?php echo $data[id] ?>">
      <input type="text" name="txtId" id="txtId" class="kotak" size="40" value="<?php echo $data[username] ?>" required></td>
    </tr>

    <tr>
      <td valign="top">Nama Lengkap</td>
      <td valign="top"><input type="text" name="txtNama" id="txtNama" class="kotak" size="40" value="<?php echo $data[nama_lengkap] ?>" required></td>
    </tr>

    <tr>
      <td valign="top">Sandi*<br/><font color="red" size="1">Kosongkan kedua sandi jika tidak ingin mengubah sandi</font></td>
      <td valign="top"><input type="password" name="txtSandi1" id="txtSandi1" class="kotak" size="40" ></td>
    </tr>

    <tr>
      <td valign="top">Ulangi Sandi</td>
      <td valign="top"><input type="password" name="txtSandi2" id="txtSandi2" class="kotak" size="40" ></td>
    </tr>

    <tr>
        <?php
            $s_ulp="";$s_tpk="";
            if($data[level]=="ULP"){
                $s_ulp="selected";
                $s_tpk="";
            }elseif($data[level]=="TPK"){
                $s_ulp="";
                $s_tpk="selected";
            }
        ?>
      <?php
        if(isset($_SESSION["ses_id_tpk"])){
          $disabled="disabled";
        }else{
          $disabled="";
        }
      ?>  
      <td valign="top">Level Pengguna</td>
      <td valign="top">
          <select name="txtLevel" id="txtLevel" class="kotak" <?php  echo $disabled?> >
          <option value="ULP" <?php echo $s_ulp?> >Unit Layanan Pengadaan Barang/jasa (ULP Kabupaten Madiun)</option>
          <option value="TPK" <?php echo $s_tpk?>>Tim Pengelola Kegiatan Desa (TPK Desa)</option>
          </select>
      </td>
    </tr>

    <tr>
      <td valign="top">Desa*<br/><font color="red" size="1">Hanya diisi untuk Level TPK</font> </td>
      <td valign="top">
          <select name="txtDesa" id="txtDesa" class="kotak" <?php echo $disabled ?> >
            <option value="0">&nbsp;</option>
            <?php
                $q=mysqli_query($mysqli,"SELECT * FROM m_desa ORDER BY nama_desa ASC");
                while($d=mysqli_fetch_array($q)){
                    $s="";
                    if($data[id_desa]==$d[id_desa]){
                        $s="selected";
                    }
                    echo "<option value='$d[id_desa]' $s>$d[nama_desa]</option>";
                }
            ?>
          </select>
      </td>
    </tr>
    
    <tr>
      <td width="204">&nbsp;</td>
      <td width="396">&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="button" id="button" value="Simpan" class="tombol"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>

