<!DOCTYPE html>
<!--
This is a starter template page. Use this page to start your new project from
scratch. This page gets rid of all links and provides the needed markup only.
-->
<?php foreach($kontak as $kontak) :   endforeach; ?> 
<?php foreach($admin_login as $user) :   endforeach; ?> 
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="x-ua-compatible" content="ie=edge">

  <title>Halaman Kasir</title>
  <!-- DataTables -->
  <link rel="stylesheet" href="<?php echo base_url();?>assets/plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" href="<?php echo base_url();?>assets/plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
  <!-- SweetAlert2 -->
  <link rel="stylesheet" href="<?php echo base_url();?>assets/plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css">
  <!-- Toastr -->
  <!--<link rel="stylesheet" href="<?php echo base_url();?>assets/plugins/toastr/toastr.min.css">-->
  <link rel="icon" href="<?php echo base_url();?>images/kontak/<?php echo $kontak->logo ;?>" type="image/png" /> 
  <!-- Font Awesome Icons -->
  <link rel="stylesheet" href="<?php echo base_url();?>assets/plugins/fontawesome-free/css/all.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="<?php echo base_url();?>assets/dist/css/adminlte.min.css">
  <!-- Google Font: Source Sans Pro -->
  
</head>
<body class="hold-transition sidebar-collapse layout-top-nav"  >
<div class="wrapper">

   

 

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
       
        <div class="row mb-2">
          <div class="col-sm-7">
              <table>
                <tr>
                  <td>
                      <a href="<?php echo base_url('home');?>"><button type="button" class="btn btn-block btn-warning btn-sm"><i class="fa fa-home"></i></button></a>
                  </td>
                  <td>
                      <a href="<?php echo base_url('transaksi');?>"><button type="button" class="btn btn-block btn-info btn-sm">Data Transaksi</button></a>
                  </td>
                   <td>
                      <a href="<?php echo base_url('kasir/hold');?>"><button type="" class="btn btn-block btn-warning btn-sm" onclick="return confirm('Apakah Keranjang ingin di Hold, ? Klik Oke jika Lanjut')"  > <i class="fa fa-sigout"></i> Hold </button> </a>
                  </td>
                   <td>
                      <a href="<?php echo base_url('kasir/hold_off');?>"><button type="" class="btn btn-block btn-warning btn-sm" onclick="return confirm('Apakah Keranjang Lepas Hold, ? Klik Oke jika Lanjut')"  > <i class="fa fa-sigout"></i> Off Hold</button> </a>
                  </td>
                  <td>
                      <button type="" class="btn btn-block btn-success btn-sm" data-toggle="modal" data-target="#modal-member"> <i class="fa fa-plus"></i> Member</button> 
                  </td>
                   <td>
                      <a href="<?php echo base_url('kasir/log_in');?>"><button type="button" class="btn btn-block btn-warning btn-sm">Batal Member</button></a>
                  </td>
                   <td>
                      <a href="<?php echo base_url('kasir/logout');?>"><button type="" class="btn btn-block btn-danger btn-sm"  > <i class="fa fa-sigout"></i> Logout kasir</button> </a>
                  </td>
                </tr>
              </table>  
          </div><!-- /.col -->
          <div class="col-sm-2">
              <button type="button" class="btn btn-block btn-outline-danger btn-lg"><?php echo nominal($sub_total); ?></button>     
              
          </div><!-- /.col -->
          <div class="col-sm-3">
             <button type="button" class="btn btn-block btn-outline-info btn-lg">USER : <?php echo strtoupper($nama_admin); ?></button> 
          </div><!-- /.col -->
        </div><!-- /.row -->
      
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <div class="content">

        <div class="row">
          <div class="col-lg-8">
            <div class="card card-success card-outline">
              <div class="card-body">
                <div class="row">
                  <div class="col-lg-12">
                    <table>
                      <!--  Cari berdasarkan barcode -->
                      <form action="<?php echo base_url('kasir/code_simpan_keranjang'); ?>" method="post">
                        <tr>
                          <td  style="width: 120px;">Barcode :</td>
                          <td style="width: 200px;">
                            <div class="input-group input-group-sm">
                              <input type="number" class="form-control" id="kode" placeholder="Kode Barcode" onkeypress="nextfieldBarcode(event)" autofocus="" name="barcode"  required="" >

                            </div>
                          </td>
                          <td >
                         
                            <input type="hidden" class="form-control-sm"    name="id_admin" value="<?php echo $id_admin; ?>">
                            <input type="hidden" class="form-control-sm"    name="id_kantor" value="<?php echo $id_kantor; ?>">
                          </td>
                          <td >
                            <input type="text" class="form-control-sm" placeholder="Nama Barang"  style="width: 250px;"   name="nama_barang" readonly="" >
                          </td>
                          <td >
                            <input type="text" class="form-control-sm" placeholder="Harga Jual"  style="width: 250px;"   name="harga_jual_ecer" readonly="" >
                          </td>
                          <td >
                            <input type="number" class="form-control-sm" style="width: 70px;"  value="1" name="jumlah">
                            <input type="hidden" class="form-control-sm"    name="jenis" value="ecer">
                          </td>
                          <td > 
                            <input type="submit" class="form-control-sm btn-info" style="width: 140px;"  value="Tambah Keranjang" name="simpan">
                          </td>
                        </tr>
                      </form>


                      <!--  Cari berdasarkan Pencarian -->
                      <form action="<?php echo base_url('kasir/code_simpan_keranjang_cari'); ?>" method="post">
                        <tr>
                          <td  style="width: 120px;">Jual Ecer : </td>
                          <td style="width: 200px;">
                            <div class="input-group input-group-sm">
                              <input type="text" class="form-control" id="kode2" placeholder="Kode" required="" readonly=""  >
                              <span class="input-group-append">
                                <button type="button" class="btn btn-success btn-flat" data-toggle="modal" data-target="#modalbarang">Klik Cari</button>
                              </span>
                            </div>
                          </td>
                          <td >
                            <input type="hidden" class="form-control-sm" placeholder="ID Barang"  style="width: 250px;"   name="id_barang" id="id_barang2">
                            <input type="hidden" class="form-control-sm"    name="id_admin" value="<?php echo $id_admin; ?>">
                            <input type="hidden" class="form-control-sm"    name="id_kantor" value="<?php echo $id_kantor; ?>">
                          </td>
                          <td >
                            <input type="text" class="form-control-sm" placeholder="Nama Barang"  style="width: 250px;"   name="nama_barang" id="nama_barang2" readonly="" >
                          </td>
                          <td >
                            <input type="text" class="form-control-sm" placeholder="Harga Jual"  style="width: 250px;"   name="harga_jual_ecer"  id="harga_jual_ecer2" readonly="" >
                          </td>
                          <td >
                            <input type="number" class="form-control-sm" style="width: 70px;"  value="1" name="jumlah">
                            <input type="hidden" class="form-control-sm"    name="jenis" value="ecer">
                          </td>
                          <td >
                            <input type="submit" class="form-control-sm btn-success" style="width: 140px;"  value="Tambah Keranjang" name="simpan">
                          </td>
                        </tr>
                      </form>

                      <form action="<?php echo base_url('kasir/code_simpan_keranjang_dos'); ?>" method="post">
                         <tr>
                          <td  style="width: 120px;">Jual Dos : </td>
                          <td style="width: 200px;">
                            <div class="input-group input-group-sm">
                              <input type="text" class="form-control" id="kode5" placeholder="Kode" required="" readonly=""  >
                              <span class="input-group-append">
                                <button type="button" class="btn btn-warning btn-flat" data-toggle="modal" data-target="#modalbarang">Klik Cari </button>
                              </span>
                            </div>
                          </td>
                          <td >
                            <input type="hidden" class="form-control-sm" placeholder="ID Barang"  style="width: 250px;"   name="id_barang" id="id_barang5">
                            <input type="hidden" class="form-control-sm"    name="id_admin" value="<?php echo $id_admin; ?>">
                            <input type="hidden" class="form-control-sm"    name="id_kantor" value="<?php echo $id_kantor; ?>">
                          </td>
                          <td >
                            <input type="text" class="form-control-sm" placeholder="Nama Barang"  style="width: 250px;"   name="nama_barang" id="nama_barang5" readonly="" >
                          </td>
                          <td >
                            <input type="text" class="form-control-sm" placeholder="Harga Jual Dos"  style="width: 250px;"   name="harga_jual_ecer"  id="harga_jual_dos5" readonly="" >
                          </td>
                          <td >
                            <input type="number" class="form-control-sm" style="width: 70px;"  value="1" name="jumlah">
                            <input type="hidden" class="form-control-sm"    name="jenis" value="dos">
                          </td>
                          <td >
                            <input type="submit" class="form-control-sm btn-warning" style="width: 140px;"  value="Tambah Keranjang" name="simpan">
                          </td>
                        </tr>
                      </form>



                    </table> 
                    <hr>




                  </div>
                </div> 
                 <table class="table">
                  <thead>
                    <tr>
                      <th>No</th>
                      <th>Nama Barang</th>
                      <th style="text-align: right;">Harga</th>
                      <th style="text-align: center;">Jumlah</th>

                      <th style="text-align: right;">Total Harga</th>
                      <th style="text-align: right;">Total Hemat</th>
                      <th></th>
                    </tr>

                  </thead>
                  <tbody>
                    <?php $no=1; foreach($keranjang as $tampil) :   

                    $id_barang= $tampil->id_barang;
                    $this->db->where('id',$id_barang);
                    $query = $this->db->get('tb_barang');
                    $cek = $query->row();

                    $nama_barang = $cek->nama_barang;




                    ?>

                    <tr>
                      <td><?php echo $no; ?></td>
                      <td><?php echo $nama_barang; ?> ( <?php echo $tampil->jenis; ?> )</td>
                      <td style="text-align: right;">
                        

                        <?php 
                        $cek_ubah=$kontak->edit_harga;
                         if($cek_ubah == 'tidak' ) { ?>
                        <?php echo nominal($tampil->harga_jual); ?>

                          <?php }else{ ?>
                            <?php if($tampil->jenis =='dos') {
                            echo nominal($tampil->harga_jual);
                            } else{ ?>
                          <form name="ubah" action="<?php echo base_url('kasir/ubah_code_harga_keranjang'); ?>" method="POST">
                            
                            <input type="hidden" name="id_nomor" value="<?php echo $tampil->id; ?>"   />   
                          
                            <input type="text" style="text-align: center;"   name="harga_ubah" value="<?php echo  $tampil->harga_jual; ?>" size="4" autocomplete="off"  onkeypress="nextfieldBarcode(event)">
                            <input type="hidden" style="text-align: center;" i name="jumlah_ubah" value="<?php echo  $tampil->jumlah; ?>" size="4" autocomplete="off"  onkeypress="nextfieldBarcode(event)">
                          </form>
                        <?php } ?>
                      <?php } ?>
                      </td>
                      <td style="text-align: center;">

                       <?php if($tampil->jenis =='dos') {
                         echo $tampil->jumlah; 
                       } else{ ?>
                        <form name="ubah" action="<?php echo base_url('kasir/ubah_code_keranjang'); ?>" method="POST">
                          <input type="hidden" name="id_kantor" value="<?php echo $tampil->id_kantor; ?>" size="5">
                          <input type="hidden" name="id_barang" value="<?php echo $tampil->id_barang; ?>" size="5">
                          <input type="hidden" name="id_admin" value="<?php echo $tampil->id_admin; ?>"   />   

                          <input type="hidden" class="form-control-sm"    name="jenis" value="<?php echo $tampil->jenis; ?>">


                          <input type="text" style="text-align: center;" id="ada<?php echo $no; ?>" name="jumlah_ubah" value="<?php echo  $tampil->jumlah; ?>" size="4" autocomplete="off"  onkeypress="nextfieldBarcode(event)">
                        </form>
                      <?php } ?>
                      </td>
                      <td style="text-align: right;"><?php echo  nominal($tampil->harga_total); ?></td>
                      <td style="text-align: right;"><?php echo  nominal($tampil->total_hemat); ?></td>
                      <td >

                      
                      <a href="" style="color: red;"  type="button"  data-toggle="modal" data-target="#modal-hapus<?php echo $tampil->id; ?>"><i class="fa fa-trash"></i></a>

                      <form class="form-horizontal" action="<?php echo base_url('kasir/hapus_keranjang'); ?>" method="POST" enctype="multipart/form-data" />  
                            <div class="modal fade" id="modal-hapus<?php echo $tampil->id; ?>">
                              <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 item pembelian ini ?</h4>
                                    <!-- id kirim -->
                                    <input type="hidden" name="id" value="<?php echo $tampil->id; ?>">
                                    <input type="password" name="password" placeholder="Masukkan password ">
                                    <input type="hidden" name="password_admin"  value="<?php echo $kontak->password_kasir;?>">


                                  </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>
                                <!-- /.modal-content -->
                              </div>
                              <!-- /.modal-dialog -->
                            </div>
                          </form>

                      </td>
                    </tr>
                    <?php $no++; endforeach; ?>
                    <tr>
                      
                      <td></td>
                      <td></td>
                      <td></td>
                      <td>Total</td>
                      <td style="text-align: right;font-weight: bold"><?php echo nominal($sub_total); ?></td>
                      <td style="text-align: right;font-weight: bold"><?php echo nominal($sub_total_hemat); ?></td>
                    </tr>
                  </tbody>
                </table>
              </div>
            </div>

             
          </div>
          <!-- /.col-md-6 -->
          <div class="col-lg-4">
            <div class="card card-primary card-outline">
              <div class="card-header ">
                 <form role="form" action="<?php echo base_url('kasir/code_simpan_pembelian'); ?>" method="POST"   target="print_popup"  onsubmit="window.open('about:blank','print_popup','width=600,height=700'); ">
                <h5 class="card-title m-0">Id Transaksi: <input type="number" name="newkode" readonly=""  value="<?php 
          $kasir = $id_admin +10;
              $date = date("dmY");
          $query = $this->db->query("SELECT max(id_transaksi) as max_id FROM tb_transaksi WHERE id_transaksi LIKE '$date$kasir%' "); 
          $row = $query->row_array();
           $max_id = $row['max_id']; 
            $max_id1 =(int) substr($max_id,10,4);
          $kode_tr = $max_id1 +1;
           
          echo  $newkode = $date.$kasir.sprintf("%04s",$kode_tr);   


     
    ?>"  >
