<div class="row">
  <!-- begin col-8 -->
  <div class="col-sm-6">
      <!-- begin panel -->
      <div class="panel panel-grey">
          <div class="panel-heading">
			  <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>
          <div class="panel panel-body table-responsive">
              <table class="table table-bordered table-hover table-striped table-td-valign-middle">
                  <thead>
                  <tr>
                    <th class="text-center">No.</th>
                    <th class="text-center">Nama Alat</th>
                    <th class="text-center">Jenis Alat</th>
                    <th class="text-center">Jenis Uji</th>
                    <th class="text-center">Keterangan</th>
					<th></th>
                  </tr>

                  </thead>
                  <tbody>
                      <?php $i = 0; foreach($data as $r){ $i++ ?>
                        <tr>
                          <td><?php echo $i ?></td>
                          <td><?php echo $r['nama_alat'] ?></td>
                          <td><?php echo $r['jenis_alat'] ?></td>
                          <td><?php echo $r['jenis_parameter'] ?></td>
                          <td><?php echo $r['keterangan'] ?></td>
						  <td class="text-center">
							<a href="<?php echo site_url('inventaris/peralatan/index?id_alatEdit='.$r['id_alat']) ?>" class="btn btn-primary btn-xs">Edit</a>
							<a href="<?php echo site_url('inventaris/peralatan/hapus_alat?id_alat='.$r['id_alat']) ?>" class="btn btn-danger btn-xs">Hapus</a>
						  </td>
                        </tr>
                      <?php } ?>
                  </tbody>
              </table>
          </div>
      </div>
      <!-- end panel -->
  </div>
  <div class="col-sm-6">
      <!-- begin panel -->
      <div class="panel panel-grey">
        <div class="panel-heading">
			     <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>
        <div class="panel-body">
    			<form class="form-horizontal" method="post" action="<?php echo site_url('inventaris/peralatan/create_edit'); ?>">
    				<div class="form-group m-b-12">
    					<input type="hidden" name="id_alat" value="<?php echo !empty($this->input->get('id_alatEdit')) ? $edit['id_alat'] : '' ?>">
              <label class="col-md-4 col-form-label control-label">Nama Alat<span class="text-danger">*</span></label>
              <div class="col-md-8">
                <input class="form-control" name="nama_alat" id="nama_alat" type="text" placeholder="Masukkan nama alat" value="<?php echo !empty($this->input->get('id_alatEdit')) ? $edit['nama_alat'] : '' ?>" required>
              </div>
            </div>
            <div class="form-group m-b-12">
                <label class="col-md-4 col-form-label control-label">Jenis Alat<span class="text-danger">*</span></label>
                <div class="col-md-8">
                    <?php $array_alat = array('Peralatan Utama', 'Pendukung', 'Penunjang Pengujian') ?>
                    <select class="form-control default-select2 jenis_alat" name="jenis_alat" id="jenis_alat" onchange="pilih_p_uji()" required>
                      <option></option>
                      <?php foreach($array_alat as $aa) { ?>
                        <option <?php echo !empty($this->input->get('id_alatEdit')) && $edit['jenis_alat'] == $aa ? 'selected' : ''; ?> value="<?php echo $aa; ?>"><?php echo $aa; ?></option>
                      <?php } ?>
                    </select>
                </div>
            </div>
            <div class="form-group m-b-12 param-uji">
                <label class="col-md-4 col-form-label control-label">Jenis Parameter Uji<span class="text-danger">*</span></label>
                <div class="col-md-8">
                    <?php $array_uji = $this->m_master->getDataMaster('parameter_uji'); ?>
                    <select style="width:310px;" class="form-control default-select2" name="jenis_uji" id="jenis_uji">
                      <option></option>
                      <?php foreach($array_uji as $aa) { ?>
                        <option <?php echo !empty($this->input->get('id_alatEdit')) && $edit['jenis_uji'] == $aa['id_jenis'] ? 'selected' : ''; ?> value="<?php echo $aa['id_jenis']; ?>"><?php echo $aa['nama_jenis']; ?></option>
                      <?php } ?>
                    </select>
                </div>
            </div>
    				<div class="form-group m-b-12">
                <label class="col-md-4 col-form-label control-label">Keterangan<span class="text-danger">*</span></label>
                <div class="col-md-8">
                    <input class="form-control" name="keterangan" id="keterangan" type="text" placeholder="Masukkan nama alat" value="<?php echo !empty($this->input->get('id_alatEdit')) ? $edit['keterangan'] : '' ?>" required>
                </div>
            </div>
    				<div class="form-group m-b-12">
    					<label class="col-md-4 col-form-label control-label"></label>
                <div class="col-md-8">
                    <button class="btn btn-primary" type="submit">Simpan Alat</button>
                </div>
            </div>
    			</form>
        </div>
      </div>
      <!-- end panel -->
  </div>
</div>

<script>
  <?php if(!empty($this->input->get('id_alatEdit')) && $edit['jenis_alat'] == 'Peralatan Utama'){ ?>
    $('.param-uji').show();
  <?php } else { ?>
    $('.param-uji').hide();
  <?php } ?>

  function pilih_p_uji(){
    var jenis_alat = $('.jenis_alat').val();

    if(jenis_alat == 'Peralatan Utama'){
      $('.param-uji').show();
    }else{
      $('.param-uji').hide();
    }

  }
</script>
