update oqs
This commit is contained in:
@@ -24,7 +24,7 @@ $(document).ready(function(){
|
||||
// window.location.reload(1);
|
||||
// }, 10000);
|
||||
|
||||
$('.queue_station').on('click',function(){
|
||||
$(document).on('click', '.queue_station', function(event){
|
||||
var orderZone=$(this).children().children().children('.order-zone').text().trim();
|
||||
// var orderItem=$(this).children().children().children('.order-item').text();
|
||||
var assigned_item_id = $(this).children().find(".assigned-order-item").text();
|
||||
@@ -68,19 +68,20 @@ $(document).ready(function(){
|
||||
$(this).addClass('selected-item');
|
||||
});
|
||||
|
||||
$(".order-item-edit").on('click', function(){
|
||||
$(document).on('click', '.order-item-edit', function(event){
|
||||
var _self = $(this); // To know in ajax return
|
||||
var assigned_item_id=$(this).attr('id').substr(5);
|
||||
window.location.href = '/oqs/'+ assigned_item_id + "/edit"
|
||||
});
|
||||
|
||||
// complete for queue item
|
||||
$('.order-complete').on('click',function(e){
|
||||
|
||||
$(document).on('click', '.order-complete', function(event){
|
||||
//e.preventDefault();
|
||||
var _self = $(this); // To know in ajax return
|
||||
var assigned_item_id=$(this).attr('id').substr(15);
|
||||
var params = { 'id':assigned_item_id };
|
||||
|
||||
|
||||
// Call update_delivery_status() for changed delivery and move to delivery
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
|
||||
@@ -69,6 +69,12 @@ class Oqs::HomeController < BaseOqsController
|
||||
render :json => items.to_json
|
||||
end
|
||||
|
||||
def get_items_by_oqs
|
||||
oqs_id = params[:id]
|
||||
items = queue_items_query(false,oqs_id)
|
||||
render :json => items.to_json
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
@@ -88,8 +94,15 @@ class Oqs::HomeController < BaseOqsController
|
||||
render :json => removed_item.to_json
|
||||
end
|
||||
|
||||
|
||||
|
||||
# Query for OQS with delivery status
|
||||
def queue_items_query(status)
|
||||
def queue_items_query(status,oqs_id=nil)
|
||||
if oqs_id == nil
|
||||
oqs = ''
|
||||
else
|
||||
oqs = " and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
|
||||
end
|
||||
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, cus.name as customer_name, odt.created_at")
|
||||
.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
|
||||
@@ -99,8 +112,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 odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}'")
|
||||
.group("assigned_order_items.assigned_order_item_id")
|
||||
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}'#{oqs}")
|
||||
.order("assigned_order_items.created_at")
|
||||
end
|
||||
|
||||
|
||||
@@ -13,15 +13,15 @@
|
||||
if qsi.is_active == false
|
||||
status="disabled"
|
||||
end %>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href=<%= '#' + qsi.station_name.gsub(' ', '_') %> role="tab" <%= status %>>
|
||||
<%= qsi[:station_name] %>
|
||||
<span class="badge badge-pill badge-default" id=<%= qsi.station_name.gsub(' ', '_') + '_count' %>>
|
||||
<%= qsi.assigned_order_items.count %>
|
||||
</span>
|
||||
<% if qsi.auto_print %>
|
||||
<span>(ap)</span>
|
||||
<% end %>
|
||||
<li class="nav-item oqs_click" >
|
||||
<p class="hidden oqs-id"><%= qsi.id %></p>
|
||||
<a class="nav-link" data-toggle="tab" href="" role="tab" <%= status %>>
|
||||
<%= qsi.station_name %>
|
||||
<span class="badge badge-pill badge-default" id=""><%= qsi.assigned_order_items.count %>
|
||||
</span>
|
||||
<% if qsi.auto_print %>
|
||||
<span>(ap)</span>
|
||||
<% end %>
|
||||
</a>
|
||||
</li>
|
||||
<% end %>
|
||||
@@ -76,63 +76,14 @@
|
||||
<!-- End Panel 0 - Completed -->
|
||||
|
||||
<!-- Order Item for Queue Station -->
|
||||
<%
|
||||
@queue_stations_items.each do |qsi|
|
||||
%>
|
||||
<!-- Generated Pane -->
|
||||
<div class="tab-pane" id=<%= qsi[:station_name].gsub(' ', '_') %> role="tabpanel">
|
||||
|
||||
<!--- Order Items -->
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<%
|
||||
@queue_items_details.each do |qid|
|
||||
if qid.price != 0
|
||||
if qid.zone_id == qsi[:zone_id] && qid.station_name == qsi[:station_name]
|
||||
%>
|
||||
<div class="card queue_station">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">
|
||||
<span class="order-zone-type"><%= qid.type %> - </span>
|
||||
<span class="order-zone"><%= qid.zone %></span>
|
||||
<small class="pull-right"><%= qid.order_id %></small>
|
||||
</h4>
|
||||
<h4>
|
||||
<span class="order-item"><%= qid.item_name %></span> [x
|
||||
<span class="order-qty"><%= qid.qty %></span> ]
|
||||
</h4>
|
||||
|
||||
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
|
||||
|
||||
<p class="card-text">
|
||||
<small class="text-muted">Order at
|
||||
<span class="order-at">
|
||||
<%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %>
|
||||
</span> -
|
||||
<span class="order-by">
|
||||
<%= qid.item_order_by %>
|
||||
</span>
|
||||
</small>
|
||||
</p>
|
||||
<!-- Hidden Fields for Items -->
|
||||
<p class="hidden order-customer"><%= qid.customer_name %></p>
|
||||
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<button id=<%= 'edit_' + qid.assigned_order_item_id.to_s %> class="btn btn-warning order-item order-item-edit">EDIT</button>
|
||||
<button id=<%= 'assigned_queue_' + qid.assigned_order_item_id.to_s %> class="btn btn-primary order-item order-complete">COMPLETE</button>
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
end
|
||||
end
|
||||
end
|
||||
%>
|
||||
<div class="card-columns oqs_append" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
|
||||
|
||||
<!--- end of Items-->
|
||||
</div>
|
||||
</div>
|
||||
<!-- end of Pane -->
|
||||
<% end %>
|
||||
<!-- End Order Item for Queue Station -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -193,4 +144,82 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
|
||||
$(".oqs_click").on("click", function(){
|
||||
|
||||
var oqs_id = $(this).find(".oqs-id").text();
|
||||
var url = 'oqs/get_items/'+oqs_id;
|
||||
show_details(url);
|
||||
|
||||
}); //End Click
|
||||
|
||||
function show_details(url){
|
||||
var oqs_append = $('.oqs_append');
|
||||
oqs_append.empty();
|
||||
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
for(var field in data) {
|
||||
var price = parseFloat(data[field].price).toFixed(2);
|
||||
|
||||
if (data[field]["options"] == "[]") {
|
||||
options = "";
|
||||
}else{
|
||||
options = data.options;
|
||||
}
|
||||
|
||||
var date = data[field]["created_at"];
|
||||
|
||||
row ='<div class="card queue_station">'
|
||||
+'<div class="card-block">'
|
||||
+'<h4 class="card-title">'
|
||||
+'<span class="order-zone-type">'+data[field]["zone"]+'- </span>'
|
||||
+'<span class="order-zone">'+ data[field]["zone"] +'</span>'
|
||||
+'<small class="pull-right">'+ data[field]["order_id"] +'- </small>'
|
||||
+'</h4>'
|
||||
|
||||
+'<h4>'
|
||||
+'<span class="order-item">'+ data[field]["item_name"] +'- </span>'
|
||||
+'<span class="order-qty">'+ data[field]["qty"] +'- </span>'
|
||||
+'</h4>'
|
||||
|
||||
+'<p class="card-text item-options">'+ options +'</p>'
|
||||
|
||||
+'<p class="card-text">'
|
||||
+'<small class="text-muted">Order at'
|
||||
+'<span class="order-at">'+ date +'</span> - '
|
||||
|
||||
+'<span class="order-by">'+ data[field]["item_order_by"] +'</span> '
|
||||
+'</small> '
|
||||
+'</p>'
|
||||
|
||||
+'<p class="hidden order-customer">'+ data[field]["customer_name"] +'</p> '
|
||||
+'<p class="hidden assigned-order-item">'+ data[field]["assigned_order_item_id"] +'</p> '
|
||||
+'</div>'
|
||||
|
||||
+'<div class="card-footer">'
|
||||
+'<button id="edit_'+ data[field]["assigned_order_item_id"]+'" 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>'
|
||||
+'</div>'
|
||||
|
||||
+'</div>';
|
||||
|
||||
|
||||
|
||||
$('.oqs_append').append(row);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
//end Ajax
|
||||
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -198,6 +198,8 @@ Rails.application.routes.draw do
|
||||
# Pass assigned_order_item_id
|
||||
get 'print/print/:id', to: "print#print"
|
||||
get 'print/print_order_summary/:id', to: "print#print_order_summary"
|
||||
|
||||
get "/get_items/:id" =>"home#get_items_by_oqs", :as => "get_order_items_by_oqs"
|
||||
#dashboard
|
||||
#
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user