<?php 
include 'header.php';
?>

<div class="container">

  <div class="my-4 border-bottom">
    <h4 class="fw-semibold fs-3"></h4>
  </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">Lengkapi Data Edit Karyawan</span>
            <a href="b_karyawan_top.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: <?php echo$_SESSION['warna_bag']; ?>; padding: 15px; border-radius: 15px; box-shadow: 0 0 15px <?php echo$_SESSION['warna_bag']; ?>;">        
            <form action="b_karyawan_update.php" method="post" enctype="multipart/form-data">

          <?php 
          $id = $_GET['id'];              
          $data = mysqli_query($koneksi, "select * from karyawan where id='$id'");
          while($d = mysqli_fetch_array($data)){
                $karyawan_iden = mysqli_query($koneksi,"select * from karyawan_iden where id='$d[id]'");
                $i = mysqli_fetch_assoc($karyawan_iden);              
            ?>
              <center>
                <?php if($i['foto'] == ""){ ?>
                  <img src="../gambar/user.png" style="width: 30px;height: auto">
                <?php }else{ ?>
                  <img src="../gambar/karyawan/<?php echo $i['foto'] ?>" style="width: 50px;height: auto">
                <?php } ?>
              </center>
                <hr>  
                <div class="form-group mb-2">
                  <label class="form-label">Nama</label>
                  <input type="text" class="form-control" name="nama" value="<?php echo $d['nama'] ?>" required="required">
                  <input type="hidden" class="form-control" name="id" value="<?php echo $d['id'] ?>" required="required">
                  <input type="hidden" class="form-control" name="foto_lama" value="<?php echo $foto ?>" required="required">
                </div>

                 <div class="form-group mb-2">
                    <label>Alamat</label>
                    <input type="text" name="alamat" required="required" class="form-control" placeholder="..." value="<?php echo $d['alamat']; ?>" style="width:100%">
                </div>
                 <div class="form-group mb-2">
                    <label>Jabatan</label>
                    <input type="text" name="jabatan" required="required" class="form-control" placeholder="..." value="<?php echo $d['jabatan']; ?>" style="width:100%">
                </div>
                            <div class="form-group mb-2">
                              <label>Nomor Induk Karyawan </label>
                              <input type="text" name="nip" required="required" class="form-control" placeholder="......" value="<?php echo $i['nip']; ?>" style="width:100%">
                            </div>                 
                            <div class="form-group mb-2">
                              <label>No. Kontak / HP / WA </label>
                              <input type="text" name="hp" required="required" class="form-control" placeholder="......" value="<?php echo $i['hp']; ?>" style="width:100%">
                            </div>                            
                            <div class="form-group mb-2">
                              <label>Kdm / Bukan (isi dengan KDM jika Karyawan ini digolongkan sebagai AO-Kredit) </label>
                              <input type="text" name="kdm" required="required" class="form-control" placeholder="......" value="<?php echo $d['jab']; ?>" style="width:100%">
                            </div>                            
                            <div class="form-group mb-2">
                              <label>Acc / Bukan (isi dengan ACC... jika Karyawan ini digolongkan sebagai Kelompok ACC Maker) </label>
                              <input type="text" name="acc" required="required" class="form-control" placeholder="......" value="<?php echo $d['acc']; ?>" style="width:100%">
                            </div>                            
                            <div class="form-group mb-2">
                              <label>Tanggal Gabung </label>
                              <input type="date" name="tanggal" required="required" class="form-control" placeholder="......" value="<?php echo $i['tanggal']; ?>" style="width:100%">
                            </div>                            
                            <div class="form-group mb-2">
                              <label>G-map Latitude </label>
                              <input type="text" name="k_latitude" required="required" class="form-control" placeholder="......" value="<?php echo $i['k_latitude']; ?>" style="width:100%">
                            </div>  
                            <div class="form-group mb-2">
                              <label>G-map Longitude </label>
                              <input type="text" name="k_longitude" required="required" class="form-control" placeholder="......" value="<?php echo $i['k_longitude']; ?>" style="width:100%">
                            </div>                
                <div class="form-group mb-2">
                  <label class="form-label">Foto</label>
                  <input type="file" name="foto" class="form-control">
                  <p>Kosongi Jika tidak ingin di ganti</p>
                </div>
              
                <div class="form-group mb-2">
                  <input type="submit" class="btn btn-primary" value="Simpan">
                </div>
                <?php
              }

              ?>
              
            </form>
          </div>

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

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