qty edit in oqs

This commit is contained in:
Yan
2017-06-25 22:41:26 +06:30
parent 30df25d78a
commit a91816bb4e
7 changed files with 79 additions and 41 deletions

View File

@@ -68,7 +68,9 @@ $(document).ready(function(){
});
$(".order-item-edit").on('click', function(){
var _self = $(this); // To know in ajax return
var assigned_item_id=$(this).attr('id').substr(5);
window.location.href = '/oqs/'+ assigned_item_id + "/edit"
});
// complete for queue item
@@ -137,4 +139,21 @@ $(document).ready(function(){
success: function(data){ }
});
});
// Qty update for OQS Edit Controller
$('#qty-update').on('click', function(){
var qty_weight = $("input[name='qty_weight']").val();
var remarks = $("textarea[name='remarks']").val();
var order_items_id = $(this).attr('data-id');
var params = { 'order_items_id': order_items_id, 'qty_weight': qty_weight, 'remarks': remarks }
$.ajax({
type: 'POST',
url: '/oqs/' + order_items_id,
data: params,
success: function(result){
alert("Updated!");
window.location.href = '/oqs';
}
});
});
});

View File

@@ -0,0 +1,18 @@
class Oqs::EditController < BaseOqsController
def index
assigned_item_id = params[:id]
assigned_item = AssignedOrderItem.find(assigned_item_id)
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_code='#{ assigned_item.item_code }'");
end
def update
order_items_id = params[:order_items_id]
qty_weight = params[:qty_weight]
remarks = params[:remarks]
order_item = OrderItem.find(order_items_id);
order_item.qty = qty_weight
order_item.remark = remarks
order_item.save
end
end

View File

@@ -23,7 +23,6 @@
</div>
<% end %>
<%= yield %>
</div>
</body>
</html>

View File

@@ -0,0 +1,27 @@
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">Update Quantity</div>
<div class="card-body">
<div class="col-md-12">
<h3><%= @order_item[0].item_name + " - [" + @order_item[0].qty.to_s + "]" %></h3>
<div class="form-group">
<label class="col-md-1">Quantity: </label>
<input type="text" name="qty_weight" class="text-right" value="<%= @order_item[0].qty %>" />
</div>
<div class="form-group">
<label class="col-md-1">Remark: </label>
<textarea rows="2" cols="22" name="remarks"></textarea>
</div>
<div class="form-group">
<a href="<%= oqs_root_path %>" class="btn btn-primary">
<i class="fa fa-arrow-left"></i> Back
</a>
<button id="qty-update" class="btn btn-info" data-id="<%= @order_item[0].order_items_id %>">Update</button>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -29,7 +29,7 @@
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="min-height:670px; max-height:670px; overflow:auto">
<div class="tab-content" style="max-height:670px; overflow:auto">
<!--- Panel 0 - Completed -->
<div class="tab-pane active" id="completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
@@ -105,7 +105,7 @@
<p class="card-text">
<small class="text-muted">Order at
<span class="order-at">
<%= qid.created_at.strftime("%Y %m %d") %>
<%= qid.created_at.getlocal.strftime("%Y-%m-%d") %>
</span> -
<span class="order-by">
<%= qid.item_order_by %>
@@ -164,7 +164,7 @@
</tbody>
</table>
</div>
<div class="card-text" style="min-height:400px; max-height:400px; overflow:auto">
<div class="card-text" style="min-height:360px; max-height:360px; overflow:auto">
<table class="table" id="oqs-order-details-table">
<thead>
<tr>

View File

@@ -199,31 +199,26 @@ $(document).ready(function(){
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0.0"){
$('#discount-amount').val(input_value);
// update_balance();
$('#discount-amount').val(input_value);
}
else{
$('#discount-amount').val(original_value + '' + input_value);
// update_balance();
$('#discount-amount').val(original_value + '' + input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value);
$('#discount-amount').val(amount);
// update_balance();
$('#discount-amount').val(amount);
break;
case 'del' :
var discount_text=$('#discount-amount').val();
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
// update_balance();
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
break;
case 'clr':
$('#discount-amount').val("0.0");
// update_balance();
$('#discount-amount').val("0.0");
break;
}
event.handled = true;
@@ -332,13 +327,7 @@ $(document).ready(function(){
var sale_id = $('#sale-id').text();
var discount_items = JSON.stringify(get_discount_item_rows());
var overall_discount = $("#order-discount").text();
var sub_total = $('#order-sub-total').text();
// var sale_item_id = $('.selected-item').attr('id').substr(0,16);
// var sub_total = $('#order-sub-total').text();
// var grand_total = $('#order-grand-total').text();
// var discount_type = $('#discount-type').val();
// var discount_value = $('#discount-amount').val();
// var discount_amount = discount_value;
var sub_total = $('#order-sub-total').text();
var ajax_url = "/origami/" + sale_id + "/discount";
var params = { 'sale_id': sale_id, 'sub_total': sub_total, 'discount_items': discount_items, 'overall_discount': overall_discount };
@@ -354,30 +343,12 @@ $(document).ready(function(){
}
else {
window.location.href = "/origami/room/" + result.table_id
}
// window.history.back();
}
}
});
});
});
/* For Receipt - Update Balance */
function update_balance(){
var discount_amount = $('#discount-amount').val();
var sub_total = $('#order-sub-total').text();
var tax = $('#order-Tax').text();
// For Percentage Discount
// if(discount_type == 1){
// discount_amount=(sub_total*discount_amount)/100;
// }
var total = (parseFloat(sub_total) + parseFloat(tax)) - discount_amount;
$('#order-discount').text(discount_amount);
$('#order-grand-total').text(total);
}
/* Remove Selection */
function selection_remove(){
$(".item-row").removeClass("selected-item");

View File

@@ -143,6 +143,10 @@ Rails.application.routes.draw do
post 'update_delivery', to: "home#update_delivery_status"
# qty update
get "/:id/edit", to: "edit#index"
post "/:id", to: "edit#update"
# Pass assigned_order_item_id
get 'print/print/:id', to: "print#print"
get 'print/print_order_summary/:id', to: "print#print_order_summary"