From e2ad5920079d782ef9dd4cd947ecf71eb0056658 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 15 Mar 2018 10:53:17 +0630 Subject: [PATCH 01/11] update start import and export menu --- data/recent_users.json | 128 +++++++++++++++++++++++++++++++++++++++++ lib/tasks/receipt.rake | 40 +++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 data/recent_users.json diff --git a/data/recent_users.json b/data/recent_users.json new file mode 100644 index 00000000..4d2e6825 --- /dev/null +++ b/data/recent_users.json @@ -0,0 +1,128 @@ +[ + { + "id": 1, + "name": "Administrator", + "role": "administrator", + "emp_id": "999", + "password_digest": "$2a$10$mfWmxBvOHt3NbWrLGOF/POTpnxF7QEtnW99qW818dkrQqVLtjQdrS", + "token_session": null, + "session_expiry": null, + "session_last_login": "2018-03-14 09:41:25 +0630", + "created_by": "SYSTEM DEFAULT", + "created_at": "2017-11-08 09:44:30 +0630", + "updated_at": "2018-03-14 16:02:09 +0630", + "image_path": {"url":null} + }, + { + "id": 2, + "name": "Waiter", + "role": "waiter", + "emp_id": "111", + "password_digest": "$2a$10$PjBemEA2yKOcoGAyXjz81OqglrASIF8RTYHVe0vqp3FQ0T4/PzJJG", + "token_session": "662e797ad508ab6c43b1", + "session_expiry": "2018-02-21 01:45:11 +0630", + "session_last_login": "2018-02-20 13:45:11 +0630", + "created_by": "SYSTEM DEFAULT", + "created_at": "2017-11-08 09:44:30 +0630", + "updated_at": "2018-02-20 13:59:17 +0630", + "image_path": {"url":null} + }, + { + "id": 3, + "name": "Waiter 2", + "role": "waiter", + "emp_id": "222", + "password_digest": "$2a$10$gXh/Tpbr8EyJSaxsbJYVh.K7Fr4bT0A1i2mWuuZm/FHQ4D/wV1E8e", + "token_session": "61868be9530b753ada84", + "session_expiry": "2018-03-14 05:41:12 +0630", + "session_last_login": "2018-03-13 17:11:12 +0630", + "created_by": "SYSTEM DEFAULT", + "created_at": "2017-11-08 09:44:30 +0630", + "updated_at": "2018-03-13 17:32:47 +0630", + "image_path": {"url":null} + }, + { + "id": 4, + "name": "Cashier", + "role": "cashier", + "emp_id": "333", + "password_digest": "$2a$10$fHo.9wOn.yr.2Ke6iuCfou6DjpyHXwQSmZQ.43O7W4SnlmzuoIEF2", + "token_session": "693f6e98bb90b6af9978", + "session_expiry": "2018-03-15 12:36:28 +0630", + "session_last_login": "2018-03-14 16:36:28 +0630", + "created_by": "SYSTEM DEFAULT", + "created_at": "2017-11-08 09:44:30 +0630", + "updated_at": "2018-03-14 17:05:14 +0630", + "image_path": {"url":null} + }, + { + "id": 5, + "name": "manager", + "role": "manager", + "emp_id": "888", + "password_digest": "$2a$10$EaU/Sxfsb8Q3kBIAyxSEJ.ZpRC9vxSdVAFvF0WXUvWiAqHyqGggoe", + "token_session": null, + "session_expiry": null, + "session_last_login": "2018-01-16 13:37:05 +0630", + "created_by": null, + "created_at": "2017-11-30 10:03:11 +0630", + "updated_at": "2018-01-16 13:48:02 +0630", + "image_path": {"url":null} + }, + { + "id": 6, + "name": "Account", + "role": "account", + "emp_id": "777", + "password_digest": "$2a$10$bJmgIxHefkvxpxJQLQPcpurTJrp8.BwP/kirJRYb1v1thrU3TDzkC", + "token_session": null, + "session_expiry": null, + "session_last_login": "2018-01-16 10:37:22 +0630", + "created_by": null, + "created_at": "2018-01-16 10:23:09 +0630", + "updated_at": "2018-01-16 10:49:24 +0630", + "image_path": {"url":null} + }, + { + "id": 7, + "name": "Supervisor", + "role": "supervisor", + "emp_id": "666", + "password_digest": "$2a$10$/WQirOw5nu6kKDiITTVa7.IGeVyxH5JmLp3/Astu/5DlOAoMLn4Ne", + "token_session": null, + "session_expiry": null, + "session_last_login": "2018-01-16 14:28:40 +0630", + "created_by": null, + "created_at": "2018-01-16 10:23:32 +0630", + "updated_at": "2018-01-16 15:32:33 +0630", + "image_path": {"url":null} + }, + { + "id": 8, + "name": "123", + "role": "waiter", + "emp_id": "123", + "password_digest": "$2a$10$v8JBsc31XkLRNZ/QhfYBg.wbVT7CyVvk83U..0PsGiz61w0Atl/WW", + "token_session": "4fc9a18a5df511e507fc", + "session_expiry": "2018-02-01 20:08:35 +0630", + "session_last_login": "2018-02-01 14:08:35 +0630", + "created_by": null, + "created_at": "2018-02-01 14:07:16 +0630", + "updated_at": "2018-02-01 17:45:10 +0630", + "image_path": {"url":null} + }, + { + "id": 9, + "name": "Cashier 2", + "role": "cashier", + "emp_id": "444", + "password_digest": "$2a$10$5n34O09xmrIHbgvX.uhr9uAaUR8etjaqiicaXr017VWm/qDkjKVue", + "token_session": "0477edce9cf259f280c1", + "session_expiry": "2018-02-20 19:07:50 +0630", + "session_last_login": "2018-02-20 11:37:50 +0630", + "created_by": null, + "created_at": "2018-02-14 17:10:12 +0630", + "updated_at": "2018-02-20 13:37:46 +0630", + "image_path": {"url":null} + } +] \ No newline at end of file diff --git a/lib/tasks/receipt.rake b/lib/tasks/receipt.rake index fa24f481..ee884fb2 100644 --- a/lib/tasks/receipt.rake +++ b/lib/tasks/receipt.rake @@ -1,4 +1,44 @@ namespace :consolidate do + + + desc 'export sers who have logged in since 2017-06-30' + task :export => :environment do + puts "Export users who have logged in since 2017-06-30" + + # get a file ready, the 'data' directory has already been added in Rails.root + filepath = File.join(Rails.root, 'data', 'recent_users.json') + puts "- exporting users into #{filepath}" + + # the key here is to use 'as_json', otherwise you get an ActiveRecord_Relation object, which extends + # array, and works like in an array, but not for exporting + users = Employee.all.as_json +puts users + # The pretty is nice so I can diff exports easily, if that's not important, JSON(users) will do + File.open(filepath, 'w') do |f| + f.write(JSON.pretty_generate(users)) + end + + puts "- dumped #{users.size} users" + end + + desc 'import users from recent users dump' + task :import => :environment do + puts "Importing current users" + + filepath = File.join(Rails.root, 'data', 'recent_users.json') + abort "Input file not found: #{filepath}" unless File.exist?(filepath) + + current_users = JSON.parse(File.read(filepath)) + + current_users.each do |cu| + puts cu.to_json + Employee.create(cu) + end + + puts "- imported #{current_users.size} users" + end + + desc "Receipt" task :receipt => :environment do Receipt.delete_all From af2f3045cf1844ce5fdcef2334573099180d8608 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 15 Mar 2018 14:25:19 +0630 Subject: [PATCH 02/11] change order items api --- app/models/order.rb | 2 +- app/views/api/orders/view_orders.json.jbuilder | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/order.rb b/app/models/order.rb index 1508c960..892c218c 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -152,7 +152,7 @@ class Order < ApplicationRecord item[:sub_items].each do |si| # Retrive instance's Price set_item = MenuItem.search_by_item_code(si[:item_instance_code]) - set_order_items.push({"item_instance_code"=>si[:item_instance_code], "quantity"=>si[:quantity], "price"=>set_item[:price]}) + set_order_items.push({"item_instance_code"=>si[:item_instance_code], "item_instance_name"=>set_item[:name], "quantity"=>si[:quantity], "price"=>set_item[:price]}) end end set_order_items = set_order_items.to_json diff --git a/app/views/api/orders/view_orders.json.jbuilder b/app/views/api/orders/view_orders.json.jbuilder index ae3fea84..dd72a3a3 100755 --- a/app/views/api/orders/view_orders.json.jbuilder +++ b/app/views/api/orders/view_orders.json.jbuilder @@ -46,9 +46,12 @@ if (@booking) child_spent += (item.price * item.qty) end # End YGN BBQ + json.order_items_id item.order_items_id + json.order_id item.order_id json.item_code item.item_code json.item_instance_code item.item_instance_code json.item_name item.item_name + json.set_menu_items item.set_menu_items json.price item.price json.qty item.qty json.options item.options From f0e81caad0cf857cde16ff646660e7021dbeab91 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 15 Mar 2018 14:35:25 +0630 Subject: [PATCH 03/11] update addorder option for set --- app/assets/javascripts/addorder.js | 41 ++++++++++++-------- app/controllers/settings/menus_controller.rb | 4 ++ app/models/menu.rb | 27 ++++++++++++- config/application.rb | 1 + lib/tasks/receipt.rake | 40 ------------------- 5 files changed, 56 insertions(+), 57 deletions(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 1df7a16e..401d894a 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -180,7 +180,7 @@ $(function() { image_path = "image/logo.png"; } } - + console.log(menu_items[field].options) row = '
' +'
' @@ -202,7 +202,7 @@ $(function() { + price +"' data-instance-code = '"+ code +"' data-instance = '" + name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '" + JSON.stringify(item_attributes) +"' data-options = '" - + options +"' data-image='"+image_path+"' data-toggle='" + + JSON.stringify(menu_items[field].options) +"' data-image='"+image_path+"' data-toggle='" +data_modal+"' data-target='."+data_target+"' data-item-sets = '" +JSON.stringify(menu_items[field].item_sets)+"'data-instances = '" +JSON.stringify(menu_items[field].instances)+"'>" @@ -237,10 +237,10 @@ $(function() { //instances = $(this).data('instance'); item_sets = $(this).data('item-sets'); instances = $(this).data('instances'); - // item_sets = $(data).attr('data-item-sets'); + item_options = $(this).data('options'); for(var field in item_sets) { - + $('.set_order').attr('data-min-qty',item_sets[field]["min_selectable_qty"]); value = item_sets[field]["instances"]; @@ -283,10 +283,20 @@ $(function() { }); } + for(var j in item_options) { + value = item_options[j]["values"]; + type = item_options[j]["type"]; + row = "