<?php 
 
     
    ?>

    </h5>
              </div>
              <div class="card-body">
                
               
                  <div class="card-body">
                     
                    <div class="row">
                      <div class="col-lg-6">
                        <div class="form-group">
                          <label for="">Sub total</label>
                          <!-- tampil  -->
                          <input type="text" style="text-align:right;"  value="<?php echo nominal($sub_total); ?>"   class="form-control"   placeholder="" required readonly>
                          <!-- asli  -->
                          <input type="hidden" class="form-control" id="sub_total" NAME="sub_total" value="<?php echo $sub_total ; ?>" onFocus="startCalc();" style="text-align:right;" onBlur="stopCalc();" readonly required/>


                          <input type="hidden" class="form-control-sm"    name="id_admin" value="<?php echo $id_admin; ?>">
                          <input type="hidden" class="form-control-sm"    name="id_kantor" value="<?php echo $id_kantor; ?>">
                        </div>
                        <div class="form-group">
                          <label for="">Cari Member</label>
                          <div class="input-group ">
                            <input type="text"  style="text-align:right;" id="id_member" name="id_member"  class="form-control" readonly="">
                            <span class="input-group-append">
                              <button type="button" class="btn btn-info" data-toggle="modal" data-target="#modalmember">Cari!</button>
                            </span>
                          </div>
                        </div>
                        <div class="form-group">
                          <label for="">Nama Member</label>
                          <input type="text" style="text-align:right;"   class="form-control" id="nama_member" placeholder="" readonly>
                        </div>
                        <div class="form-group">
                          <label for="">Point</label>
                          <input type="text" style="text-align:right;" name="point"  class="form-control" id="point" placeholder="" readonly="">
                        </div>
                      </div>
                      <div class="col-lg-6">
                        <div class="form-group">
                          <label for="">Potongan </label>
                          <input type="text" style="text-align:right;"   class="form-control" id="potongan" placeholder="" required="">
                           

                        <input type="hidden" name="potongan" id="potongan2">
                        
                        <input type="hidden" name="diskon" value="<?php echo $kontak->diskon ;?>" id="diskon">
                        </div>
                        <div class="form-group">
                          <label for="">Total </label>
                          <input type="text" style="text-align:right;"   class="form-control" id="total" placeholder="" readonly>
                           

                        <input type="hidden" name="total" id="total2">
                        </div>


                         
                        <div class="form-group">
                          <label for="">Bayar</label>
                          <input type="text" style="text-align:right;"   class="form-control" id="bayar" placeholder="">
                           

                        <input type="hidden" name="bayar" id="bayar2" required="">



                        </div>
                        <div class="form-group">
                          <label for="">Kembali</label>
                          <input type="text" placeholder="kembalian/sisa" class="form-control span11" id="kembali" style="text-align:right;" readonly="" />

                          <input type="hidden" placeholder="kembalian/sisa" class="form-control span11" id="kembali2" name="kembali" />




                        </div>
                        

                      </div>
                    </div>
                    <div class="row">
                      <div class="col-lg-12">
                        <div class="form-group">
                          <label>Pilihan Pembayaran</label>
                          <select class="custom-select" name="metode_bayar">
                            <?php  foreach($metode as $metode) :  ?> 
                            <option value="<?php echo $metode->id_metode; ?>"><?php echo $metode->nama_metode; ?></option>
                             
                            <?php  endforeach; ?>
                          </select>
                        </div>
                        <div class="form-group">
                          <label for="">keterangan </label>
                          <input type="text" style="text-align:right;" name="ket_metode"   class="form-control" id="" placeholder="">
                        </div>
                         

                      </div>
                    </div>



                    
                    

                  </div>
                  <!-- /.card-body -->

                  <div class="card-footer">
                    <button type="submit" onclick="return confirm('Apakah Transaksi Sudah Benar, ? Klik Oke jika Lanjut')" class="btn btn-primary">Simpan Transaksi</button>
                  </div>
                  <div class="col-md-12">
                    <h5>Ket. Tombol Cepat</h5>
                    <table>
                      <tr width="100%">
                        <td><b>[F5]</b> Refresh, </td>
                        <td><b>[SHIFT]</b> Cari Barang, </td>
                        <td><b>[ F2 ]</b> Ubah Pembelian, </td>
                      </tr>
                      <tr>
                        <td><b>[ End ]</b> Potongan, </td>
                        <td><b>[Esc]</b> Keluar, </td>
                        <td></td>
                      </tr>
                      <tr>
                        <td><b>[ Page Down ]</b> Bayar, </td>
                         
                      </tr>
                    </table>
                   
                  </div>  
                </form>
              </div>
            </div>
 
          </div>
          <!-- /.col-md-6 -->
        </div>
        <!-- /.row -->
      
    </div>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

   
