<?php 
include 'header.php';
    $id = $_GET['id'];
    
                $user = mysqli_query($koneksi,"select * from user where user_id='$id'");
                $u = mysqli_fetch_assoc($user);
                $foto=$u['user_foto'] ;

                $iden = mysqli_query($koneksi,"select * from karyawan WHERE id='$u[id_kar]'");
                    $i = mysqli_fetch_assoc($iden); 
        
                $angg = mysqli_query($koneksi,"select * from anggota where angg_no='$i[angg_no]'");
                $a = mysqli_fetch_assoc($angg);
                
                if ($i['ket']=='PP') { ;
                    $nm_kar=$a['nama'] ;
                } else {
                    $nm_kar=$i['nama'] ;
                }    
?>

<div class="container">

  <div class="my-2 border-bottom">
 <!--   <h2 class="fw-semibold fs-3">Profil</h2> -->
  </div>

  <section class="content">
    <div class="row justify-content-center">
      <section class="col-lg-5">       
        <div class="card card-info">

          <div class="card-header justify-content-between d-flex">
            <span class="card-title fw-semibold">Edit Profil User ID <?php echo $i['ket'] ?>.<?php echo $u[id_kar] ?>.<?php echo $id ?></span>
            <a href="index.php" class="btn btn-primary btn-sm pull-right"><i class="bi bi-reply"></i> &nbsp; Kembali</a> 
          </div>
          <div class="card-body">
<div style="background-color: #DCDCDC; padding: 15px; border-radius: 15px; box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);">              
            <form action="a_user_update_x.php" method="post" enctype="multipart/form-data">
              <div class="form-group mb-2">
                <label class="form-label">Foto Profil Karyawan</label>
                <div>
                    <center>
                    <?php if($foto == ""){ ?>
                      <img src="../gambar/user.png" style="width: 130px;height: auto">
                    <?php }else{ ?>
                      <img src="../gambar/karyawan/<?php echo $foto ?>" style="width: 350px;height: auto">
                    <?php } ?>
                    </center>
                    <input type="hidden" class="form-control" name="foto_lama" value="<?php echo $foto ?>" required="readonly">
                </div>
              </div>
                <div class="form-group mb-2">
                  <label class="form-label">Nama Karyawan (Tidak Bisa Diedit / Edit lewat Data Karyawan)</label>
                  <input type="text" class="form-control" name="nama" value="<?php echo $nm_kar ?>" required="required" readonly="readonly" >
                  <input type="hidden" class="form-control" name="id" value="<?php echo $id ?>" required="required">
                  <input type="hidden" class="form-control" name="id_kar" value="<?php echo $u['id_kar'] ?>" required="required">
                </div>

                 <div class="form-group mb-2">
                  <label class="form-label">Username</label>
                  <input type="text" class="form-control" name="user" value="<?php echo $u['user_username'] ?>" required="required">
                </div>

                
                <div class="form-group mb-2">
                  <label class="form-label">Foto</label>
                  <input type="file" name="foto" class="form-control">
                  <p>Kosong Jika tidak ingin di ganti</p>
                </div>
              
                <div class="form-group mb-2">
                  <input type="submit" class="btn btn-primary" value="Simpan">
                </div>
            </form>
          </div>

        </div>
      </section>
    </div>
  </section>

</div>
<?php include 'footer.php'; ?>