
<?php 
include 'header.php';


?>


<div class="container">

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

  <section class="content">
    <div class="row justify-content-center">
      <div class="col-lg-4">    
        <div class="card card-info">
          <div class="card-header justify-content-between d-flex">
            <span class="card-title fw-semibold">Detail Karyawan</span>
          </div>
          <div class="card-body">
            <?php 
            $id = $_GET['id'];              
            $data = mysqli_query($koneksi, "select * from karyawan where id='$id'");
            while($d = mysqli_fetch_array($data)){

                $gapok = mysqli_query($koneksi,"select * from karyawan_gapok where id='$id'");
                $g = mysqli_fetch_assoc($gapok);
                
                $iden = mysqli_query($koneksi,"select * from karyawan_iden where id='$id'");
                $i = mysqli_fetch_assoc($iden);
                
                mysqli_query($koneksi, "update karyawan set k_latitude='$i[k_latitude]',k_longitude='$i[k_longitude]' where id='$i[id]'");
                
              ?>
              <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'] ?>" disabled>
              </div>

              <div class="form-group mb-2">
                <label class="form-label">NIP</label>
                <input type="text" class="form-control" name="nip" value="<?php echo $i['nip'] ?>" disabled>
              </div>

              <div class="form-group mb-2">
                <label class="form-label">Jabatan</label>
                <input type="text" class="form-control" name="jabatan" value="<?php echo $d['jabatan'] ?>" disabled>
              </div>
              <div class="form-group mb-2">
                <label class="form-label">Alamat</label>
                <input type="text" class="form-control" name="alamat" value="<?php echo $d['alamat'] ?>" disabled>
              </div>
<!--              <hr>      -->
              <div class="form-group mb-2">
                <label class="form-label">Contak Person (HP/WA)</label>
                <input type="text" class="form-control" name="hp" value="<?php echo $i['hp'] ?>" disabled>
              </div>
              <div class="form-group mb-2">
                <label class="form-label">Tanggal Gabung</label>
                <input type="text" class="form-control" name="tgl" value="<?php echo $i['tanggal'] ?>" disabled>
              </div>
              <div class="form-group mb-2">
                <label class="form-label">Status</label>
                <input type="text" class="form-control" name="status" value="<?php echo $i['status'] ?>" disabled>
              </div>  
              <div class="form-group mb-2">
                <label class="form-label">Gol</label>
                <input type="text" class="form-control" name="gol" value="<?php echo $i['gol'] ?>" disabled>
              </div> 
          
              <?php
            }
            ?>
          </div>
        </div>






      </div>
      <div class="col-lg-3">
       <div class="card card-info">
          <div class="card-header justify-content-between d-flex">
            <span class="card-title fw-semibold">Data Gaji</span>
            <a href="b_karyawan_top.php" class="btn btn-success btn-sm pull-right"><i class="bi bi-printer"></i> &nbsp; Cetak Slip</a> 
          </div>
        <div class="card-body">
            <?php 
            $id = $_GET['id'];              
            $data = mysqli_query($koneksi, "select * from karyawan where id='$id'");
            while($d = mysqli_fetch_array($data)){

                $gapok = mysqli_query($koneksi,"select * from karyawan_gapok where id='$id'");
                $g = mysqli_fetch_assoc($gapok);
                
                $iden = mysqli_query($koneksi,"select * from karyawan_iden where id='$id'");
                $i = mysqli_fetch_assoc($iden);
                
              ?>

              <div class="form-group mb-2">
                <label class="form-label">Gaji Pokok</label>
                <input type="text" class="form-control" name="gapok" value="<?php echo "Rp. " . number_format("$g[gapok]", 0, ",", "."); ?>" disabled>
              </div>  
              <div class="form-group mb-2">
                <label class="form-label">Tunjangan Jabatan</label>
                <input type="text" class="form-control" name="jabatan" value="<?php echo "Rp. " . number_format("$g[t_jabatan]", 0, ",", "."); ?>" disabled>
              </div>                 
              <div class="form-group mb-2">
                <label class="form-label">Tunjangan Keluarga</label>
                <input type="text" class="form-control" name="keluarga" value="<?php echo "Rp. " . number_format("$g[t_keluarga]", 0, ",", "."); ?>" disabled>
              </div>                 
              <div class="form-group mb-2">
                <label class="form-label">Tunjangan Kesehatan</label>
                <input type="text" class="form-control" name="kesehatan" value="<?php echo "Rp. " . number_format("$g[t_kesehatan]", 0, ",", "."); ?>" disabled>
              </div>
              <div class="form-group mb-2">
                <label class="form-label">Potongan Arisan</label>
                <input type="text" class="form-control" name="p_arisan" value="<?php echo "Rp. " . number_format("$g[p_arisan]", 0, ",", "."); ?>" disabled>
              </div>
              <div class="form-group mb-2">
                <label class="form-label">Potongan Dansos</label>
                <input type="text" class="form-control" name="p_dansos" value="<?php echo "Rp. " . number_format("$g[p_dansos]", 0, ",", "."); ?>" disabled>
              </div>              
            <?php
          }

          ?>
        </div>
        </div>








      </div>
      <div class="col-lg-5">
       <div class="card card-info">

        <div class="card-header justify-content-between d-flex">
          <span class="card-title fw-semibold">Foto</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">
          <?php 
          $id = $_GET['id'];              
          $data = mysqli_query($koneksi, "select * from karyawan where id='$id'");
          while($d = mysqli_fetch_array($data)){
            ?>
              <center>
                <?php if($i['foto'] == ""){ ?>
                  <img src="../gambar/user.png" style="width: 100px;height: auto">
                <?php }else{ ?>
                  <img src="../gambar/karyawan/<?php echo $i['foto'] ?>" style="width: 150px;height: auto">
                <?php } ?>
              </center>
                <hr>    
                
            <label class="fw-bold">Lokasi Alamat </label>
            <div class="form-group mb-2">
              <label class="form-label">Kode Latitude</label>
              <input type="text" class="form-control" name="latitude" value="<?php echo $d['k_latitude'] ?>" disabled>
            </div>
            <div class="form-group mb-2">
              <label class="form-label">Kode Longitude</label>
              <input type="text" class="form-control" name="longitude" value="<?php echo $d['k_longitude'] ?>" disabled>
            </div>

            <hr>      


            <?php if($d['k_latitude'] == "" && $d['k_longitude'] == ""){ ?>
              <div class="alert alert-danger">Lokasi alamat g-map ini belum di input.</div>
            <?php }else{ ?>
            <div class="form-group mb-2">
                <a href="https://www.google.com/search?q=google+map+<?php echo $d['k_latitude'] ?>%2C+<?php echo $d['k_longitude'] ?>" target="_blank" class="btn btn-warning btn-sm pull-right"><i class="bi bi-shop"></i> &nbsp; Klik disini ke Google Map lokasi alamat</a>
            </div>                
<!--            
              <div class="alert alert-primary mb-2">Jarak dari rumah ke kantor : <span class="fw-bold jarak"></span></div>
              <div id="map" latitude="<?php echo $d['k_latitude'] ?>" longitude="<?php echo $d['k_longitude'] ?>" style="width:100%; height:300px"></div>
-->
            <?php } ?>

            <?php
          }

          ?>
        </div>

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

</div>

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