<!-- ./wrapper -->

<!-- REQUIRED SCRIPTS -->
  <form class="form-horizontal" action="<?php echo base_url('member/code_tambah_kasir'); ?>" method="POST" enctype="multipart/form-data" />  
      <div class="modal fade" id="modal-member">
        <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">Nama <?php echo $title4; ?></label>
                <input type="text" class="form-control" id="exampleInputEmail1" name="nama_member" placeholder="Isikan Nama" required="Nama Lengkap">
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Pilih Kategori Member    </label>
                <select class="form-control" id="exampleInputPassword1" name="id_kat_member">
                  <?php foreach($kat_member as $kat_member2) : ?>
                    <option value=" <?php echo $kat_member2->id_kat_member; ?>"> <?php echo $kat_member2->nama_kat_member; ?></option>
                  <?php endforeach; ?> 

                </select>  
              </div>
              <div class="form-group">
                <label for="exampleInputEmail1">Nomor KTP  </label>
                <input type="text" class="form-control"   id="exampleInputEmail1" name="ktp" placeholder="Nomor KTP">
              </div>
              <div class="form-group">
                <label for="exampleInputEmail1">Alamat Rumah</label>
                <input type="text" class="form-control"   id="exampleInputEmail1" name="alamat" placeholder="Alamat Rumah">
              </div>

              <div class="form-group">
                <label for="exampleInputEmail1">Nomor HP </label>
                <input type="text" class="form-control"   id="exampleInputEmail1" name="hp" placeholder="Nomor Yang Dapat Dihubungi ">
              </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>
