<div class="row">
  <!-- begin col-8 -->
  <div class="col-lg-12">
      <!-- begin panel -->
      <div class="panel panel-grey">
          <div class="panel-heading">
              <div class="panel-heading-btn">
                  <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-grey" data-click="panel-expand"><i class="fa fa-expand"></i></a>
                  <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-grey" data-click="panel-remove"><i class="fa fa-times"></i></a>
              </div>
              <a onclick="goBack()" class="btn btn-primary m-b-5"><span class="fa fa-arrow-left"></span> Kembali</a>
              <hr>
          </div>
          <div class="panel-body">
              <div class="col-sm-10">
                <form class="form-horizontal" method="post" name="" action="">
                <input type="hidden" name="type" value="personil">
                <input type="hidden" name="klik" value="submit">
                <input type="hidden" name="id_personil" value="<?php echo (!empty($id_personil) ? $id_personil : null); ?>">
                <div class="form-group m-b-11">
                    <label class="col-md-4 col-form-label control-label">Nama personil</label>
                    <div class="col-md-7">
                        <input class="form-control" name="nama_personil" value="<?php echo (!empty($edit)?$edit['nama'] : '') ?>" type="text" placeholder="Masukkan nama personil">
                    </div>
                </div>
                <div class="form-group m-b-11">
                    <label class="col-md-4 col-form-label control-label">Jabatan</label>
                    <div class="col-md-7">
                        <select name="id_jabatan[]" onchange="klik_jabatan(this.value);" class="form-control default-select2" multiple>
                          <option></option>
                          <?php foreach($jabatan as $j) { ?>
                            <option <?php echo !empty($edit) && strpos($edit['id_jabatan'], $j['id_jenis'].'|') != false ? 'selected' : ''; ?> value="<?php echo $j['id_jenis']; ?>"><?php echo $j['nama_jenis']; ?></option>
                          <?php } ?>
                        </select>

                        <input style="margin-top:5px;" class="form-control jabatan_lainnya" name="jabatan_lainnya" value="<?php echo (!empty($edit)?$edit['jabatan_lainnya'] : '') ?>" type="text" placeholder="Masukkan jabatan lainnya">
                    </div>
                </div>
                <div class="form-group m-b-11">
                    <label class="col-md-4 col-form-label control-label">NIP</label>
                    <div class="col-md-7">
                        <input class="form-control" name="nip" value="<?php echo (!empty($edit)?$edit['nip'] : '') ?>" type="text" placeholder="Masukkan NIP">
                    </div>
                </div>
                <div class="form-group m-b-11">
                    <label class="col-md-4 col-form-label control-label">Pangkat</label>
                    <div class="col-md-7">
                        <input class="form-control" name="pangkat" value="<?php echo (!empty($edit)?$edit['pangkat'] : '') ?>" type="text" placeholder="Masukkan pangkat">
                    </div>
                </div>
                <div class="form-group m-b-11">
                    <label class="col-md-4 col-form-label control-label">Alamat</label>
                    <div class="col-md-7">
                        <input class="form-control" name="alamat" value="<?php echo (!empty($edit)?$edit['alamat'] : '') ?>" type="text" placeholder="Masukkan alamat">
                    </div>
                </div>
                <div class="form-group m-b-11">
                    <label class="col-md-4 col-form-label control-label">Nomor Telepon</label>
                    <div class="col-md-7">
                        <input class="form-control" name="no_telp" value="<?php echo (!empty($edit)?$edit['no_telp'] : '') ?>" type="text" placeholder="Masukkan nomor telepon">
                    </div>
                </div>
                <div class="form-group m-b-11">
                    <label class="col-md-4 col-form-label control-label">Email</label>
                    <div class="col-md-7">
                        <input class="form-control" name="email" value="<?php echo (!empty($edit)?$edit['email'] : '') ?>" type="text" placeholder="Masukkan email">
                    </div>
                </div>
                <div class="form-group m-b-11">
                    <label class="col-md-4 col-form-label control-label">Foto</label>
                    <div class="col-md-7">
                        <input class="form-control" type="file" name="file_foto" type="text" placeholder="Masukkan foto">
                    </div>
                </div>

                <div class="form-group m-b-11">
                    <label class="col-md-4 col-form-label control-label"></label>
                    <div class="col-md-7">
                        <button type="submit" class="btn btn-md btn-success">Simpan</button>
                        <button type="reset" class="btn btn-md btn-warning">Reset</button>
                        <a onclick="goBack();" class="btn btn-md btn-danger">Batal</a>
                    </div>
                </div>

            </form>
            </div>
        </div>
      </div>
  </div>
</div>

<script>
    <?php if(!empty($edit) && strpos($edit['id_jabatan'], '8|') != false) { ?>
      $('.jabatan_lainnya').show();
    <?php } else{ ?>
      $('.jabatan_lainnya').hide();
    <?php } ?>
    function goBack() {
        window.history.back();
    }

    function klik_jabatan(x){
      console.log(x);
      if(x == 8){
        $('.jabatan_lainnya').show();
      }else{
        $('.jabatan_lainnya').hide();
      }
    }
</script>
