<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><?=$title?>
                </div>
            </div>
            <div class="portlet-body" id="page-content" style="display:nonee">
               
                <?= form_open('send_request_note/update', array('class'=>"form-horizontal") ) ?>
                <input type="hidden" name="id_amprahan_request_new" value="<?=$id?>">
                <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('tanggal', $get->tanggal, array('class'=>'form-control datepicker', 'autocomplete'=>'off')); ?>          
                        </div>
                      </div>
                    </div>

                    <?php 
                    $i1=0;
                    $this->db->where('id_amprahan_request_new',$id);
                    $q = $this->M_general->select_db('bbmc_tr_amprahan_request_new_detail');
                    foreach ($q->result() as $key ) { ?>
                    <div class="form-group request_note_details<?=$i1?>" style="<?=$i1==0?'display: block':'display: nones'?>">
                      <input type="hidden" name="id_amprahan_request_new_detail[]" value="<?=$key->id_amprahan_request_new?>">
                      <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="form-control select2 sel2_kebutuhan kebutuhan<?=$i1?>" data-id="<?=$i1?>" requireds autocomplete="off" name="id_bhp[]" style="width:100%">
                          <option value=""></option>
                          <?php foreach ($this->M_general->select_db('bbmc_re_bahan_habis_pakai')->result() as $keyb ) { ?>
                            <option value="<?=$keyb->id_re_bahan_habis_pakai?>" <?=$key->id_re_bahan_habis_pakai == $keyb->id_re_bahan_habis_pakai?'selected':''?> ><?=$keyb->nama_item?></option>
                          <?php }?>
                        </select>
                      </div>
                      <div class="col-sm-1" style="padding-left: 0px">
                       <span style="font-size:9px">Qty</span><br>
                        <!--
                        <select class="form-control select2 sel2_qty qty<?=$i1?>" data-id="<?=$i1?>" requireds autocomplete="off" name="qty[]" style="width:100%">
                          <option value=""></option>
                          <?php for ($i=1; $i < 30; $i++) { ?>
                           <option value="<?=$i?>" <?=$key->qty == $i?'selected':''?>><?=$i?></option>
                          <?php }?>
                        </select>
                        -->
                         <input type="number" name="qty[]" value="<?=$key->qty?>" class="form-control" placeholder="Qty">
                      </div>
    
                     
                      <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="<?=site_url()?>/send_request_note/delete/<?=$key->id_amprahan_request_new_detail?>" onclick="return confirm('Anda Yakin?');" data-id="<?=$i1?>" style="background: red; color:#fff; padding:5px 10px; "><i class="fa fa-times"></i></a>
                        </div>
                      </div>
                     

                    </div>
                    <?php $i1++;}?>

                   
                    
                    <?php for ($i1=1; $i1 <= 5; $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="form-control select2 sel2_kebutuhan kebutuhan<?=$i1?>" data-id="<?=$i1?>" requireds autocomplete="off" name="id_bhp[]" style="width:100%">
                          <option value=""></option>
                          <?php foreach ($this->M_general->select_db('bbmc_re_bahan_habis_pakai')->result() as $key ) { ?>
                            <option value="<?=$key->id_re_bahan_habis_pakai?>"><?=$key->nama_item?></option>
                          <?php }?>
                        </select>
                      </div>
                      <div class="col-sm-1" style="padding-left: 0px">
                       <span style="font-size:9px">Qty</span><br>
                        <!--
                        <select class="form-control select2 sel2_qty qty<?=$i1?>" data-id="<?=$i1?>" requireds autocomplete="off" name="qty[]" style="width:100%">
                          <option value=""></option>
                          <?php for ($i=1; $i < 30; $i++) { ?>
                           <option value="<?=$i?>"><?=$i?></option>
                          <?php }?>
                        </select>
                        -->
                         <input type="number" name="qty[]" value="" class="form-control" placeholder="Qty">
                      </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 }?>
                    
                    
                    

                    <?php if($get->approve =='0'){ ?>
                    <div class="form-group">
                      <label class="col-md-2 control-label"><br></label>
                      <div class="col-sm-2" style="">
                          <a href="javascript:;" class="add" style="background: green; color:#fff; padding:5px 10px; "><i class="fa fa-plus"></i></a>
                          <br><br><br>
                          <button type="submit" class="btn btn-primary">Update</button>
                      </div>
                    </div>
                    <?php }?>

                    
                    
                  </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');
  $(".kebutuhan"+ID).val("");
  $(".qty"+ID).val("");
 
  
});


</script>