<!-- Modal Tambah Data -->

 
<script src="<?php echo base_url();?>assets/js/jquery.min.js"></script>
<script>
$(document).ready(function(){

 load_data();

 function load_data(query)
 {
  $.ajax({
   url:"<?php echo base_url(); ?>kasir/fetch",
   method:"POST",
   data:{query:query},
   success:function(data){
    $('#result').html(data);
   }
  })
 }

 $('#search_text').keyup(function(){
  var search = $(this).val();
  if(search != '')
  {
   load_data(search);
  }
  else
  {
   load_data();
  }
 });
});


</script>
 
<script type="text/javascript">
   
  $(document).ready(function() {
    $('#modalbarang').on('shown.bs.modal', function() {
      $('#search_text').trigger('focus');
    });
  });
  
</script>
 
 
<div class="modal fade" id="modalbarang">
  <div class="modal-dialog modal-xl">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">Cari Data 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">
 
         

           <div class="form-group">

            <div class="input-group ">
               <input type="text" name="search_text" id="search_text"    placeholder="Masukkan Nama/ID Pencarian Barang" class="form-control" />
              <span class="input-group-append">
                <button type="button" class="btn btn-info" >Cari!</button>
              </span>
            </div>
           </div>



           <br />
           <div id="result"></div>
          </div>
          <div style="clear:both"></div>
          <button type="submit" class="btn btn-primary" data-dismiss="modal">Close</button>
      </div>
     
    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal-dialog -->
