<footer class="main-footer">
  <strong>Copyright &copy; 2014-2019 <a href="#">AdminLTE.io</a>.</strong>
  All rights reserved.  Pembuat Aplikasi: Cv. Madura Technovation.web.id
  <div class="float-right d-none d-sm-inline-block">
    <b>Version</b> 3.0.5
  </div>
</footer>

 
<script src="<?php echo base_url().'assets/js/jquery-3.2.1.js'?>"></script>
<script type="text/javascript">
        $(document).ready(function(){
                tampil_data_barang();   //pemanggilan fungsi tampil barang.
                 
                $('#example1').dataTable();
                  
                //fungsi tampil barang
                function tampil_data_barang(){
                    $.ajax({
                        type  : 'GET',
                        url   : '<?php echo base_url()?>barang/data_barang',
                        async : true,
                        dataType : 'json',
                        success : function(data){
                            var html = '';
                            var i;
                            for(i=0; i<data.length; i++){
                                html += '<tr>'+
                                        '<td>'+data[i].barcode_ecer+'</td>'+
                                        '<td>'+data[i].nama_barang+'</td>'+
                                        '<td>'+data[i].harga_jual_ecer+'</td>'+
                                        '<td>'+data[i].harga_grosir_lv1+'</td>'+
                                        '<td style="text-align:right;">'+
                                    '<a href="<?php echo base_url('barang/form_edit_new/');?>'+data[i].barcode_ecer+'" class="btn btn-info btn-xs  " onclick="return confirm(\'Are you sure you want to edit this item '+data[i].barcode_ecer+'\');"> Edit </a>'+' '+

                                    '<a href="<?php echo base_url('barang/code_hapus_barcode/');?>'+data[i].barcode_ecer+'" class="btn btn-danger btn-xs  " onclick="return confirm(\'Are you sure you want to hapus this item '+data[i].barcode_ecer+'\');"> Hapus </a>'+' '+

                                '</td>'+
                                        '</tr>';
                            }
                            $('#show_data').html(html);
                        }
 
                    });
                }
 
                //GET UPDATE
                $('#show_data').on('click','.item_edit',function(){
            var id=$(this).attr('data');
            $.ajax({
                type : "GET",
                url  : "<?php echo base_url('index.php/barang/get_barang')?>",
                dataType : "JSON",
                data : {id:id},
                success: function(data){
                        $.each(data,function(barang_kode, barang_nama, barang_harga){
                        $('#ModalaEdit').modal('show');
                                $('[name="kobar_edit"]').val(data.barang_kode);
                                $('[name="nabar_edit"]').val(data.barang_nama);
                                $('[name="harga_edit"]').val(data.barang_harga);
                        });
                }
            });
            return false;
        });
 
 
                //GET HAPUS
                $('#show_data').on('click','.item_hapus',function(){
            var id=$(this).attr('data');
            $('#ModalHapus').modal('show');
            $('[name="kode"]').val(id);
        });
 
                //Simpan Barang
                $('#btn_simpan').on('click',function(){
            var kobar=$('#kode_barang').val();
            var nabar=$('#nama_barang').val();
            var harga=$('#harga').val();
            $.ajax({
                type : "POST",
                url  : "<?php echo base_url('index.php/barang/simpan_barang')?>",
                dataType : "JSON",
                data : {kobar:kobar , nabar:nabar, harga:harga},
                success: function(data){
                    $('[name="kobar"]').val("");
                    $('[name="nabar"]').val("");
                    $('[name="harga"]').val("");
                    $('#ModalaAdd').modal('hide');
                    tampil_data_barang();
                }
            });
            return false;
        });
 
        //Update Barang
                $('#btn_update').on('click',function(){
            var kobar=$('#kode_barang2').val();
            var nabar=$('#nama_barang2').val();
            var harga=$('#harga2').val();
            $.ajax({
                type : "POST",
                url  : "<?php echo base_url('index.php/barang/update_barang')?>",
                dataType : "JSON",
                data : {kobar:kobar , nabar:nabar, harga:harga},
                success: function(data){
                    $('[name="kobar_edit"]').val("");
                    $('[name="nabar_edit"]').val("");
                    $('[name="harga_edit"]').val("");
                    $('#ModalaEdit').modal('hide');
                    tampil_data_barang();
                }
            });
            return false;
        });
 
        //Hapus Barang
        $('#btn_hapus').on('click',function(){
            var kode=$('#textkode').val();
            $.ajax({
            type : "POST",
            url  : "<?php echo base_url('index.php/barang/hapus_barang')?>",
            dataType : "JSON",
                    data : {kode: kode},
                    success: function(data){
                            $('#ModalHapus').modal('hide');
                            tampil_data_barang();
                    }
                });
                return false;
            });
 
        });
 
