

 <?php  
// fungsi untuk pengecekan tampilan form
// jika form add data yang dipilih
if ($_GET['form']=='add') { ?> 
  <!-- tampilan form add data -->
	<!-- Content Header (Page header) -->
  <section class="content-header">
    <h1>
      <i class="fa fa-edit icon-title"></i> Tambah Karyawan
    </h1>

  </section>

  <!-- Main content -->
  <section class="content">
    <div class="row">
      <div class="col-md-12">
        <div class="box box-primary">
          <!-- form start -->
          <form role="form" class="form-horizontal" action="modules/karyawan/proses.php?act=insert" method="POST"  enctype="multipart/form-data">
            <div class="box-body">
    

              <div class="form-group">
                <label class="col-sm-2 control-label">Nama</label>
                <div class="col-sm-5">
                  <input type="text" class="form-control" name="nama" autocomplete="off" required>
                </div>
              </div>

          

              <div class="form-group">
                <label class="col-sm-2 control-label">HP</label>
                <div class="col-sm-5">
                    <input type="number" class="form-control" id="hp" name="hp" autocomplete="off" required>
                </div>
              </div>
			  
			  <div class="form-group">
                <label class="col-sm-2 control-label">Sistem</label>
                <div class="col-sm-5">
                  <select class="form-control" name="sistem" required>
                    <option value="<?php echo $data['sistem']; ?>"><?php echo $data['sistem']; ?></option>
                    <option value="Bulanan">Bulanan</option>
                    <option value="Harian">Harian</option>
                  </select>
                </div>
              </div>

              <div class="form-group">
                <label class="col-sm-2 control-label">Alamat</label>
                <div class="col-sm-5">
                    <input type="text" class="form-control" id="alamat" name="alamat" autocomplete="off" >
                </div>
              </div>
			  
			  <div class="form-group">
                <label class="col-sm-2 control-label">NIK</label>
                <div class="col-sm-5">
                    <input type="text" class="form-control" id="npwp" name="npwp" autocomplete="off" >
                </div>
              </div>
			  
			  <div class="form-group">
                <label class="col-sm-2 control-label">Tempat Lahir</label>
                <div class="col-sm-5">
                    <input type="text" class="form-control" id="tempatlahir" name="tempatlahir" autocomplete="off" >
                </div>
              </div>
			  
			  
			  <div class="form-group">
                <label class="col-sm-2 control-label">Tgl Lahir</label>
                <div class="col-sm-5">
                    <input type="text" class="form-control" id="tgllahir" name="tgllahir" autocomplete="off" >
                </div>
              </div>
			  
			  
			   <div class="form-group">
                <label class="col-sm-2 control-label">Image</label>
                <div class="col-sm-5">
                  <input type="file" name="foto">
                </div>
              </div>




            </div><!-- /.box body -->

            <div class="box-footer">
              <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                  <input type="submit" class="btn btn-primary btn-submit" name="simpan" value="Simpan">
                  <a href="?module=karyawan" class="btn btn-default btn-reset">Batal</a>
                </div>
              </div>
            </div><!-- /.box footer -->
          </form>
        </div><!-- /.box -->
      </div><!--/.col -->
    </div>   <!-- /.row -->
  </section><!-- /.content -->
<?php
}
// jika form edit data yang dipilih
// isset : cek data ada / tidak
elseif ($_GET['form']=='edit') { 
  if (isset($_GET['id'])) {
      // fungsi query untuk menampilkan data dari tabel obat
      $query = mysqli_query($mysqli, "SELECT * FROM karyawan WHERE id='$_GET[id]'") 
                                      or die('Ada kesalahan pada query tampil : '.mysqli_error($mysqli));
      $data  = mysqli_fetch_assoc($query);
	   $images = $data['images'];
    }
?>
  <!-- tampilan form edit data -->
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <h1>
      <i class="fa fa-edit icon-title"></i> Edit Karyawan
    </h1>

  </section>

  <!-- Main content -->
  <section class="content">
    <div class="row">
      <div class="col-md-12">
        <div class="box box-primary">
          <!-- form start -->
          <form role="form" class="form-horizontal" action="modules/karyawan/proses.php?act=update" method="POST" enctype="multipart/form-data">
            <div class="box-body">
              <input type="text" class="form-control" style="display:none;" name="id" value="<?php echo $data['id']; ?>" required>
              <div class="form-group">
                <label class="col-sm-2 control-label">Nama</label>
                <div class="col-sm-5">
                  <input type="text" class="form-control" name="nama" value="<?php echo $data['nama']; ?>" required>
                </div>
              </div>


			  <div class="form-group">
                <label class="col-sm-2 control-label">HP</label>
                <div class="col-sm-5">
                  <input type="number" class="form-control" name="hp" value="<?php echo $data['telp']; ?>" required>
                </div>
              </div>
			  
			   <div class="form-group">
                <label class="col-sm-2 control-label">Sistem</label>
                <div class="col-sm-5">
                  <select class="form-control" name="sistem" required>
                    <option value="<?php echo $data['sistem']; ?>"><?php echo $data['sistem']; ?></option>
                    <option value="Bulanan">Bulanan</option>
                    <option value="Harian">Harian</option>
                  </select>
                </div>
              </div>
              
			  <div class="form-group">
                <label class="col-sm-2 control-label">Alamat</label>
                <div class="col-sm-5">
                  <input type="text" class="form-control" name="alamat" value="<?php echo $data['alamat']; ?>" required>
                </div>
              </div>
			  
			  <div class="form-group">
                <label class="col-sm-2 control-label">NIK</label>
                <div class="col-sm-5">
                  <input type="text" class="form-control" name="npwp" value="<?php echo $data['nik']; ?>" required>
                </div>
              </div>
			  
			  <div class="form-group">
                <label class="col-sm-2 control-label">Tempat lahir</label>
                <div class="col-sm-5">
                  <input type="text" class="form-control" name="tempatlahir" value="<?php echo $data['tempatlahir']; ?>" required>
                </div>
              </div>
			  
			  
			  <div class="form-group">
                <label class="col-sm-2 control-label">Tgl Lahir</label>
                <div class="col-sm-5">
                  <input type="text" class="form-control" name="tgllahir" value="<?php echo $data['tgllahir']; ?>" required>
                </div>
              </div>
			  
			  
			  
			  <div class="form-group">
                <label class="col-sm-2 control-label">Image</label>
                <div class="col-sm-5">
                  <input type="file" name="foto">
                  <br/>
                <?php  
                if ($data['images']=="") { ?>
                  <img style="border:1px solid #eaeaea;border-radius:5px;" src="images/user/noimg.jpg" width="128">
                <?php
                }
                else { 
					if(substr($data['images'],-3) == "pdf"){?>
						<a href="images/user/<?php echo $data['images']; ?>"><img style="border:1px solid #eaeaea;border-radius:5px;"  src="images/user/pdf.jpg" width="128"></a>
					<?php
					}else{
					?>
						<img style="border:1px solid #eaeaea;border-radius:5px;" data-toggle='modal' data-target='#myModal' src="images/user/<?php echo $data['images']; ?>" width="128">
					
                <?php
					}
                }
                ?>
                </div>
              </div>

            </div><!-- /.box body -->

            <div class="box-footer">
              <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                  <input type="submit" class="btn btn-primary btn-submit" name="simpan" value="Simpan">
                  <a href="?module=karyawan" class="btn btn-default btn-reset">Batal</a>
                </div>
              </div>
            </div><!-- /.box footer -->
          </form>
		  
		  
		  
		  
		   <?php
			echo"							
				<div id='myModal' class='modal fade' tabindex='-1' role='dialog'>
				  <div class='modal-dialog'>
					<div class='modal-content'>
						<div class='modal-body'>
							<img src='images/user/$images' class='img-responsive'>
						</div>
					</div>
				  </div>
				</div>";
				
		?>
		
		
        </div><!-- /.box -->
      </div><!--/.col -->
    </div>   <!-- /.row -->
  </section><!-- /.content -->
<?php
}
?>