</div>

<div class="modal fade" id="modalmember">
  <div class="modal-dialog modal-xl">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">Cari Member </h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        
        <table id="example3" class="table table-bordered table-striped">
          <thead>
            <tr>
              <th>No</th>
              <th>Id Member</th>
              
              <th>KTP </th>
              <th>Nama Member</th>
              <th>Point </th>
             
              
              
              
            </tr>
          </thead>
          <tbody>
            <?php $no=1; foreach($member as $rowss) :   

           

            ?>


            <tr  class="pilih3" data-id_member="<?php echo $rowss->id_member; ?>" data-nama_member="<?php echo $rowss->nama_member;  ?>" data-point="<?php echo $rowss->point;  ?>"  >
              <td><?php echo $no; ?></td>
              <td ><a onClick="masuk2(this,'<?php echo $rowss->id_member; ?>')" href="#"><?php echo $rowss->id_member;  ?></a></td>
              <td ><a onClick="masuk2(this,'<?php echo $rowss->id_member; ?>')" href="#"><?php echo $rowss->ktp;  ?></a></td>
              <td><a onClick="masuk2(this,'<?php echo $rowss->id_member; ?>')" href="#"><?php echo $rowss->nama_member;  ?></a></td>
               
               
              <td align="right"> <?php echo nominal(ceil($rowss->point)); ?></td>
              
              
              
              
            </tr>
            <?php $no++; endforeach; ?>

          </tbody>

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



