fixed invetory

This commit is contained in:
NyanLinHtut
2019-09-25 11:54:54 +06:30
parent e558746e26
commit 9d330bb28c
13 changed files with 402 additions and 146 deletions

View File

@@ -62,7 +62,7 @@
</div>
<div class="item-modal modal sx_item_detailModal" id="sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<!-- <div class="item-modal modal sx_item_detailModal" id="sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog custom-modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" style="background-color: #54A5AF;padding-top:10px !important;">
@@ -74,7 +74,7 @@
<div class="form-group">
<label class="control-label" for="attribute">Item</label>
<input type='text' id='item' class='form-control' readonly="true" value=''/>
<input type='text' id='item' class='form-control' readonly="true" value=''/>
</div>
<div class="form-group">
<label class="control-label" for="attribute">Qty</label>
@@ -92,14 +92,88 @@
<div class="form-actions">
<button type="button" class="btn btn-primary" data-dismiss="modal" id="save_to_stock_check">Save</button>
<!-- <button type="button" class="btn btn-primary add_to_order " data-dismiss="modal" id="add_to_order">Add to Order<div class="ripple-container"></div></button> -->
<button type="button" class="btn btn-primary add_to_order " data-dismiss="modal" id="add_to_order">Add to Order<div class="ripple-container"></div></button>
</div>
</div>
</div>
</div>
</div>
</div>
</div> -->
<div class=" modal sx_item_detailModal" id="sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="sx_itemModalLabel" aria-hidden="true" style="">
<div class="modal-dialog custom-modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<table width="100%" class="table table-striped">
<thead>
<tr>
<th style="">Item Name</th>
<th style="">Quantity</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<!-- <td type='text' id='item' class='form-control' readonly="true" value=''></td> -->
<td class="item_name" id="item"></td>
<!-- <td> -->
<div class="form-group">
<!-- <label class="control-label" for="attribute">Item</label> -->
<!-- <input type='text' id='item' class='form-control' readonly="true" value=''/> -->
</div>
<!-- </td> -->
<td>
<input type="number" name="qty" class="form-control col-md-12 input-number keypress_qty" placeholder="Qty" data-value="0" id="product_qty" value="" min="1" max="10000">
<!-- <input type='text' class='form-control keypress_qty' placeholder="Qty" id='product_qty' value="1" /> -->
<input type="hidden" id="instance_code" value="">
<input type="hidden" id="item_code" value="">
<input type="hidden" id="item_name" value="">
<input type="hidden" id="instance_name" value="">
</td>
<td>
<button type="button" id="remove" class="btn btn-danger" data-dismiss="modal">Remove</button>
</td>
</tr>
</tbody>
</table>
<div class="row bottom p-l-15 p-r-15 m-t-10">
<div class="col-md-3 qty_number border-top border-left" data-value="1" data-type="num">1</div>
<div class="col-md-3 qty_number border-top border-left" data-value="2" data-type="num">2</div>
<div class="col-md-3 qty_number border-top border-left" data-value="3" data-type="num">3</div>
<div class="col-md-3 qty_number border-top border-left" data-value="4" data-type="num">4</div>
</div>
<div class="row bottom p-l-15 p-r-15">
<div class="col-md-3 qty_number border-top border-left" data-value="5" data-type="num">5</div>
<div class="col-md-3 qty_number border-top border-left" data-value="6" data-type="num">6</div>
<div class="col-md-3 qty_number border-top border-left" data-value="7" data-type="num">7</div>
<div class="col-md-3 qty_number border-top border-left" data-value="8" data-type="num">8</div>
</div>
<div class="row bottom p-l-15 p-r-15">
<div class="col-md-3 qty_number border-top border-left" data-value="9" data-type="num">9</div>
<div class="col-md-3 qty_number border-top border-left" data-value="0" data-type="num">0</div>
<div class="col-md-3 qty_number border-top border-left" data-value="00" data-type="num">00</div>
<div class="col-md-3 qty_number border-top border-left bg-orange" data-type="clr">Clr</div>
</div>
</div>
<div class="modal-footer">
<div class="row">
<div class="col-md-5">
<button type="button" class="btn btn-default" data-dismiss="modal" id="close">Close</button>
</div>
<div class="col-md-5">
<!-- <button type="button" class="btn btn-primary " data-dismiss="modal" id="save">Update</button> -->
<button type="button" class="btn btn-primary" data-dismiss="modal" id="save_to_stock_check">Save</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class=" modal" id="sx_itemModal" tabindex="-1" role="dialog" aria-labelledby="sx_itemModalLabel" aria-hidden="true" style="">
@@ -155,8 +229,6 @@
<button type="button" class="btn btn-primary " data-dismiss="modal" id="save">Update</button>
</div>
</div>
</div>
</div>
</div>
@@ -250,8 +322,7 @@
+'</div>';
$('.menu_items_list').append(row);
}
}
}
//click item row for add order
$(document).on('click', '.card-box', function(event){
@@ -260,35 +331,64 @@
$("#stock_check_reason").val('');
$('#item_code').val($(this).attr('item_code'));
$('#instance_code').val($(this).attr('instance_code'));
$('#item').val($(this).attr('item_name')+"-"+$(this).attr('instance_name'));
// $('#item').val($(this).attr('item_name')+"-"+$(this).attr('instance_name'));
$('#item').text($(this).attr('item_name'));
$('#instance_name').val($(this).attr('instance_name'));
$('#item_name').val($(this).attr('item_name'));
});
$('#save_to_stock_check').on('click', function () {
$('#save_to_stock_check').on('click', function() {
if ($("#product_qty").val()>0) {
item_name = $('#item_name').val();
instance_name = $('#instance_name').val();
product_qty = $('#product_qty').val();
qty = $('#product_qty').val();
product_name = $("#item").val();
item_code = $("#item_code").val();
instance_code = $("#instance_code").val();
append = 0;
itemCode = $("#item_code").val();
instanceCode = $("#instance_code").val();
reason = $("#stock_check_reason").val();
var rowCount = $('.summary-items tbody tr').length+1;
var item_row = $('.summary-items tbody tr');
row ="<tr class='item_box' data-toggle='modal' data-target='#sx_itemModal' 'data-code ='"
+item_code+ "' data-instance-code='"+instance_code+"' data-row ='"+rowCount+ "' data-reason ='"+reason+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + instance_name +'</td>'
+'<td class="item-cell-qty" id="item_qty">' + product_qty + '</td>'
+'<td class="" id="remove"><i class="material-icons" id="remove_row" style="cursor:pointer;">delete_forever</i></td>'
+'</tr>';
$(".summary-items tbody").append(row);
$(item_row).each(function(i){
item_code = $(item_row[i]).attr('data-code');
instance_code = $(item_row[i]).attr('data-instance-code');
r_option = $(item_row[i]).attr('data-opt');
if (item_code == itemCode && instance_code == instanceCode) {
if (qty > 1) {
qty = parseInt($(item_row[i]).children('#item_qty').text()) + parseInt(qty);
test_qty = parseInt($(item_row[i]).children('#item_qty').text());
}else{
qty = parseInt($(item_row[i]).children('#item_qty').text()) + 1;
}
$(item_row[i]).children('#item_qty').text(qty);
// parseFloat($(item_row[i]).children('#item_price').text(parseFloat(price*qty).toFixed(2)));
append =1;
}else{
if (qty > 1) {
qty = qty;
}else{
qty = 1;
}
}
});
if (append===0) {
row ="<tr class='item_box' data-toggle='modal' data-target='#sx_itemModal' data-code ='"
+itemCode+ "' data-instance-code='"+instanceCode+"' data-row ='"+rowCount+ "' data-reason ='"+reason+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + instance_name +'</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="" id="remove"><i class="material-icons" id="remove_row" style="cursor:pointer;">delete_forever</i></td>'
+'</tr>';
$(".summary-items tbody").append(row);
}
}else{
swal("Opps", "Please enter number for qty ","warning");
}
@@ -424,6 +524,42 @@
}
});
$(document).on('click', '.qty_number', function(event){
if(event.handled !== true) {
var original_value;
original_value = $('#product_qty').attr('data-value');
original_qty = $('#product_qty').val();
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0"){
$('#product_qty').val(input_value);
$('#product_qty').attr('data-value',input_value);
// update_total_amount();
}else{
$('#product_qty').val(original_qty + input_value);
$('#product_qty').attr('data-value',original_qty + input_value);
// update_total_amount();
}
break;
case 'add':
case 'del' :
case 'clr':
$('#product_qty').val(1);
$('#product_qty').attr('data-value',0);
// update_total_amount();
break;
}
event.handled = true;
} else {
return false;
}
});
$("#back").on("click", function(){
window.location.href = "/inventory";
});