<?php foreach($kontak as $kontak) :   endforeach; ?>
<?php foreach($admin_login as $user) :   endforeach; ?> 
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark"> 
                 <?php echo $title1; ?>
            </h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Home</a></li>
              <li class="breadcrumb-item active"><?php echo $title1; ?></li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
      
          
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
          <div class="card">
              <div class="card-header">
                <button type="button" class="btn btn-info" data-toggle="modal" data-target="#modal-default">
                  <i class="fa fa-plus"></i> Tambah Data 
                </button>
                <a target="blank" href="<?php echo base_url('laporan/cetak_barang');?>"> <button type="button" class="btn btn-success" >
                  <i class="fa fa-print"></i> Cetak
                </button> </a>
                 

              </div>
              <!-- /.card-header -->
              <div class="card-body">
                               
<!-- <table id="example4" class="table table-striped table-bordered"  width="100%">
                <thead>
                  <tr>
                      <th>Barcode </th>
                      <th>Nama Barang</th>
                      <th > H. Beli Satuan</th>
                       <th> H. Beli Dos</th>
                      <th> H. Jual</th>
                      <th> H. Dos</th>
                      <th> H. Grosir Lv1</th>
                      <th> H. Grosir Lv2</th>
                      <th> H. Grosir Lv3</th>
                      <th> H. Grosir Lv4</th>
                      <th> Aksi</th> 
                     
                  </tr>
                </thead>
              </table> -->
                <div id="reload">
                <table  class="table table-striped" >
                        <thead>
                                <tr>
                                        <th>Kode</th>
                                        <th>Nama Barang</th>
                                        <th>Harga Jual</th>
                                         <th>Harga Jual Grosir1</th>
                                        <th style="text-align: right;">Aksi</th>
                                </tr>
                        </thead>
                        <tbody id="show_data">
                                 
                        </tbody>
                </table>
                </div>
              
              </div>
            
            </div>
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

    <!-- Modal Tambah Data -->
    <form class="form-horizontal" action="<?php echo base_url('barang/code_tambah'); ?>" method="POST" enctype="multipart/form-data" />  
      <div class="modal fade" id="modal-default">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <h4 class="modal-title">Tambah Data</h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">
              <div class="form-group">
                <label for="exampleInputEmail1">Kode Barcode Ecer</label>
                <input type="text" class="form-control" id="" name="barcode_ecer" placeholder="Isikan Kode Barcode" required="">
                <input type="hidden" name="id_admin" value="<?php echo $id_admin_login; ?>">
              </div>
              <div class="form-group">
                <label for="exampleInputEmail1">Kode Barcode Pack/Dos</label>
                <input type="text" class="form-control" id="" name="barcode_dos" placeholder="Isikan Barcode Barang dalam 1Dos/Pack/Liter dll" required="">
              </div>
              <div class="form-group">
                <label for="exampleInputEmail1">Nama Barang  </label>
                <input type="text" class="form-control" id="" name="nama_barang" placeholder="Exm: Baterai ABC AAA  " required="">
                <small>Tambahkan Merk + Ukuran ada Barang</small>
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Pilih Satuan Beli</label>
                <select class="form-control" id="exampleInputPassword1" name="id_satuan_beli">
                  <?php foreach($satuan as $satuan1) : ?>
                    <option value=" <?php echo $satuan1->id_satuan; ?>"> <?php echo $satuan1->nama_satuan; ?></option>
                  <?php endforeach; ?> 

                </select>  
              </div>

              <div class="form-group">
                <label for="exampleInputEmail1">Isi Satuan Beli</label>
                <input type="text" class="form-control" id="" name="isi" placeholder="Jumlah dalam satuan beli" required="">
              </div>
              <div class="form-group">
                <label for="exampleInputEmail1">Harga Beli Ecer/Dos</label>
                <input type="text" class="form-control" id="" name="harga_beli_dos" placeholder="Harga Beli" required="">
              </div>

              <div class="form-group">
                <label for="exampleInputPassword1">Pilih Satuan Jual</label>
                <select class="form-control" id="exampleInputPassword1" name="id_satuan_jual">
                  <?php foreach($satuan as $satuan2) : ?>
                    <option value=" <?php echo $satuan2->id_satuan; ?>"> <?php echo $satuan2->nama_satuan; ?></option>
                  <?php endforeach; ?> 

                </select>  
              </div>
              <div class="form-group">
                <label for="exampleInputEmail1">Harga Jual Ecer</label>
                <input type="text" class="form-control" id="" name="harga_jual_ecer" placeholder="Harga Jual Ecer" required="">
              </div>
              <div class="form-group">
                <label for="exampleInputEmail1">Harga Jual Dos</label>
                <input type="text" class="form-control" id="" name="harga_jual_dos" placeholder="Harga Jual Dos" required="">
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Harga Grosir Lv 1</label>
                <input type="text" class="form-control" id="exampleInputPassword1" name="harga_grosir_lv1" placeholder="Harga Jual Grosir"  >
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Min Grosir Lv 1</label>
                <input type="text" class="form-control" id="exampleInputPassword1" name="min_grosir_lv1" placeholder="Harga Grosir"  >
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Harga Grosir Lv 2</label>
                <input type="text" class="form-control" id="exampleInputPassword1" name="harga_grosir_lv2" placeholder="Harga Jual Grosir"  >
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Min Grosir Lv 2</label>
                <input type="text" class="form-control" id="exampleInputPassword1" name="min_grosir_lv2" placeholder="Harga Grosir" >
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Harga Grosir Lv 3</label>
                <input type="text" class="form-control" id="exampleInputPassword1" name="harga_grosir_lv3" placeholder="Harga Jual Grosir"  >
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Min Grosir Lv 3</label>
                <input type="text" class="form-control" id="exampleInputPassword1" name="min_grosir_lv3" placeholder="Harga Grosir" >
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Harga Grosir Lv 4</label>
                <input type="text" class="form-control" id="exampleInputPassword1" name="harga_grosir_lv4" placeholder="Harga Jual Grosir" >
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Min Grosir Lv 4</label>
                <input type="text" class="form-control" id="exampleInputPassword1" name="min_grosir_lv4" placeholder="Harga Grosir"  >
              </div>
               
              <div class="form-group">
                <label for="exampleInputPassword1">Pilih Katagori</label>
                <select class="form-control" id="exampleInputPassword1" name="id_katagori">
                  <?php foreach($katagori as $katagori1) : ?>
                    <option value=" <?php echo $katagori1->id_katagori; ?>"> <?php echo $katagori1->nama_katagori; ?></option>
                  <?php endforeach; ?> 

                </select>  
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Pilih Rak</label>
                <select class="form-control" id="exampleInputPassword1" name="id_rak">
                  <?php foreach($rak as $rak1) : ?>
                    <option value=" <?php echo $rak1->id_rak; ?>"> <?php echo $rak1->nama_rak; ?></option>
                  <?php endforeach; ?> 

                </select>  
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Pilih Selfing</label>
                <select class="form-control" id="exampleInputPassword1" name="id_selfing">
                  <?php foreach($selfing as $selfing1) : ?>
                    <option value=" <?php echo $selfing1->id_selfing; ?>"> <?php echo $selfing1->nama_selfing; ?></option>
                  <?php endforeach; ?> 

                </select>  
              </div>
               
               
              <div class="form-group">
                <label for="exampleInputFile">File Foto</label>
                <div class="input-group">

                  <input type="file" name="foto">


                </div>
              </div>
            </div>
              <div class="modal-footer justify-content-between">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="submit" class="btn btn-primary">Simpan</button>
              </div>
            </div>
            <!-- /.modal-content -->
          </div>
          <!-- /.modal-dialog -->
      </div>
    </form>