<script>
var input = document.getElementById("kode");
input.addEventListener("keyup", function(event) {
  if (event.keyCode === 113) {
    event.preventDefault();
    document.getElementById("ada1").focus();
  }

  if (event.keyCode === 35) {
    event.preventDefault();
    document.getElementById("potongan").focus();
  }
});
 
var input = document.getElementById("potongan");
input.addEventListener("keyup", function(event) {
 
  if (event.keyCode === 34) {
    event.preventDefault();
    document.getElementById("bayar").focus();
  }
});

</script> 
<!--<script src="<?php echo base_url();?>assets/js/jquery-1.11.2.min.js"></script>-->
<script type="text/javascript">

// barang
$(document).on('click', '.pilih', function (e) {
  document.getElementById("id_barang2").value = $(this).attr('data-id_barang');
  document.getElementById("nama_barang2").value = $(this).attr('data-nama_barang');
  document.getElementById("kode2").value = $(this).attr('data-barcode');
  document.getElementById("harga_jual_ecer2").value = $(this).attr('data-harga_jual_ecer');
   document.getElementById("id_barang5").value = $(this).attr('data-id_barang');
  document.getElementById("nama_barang5").value = $(this).attr('data-nama_barang');
  document.getElementById("kode5").value = $(this).attr('data-barcode');
  document.getElementById("harga_jual_dos5").value = $(this).attr('data-harga_jual_dos');

  $('#modalbarang').modal('hide');
});
$(document).on('click', '.pilih2', function (e) {
   document.getElementById("id_barang3").value = $(this).attr('data-id_barang');
  document.getElementById("nama_barang3").value = $(this).attr('data-nama_barang');
  document.getElementById("kode3").value = $(this).attr('data-kode3');
   document.getElementById("id_barang2").value = $(this).attr('data-id_barang');
  document.getElementById("nama_barang2").value = $(this).attr('data-nama_barang');
  document.getElementById("kode2").value = $(this).attr('data-kode3');
  document.getElementById("harga_jual_ecer2").value = $(this).attr('data-harga_jual_ecer');
  document.getElementById("harga_jual_dos3").value = $(this).attr('data-harga_jual_dos');

  $('#modalbarang2').modal('hide');
});


