<?php $select='select2';?>
                                <?php $nm_f="brand[]"; echo str_replace('\n','',form_hidden_('id_detail[]',$det['id']));?>
                                <!--div class="col-sm-2" id="brand-<?php echo $a?>">
                                    <label for="<?php echo $nm_f?>">Produk</label><label>(Hapus)</label></div-->
                           <div class="col-sm-4"> 
                           <div class="col-sm-12 produk" style="margin-bottom:10px;">
                                    <?php //echo form_dropdown_('brand[]',GetOptAll('master_brand','-Merk-',array('status'=>'Aktif')),$det['brand'],'class="'.$select.'" id="brand-'.$id.'" onchange="gantibrand(this.value,'.$id.')"') 
                                          echo form_dropdown_('brand[]',GetOptQuery('SELECT a.produk,b.jenis_produk,b.brand,b.title as n_produk,c.title as n_jenis_produk,d.title as n_brand FROM `sv_stok_view` a left join sv_master_produk b ON a.produk=b.id left join sv_master_jenis_produk c ON c.id=b.jenis_produk LEFT JOIN sv_master_brand d ON d.id=b.brand WHERE a.stok>0 group by b.brand','-Merk-',array(),'n_brand','brand'),$det['brand'],'class="'.$select.'" id="brand-'.$id.'" onchange="gantibrand(this.value,'.$id.')"');  
                                            ?></div>
                                <div class="col-sm-12 col-md-12 produk" id="jenis-<?php echo $id?>" style="margin-bottom:10px;">
                                    <?php $nm_f="jenis_produk[]"; echo form_dropdown_('jenis_produk[]',GetOptAll('master_jenis_produk','-Jenis Produk-',array('brand'=>'where/'.$det['brand'])),$det['jenis_produk'],'class="'.$select.' form-control" id="jenis_produk-'.$id.'" onchange="gantijenis(this.value,'.$id.')"')?>
                                </div>
                                    
                                <div class="col-sm-12 detailproduk" id="produkz-<?php echo $id?>" style="margin-bottom:10px;">
                                        <?php $nm_f="produk[]";?><?php echo form_dropdown_('produk[]',GetOptAll('master_produk','-Produk-',array('jenis_produk'=>'where/'.$det['jenis_produk'])),$det['produk'],'class="'.$select.'" id="produk-'.$id.'" onchange="gantiproduk(this.value,'.$id.')"')?>
                                    </div>
                                    <!--div class="col-sm-12" style="margin-bottom:10px;">Part Number : <span id="part_number_<?php echo $id ?>"><?php echo GetValue('part_number', 'master_produk',array('id'=>'where/'.$det['produk'])) ?></span>
                                    </div-->
                           </div>
                        <div class="col-sm-2">
                            
                                     <?php $nm_f='gudang[]'; echo form_dropdown($nm_f,GetOptAll('master_gudang','-Gudang-',array()),(isset($val[$nm_f]) ? $val[$nm_f] : ''),'class="'.$select.'" form-control" id="gudang-'.$id.'" onchange="caritgl_baru('.$id.')" '); ?>
                        </div>
                           <div class="col-md-2" id="tgl_tiba_div_<?php echo $id ?>">
                               <input type="text" name="<?php echo $nm_f?>"  id="<?php echo $nm_f?>" value="<?php echo $a= (isset($val[$nm_f]) ? $val[$nm_f] : '') ?>" class="form-control validate[required] date-picker">
                           </div>
                       <div class="col-sm-2"><input type="text" name="lot_number[]" class="form-control" value="<?php echo $det['total'] ?>">
                       </div>
                       <!--div class="col-sm-1"><?php $nm_f="satuan[]";?><?php echo form_dropdown_('satuan[]',GetOptAll('ref_satuan','-Produk-',array('status'=>'where/Aktif')),$det['satuan'],'class="'.$select.'" id="$nm_f"')?></div-->
                       <div class="col-sm-1"><input type="text" name="qty[]" class="form-control" id="total-<?php echo $id ?>"  value="<?php echo $det['qty'] ?>">
                           <input type='hidden' name="satuan[]" id="satuan-<?php echo $id ?>" value="<?php echo $det['satuan'] ?>">
                           <div class="col-md-12" id="max-stok-<?php echo $id ?>"></div>
                       </div> <label style="cursor:pointer" onclick="deletebaru(<?php echo $id ?>,<?php echo $val['id'] ?>)">(Hapus)</label>
                                
                       <script>
                  $(document).ready(function(e){
                           $('#brand-<?php echo $id ?>').css('max-width','100%').select2({});
                           $('#jenis_produk-<?php echo $id ?>').css('max-width','100%').select2({});
                           $('#produk-<?php echo $id ?>').css('max-width','100%').select2({});
                           $('#gudang-<?php echo $id ?>').css('max-width','100%').select2({});
                 });
                function deletebaru(){
                    $('#input-produk-<?php echo $id ?>').remove();
                }
                
                           </script>