<?php include("common/header.php");?>
<body>
<div class="container-scroller">
<!-- partial:partials/_navbar.html -->
<?php include("common/header2.php"); ?>
<!-- partial -->
<div class="container-fluid page-body-wrapper">
<!-- partial:partials/_sidebar.html -->
<?php include("common/menu.php"); ?>
<!-- partial -->
<div class="main-panel">
<div class="content-wrapper">
<?php include("pages/include.php");?>
</div>
<!-- content-wrapper ends -->
<!-- partial:partials/_footer.html -->
<?php include("common/footer.php"); ?>
<!-- partial -->
</div>
<!-- main-panel ends -->
</div>
<!-- page-body-wrapper ends -->
</div>
<!-- container-scroller -->
<!-- plugins:js -->
<script src="vendors/js/vendor.bundle.base.js"></script>
<script src="vendors/js/vendor.bundle.addons.js"></script>
<!-- endinject -->
<!-- Plugin js for this page-->
<!-- End plugin js for this page-->
<!-- inject:js -->
<script src="js/off-canvas.js"></script>
<script src="js/misc.js"></script>
<!-- endinject -->
<!-- Custom js for this page-->
<script src="js/dashboard.js"></script>
<script src="js/blockui.min.js"></script>
<script src="../js/function.js"></script>
<!-- End custom js for this page-->
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$('#example').DataTable();
});
$( "#datepicker").datepicker({ dateFormat: "dd-mm-yy"});
$( "#datepicker1").datepicker({ dateFormat: "dd-mm-yy"});
$( "#datepicker2").datepicker({ dateFormat: "dd-mm-yy"});
</script>
<script>
function deleteConfirm()
{
if (confirm("Are you Sure. Do you want to delete?"))
{
return true;
} else {
return false;
}
}
</script>
<script>
var productCount=100;
$(".addProduct").click(function(event){
$("#prductBox").append('<div class="row"><div class="col-md-3"><div class="form-group"><label for="exampleInputPassword4" style="display:block">Product SKU <span id="stock_'+productCount
+'" style="color:red; float:right;"></span></label><input type="hidden" value="" id="stockqty_'+productCount+'"/><input type="text" class="form-control product_barcode" list="productList'+productCount+'" name="barcode[]" id="barcode_'+productCount+'" placeholder="Barcode" onkeyup="getProductPrice(this.value,'+productCount+');" onblur="getProductPrice(this.value,'+productCount+');" autocomplete="off" required><datalist id="productList'+productCount+'"><?php $sqlProduct = mysqli_query($cn,"select `barcode` from `tbl_product` where `status`=1 order by barcode");while($sqlProductData = mysqli_fetch_array($sqlProduct)){?><option value="<?php echo $sqlProductData['barcode'];?>"><?php }?></datalist><span id="barcodeError_'+productCount+'" style="color:red;font-size:11px;"></span></div></div><div class="col-md-2"><div class="form-group"><label for="exampleInputCity1">Price</label><input type="text" class="form-control" name="price[]" id="price_'+productCount+'" placeholder="Price" onkeyup="getTotal('+productCount+');" required></div></div><div class="col-md-2"><div class="form-group"><label for="exampleInputCity1">Qty</label><input type="text" class="form-control" name="qty[]" id="qty_'+productCount+'" placeholder="Qty" onkeyup="getTotal('+productCount+');" required><span id="qtyError_'+productCount+'" style="color:red;font-size:11px;"></span></div></div><div class="col-md-2"><div class="form-group"><label for="exampleInputCity1">Total</label><input type="text" class="form-control" name="total[]" id="total_'+productCount+'" placeholder="Total" readonly required></div></div><div class="col-md-1" id="img_'+productCount+'"></div><div class="col-md-2"><div class="form-group"><a href="javascript:void(0);" class="deleteproduct"><img src="images/delets.png" style="height:30px;margin-top:25px;"/></a></div></div>');
productCount++;
});
$(".addItem").click(function(event){
$("#itemBox").append('<div class="row"><div class="col-md-3"><div class="form-group"><label for="exampleInputPassword4" style="display:block">Item Title</label><input type="text" class="form-control" name="item[]" id="item_'+productCount+'" placeholder="Item Title" autocomplete="off" required></div></div><div class="col-md-2"><div class="form-group"><label for="exampleInputCity1">Item Price</label><input type="text" class="form-control" name="item_price[]" id="item_price_'+productCount+'" placeholder="Item Price" onkeyup="getitemTotal('+productCount+');" required></div></div><div class="col-md-2"><div class="form-group"><label for="exampleInputCity1">Item Qty</label><input type="text" class="form-control" name="item_qty[]" id="item_qty_'+productCount+'" placeholder="Item Qty" onkeyup="getitemTotal('+productCount+');" required></div></div><div class="col-md-1"><div class="form-group"><label for="exampleInputCity1">Info.</label><input type="text" class="form-control" name="item_info[]" placeholder="Info"></div></div><div class="col-md-2"><div class="form-group"><label for="exampleInputCity1">Item Total</label><input type="text" class="form-control" name="item_total[]" id="item_total_'+productCount+'" placeholder="Item Total" readonly required></div></div><div class="col-md-1"><div class="form-group"><a href="javascript:void(0);" class="deleteItem"><img src="images/delets.png" style="height:30px;margin-top:25px;"/></a></div></div>');
productCount++;
});
$("#prductBox").on("click",".deleteproduct", function(e){ //user click on remove text
$(this).closest('.row').remove();
});
$("#itemBox").on("click",".deleteItem", function(e){ //user click on remove text
$(this).closest('.row').remove();
});
var status = 0;
function getProductPrice(barcode,response_id)
{
var loop = 0;
$(".product_barcode").each(function () {
var currentBarcode = $(this).val();
if(barcode==currentBarcode)
{
loop++;
}
});
if(loop>1)
{
status = 1;
$("#barcodeError_"+response_id).text("This SKU Already used");
$(".saveBtn").attr("disabled","disabled");
$(".addProduct").hide();
}
else
{
status = 0;
$("#barcodeError_"+response_id).text("");
$(".saveBtn").removeAttr("disabled");
$(".addProduct").show();
$.ajax({
url: "ajax/getProductPrice.php?barcode="+barcode,
type: 'GET',
dataType: 'html',
success: function (data) {
var data = $.parseJSON(data);
if(data.status==1)
{
$("#price_"+response_id).val(data.distributorPrice);
$("#img_"+response_id).html('<img src="pages/master/product/image/'+data.img+'" style="width:82px;"/>');
stockQty = parseInt(data.stockQty);
if(stockQty>0)
{
$("#stockqty_"+response_id).val(data.stockQty);
$("#stock_"+response_id).text('In Stock ( '+data.stockQty+' )');
$("#stock_"+response_id).css('color','green');
$(".saveBtn").removeAttr("disabled");
}
else
{
$("#stockqty_"+response_id).val(data.stockQty);
$("#stock_"+response_id).text('In Stock ( '+data.stockQty+' )');
$("#stock_"+response_id).css('color','red');
$(".saveBtn").attr("disabled","disabled");
}
$("#barcodeError_"+response_id).text("");
//$(".saveBtn").removeAttr("disabled");
$(".addProduct").show();
}
else if(data.status==2)
{
$("#price_"+response_id).val('');
$("#img_"+response_id).html('');
$("#stock_"+response_id).text('');
$("#barcodeError_"+response_id).text(data.Msg);
$(".saveBtn").attr("disabled","disabled");
$(".addProduct").hide();
}
}
});
}
}
function getState(state_id)
{
$.ajax({
url: "ajax/getState.php?state_id="+state_id,
type: 'GET',
dataType: 'html',
success: function (data) {
$("#city_id").html(data);
}
});
}
function checkCode(uniquecode,barcode,response_id)
{
$.ajax({
url: "ajax/checkCode.php?uniquecode="+uniquecode+"&barcode="+barcode,
type: 'GET',
dataType: 'html',
success: function (data) {
var data = $.parseJSON(data);
if(data.status==1)
{
$("#error_"+response_id).html('');
$("#check_"+response_id).val(1);
$(".saveOrder").removeAttr("disabled");
$('input[name="checkStatus[]"]').each(function() {
var check = $(this).val();
if(check==0)
{
$(".saveOrder").attr("disabled","disabled");
}
});
}
else if(data.status==2)
{
$("#error_"+response_id).html('<span class="tooltiptext">'+data.Msg+'</span><i class="mdi mdi-backup-restore" style="color:red;font-size:15px;"></i>');
$("#check_"+response_id).val(0);
$(".saveOrder").removeAttr("disabled");
$('input[name="checkStatus[]"]').each(function() {
var check = $(this).val();
if(check==0)
{
$(".saveOrder").attr("disabled","disabled");
}
});
}
else if(data.status==3)
{
$("#error_"+response_id).html('<span class="tooltiptext">'+data.Msg+'</span><i class="mdi mdi-backup-restore" style="color:red;font-size:15px;"></i>');
$("#check_"+response_id).val(0);
$('input[name="checkStatus[]"]').each(function() {
var check = $(this).val();
if(check==0)
{
$(".saveOrder").attr("disabled","disabled");
}
});
}
}
});
}
function getTotal(response_id)
{
var price = parseInt($("#price_"+response_id).val());
var qty = parseInt($("#qty_"+response_id).val());
var stockqty = parseInt($("#stockqty_"+response_id).val());
var total = price * qty;
$("#total_"+response_id).val(total);
//alert("stock : "+stockqty+" Sale Qty : "+qty)
if(qty>stockqty)
{
$("#qtyError_"+response_id).text("Allow Max. Qty - "+stockqty);
$(".saveBtn").attr("disabled","disabled");
$(".addProduct").hide();
}
else
{
if(status==0)
{
$("#qtyError_"+response_id).text("");
$(".saveBtn").removeAttr("disabled");
$(".addProduct").show();
}
}
}
function getitemTotal(response_id)
{
var price = parseInt($("#item_price_"+response_id).val());
var qty = parseInt($("#item_qty_"+response_id).val());
var total = price * qty;
$("#item_total_"+response_id).val(total);
}
function setDiscount(dicountType)
{
if(dicountType=='F')
{
$("#discountTitle").html("Discount Amount");
$("#discountAmount").attr("required","required");
$("#discountBox").show();
}
else if(dicountType=='P')
{
$("#discountTitle").html("Discount Percent");
$("#discountAmount").attr("required","required");
$("#discountBox").show();
}
else
{
$("#discountAmount").removeAttr("required");
$("#discountBox").hide();
}
}
</script>
</body>
</html>