// barang
$(document).on('click', '.pilih3', function (e) {
  document.getElementById("id_member").value = $(this).attr('data-id_member');
  document.getElementById("nama_member").value = $(this).attr('data-nama_member');
  document.getElementById("point").value = $(this).attr('data-point');
  
  $('#modalmember').modal('hide');
});

</script> 
<script type="text/javascript">



  /* Tanpa Rupiah */
  var bayar = document.getElementById('bayar');
  bayar.addEventListener('keyup', function(e)
  {
    bayar.value = formatRupiah(this.value);
  });

  var potongan = document.getElementById('potongan');
  potongan.addEventListener('keyup', function(e)
  {
    potongan.value = formatRupiah(this.value);
  });

bayar.addEventListener('keydown', function(event)
  {
    limitCharacter(event);
  });




  /* Fungsi */
  function formatRupiah(bilangan, prefix)
  {
    var number_string = bilangan.replace(/[^,\d]/g, '').toString(),
    split = number_string.split(','),
    sisa  = split[0].length % 3,
    rupiah  = split[0].substr(0, sisa),
    ribuan  = split[0].substr(sisa).match(/\d{1,3}/gi);

    if (ribuan) {
      separator = sisa ? '.' : '';
      rupiah += separator + ribuan.join('.');
    }

    rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
    return prefix == undefined ? rupiah : (rupiah ? 'Rp. ' + rupiah : '');
  }
   $(function(){
      $('#potongan').on("input",function(){

      var subtotal=$('#sub_total').val();
      var jumuang1=$('#potongan').val();
      var hsl1=jumuang1.replace(/[^\d]/g,"");
      var hasil1 = subtotal-hsl1;
      var test1 = numeral(hasil1).format('0,0');


      $('#potongan2').val(hsl1);

      $('#total').val(test1);
      $('#total2').val(hasil1);


    }) 
    $('#bayar').on("input",function(){

      //
      
      //
      var total=$('#total2').val();
      var jumuang=$('#bayar').val();
      var hsl=jumuang.replace(/[^\d]/g,"");
      var hasil = hsl-total;
      var test = numeral(hasil).format('0,0');


      $('#bayar2').val(hsl);

      $('#kembali').val(test);
      $('#kembali2').val(hasil);


    })


  });