<!-- 
    <?php $no=1; foreach($barang as $rows) : ?> 
 -->
    <!-- <form class="form-horizontal" action="<?php echo base_url('barang/code_ubah'); ?>" method="POST" enctype="multipart/form-data" />  
      <div class="modal fade" id="modal-edit<?php echo $rows->barcode_ecer; ?>">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <h4 class="modal-title">Edit Data <?php echo $rows->nama_barang; ?></h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">


              <input type="hidden" name="id" value="<?php echo $rows->id; ?>">
              <div class="form-group">
                <label for="exampleInputEmail1">Kode Barcode Ecer</label>
                <input type="text" class="form-control" id="" name="barcode_ecer" placeholder="Isikan Kode Barcode" value="<?php echo $rows->barcode_ecer; ?>">
              </div>
              <div class="form-group">
                <label for="exampleInputEmail1">Kode Barcode Pack/Dos</label>
                <input type="text" class="form-control" id="" name="barcode_dos" placeholder="Isikan Barcode Barang dalam 1Dos/Pack/Liter dll" value="<?php echo $rows->barcode_dos; ?>">
              </div>
              <div class="form-group">
                <label for="exampleInputEmail1">Nama Barang  </label>
                <input type="text" class="form-control" id="" name="nama_barang" placeholder="Exm: Baterai ABC AAA  " value="<?php echo $rows->nama_barang; ?>">
                <small>Tambahkan Merk + Ukuran ada Barang</small>
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Pilih Satuan Beli</label>
                <select class="form-control" id="exampleInputPassword1" name="id_satuan_beli">
                  <?php 
                  $id_satuan_beli = $rows->id_satuan_beli; 
                  $sql_menu = "SELECT * FROM tb_satuan WHERE  id_satuan = '$id_satuan_beli' ";
                  $main_menu = $this->db->query($sql_menu)->result();
                  foreach ($main_menu as $mainx) {

                    $id_satuan_belix= $mainx->id_satuan;
                    $nama_satuan_belix= $mainx->nama_satuan;

                  }
                  ?>
                  <option value="<?php echo $id_satuan_belix; ?>" ><?php echo $nama_satuan_belix; ?></option> 
                  <?php foreach($satuan as $satuanx) : ?>
                    <option value=" <?php echo $satuanx->id_satuan; ?>" > <?php echo $satuanx->nama_satuan; ?></option>
                  <?php endforeach; ?> 

                </select>  
              </div>
              <div class="form-group">
                <label for="exampleInputEmail1">Isi Satuan Beli</label>
                <input type="text" class="form-control" id="" name="isi" placeholder="Jumlah dalam satuan beli" value="<?php echo $rows->isi; ?>">
              </div>
              <div class="form-group">
                <label for="exampleInputEmail1">Harga Beli Ecer/Dos</label>
                <input type="text" class="form-control" id="" name="harga_beli_dos" placeholder="Harga Beli" value="<?php echo $rows->harga_beli_dos; ?>">
              </div>

              <div class="form-group">
                <label for="exampleInputPassword1">Pilih Satuan Jual</label>
                <select class="form-control" id="exampleInputPassword1" name="id_satuan_jual">

                  <?php 
                  $id_satuan_jual = $rows->id_satuan_jual; 
                  $sql_menu = "SELECT * FROM tb_satuan WHERE  id_satuan = '$id_satuan_jual' ";
                  $main_menu = $this->db->query($sql_menu)->result();
                  foreach ($main_menu as $xxx) {
                    echo $xxx->nama_satuan;
                    $id_satuan_jualx= $xxx->id_satuan;
                    $nama_satuan_jualx= $xxx->nama_satuan;

                  }
                  ?>

                  <option value="<?php echo $id_satuan_jualx; ?>"><?php echo $nama_satuan_jualx; ?></option>

                  <?php foreach($satuan as $satuanxx) : ?>
                    <option value="<?php echo $satuanxx->id_satuan; ?>"> <?php echo $satuanxx->nama_satuan; ?></option>
                  <?php endforeach; ?> 

                </select>  
              </div>
              <div class="form-group">
                <label for="exampleInputEmail1">Harga Jual Ecer</label>
                <input type="text" class="form-control" id="" name="harga_jual_ecer" placeholder="Harga Jual Ecer" value="<?php echo $rows->harga_jual_ecer; ?>">
              </div>
              <div class="form-group">
                <label for="exampleInputEmail1">Harga Jual Dos</label>
                <input type="text" class="form-control" id="" name="harga_jual_dos" placeholder="Harga Jual Dos" value="<?php echo $rows->harga_jual_dos; ?>">
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Harga Grosir</label>
                <input type="text" class="form-control" id="exampleInputPassword1" name="harga_grosir" placeholder="Harga Jual Grosir" value="<?php echo $rows->harga_grosir; ?>">
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Min Grosir</label>
                <input type="text" class="form-control" id="exampleInputPassword1" name="min_grosir" placeholder="Harga Grosir" value="<?php echo $rows->min_grosir; ?>">
              </div>


              <div class="form-group">
                <label for="exampleInputPassword1">Pilih Katagori</label>
                <select class="form-control" id="exampleInputPassword1" name="id_katagori">

                  <?php 
                  $id_katagori = $rows->id_katagori; 
                  $sql_menuk = "SELECT * FROM tb_katagori WHERE  id_katagori = '$id_katagori' ";
                  $main_menuk = $this->db->query($sql_menuk)->result();
                  foreach ($main_menuk as $k) {

                    $id_katagorik= $k->id_katagori;
                    $nama_katagorik= $k->nama_katagori;

                  }
                  ?>

                  <option value="<?php echo $id_katagorik; ?>"><?php echo $nama_katagorik; ?></option>


                  <?php foreach($katagori as $katagorix) : ?>
                    <option value=" <?php echo $katagorix->id_katagori; ?>"> <?php echo $katagorix->nama_katagori; ?></option>
                  <?php endforeach; ?> 

                </select>  
              </div>

              <div class="form-group">
                <label for="exampleInputPassword1">Pilih Rak</label>
                <select class="form-control" id="exampleInputPassword1" name="id_rak">

                  <?php 
                  $id_rak = $rows->id_rak; 
                  $sql_rak = "SELECT * FROM tb_rak WHERE  id_rak = '$id_rak' ";
                  $mainrak = $this->db->query($sql_rak)->result();
                  foreach ($mainrak as $r) {

                    $id_rakk= $r->id_rak;
                    $nama_rakk= $r->nama_rak;

                  }
                  ?>

                  <option value="<?php echo $id_rakk; ?>"><?php echo $nama_rakk; ?></option>

                  <?php foreach($rak as $rak2) : ?>
                    <option value=" <?php echo $rak2->id_rak; ?>"> <?php echo $rak2->nama_rak; ?></option>
                  <?php endforeach; ?> 

                </select>  
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Pilih Selfing</label>
                <select class="form-control" id="exampleInputPassword1" name="id_selfing">

                  <?php 
                  $id_selfing = $rows->id_selfing; 
                  if(empty($id_selfing)){
                    $id_selfing= 0;
                    $nama_selfing= 0;
                  }else{
                   $sql_selfing = "SELECT * FROM tb_selfing WHERE  id_selfing = '$id_selfing' ";
                   $mainselfing = $this->db->query($sql_selfing)->result();
                   foreach ($mainselfing as $s) {

                    $id_selfing= $s->id_selfing;
                    $nama_selfing= $s->nama_selfing;

                  }




                }
                ?>

                <option value="<?php echo $id_selfing; ?>"><?php echo $nama_selfing; ?></option>




                <?php foreach($selfing as $selfing2) : ?>
                  <option value=" <?php echo $selfing2->id_selfing; ?>"> <?php echo $selfing2->nama_selfing; ?></option>
                <?php endforeach; ?> 

              </select>  
            </div>
            <div class="form-group">
              <label for="exampleInputFile">File Foto</label>
              <div class="input-group">

                <input type="file" name="foto">


              </div>
            </div>   
          </div>
          <div class="modal-footer justify-content-between">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            <button type="submit" class="btn btn-primary">Simpan</button>
          </div>
        </div>

      </div>

      </div>
    </form> -->



<!--   <form class="form-horizontal" action="<?php echo base_url('barang/code_hapus'); ?>" method="POST" enctype="multipart/form-data" />  
    <div class="modal fade" id="modal-hapus<?php echo $rows->barcode_ecer; ?>">
      <div class="modal-dialog">
        <div class="modal-content bg-danger">
          <div class="modal-header">
            <h4 class="modal-title">Hapus Data </h4>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
          </div>
          <div class="modal-body">
            <h4>Apakah Yakin Menghapus Data Ini, <?php echo $rows->nama_barang; ?> ?</h4>

            <input type="hidden" name="id" value="<?php echo $rows->id; ?>">


          </div>
          <div class="modal-footer justify-content-between">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            <button type="submit" class="btn btn-primary">Hapus</button>
          </div>
        </div>

      </div>

    </div>
  </form> -->


<!--   <?php $no++; endforeach; ?> -->