<?php 
//------------------------------------------------------------------------------
//<INFO >
//     This file was generated by MyPhpGuard 1.3.54.5
//     
//     Date:07/01/2018 7:53:55 AM
//
// </INFO >
//------------------------------------------------------------------------------
 /**
 * 
 * @category    
 * @package    
 * @author      djavasoft <support@djavasoft.com>
 * @copyright   2018 djavasoft
 * @license     
 * @version    
 * @link   http://djavasoft.com
 *      
 */
?>
<script>
var ajaxBarang="data.php?kasirBarang=daftar_barang";
shortcut.add("f1",function() {
$('#doBarang').modal('show');
});
shortcut.add("f2",function() {
$('#qty').focus();
});
shortcut.add("f3",function() {
$('#num2').focus();
});
shortcut.add("end",function() {
$('#doBayarKasir').modal('show');
});
$(document).ready(function() {
$('#kodeBarang').focus();
var tableBarang = $('#tableBarang').DataTable( {
"language": {
"emptyTable": "No data available in table"
},
scrollY: '50vh',
"scrollX": true,
select: true,
keys: true,
"pageLength": 10,
"lengthMenu": [ 5,10, 25, 50 ],
"paginate":true,
"bLengthChange": false,
"info":false,
"length":false,
"ajax": ajaxBarang ,
"order": [[ 0, "desc" ]],
"columnDefs": [ {
"targets": -1,
"data": null,
"defaultContent": "<a href='#' class='btn btn-warning btn-sm' id='addBarang'><i class='fa fa-check-square-o'></i> pilih</a>"
},
{
"targets": [ 0 ],
"visible": false,
"searchable": false
}
]
} );
tableBarang
.on('key-focus', function (e, datatable, cell) {
datatable.rows().deselect();
datatable.row( cell.index().row ).select();
});
$('#tableBarang tbody').on( 'click', '#addBarang', function () {
var data = tableBarang.row( $(this).parents('tr') ).data();
var prt="'#printBarcode'";
var barcodes='<div id="printBarcode"><div style="height:100px;width:220px;margin:5px;border:1px solid #ccc;padding:5px"><center>'+data[2]+'<br><img  src="page.php?page=barcode&codetype=Code39&size=28&print=true&text='+data[ 1 ]+'"></div></div><br><a class="btn btn-primary" onclick="jQuery('+prt+').print()" href="#" id="printPenjualan"><i class="fa fa-print" aria-hidden="true"></i> Cetak Barcode</a>';
$('#idBarang').val(data[ 0 ]);
$('#kodeBarang').val(data[ 1 ]);
$('#namaBarang').val(data[ 2 ]);
$('#hargaJual').val(data[ 3 ]);
$('#stokBarang').val(data[ 4 ]);
$('#doBarang').modal('hide');
$('#loadBarcode').html(barcodes);
$('#qty').focus();
$('#qty').select();
} );
$( "#showBarang" ).click(function () {
$('#doBarang').modal('show');
tableBarang.ajax.url( ajaxBarang ).load();
} );
$( "#showBarcodes" ).click(function () {
var prt="'#printBarcode'";
var qty = $('#qty').val();
var kodeBarang = $('#kodeBarang').val();
var namaBarang = $('#namaBarang').val();
var text = '<a class="btn btn-primary" onclick="jQuery('+prt+').print()" href="#" ><i class="fa fa-print" aria-hidden="true"></i> Cetak Barcode ( '+qty+'  )</a><hr><div id="printBarcode">';
var i;
for (i = 0; i < qty; i++) {
text += '<div style="height:100px;width:220px;margin:5px;border:1px solid #ccc;padding:5px;float:left"><center><span style="font-size:11px">'+namaBarang+'</span><br><img  src="page.php?page=barcode&codetype=Code39&size=28&print=true&text='+kodeBarang+'"></div>';
}
text+='</div>';
document.getElementById("getBarcode").innerHTML = text;
} );
});
</script>
