<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>
  $(document).ready(function(){
    // Setup datatables
    $.fn.dataTableExt.oApi.fnPagingInfo = function(oSettings)
      {
          return {
              "iStart": oSettings._iDisplayStart,
              "iEnd": oSettings.fnDisplayEnd(),
              "iLength": oSettings._iDisplayLength,
              "iTotal": oSettings.fnRecordsTotal(),
              "iFilteredTotal": oSettings.fnRecordsDisplay(),
              "iPage": Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength),
              "iTotalPages": Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength)
          };
      };

      var table = $("#mytable2").dataTable({
          initComplete: function() {
              var api = this.api();
              $('#mytable_filter input')
                  .off('.DT')
                  .on('input.DT', function() {
                      api.search(this.value).draw();
              });
          },
              oLanguage: {
              sProcessing: "loading..."
          },
              processing: true,
              serverSide: true,
              ajax: {"url": "<?php echo base_url().'index.php/crudd/get_product_json'?>", "type": "POST"},
                  columns: [
                         {"data": "barcode_ecer"},
                        {"data": "barcode_dos"},
                        {"data": "nama_barang"},
                        //render number format for price
                        {"data": "harga_jual_ecer", render: $.fn.dataTable.render.number(',', '.', '')},
                    
                          {"data": "nama_rak"},
                           {"data": "stok_aplikasi"},
    <?php 
                      $username = $this->session->userdata("username");  
                      $this->db->where('username',$username);
                      $query = $this->db->get('tb_admin');
                      $row = $query->row();
                     
                      $level = $row->level;

                       
                        if($level =='manager'){
                      ?>  
                     

                     
                     
                        {"data": "view"}


                      <?php } ?>


                  ],
              order: [[5, 'asc']],
          rowCallback: function(row, data, iDisplayIndex) {
              var info = this.fnPagingInfo();
              var page = info.iPage;
              var length = info.iLength;
              $('td:eq(0)', row).html();
          }

      });
      // end setup datatables
      // get Edit Records
      $('#mytable2').on('click','.edit_record',function(){
            var code=$(this).data('code');
            var name=$(this).data('name');
            var stok=$(this).data('stok');
            var category=$(this).data('category');
            $('#ModalUpdate').modal('show');
            $('[name="id_stok"]').val(code);
            $('[name="nama_barang"]').val(name);
            $('[name="stok_aplikasi"]').val(stok);
           
      });
      // End Edit Records
      // get delete Records
      $('#mytable2').on('click','.delete_record',function(){
            var code=$(this).data('code');
            $('#ModalDelete').modal('show');
            $('[name="product_code"]').val(code);
      });
      // End delete Records
  });
</script>
<!-- <script>
  $(document).ready(function(){
    // Setup datatables
    $.fn.dataTableExt.oApi.fnPagingInfo = function(oSettings)
      {
          return {
              "iStart": oSettings._iDisplayStart,
              "iEnd": oSettings.fnDisplayEnd(),
              "iLength": oSettings._iDisplayLength,
              "iTotal": oSettings.fnRecordsTotal(),
              "iFilteredTotal": oSettings.fnRecordsDisplay(),
              "iPage": Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength),
              "iTotalPages": Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength)
          };
      };

      var table = $("#mytable").dataTable({
          initComplete: function() {
              var api = this.api();
              $('#mytable_filter input')
                  .off('.DT')
                  .on('input.DT', function() {
                      api.search(this.value).draw();
              });
          },
              oLanguage: {
              sProcessing: "loading..."
          },
              processing: true,
              serverSide: true,
              ajax: {"url": "<?php echo base_url().'barang/get_product_json'?>", "type": "POST"},
                  columns: [
                        {"data": "barcode_ecer"},
                         {"data": "nama_barang",},
                        {"data": "harga_beli_ecer", render: $.fn.dataTable.render.number(',', '.', '')},
                        //render number format for price
                        {"data": "harga_jual_ecer", render: $.fn.dataTable.render.number(',', '.', '')},
                         { "render": function ( data, type, row ) { // Tampilkan kolom aksi
                        var html  = "<a href='' type='button' data-toggle='modal' data-target='#modal-edit<?php echo $rows->id; ?>'><i class='fa fa-edit'></i></a> | "
                        html += "<a href=''>DELETE</a>"

                        return html
                    }
                },
                       
                  ],
              order: [[1, 'asc']],
          rowCallback: function(row, data, iDisplayIndex) {
              var info = this.fnPagingInfo();
              var page = info.iPage;
              var length = info.iLength;
              $('td:eq(0)', row).html();
          }

      });
      // end setup datatables
      
  });
</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$=tbDate21]').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>
