oqs updated

This commit is contained in:
Yan
2017-06-18 00:45:39 +06:30
parent 420e1b9cbc
commit 80320b6d3e
5 changed files with 50 additions and 17 deletions

View File

@@ -30,6 +30,7 @@ $(document).ready(function(){
var orderBy = $(this).children().children().children().children('.order-by').text();
var orderAt = $(this).children().children().children().children('.order-at').text();
var orderCustomer = $(this).children().children('.order-customer').text();
var order_status = $(this).children().children('.order-status').text();
$('#order-title').text("ORDER DETAILS - " + orderZone);
$('#order-by').text(orderBy);
@@ -43,6 +44,7 @@ $(document).ready(function(){
$.ajax({
type: 'GET',
url: '/oqs/' + orderZone,
data: { 'status' : order_status },
success: function(res){
for (i = 0; i < res.length; i++) {
var data = JSON.stringify(res[i]);

View File

@@ -26,15 +26,29 @@ class Oqs::HomeController < BaseOqsController
def get_order_items
items = []
table_name = params[:table_id]
status = params[:status]
dining = DiningFacility.find_by_name(table_name);
booking_id = dining.get_current_booking
BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo|
order=Order.find(bo.order_id);
order.order_items.each do |oi|
items.push(oi)
end
oqpz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
if status == ""
AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi|
oi = OrderItem.find_by_item_code(aoi.item_code)
items.push(oi)
end
else
AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=1").find_each do |aoi|
oi = OrderItem.find_by_item_code(aoi.item_code)
items.push(oi)
end
end
# booking_id = dining.get_new_booking
# BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo|
# order=Order.find(bo.order_id);
# order.order_items.each do |oi|
# items.push(oi)
# end
# end
render :json => items.to_json
end

View File

@@ -9,8 +9,24 @@ class DiningFacility < ApplicationRecord
scope :active, -> {where(is_active: true)}
def get_current_booking
puts "enter booking"
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
puts "enter booking"
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
if booking.count > 0 then
return booking[0].booking_id
else
return nil
end
end
def get_new_booking
# query for new
# if status
# to ask when req bill booking_status?
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and sale_id is null and checkout_at is null").limit(1)
# else
# booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and sale_id not null").limit(1)
# end
if booking.count > 0 then
return booking[0].booking_id

View File

@@ -18,19 +18,19 @@ class OrderQueueStation < ApplicationRecord
oqs_stations.each do |oqs|
#Get List of items -
pq_items = JSON.parse(oqs.processing_items)
if oqs.id == oqpbz.order_queue_station_id
#Loop through the processing items
pq_items.each do |pq_item|
#Processing through the looping items
order_items.each do |order_item|
if (pq_item == order_item.item_code)
pq_items.each do |pq_item|
#Processing through the looping items
order_items.each do |order_item|
if (pq_item == order_item.item_code)
if oqs.id == oqpbz.order_queue_station_id
#Same Order_items can appear in two location.
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
end
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
end
end
end
end
end
end
#Print OQS where printing is require

View File

@@ -60,6 +60,7 @@
</span>
</small>
</p>
<p class="hidden order-status">completed</p>
<p class="hidden order-customer"><%= qid.customer_name %></p>
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
</div>