update oqs update
This commit is contained in:
@@ -67,13 +67,15 @@ $(document).on('turbolinks:load', function() {
|
||||
$('#table_id').val(table_id);
|
||||
|
||||
oqs_id = $("#oqs_id").val();
|
||||
status = $("#status").val();
|
||||
|
||||
if (table_id){
|
||||
var table = table_id
|
||||
}else{
|
||||
var table = null
|
||||
}
|
||||
|
||||
if (oqs_id > 0) {
|
||||
if (oqs_id > 0 || status != "All" || tabel != null) {
|
||||
$(".oqs_click").removeClass('oqs_active');
|
||||
$(".queue_station").removeClass('queue_station_box');
|
||||
$("#completed").addClass('hide');
|
||||
@@ -84,7 +86,7 @@ $(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')
|
||||
@@ -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" || tabel != null) {
|
||||
$(".oqs_click").removeClass('oqs_active');
|
||||
$(".queue_station").removeClass('queue_station_box');
|
||||
$("#completed").addClass('hide');
|
||||
@@ -112,16 +115,44 @@ $(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" || tabel != 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){
|
||||
var oqs_append = $('.oqs_append');
|
||||
oqs_append.empty();
|
||||
var filter = $('.filter').text();
|
||||
@@ -130,7 +161,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 +193,10 @@ $(document).on('turbolinks:load', function() {
|
||||
table_type = "No Table"
|
||||
|
||||
}
|
||||
var delivery_status = ''
|
||||
if (data[field]["delivery_status"] == true) {
|
||||
delivery_status = "hidden"
|
||||
}
|
||||
|
||||
row ='<div class="card queue_station animated " data-order-no="'+data[field]["order_id"]+'">'
|
||||
+'<div class="card-block">'
|
||||
@@ -191,9 +226,11 @@ $(document).on('turbolinks:load', function() {
|
||||
+'<p class="hidden assigned-order-item">'+ data[field]["assigned_order_item_id"] +'</p> '
|
||||
+'</div>'
|
||||
|
||||
+'<div class="card-footer">'
|
||||
+'<div class="card-footer ">'
|
||||
+'<span class="'+delivery_status+'">'
|
||||
+'<button id="edit_'+ data[field]["assigned_order_item_id"] + '" data-no-turbolink="true" class="btn btn-warning order-item order-item-edit">EDIT</button>'
|
||||
+' <button id="assigned_queue_' + data[field]["assigned_order_item_id"] +'" class="btn btn-primary order-item order-complete">COMPLETE</button>'
|
||||
+'</span>'
|
||||
+'</div>'
|
||||
|
||||
+'</div>';
|
||||
|
||||
@@ -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,10 @@ 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)
|
||||
|
||||
if !items.empty?
|
||||
items.each do |item|
|
||||
if !item.set_menu_items.nil?
|
||||
@@ -155,13 +156,20 @@ class Oqs::HomeController < BaseOqsController
|
||||
|
||||
|
||||
# Query for OQS with delivery status
|
||||
def queue_items_query(status,oqs_id=nil,filter,table_id)
|
||||
def queue_items_query(status,oqs_id=nil,filter,table_id,delivery_status)
|
||||
if oqs_id == nil
|
||||
oqs = ''
|
||||
else
|
||||
oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
|
||||
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})"
|
||||
@@ -175,7 +183,8 @@ class Oqs::HomeController < BaseOqsController
|
||||
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 +193,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 +202,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 +221,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
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<label class="label-align">Select Station</label>
|
||||
<span class="hidden" id="oqs_active"></span>
|
||||
<select class="form-control select oqs_click" name="oqs_id" id="oqs_id">
|
||||
<option value="0" data-id="0">Processed</option>
|
||||
<option value="0" data-id="0">All</option>
|
||||
<% @queue_stations.each do |qsi| %>
|
||||
<% if qsi.is_active != false %>
|
||||
<% selected = ""%>
|
||||
@@ -20,6 +20,16 @@
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-lg-2 col-md-2 col-sm-2">
|
||||
<label class="label-align">Select Status</label>
|
||||
<span class="hidden" id="oqs_active"></span>
|
||||
<select class="form-control select status_click" name="status" id="status">
|
||||
<option value="All">All</option>
|
||||
<option value="New">New</option>
|
||||
<option value="Processed">Processed</option>
|
||||
</select>
|
||||
</div>
|
||||
<!--
|
||||
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
|
||||
<span class="hidden" id="room_id"></span>
|
||||
@@ -88,6 +98,12 @@
|
||||
<p class="hidden order-customer"><%= qid.customer_name %></p>
|
||||
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
|
||||
</div>
|
||||
<% if !qid.delivery_status %>
|
||||
<div class="card-footer">
|
||||
<button id="edit_<%= qid.assigned_order_item_id %>" data-no-turbolink="true" class="btn btn-warning order-item order-item-edit">EDIT</button>
|
||||
<button id="assigned_queue_<%= qid.assigned_order_item_id %>" class="btn btn-primary order-item order-complete">COMPLETE</button>
|
||||
</div>
|
||||
<%end%>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user