From 019db9f5d1e3ee3abd872ab7941e540550fe0f58 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Mon, 11 Jun 2018 11:02:40 +0630 Subject: [PATCH 1/2] Edit Survey --- app/views/origami/surveys/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/origami/surveys/_form.html.erb b/app/views/origami/surveys/_form.html.erb index d9a80bce..523e88c3 100755 --- a/app/views/origami/surveys/_form.html.erb +++ b/app/views/origami/surveys/_form.html.erb @@ -89,7 +89,7 @@ <%= f.input :total_customer, input_html: { :readonly => true,min:'1', class: 'col-md-11'} %> - <%= f.input :local , input_html: { min:'1',class: 'col-md-11' }%> + <%= f.input :local , input_html: { min:'1',class: 'col-md-11', :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyLocal(this.value);" }%>
Foreigner From 97f4a9df11ae4b28d9123c4377a8f8808e921209 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Mon, 11 Jun 2018 13:18:18 +0630 Subject: [PATCH 2/2] Pull from master --- app/assets/javascripts/channels/bill.js | 13 +-- app/controllers/origami/sales_controller.rb | 5 +- app/views/origami/home/show.html.erb | 8 +- .../origami/moveroom/move_dining.html.erb | 92 ++++++++++++++++--- .../origami/movetable/move_dining.html.erb | 66 ++++++++++++- app/views/origami/rooms/show.html.erb | 8 +- 6 files changed, 163 insertions(+), 29 deletions(-) diff --git a/app/assets/javascripts/channels/bill.js b/app/assets/javascripts/channels/bill.js index 7fa2b77e..278e3d41 100755 --- a/app/assets/javascripts/channels/bill.js +++ b/app/assets/javascripts/channels/bill.js @@ -10,12 +10,13 @@ App.order = App.cable.subscriptions.create('BillChannel', { if(data.from == "" || hostname == data.from) { if($('.table_'+data.table.id).hasClass('blue')){ - $('.table_'+data.table.id).removeClass('blue'); - $('.table_'+data.table.id).addClass('red'); - }else{ - $('.table_'+data.table.id).removeClass('orange'); - $('.table_'+data.table.id).addClass('red'); - } + $('.table_'+data.table.id).removeClass('blue'); + $('.table_'+data.table.id).removeClass('green'); + $('.table_'+data.table.id).addClass('red'); + }else{ + $('.table_'+data.table.id).removeClass('orange'); + $('.table_'+data.table.id).addClass('red'); + } $('.new_text_'+data.table.id).removeClass('hide'); $('.new_text_'+data.table.id).text('billed'); } 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 %> - - - + + + <% @@ -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 %> - - + + - + <% #end @@ -232,12 +260,40 @@ if @status_sale == 'sale'
<%= 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 %>
<%= 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 %>
<% @order_items.each do |order_item | + set_item_prices = 0 %> - + - + <% 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.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 %>
<%= order_item.qty %><%= order_item.qty*order_item.price %><%= (order_item.qty*order_item.price).to_f + set_item_prices %>