 <!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>Faktur Kirim Barang</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('kantor/data_faktur');?>"><button type="button" class="btn btn-block btn-info btn-sm">Data Faktur </button></a>
                  </td>
                  
                   
              	</tr>
              </table>	
          </div><!-- /.col -->
          <div class="col-sm-2">
           		<button type="button" class="btn btn-block btn-outline-danger btn-lg">Toko : <?php echo $nama_kantor;?></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('kantor/code_simpan_keranjang_kirim'); ?>" method="post">
				          		<tr>
				          			<td  style="width: 120px;"> Kode Barcode :</td>
				          			<td style="width: 200px;">
				          				<div class="input-group input-group-sm">
				          					<input type="text" class="form-control" id="kode" placeholder="Kode Barcode"  onkeypress="nextfieldBarcode(event)" autofocus="" required="" autocomplete="off" >
				          					 
				          				</div>
				          			</td>
				          			<td >
				          					<input type="hidden" class="form-control-sm" placeholder="ID Barang"  style="width: 250px;"   name="id_barang">
				          					<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" autocomplete="off" readonly="">
				          			</td>
				          			<td >
                          
				          					<input type="date" class="form-control-sm" placeholder="Tgl Expired"  style="width: 250px;"     name="expired" required="">
                                                   	<!-- 	<input type="date" class="form-control-sm" placeholder="Tgl Expired"  style="width: 250px;"  value="<?php $tgl1 = date('Y-m-d');// pendefinisian tanggal awal
                                                   echo $tgl2 = date('Y-m-d', strtotime('+10 years', strtotime($tgl1))); ?>"    name="expired" required=""> -->
				          			</td>
				          			<td >
				          					<input type="number" class="form-control-sm" style="width: 70px;"  value="1" name="jumlah">
				          			</td>
				          			<td > 
				          					<input type="submit" class="form-control-sm btn-info" style="width: 140px;"  value="Tambah Keranjang" name="simpan">
				          			</td>
				          		</tr>
								</form>

								  <form action="<?php echo base_url('kantor/code_simpan_keranjang_kirim'); ?>" method="post">
                        <tr>
                          <td  style="width: 120px;">Cari Barang : </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="date" class="form-control-sm" placeholder="Tgl Expired"  style="width: 250px;"     name="expired"  id="harga_jual_ecer2" required>
                          </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>
				          		<!--  Cari berdasarkan Pencarian -->
							 
				          	</table> 
				          	<hr>
				          		
 
				           
				          
				          </div>
				        </div> 
 								<table class="table">
 									<thead>
 										<tr>
 											<th>No</th>
 											<th>ID Barang</th>
	 										<th>Nama Barang</th>
	 									 
	 										<th style="text-align: center;">Jumlah</th>
	 										<th>Expired Barang</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();
										$barcode_ecer = $cek->barcode_ecer;
 										$nama_barang = $cek->nama_barang;
 									 

				              				 

												?>

 										<tr>
 											<td><?php echo $no; ?></td>
 											<td><?php echo $barcode_ecer; ?></td>
 										 <td><?php echo $nama_barang; ?></td>
 											<td style="text-align: center;"><?php echo  $tampil->jumlah; ?></td>
 											<td><?php echo  $tampil->expired; ?></td> 
 											<td ><a href="<?php echo base_url('kantor/hapus_keranjang_kirim'); ?>/<?php echo $tampil->id; ?>" style="color: red;" ><i class="fa fa-trash"></i></a></td>
 										</tr>
 										<?php $no++; endforeach; ?>
 									</tbody>
 								</table>
              </div>
            </div>

             
          </div>
       
          <div class="col-lg-4">
            <div class="card card-primary card-outline">
              <div class="card-header ">
                <h5 class="card-title m-0">Penyimpanan Faktur</h5>
              </div>
              <div class="card-body">
                
              	<form role="form" action="<?php echo base_url('kantor/code_simpan_faktur_kirim'); ?>" method="POST" >
              		<div class="card-body">
              			 
              			 
              			<div class="row">
              				<div class="col-lg-12">
              					<div class="form-group">
              						<label for="">Nomor Faktur  </label>
              						<input type="number" name="id_faktur"   class="form-control" id="" placeholder="" 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>Jenis Faktur</label>
              						<select class="custom-select" name="jenis" required="">
              						 
              						<!-- 	<option value="masuk">masuk</option> -->
              							<option value="keluar">keluar</option>
              							 
              						</select>
              					</div>
              					
              					<div class="form-group">
              						<label>Pilihan Supliyer Pengirim</label>
              						<select class="custom-select" name="id_supliyer">
              							<?php  foreach($supliyer as $supliyer) :  ?> 
              							<option value="<?php echo $supliyer->id_supliyer; ?>"><?php echo $supliyer->nama_supliyer; ?></option>
              							 
              							<?php  endforeach; ?>
              						</select>
              					</div>
              					 
              					<div class="form-group">
              						<label for="">Total Nominal Faktur </label>
              						<input type="number"   name="nominal"   class="form-control" id="" placeholder="" >
              					</div>
              					<div class="form-group">
              						<label for="">Status </label>
              						<select class="form-control" name="status">

              							<!-- <option value="LUNAS">LUNAS</option>
              							<option value="HUTANG">HUTANG</option>
              							<option value="BARANG DITERIMA">BARANG DITERIMA</option> -->
              							<option value="KIRIM BARANG">KIRIM BARANG</option>
              						</select>
              					</div>
              					<div class="form-group">
              						<label for="">Jatuh Tempo </label>
              						<input type="date"   name="jatuh_tempo"   class="form-control" id="" placeholder="" >
              					</div>
              					<div class="form-group">
              						<label>Nama Supir</label>
              						<input type="text" name="supir" class="form-control">   
              					</div>
              					<div class="form-group">
              						<label for="">Keterangan Lainnya </label>
              						<input type="text"  name="keterangan"   class="form-control" id="" placeholder="" >
              					</div>
              					 

              				</div>
              			</div>



              			
              			

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

              		<div class="card-footer">
              			<button type="submit" onclick="return confirm('Apakah Anda Yakin Menyimpan Faktur, ? Klik Oke jika Lanjut')" class="btn btn-primary">Simpan Faktur</button>
              		</div>
              	 
              	</form>
              </div>
            </div>
 
          </div>
          <!-- /.col-md-6 -->
        </div>
        <!-- /.row -->
      
    </div>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

   
