app order with order
This commit is contained in:
@@ -35,12 +35,13 @@ class Foodcourt::FoodCourtController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@app_order_new_count =Booking.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
|
@app_order_new_count = Booking.select("bookings.*,customers.*")
|
||||||
|
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
|
||||||
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
|
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
|
||||||
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
|
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
|
||||||
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
|
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
|
||||||
.where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}' and bookings.booking_status='assign'").uniq.length
|
.where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}' and DATE(bookings.created_at) = '#{Date.today}' and bookings.booking_status='assign'").uniq.length
|
||||||
puts @app_order_new_count
|
|
||||||
render "foodcourt/addorders/detail"
|
render "foodcourt/addorders/detail"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -62,18 +62,19 @@ class Foodcourt::OrdersController < BaseFoodcourtController
|
|||||||
.where("orders.source='app' and bookings.booking_id='#{params[:booking_id]}'").first
|
.where("orders.source='app' and bookings.booking_id='#{params[:booking_id]}'").first
|
||||||
@customer_id =@booking.customer_id
|
@customer_id =@booking.customer_id
|
||||||
@booking_id =@booking.booking_id
|
@booking_id =@booking.booking_id
|
||||||
|
@order_id =@booking.order_id
|
||||||
end
|
end
|
||||||
@bookings = Booking.select("bookings.*,customers.*")
|
@bookings = Booking.select("bookings.*,customers.*")
|
||||||
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
|
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
|
||||||
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
|
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
|
||||||
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
|
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
|
||||||
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
|
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
|
||||||
.where("orders.source='app' and DATE(bookings.created_at) = '#{Date.today}'").order("bookings.created_at desc").uniq
|
.where("orders.source='app' and DATE(bookings.created_at) = '#{Date.today}' and bookings.shop_code='#{Shop.current_shop.shop_code}'").order("bookings.created_at desc").uniq
|
||||||
end
|
end
|
||||||
def completed
|
def completed
|
||||||
customer =Customer.find_by_customer_id(params[:customer_id])
|
customer =Customer.find_by_customer_id(params[:customer_id])
|
||||||
phone_number =customer.contact_no
|
phone_number =customer.contact_no
|
||||||
if Order.send_message(phone_number,params[:booking_id])
|
if Order.send_message(phone_number,params[:order_id])
|
||||||
booking =Booking.find(params[:booking_id])
|
booking =Booking.find(params[:booking_id])
|
||||||
booking.booking_status ='completed'
|
booking.booking_status ='completed'
|
||||||
booking.save!
|
booking.save!
|
||||||
|
|||||||
@@ -591,8 +591,8 @@ class Order < ApplicationRecord
|
|||||||
Rails.logger.debug '...... order sync completed .....'
|
Rails.logger.debug '...... order sync completed .....'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def self.send_message(phone, booking_id)
|
def self.send_message(phone, order_id)
|
||||||
url = "http://smspoh.com/api/http/send?key=5QfyN0OtGsFXnOqwtpVAGZCyPGP28nbX_Nm_oPsUw2ybq714T_951ycz3Ypl5URA&message=Your order "+booking_id.to_s+" is ready to pick up&recipients="+ phone.to_s
|
url = "http://smspoh.com/api/http/send?key=5QfyN0OtGsFXnOqwtpVAGZCyPGP28nbX_Nm_oPsUw2ybq714T_951ycz3Ypl5URA&message=Your order "+order_id.to_s+" is ready to pick up&recipients="+ phone.to_s
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@result = HTTParty.get(url.to_str)
|
@result = HTTParty.get(url.to_str)
|
||||||
|
|||||||
@@ -50,8 +50,7 @@
|
|||||||
<div class="card <%= bk_color %> text-white" data-id ="<%= bk.booking_id %>">
|
<div class="card <%= bk_color %> text-white" data-id ="<%= bk.booking_id %>">
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
Cus Ph :<%= bk.contact_no %><span style="font-size:12px;float:right;line-height:inherit;">Order Time :<%= bk.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span><br>
|
Cus Ph :<%= bk.contact_no %><span style="font-size:12px;float:right;line-height:inherit;">Order Time :<%= bk.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span><br>
|
||||||
BK :<%= bk.booking_id %><span style="font-size:12px;float:right;line-height:inherit;"><%= bk_status %></span>
|
Order No :<%= bk.orders[0].order_id %><span style="font-size:12px;float:right;line-height:inherit;"><%= bk_status %></span> </div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -65,6 +64,7 @@
|
|||||||
<div class="col-md-9 col-lg-9 col-sm-9">
|
<div class="col-md-9 col-lg-9 col-sm-9">
|
||||||
<strong id="order-title" class="font-14 p-l-10">ORDER DETAILS </strong>| <span class="font-14">Table-<%=@booking.dining_facility.name%></span><br>
|
<strong id="order-title" class="font-14 p-l-10">ORDER DETAILS </strong>| <span class="font-14">Table-<%=@booking.dining_facility.name%></span><br>
|
||||||
<strong class="font-14 p-l-10">Booking - <%=@booking.booking_id%></strong>
|
<strong class="font-14 p-l-10">Booking - <%=@booking.booking_id%></strong>
|
||||||
|
<strong class="font-14 p-l-10">Order No- <%=@booking.order_id%></strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3 col-lg-3 col-sm-3">
|
<div class="col-md-3 col-lg-3 col-sm-3">
|
||||||
<button type="button" class="btn btn-block btn-default waves-effect" id='back'>
|
<button type="button" class="btn btn-block btn-default waves-effect" id='back'>
|
||||||
@@ -122,38 +122,38 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$('#back').on('click', function () {
|
$('#back').on('click', function () {
|
||||||
window.location.href ="<%=foodcourt_food_court_path %>";
|
window.location.href ="<%=foodcourt_food_court_path %>";
|
||||||
});
|
});
|
||||||
$('#done_order').on('click', function () {
|
$('#done_order').on('click', function () {
|
||||||
swal({
|
swal({
|
||||||
title: "Alert !",
|
title: "Alert !",
|
||||||
text: 'Order Complete?',
|
text: 'Order Complete?',
|
||||||
type: "warning",
|
type: "warning",
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonColor: "#DD6B55",
|
confirmButtonColor: "#DD6B55",
|
||||||
confirmButtonText: "Yes",
|
confirmButtonText: "Yes",
|
||||||
cancelButtonClass: 'btn btn-danger',
|
cancelButtonClass: 'btn btn-danger',
|
||||||
closeOnConfirm: false
|
closeOnConfirm: false
|
||||||
}, function (isConfirm) {
|
}, function (isConfirm) {
|
||||||
if (isConfirm) {
|
if (isConfirm) {
|
||||||
$('.confirm').prop("disabled",true);
|
$('.confirm').prop("disabled",true);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/foodcourt/<%=@booking_id %>/completed",
|
url: "/foodcourt/<%=@booking_id %>/<%=@order_id %>/completed",
|
||||||
data: {customer_id:"<%=@customer_id %>"},
|
data: {customer_id:"<%=@customer_id %>"},
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
swal({
|
swal({
|
||||||
title: "Information!",
|
title: "Information!",
|
||||||
text: 'Send sms to customer ',
|
text: 'Send sms to customer ',
|
||||||
type: "success",
|
type: "success",
|
||||||
}, function () {
|
}, function () {
|
||||||
window.location.href ="<%=foodcourt_app_order_by_booking_path %>";
|
window.location.href ="<%=foodcourt_app_order_by_booking_path %>";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -688,7 +688,7 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
post '/customer_view' => "second_display#customer_view",:as => "customer_view", :defaults => { :format => 'json' }
|
post '/customer_view' => "second_display#customer_view",:as => "customer_view", :defaults => { :format => 'json' }
|
||||||
get "food_court" => "food_court#index"
|
get "food_court" => "food_court#index"
|
||||||
get "app_orders" => "orders#app_orders",:as => "app_order_by_booking"
|
get "app_orders" => "orders#app_orders",:as => "app_order_by_booking"
|
||||||
post ':booking_id/completed' => "orders#completed", :defaults => { :format => 'json' }
|
post ':booking_id/:order_id/completed' => "orders#completed", :defaults => { :format => 'json' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user