diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index acca225a..f4d21724 100755 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -67,13 +67,15 @@ $(document).on('turbolinks:load', function() { $('#table_id').val(table_id); oqs_id = $("#oqs_id").val(); - if (table_id){ + status = $("#status").val(); + + if (table_id.length>0){ var table = table_id }else{ var table = null } - if (oqs_id > 0) { + if (oqs_id > 0 || status != "All" || table != null) { $(".oqs_click").removeClass('oqs_active'); $(".queue_station").removeClass('queue_station_box'); $("#completed").addClass('hide'); @@ -83,8 +85,8 @@ $(document).on('turbolinks:load', function() { // oqs_id = $(this).find(".oqs-id").text(); $("#oqs_active").attr('data-id',oqs_id); var url = 'oqs/get_items/'+oqs_id; - - show_details(url,table); + console.log(table) + show_details(url,table,status); }else{ $("#completed").removeClass('hide') $(".oqs_append").addClass('hide') @@ -94,6 +96,7 @@ $(document).on('turbolinks:load', function() { // $(".oqs_click").on("click", function(){ $(document).on('click', '.oqs_click', function(event){ oqs_id = $(this).val(); + status = $("#status").val(); var table_id = $('#table_id').val(); if (table_id){ var table = table_id @@ -101,7 +104,7 @@ $(document).on('turbolinks:load', function() { var table = null } - if (oqs_id > 0) { + if (oqs_id > 0 || status != "All" || table_id != null) { $(".oqs_click").removeClass('oqs_active'); $(".queue_station").removeClass('queue_station_box'); $("#completed").addClass('hide'); @@ -112,16 +115,45 @@ $(document).on('turbolinks:load', function() { $("#oqs_active").attr('data-id',oqs_id); var url = 'oqs/get_items/'+oqs_id; - show_details(url,table); + show_details(url,table,status); + }else{ + $("#completed").removeClass('hide') + $(".oqs_append").addClass('hide') + } + }); //End Click + + // $(".oqs_click").on("click", function(){ + $(document).on('click', '.status_click', function(event){ + oqs_id = $("#oqs_id").val(); + status = $(this).val(); + var table_id = $('#table_id').val(); + if (table_id){ + var table = table_id + }else{ + var table = null + } + + if (oqs_id > 0 || status != "All" || table != null) { + $(".oqs_click").removeClass('oqs_active'); + $(".queue_station").removeClass('queue_station_box'); + $("#completed").addClass('hide'); + $(".oqs_append").removeClass('hide'); + $("#oqs_active").addClass('oqs_active'); + $(".queue_station").addClass('queue_station_box'); + // oqs_id = $(this).find(".oqs-id").text(); + $("#oqs_active").attr('data-id',oqs_id); + var url = 'oqs/get_items/'+oqs_id; + + show_details(url,table,status); }else{ $("#completed").removeClass('hide') $(".oqs_append").addClass('hide') } - }); //End Click - function show_details(url,table_id){ + function show_details(url,table_id,status){ + console.log(table_id) var oqs_append = $('.oqs_append'); oqs_append.empty(); var filter = $('.filter').text(); @@ -130,7 +162,7 @@ $(document).on('turbolinks:load', function() { $.ajax({ type: "GET", url: url, - data: {'filter':filter,'table_id':table_id}, + data: {'filter':filter,'table_id':table_id,'status':status}, dataType: "json", success: function(data) { for(var field in data) { @@ -162,6 +194,10 @@ $(document).on('turbolinks:load', function() { table_type = "No Table" } + var delivery_status = '' + if (data[field]["delivery_status"] == true) { + delivery_status = "hidden" + } row ='
' +'
' @@ -191,9 +227,11 @@ $(document).on('turbolinks:load', function() { +' ' +'
' - +''; diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index be896f1e..654dcaff 100755 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -13,7 +13,8 @@ class Oqs::HomeController < BaseOqsController @queue_stations = OrderQueueStation.active - @queue_completed_item = completed_order(@filter) + # @queue_completed_item = completed_order(@filter) + @queue_completed_item = all_order(@filter) if !@queue_completed_item.empty? @queue_completed_item.each do |queue_item| if !queue_item.set_menu_items.nil? @@ -114,10 +115,11 @@ class Oqs::HomeController < BaseOqsController oqs_id = params[:id] filter = params[:filter] table_id = params[:table_id] - puts params - puts table_id - puts "sssssssssssss" - items = queue_items_query(false,oqs_id,filter,table_id) + status = params[:status] + + items = queue_items_query(false,oqs_id,filter,table_id,status) +puts "items0" +puts items.to_json if !items.empty? items.each do |item| if !item.set_menu_items.nil? @@ -155,27 +157,35 @@ class Oqs::HomeController < BaseOqsController # Query for OQS with delivery status - def queue_items_query(status,oqs_id=nil,filter,table_id) - if oqs_id == nil - oqs = '' + def queue_items_query(status,oqs_id=nil,filter,table_id,delivery_status) + if oqs_id != "0" + oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' " else - oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' " + oqs = '' end + if delivery_status == "All" + queue_status = '' + elsif delivery_status == "Processed" + queue_status = "and assigned_order_items.delivery_status = true " + else + queue_status = "and assigned_order_items.delivery_status = false " + end if !table_id.empty? tableId = table_id.to_a.map{|h| h}.join(",") table = "and df.id IN (#{tableId})" else table = '' end - + query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type as table_type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items, - cus.name as customer_name, odt.created_at") + cus.name as customer_name, odt.created_at, + assigned_order_items.delivery_status") .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id left join orders as od ON od.order_id = assigned_order_items.order_id @@ -184,7 +194,7 @@ class Oqs::HomeController < BaseOqsController left join booking_orders as bo on bo.order_id = assigned_order_items.order_id left join bookings as bk on bk.booking_id = bo.booking_id left join dining_facilities as df on df.id = bk.dining_facility_id") - .where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} #{table}") + .where("assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} #{table} #{queue_status}") query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) .order("assigned_order_items.assigned_order_item_id desc") .group("odt.order_items_id") @@ -193,7 +203,7 @@ class Oqs::HomeController < BaseOqsController # Completed Order def completed_order(filter) - query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items, cus.name as customer_name, odt.created_at") + query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items, cus.name as customer_name, odt.created_at,assigned_order_items.delivery_status") .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id left join orders as od ON od.order_id = assigned_order_items.order_id @@ -212,6 +222,26 @@ class Oqs::HomeController < BaseOqsController # completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true'); end + # all Order + def all_order(filter) + query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items, cus.name as customer_name, odt.created_at,assigned_order_items.delivery_status") + .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id + left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id + left join orders as od ON od.order_id = assigned_order_items.order_id + left join order_items as odt ON odt.item_instance_code = assigned_order_items.instance_code AND odt.order_id = assigned_order_items.order_id + left join customers as cus ON cus.customer_id = od.customer_id + left join booking_orders as bo on bo.order_id = assigned_order_items.order_id + left join bookings as bk on bk.booking_id = bo.booking_id + left join dining_facilities as df on df.id = bk.dining_facility_id") + .where("assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'") + query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) + .group("odt.order_items_id") + .order("assigned_order_items.created_at") + + + # completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true'); + end + # def queue_items_count_query(status,filter) # query = AssignedOrderItem.select("count(odt.item_code) as total,oqs.id as station_id") # .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 88b660b4..7f2ea4e1 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -1,43 +1,40 @@
-
-
-
-
- - - -
- -
-
- +
+
+
+
+ + + +
+ +
+ + + +
+
+
@@ -88,6 +85,12 @@
+ <% if !qid.delivery_status %> + + <%end%>
<% end %>