<style type="text/css">
.col-md-2, .col-md-4, .col-md-6, .col-md-8{padding: 0px}
.panel-body{padding: 0px}
.form-inline{padding-bottom: 25px}
.form-inline .form-control{width: 100%}
</style>

<div class="row" id="portlet-content">
    <div class="col-md-12">
        <div class="portlet light" style="position:relative">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-credit-card-alt"></i>BHP 
                </div>
            </div>
            <div class="portlet-body" id="page-content" style="display:nonee">
               
                <?= form_open('front_office/ugd_dir/ugd/save_penggunaan_tambah', array('class'=>"form-horizontal") ) ?>
                
                <div class="panel-body">
                  <div class="col-md-12">
                    <div class="form-group ">
    
                    <div class="form-group">

                      <label class="col-md-2 control-label"><br>Tanggal</label>
                      <div class="col-sm-2">
                        <span style="font-size:9px">Tanggal Pengajuan</span><br>
                        <div class="input-group">    

                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>         
                        <?= form_input('tgl', date('Y-m-d'), array('class'=>'form-control datepicker', 'autocomplete'=>'off')); ?>          
                        </div>
                      </div>  

                      
                      
                      <?php if($id_kunjungan != null){ ?>
                      <input type="hidden" name="id_re_kunjungan" value="<?=$id_kunjungan?>">
                      <div class="col-sm-7">
                        <span style="font-size:9px">Kunjungan</span><br>
                        <div class="input-group">    
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>         
                        <select <?=$id_kunjungan!=null?'disabled':''?> class="select2" id="id_re_kunjungan"  class="form-control" style="width:100%">
                                <option value=""></option>
                                <?php 
                                $where = "(`status_perawatan` = '4' OR `pemeriksaan_khusus` LIKE '%cek_laboratorium%')";
                                $this->db->where($where);
                                $this->db->where('batal_periksa','0');
                                $this->db->order_by('tgl_kunjungan');
                                //$this->db->like('tgl_kunjungan',date('Y-m-d'));
                                $q = $this->Content_m->get_kunjungan_pasien();

                                foreach ($q->result() as $key ) { ?>
                                  <option value="<?=$key->id_re_kunjungan?>" <?=$key->id_re_kunjungan == $id_kunjungan?'selected':''?>>No Kunjungan <?=$key->id_re_kunjungan?>, BBMC-<?=$key->nrm?>, <?=strtoupper($key->nama_pasien)?></option>
                                <?php }?>
                            </select>
                        </div>
                      </div>
                      <?php }else{ ?>
                      <input type="hidden" name="id_re_kunjungan" value="">
                      <?php }?>
                      

                    </div>


                  
                    <?php 
                    //jika sudah ada pengeluaran stok
                    $ia=0;
                    $this->db->where('id_re_kunjungan',$id_kunjungan);
                    $aa = $this->Content_m->select_db('bbmc_tr_laboratorium_pengeluaran_stok');

                    foreach ($aa->result() as $keya ) { ?>
                    <div class="form-group request_note_detail<?=$ia?>" style="<?=$ia==0?'display: block':'display: noene'?>">
                      <label class="col-md-2 control-label"><br> <?php if($ia == 0){echo "Deskripsi";}?></label>
                      <div class="col-sm-5">
                        <span style="font-size:9px">BHP</span><br>
                          <select class="select2" id="id_bhp" name="id_bhp[]" class="form-control" style="width:100%">
                              <option value=""></option>
                              <?php 
                              $q = $this->M_general->get_bhp_stok_lab();
                              foreach ($q->result() as $key ) { ?>
                                <option value="<?=$key->id_bhp?>" <?=$keya->id_bhp == $key->id_bhp?'selected':''?> ><?=$key->nama_item?></option>
                              <?php }?>
                          </select>
                      </div>
                      <div class="col-sm-1" style="padding-left: 0px">
                        <span style="font-size:9px">Jumlah Keluar </span><br>
                        <input type="number" name="qty[]" value="<?=$keya->qty?>" class="form-control" placeholder="">
                      </div>
                    </div>
                    <?php $ia++;} ?>





                    <?php for ($i1=$ia-1; $i1 <= 15; $i1++) { ?>
                     <div class="form-group request_note_detail<?=$i1?>" style="<?=$i1==0?'display: block':'display: none'?>">
                      <label class="col-md-2 control-label"><br> <?php if($i1 == 0){echo "Deskripsi";}?></label>
                      <div class="col-sm-5">
                        <span style="font-size:9px">BHP</span><br>
                        <select class="select2" id="id_bhp" name="id_bhp[]" class="form-control" style="width:100%">
                              <option value=""></option>
                              <?php 
                              $q = $this->M_general->get_bhp_stok_lab();
                              foreach ($q->result() as $key ) { ?>
                                <option value="<?=$key->id_bhp?>"><?=$key->nama_item?></option>
                              <?php }?>
                          </select>
                      </div>
                      <div class="col-sm-1" style="padding-left: 0px">
                        <span style="font-size:9px">Jumlah Keluar </span><br>
                        <input type="number" name="qty[]" value="" class="form-control" placeholder="">
                      </div>
                      <?php if($i1 != 0){ ?>
                      <div class="col-sm-1" style="padding-left: 0px; ">
                        <span style="font-size:9px"></span><br>
                        <div style="border:0px solid black; padding-top: 7px">
                        <a href="javascript:;" class="del" data-id="<?=$i1?>" style="background: red; color:#fff; padding:5px 10px; "><i class="fa fa-times"></i></a>
                        </div>
                      </div>
                      <?php }?>
                    </div>
                    <?php }?>
                    

                     <div class="form-group">
                      <label class="col-md-2 control-label"></label>
                      <div class="col-sm-7 ol-sm-7">
                         <a href="javascript:;" class="add" style="background: green; color:#fff; padding:5px 10px; "><i class="fa fa-plus"></i></a>
                      </div>
                    </div>


                    <div class="form-group">
                      <label class="col-md-2 control-label"><br>Keterangan</label>
                      <div class="col-sm-5 ol-sm-5">
                        <span style="font-size:9px">Keterangan</span><br>
                         
                        <textarea class="form-control" name="keterangan" style="height: 80px; width: 100%"></textarea>
                        
                      </div>
                    </div>


                        
                   

                    <div class="form-group">
                      <label class="col-md-2 control-label"><br></label>
                      <div class="col-sm-2" style="">
                          <button type="submit" class="btn btn-primary">Create</button>
                      </div>
                    </div>

                    
                    
                  </div>
                </div>
                
                <?= form_close() ?>
             
            </div>
           
        </div>
    </div>
</div>

<script>
$( "#loading-content,#loading" ).fadeOut( "fast", function() {
    $( "#page-content" ).fadeIn("fast");
});

 $(".select2").select2({
    placeholder: "Pilih ..",
    
    language: "id"
  });

var c=1;
$(".add").click(function(){
  //alert(1);
  $(".request_note_detail"+c).css('display','block');
  c++;

  if(c >= 7){
    //alert("Maksimal 6 Entry");
  }
});


$(".del").click(function(){
  var ID=$(this).attr('data-id');
  $(".request_note_detail"+ID).css('display','none');
  
});


</script>