</script>
<script>
  $(document).ready(function() {
    $('#example4').dataTable( {
      "bProcessing": true,
      "bServerSide": true,
      "sAjaxSource": "<?php echo base_url()?>data.php",
      "aoColumns": [
        null,
        null,
         {render: $.fn.dataTable.render.number(',', '.', '')},
        {render: $.fn.dataTable.render.number(',', '.', '')},
        {render: $.fn.dataTable.render.number(',', '.', '')},
         {render: $.fn.dataTable.render.number(',', '.', '')},
          {render: $.fn.dataTable.render.number(',', '.', '')},
           {render: $.fn.dataTable.render.number(',', '.', '')},
            {render: $.fn.dataTable.render.number(',', '.', '')},
             {render: $.fn.dataTable.render.number(',', '.', '')},
        {
        "mData": "0", <!-- Ini adalah untuk Link ID urutan kolom seperti table mulai dari 0 untuk data pertama -->
        "mRender": function ( data, type, full ) {
          return '<a href="<?php echo base_url('barang/form_edit_new/');?>'+data+'"  target="_blank" class="btn btn-success" onclick="return confirm(\'Are you sure you want to edit this item '+data+'\');" > EDIT </a> <a href="<?php echo base_url('barang/code_hapus_barcode/');?>'+data+'"  target="_blank" class="btn btn-danger" onclick="return confirm(\'Are you sure you want to delete this item '+data+'\');"> DELETE </a>';
          }
        }
      ]
    } );
  } );
  </script>

 


<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
  <!-- Control sidebar content goes here -->
</aside>
<!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->

<!-- sweetalert2 -->

 



<!-- bs-custom-file-input -->
<script src="<?php echo base_url();?>assets/plugins/bs-custom-file-input/bs-custom-file-input.min.js"></script>
<!-- jQuery -->
<!-- <script src="<?php echo base_url();?>assets/plugins/jquery/jquery.min.js"></script> -->
<!-- jQuery UI 1.11.4 -->
<script src="<?php echo base_url();?>assets/plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
  $.widget.bridge('uibutton', $.ui.button)
</script>
<!-- Bootstrap 4 -->
<script src="<?php echo base_url();?>assets/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="<?php echo base_url();?>assets/plugins/inputmask/min/jquery.inputmask.bundle.min.js"></script>

<!-- ChartJS -->
<script src="<?php echo base_url();?>assets/plugins/chart.js/Chart.min.js"></script>
<!-- Sparkline -->
<script src="<?php echo base_url();?>assets/plugins/sparklines/sparkline.js"></script>
 
<!-- jQuery Knob Chart -->
<script src="<?php echo base_url();?>assets/plugins/jquery-knob/jquery.knob.min.js"></script>


  <script>
    $(document).ready(function () {
     
        $('input[id$=tbDate1]').datepicker({
          dateFormat: 'yy-mm-dd'
      });
    });
</script>
 <script>
    $(document).ready(function () {
     
        $('input[id$=tbDate2]').datepicker({
          dateFormat: 'yy-mm-dd'
      });
    });
</script>
  <script>
    $(document).ready(function () {
     
        $('input[id$=tbDate3]').datepicker({
          dateFormat: 'yy-mm-dd'
      });
    });
