  <div class="content-wrapper" style="margin-bottom: 0px">
    <div style="margin-left: 20px;margin-right: 10px">
      <div class="row">
        <div class="col-md-4">
          <div class="panel panel-default">
            <div class="panel-body">
              <table class="table table-bordered table-responsive">
                
                <tr class="odd gradeX">
                  <td style="height:35px; text-align: left;font-size: 13pt" >Total Harga</td>
                  <td style="height:35px; text-align: right;font-size: 13pt" >
                      <span ><strong>&nbsp;Rp. <span id="total_harga"><?php echo number_format($faktur->total_penjualan_sdiskon, 0, ',', '.') ?></span></strong></span>
                      <input class="span8" id="tot" name="total_harga" type="hidden" value="" placeholder="" />
                  </td>
                  
                </tr>
				 <tr class="odd gradeX">
                  <td style="height:35px; text-align: left;font-size: 13pt" >Discount</td>
                  <td style="height:35px; text-align: right;font-size: 13pt" >
                      <span >&nbsp;Rp. <span id="disc"><?php echo number_format($faktur->ndisc, 0, ',', '.') ?></span></span>
                      <input class="span8" id="ndisc" name="ndisc" type="hidden" value="" placeholder="" />
                  </td>
                  
                </tr>
				 <tr class="odd gradeX">
                  <td style="height:35px; text-align: left;font-size: 13pt" >Pb1 10%</td>
                  <td style="height:35px; text-align: right;font-size: 13pt" >
                      <span >&nbsp;Rp. <span id="pb1"><?php echo number_format($faktur->nppn, 0, ',', '.') ?></span></span>
                      <input class="span8" id="pb1" name="pb1" type="hidden" value="" placeholder="" />
                  </td>
                  
                </tr>
				 <tr class="odd gradeX">
                  <td style="height:35px; text-align: left;font-size: 13pt" >Ongkir</td>
                  <td style="height:35px; text-align: right;font-size: 13pt" >
                      <span >&nbsp;Rp. <span id="ongkir"><?php echo number_format($faktur->ongkir, 0, ',', '.') ?></span></span>
                      <input class="span8" id="ongkir" name="ongkir" type="hidden" value="" placeholder="" />
               
                  </td>
                  
                </tr>
				
				<tr>
                  <td style="height:35px; text-align: left;font-size: 13pt" ><b>Netto</b></td>
                  <td style="height:35px; text-align: right;font-size: 13pt" >
				  <span><strong >&nbsp;Rp. <span> <?php echo number_format($faktur->netto, 0, ',', '.') ?></span></span></strong>
				  </td>
                </tr>
				<tr>
                  <td style="height:35px; text-align: left;font-size: 13pt" ><font color='blue'><b>Bayar</b></font></td>
                  <td style="height:35px; text-align: right;font-size: 13pt" >
				  <strong>&nbsp;Rp. <?php echo number_format($faktur->nbayar, 0, ',', '.') ?></strong></td>
                </tr>
                <tr>
                  <td style="height:35px; text-align: left;font-size: 13pt;" ><font color='red'><b>Kembalian</b></font></td>
                  <td style="height:35px; text-align: right;font-size: 13pt" >
				  <strong ><font color='red'>&nbsp;Rp. <?php echo number_format($faktur->nkembali, 0, ',', '.') ?></font></strong>
				  </td>
                </tr>
              </table>
                <div class="form-inline" style="text-align: center;">
					<form name ="cal">
						<tr>
							<input type="hidden" name="nofak_dis" id="nofak_dis" value="<?php echo $faktur->no_faktur_penjualan ?>">
							<input type="hidden" name="sum_belanja" id="sum_belanja" value="<?php echo $faktur->netto ?>">				  
							<td align='right'> <input style="width:160px;height:35px; text-align: right;" type="button" class="form-control pull-right" id="display" placeholder="Cash (Rp)" name="display"></td>	
						</tr>	
						<br><br>
						<?php if( $faktur->layanan==1 or $faktur->layanan==2) {?>
						     <?php if($faktur->nbayar==0 ) { ?>
						<tr>
							<td><input style="height:40px; text-align: center;" type="button" value ="7" onclick ="cal.display.value+='7'"></td>
							<td><input style="height:40px; text-align: center;"  type="button" value ="8" onclick ="cal.display.value+='8'"></td>
							<td><input style="height:40px; text-align: center;" type="button" value ="9" onclick ="cal.display.value+='9'"></td>	
							<td><input style="width:75px;height:40px; text-align: center;" type="button" value ="Rp.20.000" onclick ="cal.display.value='20000'" id="dua"></td>
							<td><input type="button" value ="CASH" class="btn btn-success pull-right" style="width:75px;height:40px; text-align: center;" id="btnHitung"></td>
							<br>
						
							<td><input style="height:40px; text-align: center;"  type="button" value ="4" onclick ="cal.display.value+='4'"></td>
							<td><input style="height:40px; text-align: center;" type="button" value ="5" onclick ="cal.display.value+='5'"></td>
							<td><input style="height:40px; text-align: center;"  type="button" value ="6" onclick ="cal.display.value+='6'"></td>
							<td><input style="width:75px;height:40px; text-align: center;"  type="button" value ="Rp.50.000" onclick ="cal.display.value='50000'" id="tiga"></td>
							<td><input type="button" value ="GOPAY" class="btn btn-success pull-right" style="width:75px;height:40px; text-align: center;" id="btnHitung1"></td>
							
						
							<br>
							<td><input style="height:40px; text-align: center;" type="button" value ="1" onclick ="cal.display.value+='1'"></td>
							<td><input style="height:40px; text-align: center;" type="button" value ="2" onclick ="cal.display.value+='2'"></td>
							<td><input style="height:40px; text-align: center;" type="button" value ="3" onclick ="cal.display.value+='3'"></td>
							<td><input style="width:75px;height:40px; text-align: center;" type="button" value ="Rp.100.000" onclick ="cal.display.value='100000'" id="empat"></td>
							<td><input type="button" value ="OVO" class="btn btn-success pull-right" style="width:75px;height:40px; text-align: center;" id="btnHitung2"></td>
							
							<br>
							<td><input style="height:40px; text-align: center;" type="button" value ="0" onclick ="cal.display.value+='0'"></td>
							<td><input style="height:40px; text-align: center;" type="button" align='left' value ="00"  onclick ="cal.display.value+='00'"></td>
							<td><input style="height:40px; text-align: center;" type="button" align='left' value ="000" onclick ="cal.display.value+='000'" id='lima'></td>
							<td><input style="width:75px;height:40px; text-align: center;" type="button" value ="DELETE" onclick ="cal.display.value=''" id="del"></td>
							<td><input type="button" value ="SHOPEE" class="btn btn-success pull-right" style="width:75px;height:40px; text-align: center;" id="btnHitung3"></td>
							<br>
						</tr>
						
						
						<?php }
						}?>
						</form>	
						<td>
									<?php if($faktur->nbayar >= ($faktur->netto)-1) { ?>
									<form target="printstruk" id="formCetakStruk" class="form-inline" action="<?php echo base_url('kasir/cetak-struk/') ?>" onsubmit="window.location('about:blank','printstruk','width=500,height=400');" method="post">
										<input type="hidden" name="sum_print" id="sum_print" value="<?php echo $faktur->netto ?>">
										<input type="hidden" name="diskon_print" id="diskon_print" value="<?php echo $faktur->diskon ?>">
										<input type="hidden" name="nofak_print" id="nofak_print" value="<?php echo $faktur->no_faktur_penjualan ?>">
										<input type="hidden" name="cash_print" id="cash_print" value="<?php echo $faktur->nbayar ?>">
										<input type="hidden" name="kdharga" id="kdharga" value="<?php echo $faktur->kdharga ?>">
										<input type="hidden" name="noorder" id="noorder" value="<?php echo $faktur->noorder ?>">
										<input type="hidden" name="debet_print" id="debet_print" value="0">
										<input type="hidden" name="bank_print" id="bank_print">
										<button onclick="newTransaksi();" type="submit" id="btnCetakStruk" style="width:75px;height:40px; text-align: center;" class="btn btn-danger pull-right">PRINT</button>
									</form>
										<?php } else {?>
											<button type="button" class="btn btn-primary pull-right" data-id="<?php echo $faktur->no_faktur_penjualan ?>" data-toggle="modal" style="width:75px;height:40px; text-align: center;" data-target=".modalKecil">EDIT</button>
										<?php }?>
							</td>			
				</div>
				
				
                </div>
            </div>
          </div>

		
        <div class="col-md-7">
          <div class="panel panel-default">
            <div class="panel-heading">
                Faktur : <?php echo $faktur->no_faktur_penjualan . ' / ' . $faktur->keter?>
                <?php if($faktur->idpromo !=null) {?> 
					<td align="left" style="font-size: 12pt" >Kode Promosi-> <?php echo $faktur->idpromo ?></td>
				<?php }?>
                <span class="pull-right"><?php echo date_indo($tgl) ?> <span id="waktu"></span></span>
            </div>
            <div class="panel-body">
            <table id="tbUser" class="table table-bordered table-responsive">
              <thead>
                <tr>
                  <td>Kode</td>
                  <td>Nama Barang</td>
                  <td align="right">Harga</td>
                  <td align="center">Jumlah</td>
                  <td align="center">Diskon %</td>
                  <td align="right">PPn</td>
                  <td align="right">Subtotal</td>
                </tr>
              </thead>
              <tbody>
                <?php foreach ($list->result() as $key): ?>
                <tr>
                  <td><?php echo $key->kd_barang ?></td>
                  <td><?php echo substr($key->nm_barang, 0, 40) ?></td>
                  <td align="right"><?php echo number_format($key->harga, 0, ',', '.') ?></td>
                  <td align="center"><?php echo $key->jumlah ?></td>
                  <td align="center"><?php echo $key->diskonpersen ?> %</td>
                  <td align="center"><?php echo $key->nppn ?></td>
                  <td align="right"><?php echo number_format(($key->sub_total_jual+$key->nppn), 0, ',', '.') ?></td>
                </tr>
