diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index c55525bc..de1024ea 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1,7 +1,7 @@ $(function() { var role = $('#role').val(); - type = $('#type').val(); - modify_order = $('#modify_order').val(); + type = window.location.href.indexOf("quick_service"); + modify_order = window.location.href.indexOf("modify_order"); //click menu sidebar menu category $(".product").on("click", function(){ var url = $(this).attr('data-ref'); @@ -76,8 +76,8 @@ $(function() { } //end show list function //click menu sidebar menu category - // $(".menu_category").on("click", function(){ $(document).on('click', '.menu_category', function(event){ + event.preventDefault(); var menu_id = $(this).attr("data-id"); var url = "get_menu_category/"+menu_id; show_menu_item_list(url); @@ -88,13 +88,16 @@ $(function() { function show_menu_item_list(url_item){ var menu_list = $('.menu_items_list'); menu_list.empty(); - - if (modify_order=="true" && type =="true") { - url_item = '../../../addorders/'+url_item; - }if(modify_order=="false" && type =="true"){ - url_item = 'addorders/'+url_item - }else{ - url_item = url_item; + + type = window.location.href.indexOf("quick_service"); + modify_order = window.location.href.indexOf("modify_order"); + if (type != -1 && modify_order != -1) { + url_item = '../../../addorders/'+url_item; + }if(modify_order == -1 && type != -1){ + url_item = 'addorders/'+url_item; + } + if (type ==-1 && modify_order == -1){ + url_item = url_item } //Start Ajax @@ -756,14 +759,10 @@ $(function() { e.preventDefault(); $("#oqs_loading_wrapper").show(); - type = $('#type').val(); - if (type == 'true') { - // if (role == 'waiter') { - type = 'quick_service' - // }else{ - // type = 'cashier' - // } + type = window.location.href.indexOf("quick_service"); + if (type != 'true') { + type = 'quick_service' var table_type = $('#table_type').text(); var table_id = $('#table_id').val(); var customer_id = $('#customer_id').val(); @@ -783,15 +782,15 @@ $(function() { var params = {'order_source': type, 'order_type': "dine_in", 'customer_id': customer_id, 'guest_info': "",'booking_id':booking_id, 'table_id': table_id, - 'order_items': order_items }; + 'order_items': order_items,'create_type' : "create_only" }; }else{ var params = {'order_source': type, 'order_type': "dine_in", 'customer_id': customer_id, 'guest_info': "", 'table_id': table_id, - 'order_items': order_items }; + 'order_items': order_items,'create_type' : "create_only" }; } - - if (table_id.length>0 || role == 'waiter') { + + // if (table_id.length>0 || role == 'waiter') { $.ajax({ type: "POST", url: ajax_url, @@ -810,12 +809,12 @@ $(function() { } } }); - }else{ - $(this).removeAttr('disabled', ''); - $("#oqs_loading_wrapper").hide(); + // }else{ + // $(this).removeAttr('disabled', ''); + // $("#oqs_loading_wrapper").hide(); - swal("Opps","Please Select Table or Room","warning"); - } + // swal("Opps","Please Select Table or Room","warning"); + // } }); @@ -824,9 +823,10 @@ $(function() { $(this).attr('disabled', 'disabled'); e.preventDefault(); type = "quick_service" + modify_order = window.location.href.indexOf("modify_order"); $("#oqs_loading_wrapper").show(); console.log(modify_order) - if (modify_order == "true") { + if (modify_order !=-1) { console.log($('#sale_id').text()) var ajax_url = '../../../quick_service/update_modify_order'; var table_type = $('#table_type').text(); @@ -848,12 +848,12 @@ $(function() { var params = {'order_source': type, 'order_type': "dine_in", 'customer_id': customer_id, 'guest_info': "",'booking_id':booking_id, 'table_id': table_id, - 'order_items': order_items,'sale_id': sale_id }; + 'order_items': order_items,'sale_id': sale_id,'create_type': "create_pay" }; }else{ var params = {'order_source': type, 'order_type': "dine_in", 'customer_id': customer_id, 'guest_info': "", 'table_id': table_id, - 'order_items': order_items,'sale_id': sale_id }; + 'order_items': order_items,'sale_id': sale_id,'create_type': "create_pay" }; } $.ajax({ @@ -985,7 +985,7 @@ $(function() { $("#back").on("click", function(){ var table_id = $('#table_id').text(); var table_type = $('#table_type').text(); - type = $('#type').val(); + type = window.location.href.indexOf("quick_service"); if (type == 'true') { var table_type = $('#table_id').find("option:selected").data('type'); var table_id = $('#table_id').val(); @@ -1099,7 +1099,8 @@ $(function() { //click menu sidebar menu category - $(".sub_click").on("click", function(){ + $(document).on('click', '.sub_click', function(event){ + event.preventDefault(); var menu_id = $(this).attr("data-id"); var url = "get_menu_sub_category/"+menu_id; sub_category = $(this).find('.sub_category_list'); @@ -1110,11 +1111,12 @@ $(function() { //show menu item list when click menu category function show_sub_category_list(url,sub_category){ - if (modify_order == "true" && type =="true") { + if (type != -1 && modify_order != -1) { var url = "../../../addorders/"+url; - }if(modify_order=="false" && type =="true"){ + }if(modify_order== -1 && type != -1){ var url = 'addorders/'+url; - }else{ + } + if (type ==-1 && modify_order == -1){ var url = url; } diff --git a/app/assets/stylesheets/addorder.scss b/app/assets/stylesheets/addorder.scss index faff5850..d8adba16 100755 --- a/app/assets/stylesheets/addorder.scss +++ b/app/assets/stylesheets/addorder.scss @@ -175,7 +175,7 @@ section.content{ text-align: center; } -.add_icon{ +.menu_item_box{ cursor: pointer; } diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 42412c51..c9b1bc44 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -37,9 +37,10 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController def get_menu_category () if (params[:id]) - puts params[:id] + #Pull this menu @menu = MenuCategory.find_by_id(params[:id]) + # puts @menu.menu_items[1].item_attributes.to_json return @menu else @@ -49,7 +50,6 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController def get_menu() if (params[:id]) - puts params[:id] #Pull this menu @menu = Menu.find_by_id(params[:id]) @menu_category = MenuCategory.where("menu_id='#{@menu.id}'").order("order_by asc") @@ -61,10 +61,13 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController end def get_menu_sub_category () + id = params[:id] + if (id) #Pull this menu @sub_menu = MenuCategory.where("menu_category_id = #{id}").active + # puts @menu.menu_items[1].item_attributes.to_json return @sub_menu end @@ -153,7 +156,7 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController end @status, @booking = @order.generate - if current_user.role != "waiter" + if current_user.role != "waiter" && params[:create_type] == "create_pay" if @status && @booking && @order.source == 'quick_service' @status, @sale = Sale.request_bill(@order,current_user,current_login_employee) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index fa7e5914..970095e9 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -403,6 +403,19 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) 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, "FOC",nil,nil) + + 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/pending_order_controller.rb b/app/controllers/origami/pending_order_controller.rb index 4ed81121..d738a0a5 100644 --- a/app/controllers/origami/pending_order_controller.rb +++ b/app/controllers/origami/pending_order_controller.rb @@ -23,15 +23,15 @@ class Origami::PendingOrderController < BaseOrigamiController @order_items = Array.new @bookings.booking_orders.each do |booking_order| - order = Order.find(booking_order.order_id) - if (order.status == "new") - order.order_items.each do |item| + @order = Order.find(booking_order.order_id) + if (@order.status == "new") + @order.order_items.each do |item| @order_items.push(item) end end end end - + puts @status if @bookings.dining_facility_id.to_i > 0 @table_id = Booking.find(@bookings.booking_id).dining_facility_id @dining = DiningFacility.find(@table_id) diff --git a/app/controllers/origami/quick_service_controller.rb b/app/controllers/origami/quick_service_controller.rb index 2b943e7e..44dcfcb8 100644 --- a/app/controllers/origami/quick_service_controller.rb +++ b/app/controllers/origami/quick_service_controller.rb @@ -14,7 +14,7 @@ class Origami::QuickServiceController < ApplicationController # @rooms = Room.all.active.order('zone_id asc').group("zone_id") # @all_table = Table.all.active.order('status desc') # @all_room = Room.all.active.order('status desc') - render "origami/addorders/detail" + render "origami/addorders/detail" end def modify_order diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb index 3c1a39ab..acb06c4f 100755 --- a/app/models/menu_category.rb +++ b/app/models/menu_category.rb @@ -52,7 +52,7 @@ class MenuCategory < ApplicationRecord if from > to h = to_t.hour if h < 12 # before noon - if h = 0 + if h == 0 to = 24 to = to * 3600 + to_t.min* 60 + to_t.sec end diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 0c3e7bb5..9190ccf7 100755 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -1,4 +1,3 @@ - <%= stylesheet_link_tag 'addorder', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'addorder', 'data-turbolinks-track': 'reload' %>
- + <%end%> - <% if current_user.role != "waiter"%> + <% if current_user.role != "waiter" && @status != "order"%> <%end%> <% if @status != "sale"%>