<!-- ./wrapper -->

<!-- REQUIRED SCRIPTS -->
<!-- Modal Tambah Data -->
<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 Member</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="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>


<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="caribarang">
	<div class="modal-dialog modal-xl">
		<div class="modal-content">
			<div class="modal-header">
				<h4 class="modal-title">Cari Barang 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">
				<form>
					<div class="form-group">
						<label>Title</label>
						<input type="text" name="cari" class="form-control" id="title" placeholder="Title" style="width:500px;">
					</div>
					<div class="form-group">
						<label>Description</label>
						<textarea name="id_barang" class="form-control" placeholder="Description" style="width:500px;"></textarea>
					</div>
				</form>

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


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

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

// barang
$(document).on('click', '.pilih2', 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');
            break;
            
            
            // F5
            case 116:
            location.reload(); 
            break;
        }
        //menghilangkan fungsi default tombol
        
    };
 
</script>
 
<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>
<!-- jQuery -->
<script src="<?php echo base_url();?>assets/plugins/jquery/jquery.min.js"></script>
<script src="<?php echo base_url().'assets/js/jquery.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 -->
<script src="<?php echo base_url();?>assets/dist/js/demo.js"></script>
<!-- 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>
<!-- Toastr -->
<script src="<?php echo base_url();?>assets/plugins/toastr/toastr.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')=='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>


 <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().'index.php/crud/get_product_json'?>", "type": "POST"},
                  columns: [
                        {"data": "id"},
                        {"data": "barcode_ecer"},
                         {"data": "barcode_dos"},
                         {"data": "nama_barang"},
                        //render number format for price
                        {"data": "harga_jual_ecer", render: $.fn.dataTable.render.number(',', '.', '')},
                         {"data": "harga_jual_dos", render: $.fn.dataTable.render.number(',', '.', '')},
                        {"data": "isi", render: $.fn.dataTable.render.number(',', '.', '')},
                        // {"data": "harga_grosir", render: $.fn.dataTable.render.number(',', '.', '')},
                        {"data": "stok_aplikasi", render: $.fn.dataTable.render.number(',', '.', '')},
                        
                        {"data": "view"}
                  ],
              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
      // get Edit Records
      
  });
</script>
</body>
</html>
