  <div class="content-wrapper" style="margin-bottom: 20px">
    <div class="container">
      <div class="row pad-botm">
          <div class="col-md-12">
               <h4 align="center">LIST BIAYA</h4>
            <h5 align="center">KEDAI : <?php echo $toko->nm_toko ?></h5>
          </div>
      </div>
      <div class="row">
        <div class="col-md-12">
            <h3><span class="pull-right no-print"><a href="" data-toggle="modal" data-target=".modalmember">+ Biaya</a></span></h3>
            <table id="tbUser" class="table table-bordered table-striped table-responsive">
              <thead>
                <tr>
                  <th>No</th>
                  <th>ID</th>
                  <th>Tanggal</th>
                  <th>Jenis</th>
                  <th>Keterangan</th>
                  <th>Nilai</th>
                  <th class="no-print">Aksi</th>
                </tr>
              </thead>
              <tbody>
                <?php foreach ($biaya->result() as $key): 
                ?>
                <tr>
                  <td><?php echo $no++ ?></td>
                  <td><?php echo $key->id ?></td>
                  <td><?php echo $key->tgl ?></td>
                  <td><?php echo $key->jenis ?></td>
                  <td><?php echo $key->ket ?></td>
                  <td align="right"><?php echo number_format($key->biaya, 0, ',', '.') ?></td>
                   <td class="no-print" align="center">
                  <a href="javascript:void(0);" class="update-record"  
                        data-id="<?php echo $key->id; ?>" 
                        data-jenis="<?php echo $key->jenis; ?>" 
                        data-ket="<?php echo $key->ket; ?>"  
                        data-biaya="<?php echo $key->biaya; ?>" 
                  >Edit </a> |
                  <a href="javascript:void(0);" class="hapus_record" 
					    data-id="<?php echo $key->id ?>">
					    <font color='red' >Hapus</font></a>
                  </td>
            
                 
                </tr>
                <?php endforeach?>
              </tbody>
            </table>
        </div>
      </div>
    </div>
  </div>
  
 
<div class="modal fade modalmember" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog">
 
    <div class="modal-content">
      <div class="modal-header">
        <h4><font color='red'><b>Input Biaya</b></font></h4>
        
      </div>
        <div class="modal-body" align='center' >
          <form class="form-horizontal" action="<?php echo base_url('kasir/simpan_biaya/')?>" method="post">
            
            <div class="form-group" >
              <div class="col-md-12" >
                <select name="jenis_biaya" id="jenis_biaya" class="form-control" required>
                    <option value="">Jenis</option>
                    <option value="6301.001">Bahan Baku (es batu, gas, dll)</option>
                    <option value="6301.007">Token Listrik</option>
                    <option value="6301.008">Telp & Wifi (kuota,internet,pulsa dll)</option>
                    <option value="6301.004">Uang Makan</option>
                    <option value="6307.006">Biaya Iuran (sampah,keamanan,lingkungan)</option>
                    <option value="6306.006">Biaya Lain-lain</option>
                    <option value="8902.001">Biaya Insentif Ongkir </option>
                    <option value="1120.103">Setor Tunai/ Transfer</option>
                    <option value="9999.001">Biaya Claim Dapur Produksi </option>
                </select>
              </div>
            </div>
            <div  class="form-group">
              <div class="col-md-12">
                <input  type="text" class="form-control" id="ket" name="ket"  value='' placeholder='Keterangan' required ></input>
              </div>
            </div>
			<div class="form-group" >
              <div class="col-md-12">
                <input type="number" class="form-control" id="biaya" name="biaya" placeholder='Nilai..'  required >
              </div>
            </div>
            
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          <button type="submit" id="btnSimpan" class="btn btn-primary">Simpan</button>
        </div>
        </form>
    </div>
 </div>
  </div>
</div>   
  
  <!-- Modal Update -->
  <div class="modal fade" id="modalEdit" role="dialog">
    <div class="modal-dialog modal-md">
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Edit Biaya</h4>
        </div>
        <div class="modal-body">
          <form class="form-horizontal" action="<?php echo base_url('kasir/simpan_edit_biaya') ?>" method="post">
            <div class="form-group">
              <label class="control-label col-sm-3" for="kode_menu_e">Kode ID</label>
              <div class="col-sm-3">
                <input type="text" class="form-control" id="kode_menu_e" name="kode_menu_e" readonly="readonly" required>
              </div>
            </div>
            <div class="form-group">
              <label class="control-label col-sm-3" for="nama_menu_e">Jenis</label>
              <div class="col-md-8">
                <input type="text" class="form-control" id="nama_menu_e" name="nama_menu_e" readonly>
              </div>
            </div>
           
            <div class="form-group">
              <label class="control-label col-sm-3" for="status_e">Keterangan</label>
              <div class="col-md-5">
                <input type="text" class="form-control" id="status_e" name="status_e" required>
              </div>
            </div>
            <div class="form-group">
              <label class="control-label col-sm-3" for="alamat_e">Nilai</label>
              <div class="col-md-8">
                <input type="text" class="form-control" id="alamat_e" name="alamat_e" required>
              </div>
            </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          <button type="submit" id="btnSimpan" class="btn btn-primary">Simpan</button>
        </div>
        </form>
      </div>
    </div>
  </div>
     <!-- CONTENT-WRAPPER SECTION END-->
    <section class="footer-section no-print">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                   &copy; Copyright <?php echo date('Y') ?>, <a href="enambelasapp.my.id" target="_blank">Mandiri</a>
                </div>
            </div>
        </div>
    </section>
</div>


</div>
 
