diff --git a/app/controllers/origami/sales_controller.rb b/app/controllers/origami/sales_controller.rb
index 6f4980cc..56e6fbc8 100755
--- a/app/controllers/origami/sales_controller.rb
+++ b/app/controllers/origami/sales_controller.rb
@@ -37,7 +37,10 @@ class Origami::SalesController < BaseOrigamiController
# create sale item
saleobj = Sale.find(sale_id)
order.order_items.each do |orer_item|
- saleobj.add_item (orer_item)
+ saleobj.add_item (orer_item)
+ if !orer_item.set_menu_items.nil?
+ saleobj.add_sub_item(orer_item.set_menu_items)
+ end
end
# Re-compute for add
diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb
index 59351a85..93f7d236 100755
--- a/app/views/origami/home/show.html.erb
+++ b/app/views/origami/home/show.html.erb
@@ -383,6 +383,7 @@
<%
count = 0
@order_items.each do |order_item|
+ set_item_prices = 0
count += 1
%>
@@ -398,7 +399,9 @@
<% end %>
<% if !order_item.set_menu_items.nil?
- JSON.parse(order_item.set_menu_items).each do |item_instance| %>
+ JSON.parse(order_item.set_menu_items).each do |item_instance|
+ set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f
+ %>
<%= item_instance["item_instance_name"] %>
<% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %>
@@ -410,10 +413,11 @@
<% end %>
<% end
+ sub_total += set_item_prices
end %>
<%= order_item.qty %> |
- <%= order_item.qty*order_item.price %> |
+ <%= (order_item.qty*order_item.price).to_f + set_item_prices %> |
<%
end
diff --git a/app/views/origami/moveroom/move_dining.html.erb b/app/views/origami/moveroom/move_dining.html.erb
index 543e33d0..84ad9da9 100755
--- a/app/views/origami/moveroom/move_dining.html.erb
+++ b/app/views/origami/moveroom/move_dining.html.erb
@@ -203,15 +203,43 @@
unless @order_items.nil? || @order_items.empty?
count = 0
@order_items.each do |order_item |
+ set_item_prices = 0
count += 1
sub_total = sub_total + (order_item.price * order_item.qty)
#unless order_item.price <= 0 %>
- | <%= count %> |
- <%= order_item.item_name %> |
+ <%= count %> |
+
+ <%= order_item.item_name %>
+ <% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
+ <% JSON.parse(order_item.options).each do |option| %>
+
+ <%= option %>
+
+ <% end %>
+ <% end %>
+
+ <% if !order_item.set_menu_items.nil?
+ JSON.parse(order_item.set_menu_items).each do |item_instance|
+ set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f
+ %>
+
+ <%= item_instance["item_instance_name"] %>
+ <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %>
+ <% (item_instance["options"]).each do |set_item_option| %>
+
+ <%= set_item_option %>
+
+ <% end %>
+ <% end %>
+
+ <% end
+ sub_total += set_item_prices
+ end %>
+ |
<%= order_item.qty %> |
- <%= order_item.qty*order_item.price %> |
+ <%= (order_item.qty*order_item.price).to_f + set_item_prices %> |
<%
#end
@@ -231,12 +259,40 @@ if @status_sale == 'sale'
<%
@order_items.each do |order_item |
+ set_item_prices = 0
%>
- | <%= order_item.item_name %> |
- <%= order_item.qty %> |
- <%= order_item.qty*order_item.price %> |
+
+ <%= order_item.item_name %>
+ <% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
+ <% JSON.parse(order_item.options).each do |option| %>
+
+ <%= option %>
+
+ <% end %>
+ <% end %>
+
+ <% if !order_item.set_menu_items.nil?
+ JSON.parse(order_item.set_menu_items).each do |item_instance|
+ set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f
+ %>
+
+ <%= item_instance["item_instance_name"] %>
+ <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %>
+ <% (item_instance["options"]).each do |set_item_option| %>
+
+ <%= set_item_option %>
+
+ <% end %>
+ <% end %>
+
+ <% end
+ sub_total += set_item_prices
+ end %>
+ |
+ <%= order_item.qty %> |
+ <%= (order_item.qty*order_item.price).to_f + set_item_prices %> |
<%
@@ -327,18 +383,28 @@ end
change_to = $('#change_table_value').val();
change_from = "<%= @dining.id %>";
if (change_to == ""){
- alert("Please Select Room")
+ swal({
+ title: "Alert!!",
+ text: 'Please Select Table !',
+ type: 'warning',
+ });
}else{
$.ajax({type: "POST",
url: "<%= origami_moving_path %>",
data: "change_from="+ change_from + "&change_to=" + change_to,
success:function(result){
- alert("Moving Success")
- if (result.get_type == 'Table'){
- window.location.href = '/origami/table/' + change_to;
- }else{
- window.location.href = '/origami/room/' + change_to;
- }
+ // alert("Moving Success")
+ swal({
+ title: "Information!",
+ text: 'Moving Success',
+ type: 'success',
+ }, function (){
+ if (result.get_type == 'Table'){
+ window.location.href = '/origami/table/' + change_to;
+ }else{
+ window.location.href = '/origami/room/' + change_to;
+ }
+ });
}
});
}
diff --git a/app/views/origami/movetable/move_dining.html.erb b/app/views/origami/movetable/move_dining.html.erb
index 64102211..c15aeea8 100755
--- a/app/views/origami/movetable/move_dining.html.erb
+++ b/app/views/origami/movetable/move_dining.html.erb
@@ -204,15 +204,43 @@
unless @order_items.nil? || @order_items.empty?
count = 0
@order_items.each do |order_item |
+ set_item_prices = 0
count += 1
sub_total = sub_total + (order_item.price * order_item.qty)
#unless order_item.price <= 0 %>
- | <%= count %> |
- <%= order_item.item_name %> |
+ <%= count %> |
+
+ <%= order_item.item_name %>
+ <% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
+ <% JSON.parse(order_item.options).each do |option| %>
+
+ <%= option %>
+
+ <% end %>
+ <% end %>
+
+ <% if !order_item.set_menu_items.nil?
+ JSON.parse(order_item.set_menu_items).each do |item_instance|
+ set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f
+ %>
+
+ <%= item_instance["item_instance_name"] %>
+ <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %>
+ <% (item_instance["options"]).each do |set_item_option| %>
+
+ <%= set_item_option %>
+
+ <% end %>
+ <% end %>
+
+ <% end
+ sub_total += set_item_prices
+ end %>
+ |
<%= order_item.qty %> |
- <%= order_item.qty*order_item.price %> |
+ <%= (order_item.qty*order_item.price).to_f + set_item_prices %> |
<%
#end
@@ -232,12 +260,40 @@ if @status_sale == 'sale'
<%
@order_items.each do |order_item |
+ set_item_prices = 0
%>
- | <%= order_item.item_name %> |
+
+ <%= order_item.item_name %>
+ <% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
+ <% JSON.parse(order_item.options).each do |option| %>
+
+ <%= option %>
+
+ <% end %>
+ <% end %>
+
+ <% if !order_item.set_menu_items.nil?
+ JSON.parse(order_item.set_menu_items).each do |item_instance|
+ set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f
+ %>
+
+ <%= item_instance["item_instance_name"] %>
+ <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %>
+ <% (item_instance["options"]).each do |set_item_option| %>
+
+ <%= set_item_option %>
+
+ <% end %>
+ <% end %>
+
+ <% end
+ sub_total += set_item_prices
+ end %>
+ |
<%= order_item.qty %> |
- <%= order_item.qty*order_item.price %> |
+ <%= (order_item.qty*order_item.price).to_f + set_item_prices %> |
<%
diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb
index 4a77a743..6ce32cad 100755
--- a/app/views/origami/rooms/show.html.erb
+++ b/app/views/origami/rooms/show.html.erb
@@ -367,6 +367,7 @@
<%
count = 0
@order_items.each do |order_item |
+ set_item_prices = 0
count += 1
%>
@@ -382,7 +383,9 @@
<% end %>
<% if !order_item.set_menu_items.nil? && order_item.set_menu_items != '[]'
- JSON.parse(order_item.set_menu_items).each do |item_instance| %>
+ JSON.parse(order_item.set_menu_items).each do |item_instance|
+ set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f
+ %>
<%= item_instance["item_instance_name"] %>
<% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %>
@@ -394,10 +397,11 @@
<% end %>
<% end
+ sub_total += set_item_prices
end %>
<%= order_item.qty %> |
- <%= order_item.qty*order_item.price %> |
+ <%= (order_item.qty*order_item.price).to_f + set_item_prices %> |
<%