"+type+"

" + $(value).each(function(i){ + row +=""; + }); + $(".options-list").append(row); + } $('.set-item').attr('data-code',instances[0]['code']); $('.set-item').attr('data-name',instances[0]['name']); $('.set-item').attr('data-price',instances[0]['price']); - $('.set-item').attr('data-options','[]'); + // $('.set-item').attr('data-options','[]'); $('.set-item').attr('data-parent',true); $('#set_change_qty').val(1); @@ -371,32 +381,28 @@ $(function() { customer_display_view(item,"set_add"); attribute_arr = [] - option_arr = [] var rowCount = $('.summary-items tbody tr').length+1; - option_arr = [] code = $('.set-item').attr('data-code'); name = $('.set-item').attr('data-name'); price = $('.set-item').attr('data-price'); option = $('.set-item').attr('data-options'); parent = $('.set-item').attr('data-parent'); total = qty * price ; - option_arr.push(option); row ="" + +option+"' data-row ='"+rowCount+ "' data-parent ='"+parent+ "'>" +''+rowCount+'' - +'' + item_name+ ' ' + name +'' + +'' + item_name+ ' ' + name +'-' + option +'' +'' + qty + '' +'' + parseFloat(total).toFixed(2) +'' +''; $(".summary-items tbody").append(row); - var rowCount = $('.summary-items tbody tr').length+1; $(items).each(function(i){ code = $(items[i]).attr('data-code'); @@ -406,15 +412,14 @@ $(function() { sub_item = $(items[i]).attr('data-sub-item'); option = $(items[i]).attr('data-options'); total = qty * price ; - option_arr.push(option); row ="" + +option+"' data-row ='"+rowCount+ "' data-sub-item ='"+sub_item+ "'>" +''+rowCount+'' - +'' + item_name+ ' ' + name +'' + +'' + item_name+ ' ' + name +'-' + option +'' +'' + qty + '' +'' + parseFloat(total).toFixed(2) @@ -626,8 +631,6 @@ $(function() { if(group == "set_menu"){ - code = $(this).data('code'); - value = $(this).data('value'); instance = $(".selected-instance"); $(instance).each(function(i){ @@ -638,6 +641,12 @@ $(function() { } }); } + + if(group == "set_menu_default"){ + option_arr = get_selected_attributes('selected-option'); + $('.set-item').attr('data-options',JSON.stringify(option_arr)); + $('.set_default_option').text(option_arr); + } }); //End selecct attribute buttom diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index 240343b1..4d7d6026 100755 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -6,6 +6,10 @@ class Settings::MenusController < ApplicationController # GET /settings/menus.json def index @settings_menus = Menu.all.page(params[:page]).per(10) + respond_to do |format| + format.html + format.csv { send_data Menu.to_csv } + end end # GET /settings/menus/1 diff --git a/app/models/menu.rb b/app/models/menu.rb index b96fe03a..052a7042 100755 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -31,4 +31,29 @@ class Menu < ApplicationRecord menu.destroy return false end -end + + def self.to_csv + m_attributes = %w{id name is_active valid_days valid_time_from valid_time_to created_by created_at updated_at} + CSV.generate(headers: true) do |csv| + csv << m_attributes + menu = Menu.all + menu.each do |user| + puts user + csv << m_attributes.map{ |attr| user.send(attr)} + end + end + + # mc_attributes = %w{id menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at} + # CSV.generate(headers: true) do |csv| + # csv << m_attributes + + # csv << mc_attributes + # MenuCategory.all.each do |user| + # puts user + # csv << mc_attributes.map{ |attr| user.send(attr)} + # end + # end + + end + +end \ No newline at end of file diff --git a/config/application.rb b/config/application.rb index 6a3bc551..f4cbac01 100755 --- a/config/application.rb +++ b/config/application.rb @@ -1,5 +1,6 @@ require_relative 'boot' +require 'csv' require 'rails/all' # Require the gems listed in Gemfile, including any gems diff --git a/lib/tasks/receipt.rake b/lib/tasks/receipt.rake index ee884fb2..fa24f481 100644 --- a/lib/tasks/receipt.rake +++ b/lib/tasks/receipt.rake @@ -1,44 +1,4 @@ namespace :consolidate do - - - desc 'export sers who have logged in since 2017-06-30' - task :export => :environment do - puts "Export users who have logged in since 2017-06-30" - - # get a file ready, the 'data' directory has already been added in Rails.root - filepath = File.join(Rails.root, 'data', 'recent_users.json') - puts "- exporting users into #{filepath}" - - # the key here is to use 'as_json', otherwise you get an ActiveRecord_Relation object, which extends - # array, and works like in an array, but not for exporting - users = Employee.all.as_json -puts users - # The pretty is nice so I can diff exports easily, if that's not important, JSON(users) will do - File.open(filepath, 'w') do |f| - f.write(JSON.pretty_generate(users)) - end - - puts "- dumped #{users.size} users" - end - - desc 'import users from recent users dump' - task :import => :environment do - puts "Importing current users" - - filepath = File.join(Rails.root, 'data', 'recent_users.json') - abort "Input file not found: #{filepath}" unless File.exist?(filepath) - - current_users = JSON.parse(File.read(filepath)) - - current_users.each do |cu| - puts cu.to_json - Employee.create(cu) - end - - puts "- imported #{current_users.size} users" - end - - desc "Receipt" task :receipt => :environment do Receipt.delete_all From dcac662c8ef0208d089dcf092b839f8051abb57b Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 15 Mar 2018 15:51:12 +0630 Subject: [PATCH 04/11] change set menu item format in api and origami --- app/controllers/origami/home_controller.rb | 10 ----- app/controllers/origami/rooms_controller.rb | 10 ----- app/models/order.rb | 4 +- app/views/origami/home/show.html.erb | 42 +++++++++++++++++++-- app/views/origami/rooms/show.html.erb | 42 +++++++++++++++++++-- 5 files changed, 78 insertions(+), 30 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 6a6c0c90..a8e2818c 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -74,16 +74,6 @@ class Origami::HomeController < BaseOrigamiController @date = order.created_at @booking= booking order.order_items.each do |item| - if !item.set_menu_items.nil? - instance_item_sets = JSON.parse(item.set_menu_items) - arr_instance_item_sets = Array.new - instance_item_sets.each do |instance_item| - item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name - arr_instance_item_sets.push(item_instance_name) - item.price = item.price.to_f + instance_item["price"].to_f - end - item.set_menu_items = arr_instance_item_sets - end @order_items.push(item) # assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id) # if !assigned_order_items.nil? diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 3aa98282..11a7f93d 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -68,16 +68,6 @@ class Origami::RoomsController < BaseOrigamiController @date = order.created_at @booking = booking order.order_items.each do |item| - if !item.set_menu_items.nil? - instance_item_sets = JSON.parse(item.set_menu_items) - arr_instance_item_sets = Array.new - instance_item_sets.each do |instance_item| - item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name - arr_instance_item_sets.push(item_instance_name) - item.price = item.price.to_f + instance_item["price"].to_f - end - item.set_menu_items = arr_instance_item_sets - end @order_items.push(item) # assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id) # if !assigned_order_items.nil? diff --git a/app/models/order.rb b/app/models/order.rb index 892c218c..02f4b618 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -135,7 +135,7 @@ class Order < ApplicationRecord #loop to add all items to order ordered_list.each do |item| - + menu_item = MenuItem.search_by_item_code(item[:item_instance_code]) # For Product while item code not in menu item @@ -152,7 +152,7 @@ class Order < ApplicationRecord item[:sub_items].each do |si| # Retrive instance's Price set_item = MenuItem.search_by_item_code(si[:item_instance_code]) - set_order_items.push({"item_instance_code"=>si[:item_instance_code], "item_instance_name"=>set_item[:name], "quantity"=>si[:quantity], "price"=>set_item[:price]}) + set_order_items.push({"item_instance_code"=>si[:item_instance_code], "item_instance_name"=>set_item[:name], "quantity"=>si[:quantity], "price"=>set_item[:price], "options"=>si[:options]}) end end set_order_items = set_order_items.to_json diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 8c2e58bc..accbd5d9 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -292,9 +292,26 @@ <%= 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? - order_item.set_menu_items.each do |item_instance| %> -
<%= item_instance %> + JSON.parse(order_item.set_menu_items).each do |item_instance| %> +
+ <%= item_instance["item_instance_name"] %> + <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %> + <% JSON.parse(item_instance["options"]).each do |set_item_option| %> +
+ <%= set_item_option %> + + <% end %> + <% end %> +
<% end end %> @@ -371,9 +388,26 @@ <%= 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? - order_item.set_menu_items.each do |item_instance| %> -
<%= item_instance %> + JSON.parse(order_item.set_menu_items).each do |item_instance| %> +
+ <%= item_instance["item_instance_name"] %> + <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %> + <% JSON.parse(item_instance["options"]).each do |set_item_option| %> +
+ <%= set_item_option %> + + <% end %> + <% end %> +
<% end end %> diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 1edb07cf..4a21fb24 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -277,9 +277,26 @@ <%= 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? - order_item.set_menu_items.each do |item_instance| %> -
<%= item_instance %> + JSON.parse(order_item.set_menu_items).each do |item_instance| %> +
+ <%= item_instance["item_instance_name"] %> + <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %> + <% JSON.parse(item_instance["options"]).each do |set_item_option| %> +
+ <%= set_item_option %> + + <% end %> + <% end %> +
<% end end %> @@ -345,9 +362,26 @@ <%= 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? - order_item.set_menu_items.each do |item_instance| %> -
<%= item_instance %> + JSON.parse(order_item.set_menu_items).each do |item_instance| %> +
+ <%= item_instance["item_instance_name"] %> + <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %> + <% JSON.parse(item_instance["options"]).each do |set_item_option| %> +
+ <%= set_item_option %> + + <% end %> + <% end %> +
<% end end %> From 6ccf3152429ddd1d1daab92a464c05c3834443e3 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 15 Mar 2018 16:14:15 +0630 Subject: [PATCH 05/11] remove JSON parse in set item options --- app/views/origami/home/show.html.erb | 14 +++++++------- app/views/origami/rooms/show.html.erb | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index accbd5d9..54b0e956 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -304,13 +304,13 @@ JSON.parse(order_item.set_menu_items).each do |item_instance| %>
<%= item_instance["item_instance_name"] %> - <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %> - <% JSON.parse(item_instance["options"]).each do |set_item_option| %> -
- <%= set_item_option %> - - <% end %> + <% if !item_instance["options"].nil? && !item_instance["options"].empty? %> + <% (item_instance["options"]).each do |set_item_option| %> +
+ <%= set_item_option %> + <% end %> + <% end %>
<% end end %> @@ -401,7 +401,7 @@
<%= item_instance["item_instance_name"] %> <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %> - <% JSON.parse(item_instance["options"]).each do |set_item_option| %> + <% (item_instance["options"]).each do |set_item_option| %>
<%= set_item_option %> diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 4a21fb24..d98a3fe2 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -290,7 +290,7 @@
<%= item_instance["item_instance_name"] %> <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %> - <% JSON.parse(item_instance["options"]).each do |set_item_option| %> + <% (item_instance["options"]).each do |set_item_option| %>
<%= set_item_option %> @@ -375,7 +375,7 @@
<%= item_instance["item_instance_name"] %> <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %> - <% JSON.parse(item_instance["options"]).each do |set_item_option| %> + <% (item_instance["options"]).each do |set_item_option| %>
<%= set_item_option %> From 8cea60ec02361fd40518372b2616aca1e5a82255 Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 16 Mar 2018 09:42:56 +0630 Subject: [PATCH 06/11] SQA urgent issues --- .../origami/payments_controller.rb | 37 ++++++++++--------- app/controllers/origami/shifts_controller.rb | 1 + app/models/order.rb | 22 +++++------ app/pdf/order_item_pdf.rb | 2 +- app/pdf/order_item_slim_pdf.rb | 2 +- app/pdf/order_set_item_pdf.rb | 2 +- app/pdf/order_summary_pdf.rb | 3 +- app/pdf/order_summary_set_pdf.rb | 2 +- app/pdf/order_summary_slim_pdf.rb | 2 +- app/views/origami/home/index.html.erb | 2 +- .../origami/pending_order/index.html.erb | 22 ++++++++++- app/views/origami/pending_order/show.html.erb | 28 ++++++++++++-- app/views/origami/shifts/show.html.erb | 11 ++++-- app/views/reports/product_sale/index.html.erb | 2 +- config/locales/en.yml | 1 + config/locales/mm.yml | 1 + config/routes.rb | 2 +- 17 files changed, 96 insertions(+), 46 deletions(-) mode change 100644 => 100755 app/pdf/order_item_slim_pdf.rb mode change 100644 => 100755 app/pdf/order_set_item_pdf.rb mode change 100644 => 100755 app/pdf/order_summary_set_pdf.rb mode change 100644 => 100755 app/pdf/order_summary_slim_pdf.rb mode change 100644 => 100755 app/views/origami/pending_order/index.html.erb mode change 100644 => 100755 app/views/origami/pending_order/show.html.erb mode change 100644 => 100755 app/views/reports/product_sale/index.html.erb diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index c764b92f..49320273 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -104,7 +104,9 @@ class Origami::PaymentsController < BaseOrigamiController end end #end rounding adjustment - + puts "sale" + puts saleObj.to_json + sale_payment = SalePayment.new sale_payment.process_payment(saleObj, current_user.name, cash, "cash") @@ -152,12 +154,24 @@ class Origami::PaymentsController < BaseOrigamiController if customer.membership_id != nil && rebate && credit_data.nil? member_info = Customer.get_member_account(customer) - if member_info["status"] == true - rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no) - current_balance = SaleAudit.paymal_search(sale_id) - end + rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no) + current_balance = SaleAudit.paymal_search(sale_id) end + #orders print out + if params[:type] == "quick_service" + booking = Booking.find_by_sale_id(sale_id) + if booking.dining_facility_id.to_i>0 + table_id = booking.dining_facility_id + else + table_id = 0 + end + + booking.booking_orders.each do |order| + Order.pay_process_order_queue(order.order_id,table_id) + end + end + #for card sale data card_data = Array.new card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id) @@ -181,19 +195,6 @@ class Origami::PaymentsController < BaseOrigamiController filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data) render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) - - if params[:type] == "quick_service" - booking = Booking.find_by_sale_id(sale_id) - if booking.dining_facility_id.to_i>0 - table_id = booking.dining_facility_id - else - table_id = 0 - end - - booking.booking_orders.each do |order| - Order.pay_process_order_queue(order.order_id,table_id) - end - end end end end diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 19def9b6..d0b73f99 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -3,6 +3,7 @@ class Origami::ShiftsController < BaseOrigamiController end def show + @type = params[:type] @shift = ShiftSale.current_open_shift(current_user.id) #for bank integration bank_integration = Lookup.collection_of('bank_integration') diff --git a/app/models/order.rb b/app/models/order.rb index 02f4b618..25c5db4a 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -339,17 +339,17 @@ class Order < ApplicationRecord #Process order items and send to order queue def self.pay_process_order_queue(id,table_id) sidekiq = Lookup.find_by_lookup_type("sidekiq") - if !sidekiq.nil? - OrderQueueProcessorJob.perform_later(id, table_id) - else - order = Order.find(id) - if order - oqs = OrderQueueStation.new - oqs.process_order(order, table_id) - end - assign_order = AssignedOrderItem.assigned_order_item_by_job(id) - ActionCable.server.broadcast "order_queue_station_channel",order: assign_order - end + if !sidekiq.nil? + OrderQueueProcessorJob.perform_later(id, table_id) + else + order = Order.find(id) + if order + oqs = OrderQueueStation.new + oqs.process_order(order, table_id) + end + assign_order = AssignedOrderItem.assigned_order_item_by_job(id) + ActionCable.server.broadcast "order_queue_station_channel",order: assign_order + end end def check_cup_status(status) diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 379e919c..fabc8d11 100755 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -37,7 +37,7 @@ class OrderItemPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if order_item.dining.to_i > 0 + if !order_item.dining.nil? text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_item_slim_pdf.rb b/app/pdf/order_item_slim_pdf.rb old mode 100644 new mode 100755 index 09cce4d1..146b585f --- a/app/pdf/order_item_slim_pdf.rb +++ b/app/pdf/order_item_slim_pdf.rb @@ -37,7 +37,7 @@ class OrderItemSlimPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if order_item_slim.dining.to_i > 0 + if !order_item_slim.dining.nil? text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_set_item_pdf.rb b/app/pdf/order_set_item_pdf.rb old mode 100644 new mode 100755 index 6aa6efc4..9aac0d0e --- a/app/pdf/order_set_item_pdf.rb +++ b/app/pdf/order_set_item_pdf.rb @@ -37,7 +37,7 @@ class OrderSetItemPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if order_set_item.dining.to_i > 0 + if !order_set_item.dining.nil? text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 6c8dacac..17cf905c 100755 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -36,7 +36,8 @@ class OrderSummaryPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - if order[0].dining.to_i > 0 + + if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_summary_set_pdf.rb b/app/pdf/order_summary_set_pdf.rb old mode 100644 new mode 100755 index 8828ea43..14b2f796 --- a/app/pdf/order_summary_set_pdf.rb +++ b/app/pdf/order_summary_set_pdf.rb @@ -36,7 +36,7 @@ class OrderSummarySetPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - if order[0].dining.to_i > 0 + if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_summary_slim_pdf.rb b/app/pdf/order_summary_slim_pdf.rb old mode 100644 new mode 100755 index 73023278..c88061ea --- a/app/pdf/order_summary_slim_pdf.rb +++ b/app/pdf/order_summary_slim_pdf.rb @@ -36,7 +36,7 @@ class OrderSummarySlimPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - if order[0].dining.to_i > 0 + if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 3577aa48..aa000aab 100755 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -241,7 +241,7 @@ $('#cash_out').on('click',function(){ $('#close_cashier').on('click',function(e){ e.preventDefault(); // Prevent the href from redirecting directly - var linkURL = '/origami/shift/close'; + var linkURL = '/origami/shift/cashier/close'; warnBeforeRedirect(linkURL); }) diff --git a/app/views/origami/pending_order/index.html.erb b/app/views/origami/pending_order/index.html.erb old mode 100644 new mode 100755 index 8fa9a7af..2d4ba1d4 --- a/app/views/origami/pending_order/index.html.erb +++ b/app/views/origami/pending_order/index.html.erb @@ -34,7 +34,9 @@ reply <%= t("views.btn.back") %> - + <% if current_user.role != "waiter" %> + + <% end %>
@@ -51,4 +53,22 @@ $('#back').on('click', function () { window.location.href = '/origami/quick_service'; }) + + $('#close_cashier').on('click',function(e){ + e.preventDefault(); // Prevent the href from redirecting directly + var linkURL = '/origami/shift/quick_service/close'; + warnBeforeRedirect(linkURL); + }); + + function warnBeforeRedirect(linkURL) { + swal({ + title: "Alert!", + text: "Are you sure you want to close cashier?", + type: "warning", + showCancelButton: true + }, function() { + // Redirect the user + window.location.href = linkURL; + }); + } diff --git a/app/views/origami/pending_order/show.html.erb b/app/views/origami/pending_order/show.html.erb old mode 100644 new mode 100755 index d7c929f7..ac164636 --- a/app/views/origami/pending_order/show.html.erb +++ b/app/views/origami/pending_order/show.html.erb @@ -1,7 +1,7 @@
-
+
PENDING ORDER @@ -148,7 +148,7 @@
-
+
<% if current_user.role != "waiter" || @status != "sale"%> @@ -167,6 +167,9 @@ <% if @status != "sale"%> <%end%> + <% if current_user.role != "waiter" %> + + <% end %>
@@ -203,12 +206,11 @@ $(document).ready(function(){ url: ajax_url, // data: 'order_id='+ order_id, success: function (result) { - console.log(result) if (!result.status) { swal("Information!", result.error_message); } else { - window.location.href = '../pending_order/'+ result.data; + location.reload(); } } }); @@ -269,5 +271,23 @@ $(document).ready(function(){ } return false; }); + + $('#close_cashier').on('click',function(e){ + e.preventDefault(); // Prevent the href from redirecting directly + var linkURL = '/origami/shift/quick_service/close'; + warnBeforeRedirect(linkURL); + }); + + function warnBeforeRedirect(linkURL) { + swal({ + title: "Alert!", + text: "Are you sure you want to close cashier?", + type: "warning", + showCancelButton: true + }, function() { + // Redirect the user + window.location.href = linkURL; + }); + } }); diff --git a/app/views/origami/shifts/show.html.erb b/app/views/origami/shifts/show.html.erb index 4ea71dec..4e42f11b 100755 --- a/app/views/origami/shifts/show.html.erb +++ b/app/views/origami/shifts/show.html.erb @@ -58,6 +58,7 @@
diff --git a/app/views/settings/tax_profiles/index.html.erb b/app/views/settings/tax_profiles/index.html.erb index bda31d46..e1e63c06 100755 --- a/app/views/settings/tax_profiles/index.html.erb +++ b/app/views/settings/tax_profiles/index.html.erb @@ -30,9 +30,7 @@ <% @settings_tax_profiles.each do |settings_tax_profile| %> - - <%= settings_tax_profile.group_type %> - + <%= settings_tax_profile.group_type %> <%= settings_tax_profile.name %> <%= settings_tax_profile.rate %> <%= settings_tax_profile.inclusive %> diff --git a/app/views/settings/tax_profiles/show.html.erb b/app/views/settings/tax_profiles/show.html.erb index 77a503f2..b405066f 100755 --- a/app/views/settings/tax_profiles/show.html.erb +++ b/app/views/settings/tax_profiles/show.html.erb @@ -15,6 +15,11 @@

<%= t("en.tax_profile") %>

+ + + + + From e956b54886ade60a79b8f5b6a4a41d3f2ccc3a33 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 16 Mar 2018 17:41:30 +0630 Subject: [PATCH 09/11] update option and menu export csv single --- Gemfile | 4 +- app/assets/javascripts/addorder.js | 54 ++++---- app/controllers/api/orders_controller.rb | 3 +- .../origami/addorders_controller.rb | 6 +- app/controllers/settings/menus_controller.rb | 14 +- .../transactions/orders_controller.rb | 9 +- app/models/menu.rb | 19 +-- app/models/menu_category.rb | 17 ++- app/models/order_item.rb | 3 +- app/views/origami/addorders/detail.html.erb | 2 +- app/views/settings/menus/index.html.erb | 5 + config/application.rb | 2 + config/routes.rb | 1 + data/recent_users.json | 128 ------------------ 14 files changed, 84 insertions(+), 183 deletions(-) delete mode 100644 data/recent_users.json diff --git a/Gemfile b/Gemfile index 94ed4ef3..4ca47865 100755 --- a/Gemfile +++ b/Gemfile @@ -48,7 +48,6 @@ gem 'prawn' gem 'prawn-table' gem 'spreadsheet' gem 'to_xls-rails' - #Reporting gem #gem 'compendium' #gem "cancan" @@ -81,7 +80,6 @@ gem 'kaminari', '~> 1.0.1' gem 'filterrific' gem 'cancancan', '~> 1.10' - #pageless no need for current # gem 'will_paginate' # gem 'pageless-rails', github: 'rorlab/pageless-rails' @@ -129,4 +127,4 @@ gem 'momentjs-rails' # for date-range selector # gem 'bootstrap-datepicker-rails' # date picker # gem 'jquery-datetimepicker-rails' # gem 'select2-rails' # for multi-select and auto-complete select box -gem "chartkick" #chart lib +gem "chartkick" #chart lib \ No newline at end of file diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 401d894a..f6365db0 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -180,7 +180,6 @@ $(function() { image_path = "image/logo.png"; } } - console.log(menu_items[field].options) row = '
' +'
' @@ -190,6 +189,7 @@ $(function() { +JSON.stringify(menu_items[field].instances)+"' data-id = '" +JSON.stringify(menu_items[field].attributes)+"' data-item = '" +JSON.stringify(item_attributes)+"' data-option = '" + +JSON.stringify(menu_items[field].options)+"'data-opt = '" +JSON.stringify(menu_items[field].options)+"' data-item-sets = '" +JSON.stringify(menu_items[field].item_sets)+"' data-toggle='modal' data-target='."+data_target+"' >" +"" @@ -202,6 +202,7 @@ $(function() { + price +"' data-instance-code = '"+ code +"' data-instance = '" + name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '" + JSON.stringify(item_attributes) +"' data-options = '" + + JSON.stringify(menu_items[field].options) +"' data-opt = '" + JSON.stringify(menu_items[field].options) +"' data-image='"+image_path+"' data-toggle='" +data_modal+"' data-target='."+data_target+"' data-item-sets = '" +JSON.stringify(menu_items[field].item_sets)+"'data-instances = '" @@ -296,7 +297,7 @@ $(function() { $('.set-item').attr('data-code',instances[0]['code']); $('.set-item').attr('data-name',instances[0]['name']); $('.set-item').attr('data-price',instances[0]['price']); - // $('.set-item').attr('data-options','[]'); + $('.set-item').attr('data-options',''); $('.set-item').attr('data-parent',true); $('#set_change_qty').val(1); @@ -351,6 +352,7 @@ $(function() { sub_total = $('#set_total_price').text(); name = $(this).data('name'); price = $(this).data('price'); + options = $(this).attr('data-options',''); // qty = $('#set_change_qty').val(); qty = document.getElementById("set_count").value; total = qty*price; @@ -379,14 +381,14 @@ $(function() { item = get_set_item(items); customer_display_view(item,"set_add"); - + var option = '' attribute_arr = [] var rowCount = $('.summary-items tbody tr').length+1; code = $('.set-item').attr('data-code'); name = $('.set-item').attr('data-name'); price = $('.set-item').attr('data-price'); - option = $('.set-item').attr('data-options'); + option = ($('.set-item').attr('data-options') === 'undefined') ? '' :$('.set-item').attr('data-options'); parent = $('.set-item').attr('data-parent'); total = qty * price ; row ="
" +'' - +'' + +'' +'' +''; $(".summary-items tbody").append(row); var rowCount = $('.summary-items tbody tr').length+1; + var set_option = '' $(items).each(function(i){ code = $(items[i]).attr('data-code'); name = $(items[i]).attr('data-name'); price = $(items[i]).attr('data-price'); - option = $(items[i]).attr('data-options'); + set_option = ($(items[i]).attr('data-options') === 'undefined') ? ' ' :$(items[i]).attr('data-options'); + sub_item = $(items[i]).attr('data-sub-item'); - option = $(items[i]).attr('data-options'); total = qty * price ; row ="" + +set_option+"' data-row ='"+rowCount+ "' data-sub-item ='"+sub_item+ "'>" +'' - +'' + +'' +'' +'' - +'' + +'' +'' +' + <% order_item_count = 0 %> <% if !@order_items.nil? %> <% sub_total = 0 %> <% @order_items.each do |order_item| %> <% if order_item.include? ('all_order') %> <% order_item['all_order'].each do |odr_item| %> <% + order_item_count = order_item_count.to_i + 1 sub_total += odr_item['qty'].to_f * odr_item['price'].to_f %> > @@ -385,10 +387,10 @@ //order_item_split $('#order_item_split').on('click',function () { - var cnt_order_item = "<%= @order_items.count %>"; + var cnt_order_item = "<%= order_item_count %>"; var order_items = get_selected_order_items();// Selected Order Items - var cnt_items = parseInt(cnt_order_item - 1) - parseInt(order_items.length); + var cnt_items = parseInt(cnt_order_item) - parseInt(order_items.length); if (order_items.length > 0){ // if(cnt_items > 0){ swal({ From e55ff8b5e0d240c8b4eb20f819917b97f21e1e63 Mon Sep 17 00:00:00 2001 From: phyusin Date: Mon, 19 Mar 2018 09:17:12 +0630 Subject: [PATCH 11/11] SQA feedback --- app/controllers/oqs/edit_controller.rb | 17 ++++++++++------- app/views/oqs/edit/index.html.erb | 4 ++++ app/views/origami/pending_order/show.html.erb | 10 +++++++++- app/views/origami/split_bill/index.html.erb | 5 +++-- 4 files changed, 26 insertions(+), 10 deletions(-) mode change 100755 => 100644 app/controllers/oqs/edit_controller.rb mode change 100755 => 100644 app/views/oqs/edit/index.html.erb mode change 100755 => 100644 app/views/origami/pending_order/show.html.erb mode change 100755 => 100644 app/views/origami/split_bill/index.html.erb diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb old mode 100755 new mode 100644 index b123ac73..94ba5842 --- a/app/controllers/oqs/edit_controller.rb +++ b/app/controllers/oqs/edit_controller.rb @@ -6,6 +6,11 @@ class Oqs::EditController < BaseOqsController if params[:type] == 'oqs' assigned_item = AssignedOrderItem.find(assigned_item_id) @order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.instance_code }'") + elsif + assigned_item = OrderItem.find(assigned_item_id) + @booking = Booking.joins(" JOIN booking_orders as bko on bko.booking_id = bookings.booking_id") + .where("bko.order_id = '#{assigned_item.order_id}'").first() + @order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.item_instance_code }'") else assigned_item = OrderItem.find(assigned_item_id) dining = DiningFacility.find_by_id(params[:type]) @@ -25,13 +30,6 @@ class Oqs::EditController < BaseOqsController order_item.item_order_by = current_user.name order_item.qty = qty_weight order_item.remark = remarks - if !order_item.set_menu_items.nil? - instance_item_sets = JSON.parse(order_item.set_menu_items) - instance_item_sets.each_with_index do |instance_item, instance_index| - instance_item_sets[instance_index]["quantity"] = qty_weight - end - order_item.set_menu_items = instance_item_sets.to_json - end order_item.save if ENV["SERVER_MODE"] != "cloud" #no print in cloud server @@ -67,4 +65,9 @@ class Oqs::EditController < BaseOqsController end end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/views/oqs/edit/index.html.erb b/app/views/oqs/edit/index.html.erb old mode 100755 new mode 100644 index 775b214d..7a1eebab --- a/app/views/oqs/edit/index.html.erb +++ b/app/views/oqs/edit/index.html.erb @@ -112,6 +112,8 @@ $(document).ready(function(){ 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 } + var booking_id = '<%= @booking.booking_id %>'; + $.ajax({ type: 'POST', url: '/oqs/' + order_items_id, @@ -121,6 +123,8 @@ $(document).ready(function(){ <% if !@link_type.nil? %> <% if @link_type == 'oqs' %> window.location.href = '/oqs'; + <% elsif @link_type == 'pending' %> + window.location.href = '/origami/quick_service/pending_order/'+booking_id; <% else %> <% if !@dining_type.nil? %> <% if @dining_type == 'Table' %> diff --git a/app/views/origami/pending_order/show.html.erb b/app/views/origami/pending_order/show.html.erb old mode 100755 new mode 100644 index ac164636..a7ade0a4 --- a/app/views/origami/pending_order/show.html.erb +++ b/app/views/origami/pending_order/show.html.erb @@ -100,7 +100,7 @@ @order_items.each do |order_item| sub_total = sub_total + order_item.price %> - + @@ -289,5 +289,13 @@ $(document).ready(function(){ window.location.href = linkURL; }); } + + /*edit order in oqs*/ + $('.edit_order').on('click',function(){ + var assigned_order_item_id = $(this).attr('data-id'); + if((assigned_order_item_id!=undefined) && (assigned_order_item_id!='')){ + window.location.href = '/oqs/'+ assigned_order_item_id + "/edit/pending"; + } + }); }); diff --git a/app/views/origami/split_bill/index.html.erb b/app/views/origami/split_bill/index.html.erb old mode 100755 new mode 100644 index 69743cf1..a62fb66e --- a/app/views/origami/split_bill/index.html.erb +++ b/app/views/origami/split_bill/index.html.erb @@ -60,7 +60,7 @@ <% if order_item.include? ('all_order') %> <% order_item['all_order'].each do |odr_item| %> <% - order_item_count = order_item_count.to_i + 1 + order_item_count = order_item_count.to_i + 1 sub_total += odr_item['qty'].to_f * odr_item['price'].to_f %> > @@ -389,7 +389,6 @@ $('#order_item_split').on('click',function () { var cnt_order_item = "<%= order_item_count %>"; var order_items = get_selected_order_items();// Selected Order Items - var cnt_items = parseInt(cnt_order_item) - parseInt(order_items.length); if (order_items.length > 0){ // if(cnt_items > 0){ @@ -425,6 +424,7 @@ $.each(orders, function(key,value){ if($("a[href$='#"+value.order_id+"']").parent().hasClass('selected-split-item')){ $("a[href$='#"+value.order_id+"']").parent().removeClass('selected-split-item'); + $(".item-row").removeClass('selected-split-item'); } }); } @@ -623,6 +623,7 @@ function orderItemSplitBillProcess(cnt_items){ if(cnt_items == 0){ booking_id = json_booking.booking_id; } + console.log(booking_id); var order_ids = []; var arr_order_ids = [];
<%= t("views.right_panel.detail.group_type") %>:<%= @settings_tax_profile.group_type %>
<%= t("views.right_panel.detail.name") %>: <%= @settings_tax_profile.name %>
'+rowCount+'' + item_name+ ' ' + name +'-' + option +'' + item_name+ ' ' + name +' ' + option +'' + qty + '' + parseFloat(total).toFixed(2) @@ -404,22 +406,23 @@ $(function() { +'
'+rowCount+'' + item_name+ ' ' + name +'-' + option +'' + item_name+ ' ' + name +' ' + set_option +'' + qty + '' + parseFloat(total).toFixed(2) @@ -659,7 +662,6 @@ $(function() { attribute_arr = get_selected_attributes('selected-attribute'); option_arr = get_selected_attributes('selected-option'); - if (item_row.length>0) { var instances = jQuery.parseJSON(item_row.attr('data-instances')); @@ -700,7 +702,7 @@ $(function() { var item_data = $(this); item = get_item(item_data); customer_display_view(item,"add"); - show_item_detail(item_data); + show_item_detail(item_data,"add_to_order"); calculate_sub_total(); }); //End add order Click @@ -710,11 +712,11 @@ $(function() { var item_data = $(this); item = get_item(item_data); customer_display_view(item,"add"); - show_item_detail(item_data); + show_item_detail(item_data,"add_icon"); calculate_sub_total(); }); //End Add Icon Click - function show_item_detail(data){ + function show_item_detail(data,click_type){ qty = parseInt(data.attr('data-qty')); append = 0; @@ -726,23 +728,26 @@ $(function() { }else{ instance = "("+data.attr('data-instance')+")"; } - - d_option = data.attr('data-options'); - if (d_option){ - option_name = "-"+data.attr('data-options'); + d_option = data.attr('data-opt'); + if (click_type != "add_icon"){ + option_name = "-"+data.attr('data-options'); + data_option = data.attr('data-options') ; }else{ - option_name = ''; + option_name = ' '; + data_option = '[]'; } + var rowCount = $('.summary-items tbody tr').length+1; var item_row = $('.summary-items tbody tr'); $(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-options'); - - if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')&&r_option==d_option) { + r_option = $(item_row[i]).attr('data-opt'); +console.log(r_option) +console.log(d_option) + if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')&&r_option == d_option) { if (qty > 1) { qty = parseInt($(item_row[i]).children('#item_qty').text()) + qty; }else{ @@ -766,9 +771,10 @@ $(function() { +instance+ "' data-code='"+data.attr('data-item-code')+"' data-instance-code='" +data.attr('data-instance-code')+"' data-attributes='" +data.attr('data-attributes')+"' data-options ='" + +data_option+"' data-opt ='" +data.attr('data-options')+"' data-row ='"+rowCount+ "'>" +''+rowCount+'' + data.attr('data-name')+ ' ' + instance +' ' + option_name +'' + data.attr('data-name')+ ' ' + instance +''+option_name+'' + qty + '' + parseFloat(price).toFixed(2) @@ -822,8 +828,6 @@ $(function() { data: params, dataType: "json", success:function(result){ - console.log(type) - console.log(table_type) if (type == "quick_service") { window.location.href = "/origami/quick_service" }else{ @@ -889,7 +893,7 @@ $(function() { dataType: "json", success:function(result){ if (result.status) { - console.log(result) + if (result.data == null){ swal({ title: "Please Open Shift !", diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 2e9602c8..43e1bd11 100755 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -67,7 +67,8 @@ class Api::OrdersController < Api::ApiController end } #end extra time - + puts params[:order_items] + puts "ITEM aaaaaaaaaaaaaaaaaaa" # begin @order = Order.new @order.source = params[:order_source] diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 7dd2b3f0..3a8dea9b 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -94,10 +94,10 @@ class Origami::AddordersController < BaseOrigamiController extra_time = Time.at(time) end end - if i["parent_order_item_id"] - items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": i["options"]} + if i["parent_order_item_id"]; + items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": JSON.parse(i["options"])} else - items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]} + items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": JSON.parse(i["options"])} end items_arr.push(items) } diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index 4d7d6026..0a6d87c7 100755 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -7,9 +7,12 @@ class Settings::MenusController < ApplicationController def index @settings_menus = Menu.all.page(params[:page]).per(10) respond_to do |format| - format.html - format.csv { send_data Menu.to_csv } - end + format.html + # format.csv { send_data MenuCsvExport.generate } + +format.csv { send_data Menu.to_csv } +# format.csv { send_data MenuCategory.to_csv } + end end # GET /settings/menus/1 @@ -71,6 +74,11 @@ class Settings::MenusController < ApplicationController # end end + def import + Menu.import(params[:file]) + redirect_to settings_menu_path, notice: "imported" + end + private # Use callbacks to share common setup or constraints between actions. def set_settings_menu diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index 17a117bb..52abf7fd 100755 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -21,11 +21,12 @@ class Transactions::OrdersController < ApplicationController @receipt_no = filter @from = from @to = to - + respond_to do |format| - format.html # index.html.erb - format.json { render json: @orders } - end + format.html + format.json { render json: @orders } + # format.csv { send_data OrdersCsvExport.generate } + end end def show diff --git a/app/models/menu.rb b/app/models/menu.rb index 052a7042..12784eea 100755 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -33,27 +33,20 @@ class Menu < ApplicationRecord end def self.to_csv - m_attributes = %w{id name is_active valid_days valid_time_from valid_time_to created_by created_at updated_at} + m_attributes = %w{name is_active valid_days valid_time_from valid_time_to created_by created_at updated_at} CSV.generate(headers: true) do |csv| csv << m_attributes menu = Menu.all menu.each do |user| - puts user csv << m_attributes.map{ |attr| user.send(attr)} end end + end - # mc_attributes = %w{id menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at} - # CSV.generate(headers: true) do |csv| - # csv << m_attributes - - # csv << mc_attributes - # MenuCategory.all.each do |user| - # puts user - # csv << mc_attributes.map{ |attr| user.send(attr)} - # end - # end - + def self.import(file) + CSV.foreach(file.path, headers:true) do |row| + Menu.create! row.to_hash + end end end \ No newline at end of file diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb index acb06c4f..65477a37 100755 --- a/app/models/menu_category.rb +++ b/app/models/menu_category.rb @@ -1,7 +1,7 @@ class MenuCategory < ApplicationRecord # before_create :generate_menu_category_code - belongs_to :menu + belongs_to :menu , counter_cache: true has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id" belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true has_many :menu_items @@ -83,4 +83,19 @@ class MenuCategory < ApplicationRecord # def generate_menu_category_code # self.code = SeedGenerator.generate_code(self.class.name, "C") # end + + def self.to_csv + + mc_attributes = %w{id menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at} + CSV.generate(headers: true) do |csv| + csv << mc_attributes + + csv << mc_attributes + MenuCategory.all.each do |user| + puts user + csv << mc_attributes.map{ |attr| user.send(attr)} + end + end + + end end diff --git a/app/models/order_item.rb b/app/models/order_item.rb index 776bb94c..87d60e63 100755 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -5,7 +5,8 @@ class OrderItem < ApplicationRecord before_create :generate_custom_id #Associations - belongs_to :order, autosave: true + belongs_to :order, autosave: true + # belongs_to :order, counter_cache: true #Validation validates_presence_of :item_code, :item_name, :qty diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 6c580f40..4e93e5a7 100755 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -375,7 +375,7 @@
<%= order_item.item_name %> <%= order_item.qty %> <%= order_item.price %>