<div class="modal fade modalKecil" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <h4><font color='red'><b>Input Validasi Token</b></font></h4>
		<?php 
			$tgl=date('j');
			$jam=date('G');
			$detik=date('s');
			if ($detik==0)  $token=((($tgl*$jam*1)*1305));
			if ($detik>0) $token=((($tgl*$jam*$detik)*1305));
		?>
		
      </div>
        <div class="modal-body" align='center' >
          <form class="form-horizontal" action="<?php echo base_url('gudang/masuk_token/')?>" method="post">
            <div  class="form-group">
              <label  class="control-label " for="id_fak">Kode Token</label>
              <div class="col-sm-10">
                <input  type="text" class="form-control" id="token" name="token"  value='<?php echo $token ?>' readonly>
              </div>
            </div>
            <div class="form-group" >
              <label class="control-label " for="idtoken">Password</label>
              <div class="col-sm-10">
                <input type="number" class="form-control" id="idtoken" name="idtoken" required >
              </div>
            </div>
			<div class="form-group" >
              <label class="control-label " for="note">Note</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="note" name="note" required >
              </div>
            </div>
        </div>
        <div class="modal-footer">
		 <input type="hidden" name="nobuk" id="nobuk" value="<?php echo $nobukti ?>">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          <button type="submit" id="btnSimpan" class="btn btn-primary">Simpan</button>
        </div>
        </form>
    </div>
 
  </div>
</div>
<div class="modal fade" id="modalHapus" role="dialog">
    <div class="modal-dialog">
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Hapus Biaya</h4>
        </div>
        <div class="modal-body">
          <form class="form-horizontal" action="<?php echo base_url('kasir/hapus_biaya') ?>" method="post">
           <h4>Apakah Kamu Yakin Menghapus Data Biaya Ini?</h4>
        </div>
        <input type="hidden" id="kode_menu_h" name="kode_menu_h">
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Tidak</button>
          <button type="submit" id="btnHapus" class="btn btn-primary">Ya</button>
        </div>
        </form>
      </div>
    </div>
  </div>

    <!-- FOOTER SECTION END-->
    <!-- JAVASCRIPT FILES PLACED AT THE BOTTOM TO REDUCE THE LOADING TIME  -->
    <script src="<?php echo base_url() ?>/assets/js/jquery-3.3.1.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/jquery.dataTables.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/bootstrap.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/custom.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/sweetalert.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/toastr.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/jquery.price_format.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/bootstrap-select.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/dataTables.bootstrap.js"></script>
  <script>
      $('#tbUser').DataTable({
          "paging":   true,
          "info": false,
          "searching": false,
      });
      $('form').attr('autocomplete', 'off');
      $("ul.nav li.dropdown").hover(function(){$(this).find(".dropdown-menu").stop(!0,!0).delay(100).fadeIn(500)},function(){$(this).find(".dropdown-menu").stop(!0,!0).delay(100).fadeOut(500)});
      var pesan="<?php echo $this->session->flashdata('msg'); ?>",error="<?php echo $this->session->flashdata('error'); ?>";pesan?(toastr.options={positionClass:"toast-top-right"},toastr.success(pesan)):error&&swal(error);
      function convertToRupiah(r){for(var e="",t=r.toString().split("").reverse().join(""),n=0;n<t.length;n++)n%3==0&&(e+=t.substr(n,3)+".");return e.split("",e.length-1).reverse().join("")};

      $(document).ready(function() {
          $('.bootstrap-select').selectpicker();
            
            
            $('body').on('click','.update-record',function(){    
                var id = $(this).data('id');
                var jenis = $(this).data('jenis');
                var ket = $(this).data('ket');
                var biaya = $(this).data('biaya');
                
                $(".strings").val('');
                $(".strings2").val('');
                $('#modalEdit').modal('show');
                $('[name="kode_menu_e"]').val(id);
                $('[name="nama_menu_e"]').val(jenis);
                $('[name="status_e"]').val(ket);
                $('[name="alamat_e"]').val(biaya);
                
                
                //AJAX REQUEST TO GET SELECTED PRODUCT
                $.ajax({
                    url: "<?php echo base_url('gudang/get_bahan_promo'); ?>",
                    method: "POST",
                    data :{kode_menu:kode_menu},
                    cache:false,
                    success : function(data){
                        var item=data;
                        var val1=item.replace("[","");
                        var val2=val1.replace("]","");
                        var values=val2;
                        var akhir = values.replace(/['"]+/g, '');
                        $.each(akhir.split(","), function(i,e){
                            $(".strings option[value='" + e + "']").prop("selected", true).trigger('change');
                            $(".strings").selectpicker('refresh');
                            $(".strings2 option[value='" + e + "']").prop("selected", true).trigger('change');
                            $(".strings2").selectpicker('refresh');
                        });
                    }

                });
                return false;
            });

            //GET CONFIRM DELETE
            $('.hapus_record').on('click',function(){
                var kode = $(this).data('id');
                $('#modalHapus').modal('show');
                $('[name="kode_menu_h"]').val(kode);
            });
      });

      $(function(){
          $('#harga_jual').priceFormat({
              prefix: '',
              centsLimit: 0,
              thousandsSeparator: '.'
          });
      });
      $(function(){
          $('#harga_jual_e').priceFormat({
              prefix: '',
              centsLimit: 0,
              thousandsSeparator: '.'
          });
      });
      $(document).on('click', '.pilih', function (e) {
                document.getElementById("kode_menu").value = $(this).attr('data-nim'),
                document.getElementById("nama_menu").value = $(this).attr('data-nam');
               $('#modallistmenu').modal('hide');
            }); 

    </script>
           
</body>
</html>