</script>
  <script>
    $(document).ready(function () {
     
        $('input[id$=tbDate4]').datepicker({
          dateFormat: 'yy-mm-dd'
      });
    });
</script>
  <script>
    $(document).ready(function () {
     
        $('input[id$=tbDate5]').datepicker({
          dateFormat: 'yy-mm-dd'
      });
    });
</script>
  <script>
    $(document).ready(function () {
     
        $('input[id$=tbDate6]').datepicker({
          dateFormat: 'yy-mm-dd'
      });
    });
</script>
 <script>
    $(document).ready(function () {
     
        $('input[id$=tbDate7]').datepicker({
          dateFormat: 'yy-mm-dd'
      });
    });
</script>
<!-- Tempusdominus Bootstrap 4 -->
<script src="<?php echo base_url();?>assets/plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- Summernote -->
<script src="<?php echo base_url();?>assets/plugins/summernote/summernote-bs4.min.js"></script>
<!-- overlayScrollbars -->
<script src="<?php echo base_url();?>assets/plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
<!-- AdminLTE App -->
<script src="<?php echo base_url();?>assets/dist/js/adminlte.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="<?php echo base_url();?>assets/dist/js/pages/dashboard.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="<?php echo base_url();?>assets/dist/js/demo.js"></script>
<!-- bs-custom-file-input -->
 
 
 
<!-- SweetAlert2 -->
<script src="<?php echo base_url();?>assets/plugins/sweetalert2/sweetalert2.min.js"></script>
<!-- Toastr -->
<script src="<?php echo base_url();?>assets/plugins/toastr/toastr.min.js"></script>

<script src="<?php echo base_url();?>assets/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="<?php echo base_url();?>assets/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="<?php echo base_url();?>assets/plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="<?php echo base_url();?>assets/plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>

 
 
<script>
  $(function () {
    $("#example1").DataTable({


      "responsive": true,
      "autoWidth": false,
      "iDisplayLength": 100,
      "deferRender": true,

    //        "scrollY":        500,
    //        "bJQueryUI" : false,
    // "sScrollY" : "300px",
    // "sScrollX" : "100%",
    // "sScrollXInner" : "100%",
    // "bScrollCollapse" : false,
    // "bPaginate" : false,
    // "bSort" : false,
    // "bSortClasses" : false,
    // "bFilter" : false,
    // "bInfo" : false,
    // "bProcessing" : false,
    // "bStateSave" : false,
    // "bServerSide" : false,
    // "bDeferRender" : false
    

    });
    $('#example2').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": false,
      "ordering": true,
      "info": true,
      "autoWidth": false,
      "responsive": true,
    });
  });