<?php
$tot_item += $key->jumlah;
$tot_ppn += $key->nppn;
$tot_belanja += ($key->sub_total_jual+$key->nppn);
?>
                <?php endforeach?>
              </tbody>
              <tr>
                <td colspan="3" align="right"><strong>Total</strong></td>
                <td align="center"><strong><?php echo $tot_item ?> Items</strong></td>
                <td colspan='2' align="right"><strong>Rp. <?php echo number_format($tot_ppn, 0, ',', '.') ?></strong></td>
                <td align="right"><strong>Rp. <?php echo number_format($tot_belanja, 0, ',', '.') ?></strong></td>
              </tr>
            </table>
            </div>
          </div>
        </div>
    </div>
  </div>
 </div> 
 
<div class="modal fade modalKecil" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-sm">
 
    <div class="modal-content">
      <div class="modal-header" align='center'>
        <h4><font color='red'><b>INPUT VALIDASI TOKEN</b></font></h4>
		<?php 
			$tgl=date('j');
			$jam=date('G');
			$detik=date('s');
			if ($detik==0)  $token=((($tgl*$jam*1)*1305));
			if ($detik>0) $token=((($tgl*$jam*$detik)*1305));
		?>
		
      </div>
        <div class="modal-body" align='center' >
          <form  class="form-horizontal" action="<?php echo base_url('kasir/kode_harga_token/')?>" method="post">
            <div class="form-group">
                <tr>
                    <td><label  class="control-label " for="id_fak">Kode Token</label></td>
                    <td><input style="width:80%;height:45px;" type="text" class="form-control" id="token" name="token"  value='<?php echo $token ?>' readonly></td>
                </tr>
                <tr>
                    <td><label class="control-label " for="idtoken">Password</label></td>
                    <td><input style="width:80%;height:45px;"  type="number" class="form-control" id="idtoken" name="idtoken" required ></td>
                </tr>
                <tr>
                    <td><label class="control-label " for="note">Catatan</label></td>
                    <td><input style="width:80%;height:45px;" type="text" class="form-control" id="note" name="note" required ></td>
                </tr>    
                <tr><td></td></tr>
        </div>
        <div class="modal-footer">
		 <input type="hidden" name="nobuk" id="nobuk" value="<?php echo $faktur->no_faktur_penjualan ?>">
          <button type="button" class="btn btn-default;text-align:'left';" data-dismiss="modal">Close</button>
          <button type="submit" id="btnSimpan" class="btn btn-primary ;text-align:'right';">Simpan</button>
        </div>
        </form>
    </div>
 
  </div>