</script>
<script>
  // https://tutorialweb.net/menangkap-tombol-keyboard-dengan-javascript/
document.onkeydown = function (e) {
  switch (e.keyCode) {
            // tombol shif
            case 16:
            $('#modalbarang').modal('show');
            break;
            // Esc
            case 27:
            $('#modalbarang').modal('hide');
            $('#modalbarang2').modal('hide');
            break;
            
            
            // F5
            case 116:
            location.reload(); 
            break;
        }
        //menghilangkan fungsi default tombol
        
    };
 
</script>
<!-- jQuery -->
<!--<script src="<?php echo base_url();?>assets/plugins/jquery/jquery.min.js"></script>-->
 <script src="<?php echo base_url().'assets/js/numeral.min.js'?>"></script>
<!-- Bootstrap 4 -->
<script src="<?php echo base_url();?>assets/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- AdminLTE App -->
<script src="<?php echo base_url();?>assets/dist/js/adminlte.min.js"></script>
 
<!-- DataTables -->
<!-- <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> -->
 
<!-- AdminLTE for demo purposes -->
 
<!-- page script -->
<script>
  $(function () {
    $("#example1").DataTable({
      "responsive": true,
      "autoWidth": false,
    });
    $('#example2').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": false,
      "ordering": true,
      "info": true,
      "autoWidth": false,
      "responsive": true,
    });
    $("#example3").DataTable({
      "responsive": true,
      "autoWidth": false,
    });
  });
</script>
  
<!-- <script type="text/javascript">
  $(document).ready(function(){
    $('#kode').on('input',function(){

      var kode=$(this).val();
      $.ajax({
        type : "POST",
        url  : "<?php echo base_url('kasir/get_barang')?>",
        dataType : "JSON",
        data : {kode: kode},
        cache:false,
        success: function(data){
          $.each(data,function(kode, nama_barang ,id_barang,harga_jual_ecer){
            $('[name="nama_barang"]').val(data.nama_barang);
            $('[name="id_barang"]').val(data.id_barang);
            $('[name="harga_jual_ecer"]').val(data.harga_jual_ecer);
             

          });

        }
      });
      return false;
    });

  });
</script> -->



 
<!-- SweetAlert2 -->
<script src="<?php echo base_url();?>assets/plugins/sweetalert2/sweetalert2.min.js"></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-pembelian'):?>
  <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-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-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')=='success-login_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: 'Login kasir 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-kosong'):?>
  <script type="text/javascript">
    $(function() {
      const Toast = Swal.mixin({
        toast: true,
        position: 'top-end',
        showConfirmButton: false,
        timer: 3000
      });



      $(function() {
        Toast.fire({
          icon: 'error',
          title: 'Barang Tidak ada'
        })
      });


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



      $(function() {
        Toast.fire({
          icon: 'error',
          title: 'password hapus salah'
        })
      });


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



      $(function() {
        Toast.fire({
          icon: 'error',
          title: 'Stok Kosong '
        })
      });


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



      $(function() {
        Toast.fire({
          icon: 'warning',
          title: 'Stok Tidak Cukup '
        })
      });


    });
  </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>