</script>
 
 
 <?php if($this->session->flashdata('msg')=='success'):?>
  <script type="text/javascript">
    $(function() {
      const Toast = Swal.mixin({
        toast: true,
        position: 'top-end',
        showConfirmButton: false,
        timer: 3000
      });



      $(function() {
        Toast.fire({
          icon: 'success',
          title: 'Data Berhasil Disimpan'
        })
      });


    });
  </script>
  <?php elseif($this->session->flashdata('msg')=='success-login'):?>
  <script type="text/javascript">
    $(function() {
      const Toast = Swal.mixin({
        toast: true,
        position: 'top-end',
        showConfirmButton: false,
        timer: 3000
      });



      $(function() {
        Toast.fire({
          icon: 'success',
          title: 'Login Berhasil '
        })
      });


    });
  </script>
   <?php elseif($this->session->flashdata('msg')=='success-retur'):?>
  <script type="text/javascript">
    $(function() {
      const Toast = Swal.mixin({
        toast: true,
        position: 'top-end',
        showConfirmButton: false,
        timer: 3000
      });



      $(function() {
        Toast.fire({
          icon: 'success',
          title: 'Retur Berhasil '
        })
      });


    });
  </script>
  <?php elseif($this->session->flashdata('msg')=='success-singkron'):?>
  <script type="text/javascript">
    $(function() {
      const Toast = Swal.mixin({
        toast: true,
        position: 'top-end',
        showConfirmButton: false,
        timer: 3000
      });



      $(function() {
        Toast.fire({
          icon: 'success',
          title: 'Singkron Data Barang Berhasil '
        })
      });


    });
  </script>
    <?php elseif($this->session->flashdata('msg')=='success-edit'):?>
    <script type="text/javascript">
        $(function() {
            const Toast = Swal.mixin({
                toast: true,
                position: 'top-end',
                showConfirmButton: false,
                timer: 3000
            });



            $(function() {
                Toast.fire({
                    icon: 'success',
                    title: 'Perubahan Berhasil Disimpan'
                })
            });


        });
    </script>

     <?php elseif($this->session->flashdata('msg')=='success-logout-kasir'):?>
    <script type="text/javascript">
        $(function() {
            const Toast = Swal.mixin({
                toast: true,
                position: 'top-end',
                showConfirmButton: false,
                timer: 3000
            });



            $(function() {
                Toast.fire({
                    icon: 'success',
                    title: 'Setoran Berhasil Tersimpan'
                })
            });


        });
    </script>

      <?php elseif($this->session->flashdata('msg')=='success-opname'):?>
    <script type="text/javascript">
        $(function() {
            const Toast = Swal.mixin({
                toast: true,
                position: 'top-end',
                showConfirmButton: false,
                timer: 3000
            });



            $(function() {
                Toast.fire({
                    icon: 'success',
                    title: 'Stok Opname Berhasil'
                })
            });


        });
    </script>
  <?php elseif($this->session->flashdata('msg')=='success-hapus'):?>
  <script type="text/javascript">
    $(function() {
      const Toast = Swal.mixin({
        toast: true,
        position: 'top-end',
        showConfirmButton: false,
        timer: 3000
      });



      $(function() {
        Toast.fire({
          icon: 'success',
          title: 'Hapus Data Berhasil '
        })
      });


    });
  </script>

  <?php elseif($this->session->flashdata('msg')=='error'):?>
  <script type="text/javascript">
    $(function() {
      const Toast = Swal.mixin({
        toast: true,
        position: 'top-end',
        showConfirmButton: false,
        timer: 3000
      });



      $(function() {
        Toast.fire({
          icon: 'error',
          title: 'Data Gagal Disimpan'
        })
      });


    });
  </script>
  <?php elseif($this->session->flashdata('msg')=='error-login_kasir'):?>
  <script type="text/javascript">
    $(function() {
      const Toast = Swal.mixin({
        toast: true,
        position: 'top-end',
        showConfirmButton: false,
        timer: 3000
      });



      $(function() {
        Toast.fire({
          icon: 'error',
          title: 'Nominal Tidak Boleh 0 ataupun kosong'
        })
      });


    });
  </script>
  <?php elseif($this->session->flashdata('msg')=='error-setor'):?>
  <script type="text/javascript">
    $(function() {
      const Toast = Swal.mixin({
        toast: true,
        position: 'top-end',
        showConfirmButton: false,
        timer: 3000
      });



      $(function() {
        Toast.fire({
          icon: 'error',
          title: 'Maaf Anda Sudah Logout dan Setor '
        })
      });


    });
  </script>
  <?php elseif($this->session->flashdata('msg')=='error-awal'):?>
  <script type="text/javascript">
    $(function() {
      const Toast = Swal.mixin({
        toast: true,
        position: 'top-end',
        showConfirmButton: false,
        timer: 3000
      });



      $(function() {
        Toast.fire({
          icon: 'error',
          title: 'Maaf Anda Belum Mengisi   Case Awal '
        })
      });


    });
  </script>
  <?php elseif($this->session->flashdata('msg')=='error-img'):?>
  <script type="text/javascript">
    $(function() {
      const Toast = Swal.mixin({
        toast: true,
        position: 'top-end',
        showConfirmButton: false,
        timer: 3000
      });



      $(function() {
        Toast.fire({
          icon: 'error',
          title: 'Data Gagal Disimpan, Gambar Error'
        })
      });


    });
  </script>

  <?php else:?>

  <?php endif;?>

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