</div> 
    <!-- FOOTER SECTION END-->
    <!-- JAVASCRIPT FILES PLACED AT THE BOTTOM TO REDUCE THE LOADING TIME  -->
<style>

*{
box-sizing:border-box;
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
}
.wrap{
width:200px;
margin:auto;
height:auto;
background: linear-gradient(50deg, #B000EA,black);
padding:5px;
border-radius: 2px;
box-shadow: 1px 5px 5px black
}
input[type=text]{
width:80%;
padding:10px;
font-size:20px;
font-height:bold;
margin-top:20px;
border-radius:1px;
}
input[type=button]{
width:40px;
padding:10px;
font-size:15px;
font-height:bold;
border-radius:1px;
align : right;
}
#del{
width:30%;
}
#dua{
width:30%;
font-size:12px;
font-height:bold;
border-radius:1px;
}
#tiga{
width:30%;
font-size:12px;
font-height:bold;
border-radius:1px;
}
#empat{
width:30%;
font-size:12px;
font-height:bold;
border-radius:1px;
align : left;
}
#lima{
font-size:13px;
}
</style>	
    <script src="<?php echo base_url() ?>/assets/js/jquery-3.3.1.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/jquery.dataTables.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/bootstrap.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/custom.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/sweetalert.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/toastr.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/jquery-ui.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/jquery.price_format.min.js"></script>
	
	
    <script>
      $('form').attr('autocomplete', 'off');
      $('input').attr('autocomplete', 'off');
      $("ul.nav li.dropdown").hover(function(){$(this).find(".dropdown-menu").stop(!0,!0).delay(100).fadeIn(500)},function(){$(this).find(".dropdown-menu").stop(!0,!0).delay(100).fadeOut(500)});
      var pesan="<?php echo $this->session->flashdata('msg'); ?>",error="<?php echo $this->session->flashdata('error'); ?>";pesan?(toastr.options={positionClass:"toast-top-right"},toastr.success(pesan)):error&&swal(error,"","error");

      function startTime() {
        var today = new Date();
        var h = today.getHours();
        var m = today.getMinutes();
        var s = today.getSeconds();
        m = checkTime(m);
        s = checkTime(s);
        document.getElementById('waktu').innerHTML = h + ":" + m + ":" + s;
        var t = setTimeout(startTime, 500);
      }

      function checkTime(i) {
          if (i < 10) {i = "0" + i};
          return i;
      }

    $(document).ready(function() {
        startTime();
        $('#display').focus();
        $('#btnHitung').on('click',function(e){
            e.preventDefault();
            var belanja = $('#sum_belanja').val();
			var jnsbayar = '1';;
			var nofak = $('#nofak_dis').val();;
			
            var cash = $('#display').val();
            var cash1 = cash.replace(/[^\d]/g,"");
            var kembali = (Number(cash1))-Number(belanja);           
				if (jnsbayar='1') {
					if (kembali+1>=0) {
						$("#kembali").html(convertToRupiah(kembali));
						window.location.href = "<?php echo base_url('kasir/transaksi-bayar/') ?>"+nofak+"/"+jnsbayar+"/"+cash1+"/"+kembali;
					}
					if ((kembali+1)<0) {
						alert("Uang tidak  cukup"  );
						} 
				}	
        });
		 $('#btnHitung1').on('click',function(e){
            e.preventDefault();
            var belanja = $('#sum_belanja').val();
			var jnsbayar = '3';
			var nofak = $('#nofak_dis').val();;
			
            var cash = $('#display').val();
            var cash1 = Number(belanja);  
            var kembali = (Number(cash1))-Number(belanja);           
				if (kembali>=0) {
					$("#kembali").html(convertToRupiah(kembali));
					window.location.href = "<?php echo base_url('kasir/transaksi-bayar/') ?>"+nofak+"/"+jnsbayar+"/"+cash1+"/"+kembali;
					}
        });
		 $('#btnHitung2').on('click',function(e){
            e.preventDefault();
            var belanja = $('#sum_belanja').val();
			var jnsbayar = '4';
			var nofak = $('#nofak_dis').val();;
			
            var cash = $('#display').val();
            var cash1 = Number(belanja);  
            var kembali = (Number(cash1))-Number(belanja);           
				if (kembali>=0) {
					$("#kembali").html(convertToRupiah(kembali));
					window.location.href = "<?php echo base_url('kasir/transaksi-bayar/') ?>"+nofak+"/"+jnsbayar+"/"+cash1+"/"+kembali;
					}
				
        });
		 $('#btnHitung3').on('click',function(e){
            e.preventDefault();
            var belanja = $('#sum_belanja').val();
			var jnsbayar = '5';
			var nofak = $('#nofak_dis').val();;
			
            var cash = $('#display').val();
            var cash1 = Number(belanja);  
            var kembali = (Number(cash1))-Number(belanja);           
				if (kembali>=0) {
					$("#kembali").html(convertToRupiah(kembali));
					window.location.href = "<?php echo base_url('kasir/transaksi-bayar/') ?>"+nofak+"/"+jnsbayar+"/"+cash1+"/"+kembali;
					}
				
        });
       $('#btnCetakStruk').on('click',function(e){
            var belanja = $('#sum_belanja').val();
            var cash = $('#cash_print').val();
            var debet = $('#debet_print').val();
            var kembali = (Number(cash)+Number(debet))-Number(belanja);
           
              $('#formCetakStruk').submit(function() {
                    window.open('about:blank','printstruk','width=500,height=400');
                    this.target = 'printstruk';
                    window.location.href = "<?php echo base_url('kasir/transaksi-selesai/') ?>";
                    
              });
        });

        function newTransaksi(){
          window.location.href = "<?php echo base_url('kasir/transaksi-selesai/') ?>";
        }

        $(function(){
          $('#cash_print').on("keyup",function(){
              var cash = $('#cash_print').val();
              var cash1 = cash.replace(/[^\d]/g,"");
              $('#cash_print').val(cash1);
          })
        });
        $(function(){
          $('#debet').on("keyup",function(){
              var debet = $('#debet').val();
              var debet1 = debet.replace(/[^\d]/g,"");
              $('#debet_print').val(debet1);
          })
        });
        $(function(){
          $('#bank').on("keyup",function(){
              var bank = $('#bank').val();
              $('#bank_print').val(bank);
          })
        });
      });

      function isNumber(evt) {
          evt = (evt) ? evt : window.event;
          var charCode = (evt.which) ? evt.which : evt.keyCode;
          if (charCode > 31 && (charCode < 48 || charCode > 57)) {
              return false;
          }
        return true;
      }

      $(function(){
          $('#display').priceFormat({
                  prefix: '',
                  centsLimit: 0,
                  thousandsSeparator: '.'
          });
          $('#debet').priceFormat({
                  prefix: '',
                  centsLimit: 0,
                  thousandsSeparator: '.'
          });
    });

    function convertToRupiah(angka){
          var rupiah = '';
          var angkarev = angka.toString().split('').reverse().join('');
          for(var i = 0; i < angkarev.length; i++) if(i%3 == 0) rupiah += angkarev.substr(i,3)+'.';
          return rupiah.split('',rupiah.length-1).reverse().join('');
    };
    </script>

</body>
</html>