This commit is contained in:
Nweni
2017-06-17 16:00:56 +06:30
parent b2ed77947e
commit e55ab32fad
3 changed files with 34 additions and 34 deletions

View File

@@ -1,22 +1,22 @@
class Oqs::HomeController < BaseOqsController
def index
queue_stations=OrderQueueStation.all
@queue_items_details = queue_items_query(0)
@queue_completed_item = queue_items_query(1)
@queue_completed_item = queue_items_query(1)
@queue_stations_items=Array.new
# Calculate Count for each station tab
queue_stations.each do |que|
queue_stations.each do |que|
i=0
@queue_items_details.each do |qid|
if qid.station_name == que.station_name
i=i+1
end
end
@queue_stations_items.push({:station_name => que.station_name, :is_active => que.is_active ,:item_count => i })
@queue_items_details.each do |qid|
if qid.station_name == que.station_name
i=i+1
end
end
@queue_stations_items.push({:station_name => que.station_name, :is_active => que.is_active ,:item_count => i })
end
@queue_stations_items
@@ -35,24 +35,23 @@ class Oqs::HomeController < BaseOqsController
# update delivery status for completed same order items
assigned_items.each do |ai|
ai.delivery_status=true
ai.save
ai.save
removed_item.push(ai.assigned_order_item_id)
end
render :json => removed_item.to_json
end
render :json => removed_item.to_json
end
# Query for OQS with status
def queue_items_query(status)
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id
.joins("left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id
left join dining_facilities as df on df.zone_id = oqpz.zone_id
left join order_queue_stations as oqs ON oqs.id = assigned_order_items.order_queue_station_id
left join orders as od ON od.order_id = assigned_order_items.order_id
left join order_items as odt ON odt.item_code = assigned_order_items.item_code
left join customers as cus ON cus.customer_id = od.customer_id")
.where("assigned_order_items.delivery_status = #{status}")
.where("assigned_order_items.delivery_status = #{status}")
.group("assigned_order_items.assigned_order_item_id")
.order("odt.item_name DESC")
.order("odt.item_name DESC")
end
end